mirror of
https://github.com/NixOS/nix
synced 2025-07-08 06:53:54 +02:00
Precompile headers
This cuts 'make install -j6' on my laptop from 170s to 134s.
This commit is contained in:
parent
39a2e166dd
commit
5ff4d77f55
6 changed files with 118 additions and 5 deletions
42
mk/precompiled-headers.mk
Normal file
42
mk/precompiled-headers.mk
Normal file
|
@ -0,0 +1,42 @@
|
|||
PRECOMPILE_HEADERS ?= 1
|
||||
|
||||
print-var-help += \
|
||||
echo " PRECOMPILE_HEADERS ($(PRECOMPILE_HEADERS)): Whether to use precompiled headers to speed up the build";
|
||||
|
||||
GCH = $(buildprefix)precompiled-headers.h.gch
|
||||
|
||||
$(GCH): precompiled-headers.h
|
||||
@rm -f $@
|
||||
@mkdir -p "$(dir $@)"
|
||||
$(trace-gen) $(CXX) -x c++-header -o $@ $^ $(GLOBAL_CXXFLAGS)
|
||||
|
||||
PCH = $(buildprefix)precompiled-headers.h.pch
|
||||
|
||||
$(PCH): precompiled-headers.h
|
||||
@rm -f $@
|
||||
@mkdir -p "$(dir $@)"
|
||||
$(trace-gen) $(CXX) -x c++-header -o $@ $^ $(GLOBAL_CXXFLAGS)
|
||||
|
||||
clean-files += $(GCH) $(PCH)
|
||||
|
||||
ifeq ($(PRECOMPILE_HEADERS), 1)
|
||||
|
||||
ifeq ($(CXX), g++)
|
||||
|
||||
GLOBAL_CXXFLAGS_PCH += -include $(buildprefix)precompiled-headers.h -Winvalid-pch
|
||||
|
||||
GLOBAL_ORDER_AFTER += $(GCH)
|
||||
|
||||
else ifeq ($(CXX), clang++)
|
||||
|
||||
GLOBAL_CXXFLAGS_PCH += -include-pch $(PCH) -Winvalid-pch
|
||||
|
||||
GLOBAL_ORDER_AFTER += $(PCH)
|
||||
|
||||
else
|
||||
|
||||
$(error Don't know how to precompile headers on $(CXX))
|
||||
|
||||
endif
|
||||
|
||||
endif
|
Loading…
Add table
Add a link
Reference in a new issue