From 55bea514304417d8f9202a9a1a4a51b75ba29e62 Mon Sep 17 00:00:00 2001 From: Ryan Prichard Date: Thu, 22 Oct 2015 03:04:17 -0500 Subject: [PATCH] Implement precompiled headers in misc/buffer-tests * I'm still going to try to include what is used in each module. * At some point, I should implement these in the main project. It will need more testing on the various compilers. It really needs to be on-by-default everywhere. If it's off, then at least pch.h should be included everywhere, to minimize configuration differences between my checkout and other people's checkouts. * There should be some way to configure it off to check whether includes are correct. * The change reduces build times from 27.6s to 15.2s on a single-core VM. --- misc/buffer-tests/Makefile | 25 ++++++++++++++++++------- misc/buffer-tests/harness/pch.h | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100755 misc/buffer-tests/harness/pch.h diff --git a/misc/buffer-tests/Makefile b/misc/buffer-tests/Makefile index 224d1ea..8f0cf25 100644 --- a/misc/buffer-tests/Makefile +++ b/misc/buffer-tests/Makefile @@ -8,23 +8,34 @@ CFLAGS += -MMD -Wall -Iharness -I../../shared CXXFLAGS += -MMD -Wall -Iharness -I../../shared -std=c++11 -Wno-format LDFLAGS += -static -static-libgcc -static-libstdc++ +# To disable PCH, just comment out these two lines. +PCHFLAGS = -include build/pch.h +PCHDEPS = build/pch.h.gch + # Use gmake -n to see the command-lines gmake would run. +.PHONY : default +default : all + +build/pch.h.gch : harness/pch.h + @echo Compiling PCH $< + @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< + build/%.o : %.c @echo Compiling $< @$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< -build/%.o : %.cc +build/%.o : %.cc $(PCHDEPS) @echo Compiling $< - @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< + @$(CXX) $(PCHFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< -build/%.o : ../../shared/%.cc +build/%.o : ../../shared/%.cc $(PCHDEPS) @echo Compiling $< - @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< + @$(CXX) $(PCHFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< -build/%.o : harness/%.cc +build/%.o : harness/%.cc $(PCHDEPS) @echo Compiling $< - @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< + @$(CXX) $(PCHFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $< .PRECIOUS : build/%.o @@ -59,6 +70,6 @@ Worker.exe : $(WORKER_OBJECTS) $(COMMON_OBJECTS) .PHONY : clean clean: - rm -f build/*.exe build/*.o build/*.d + rm -f build/*.exe build/*.o build/*.d build/*.gch -include build/*.d diff --git a/misc/buffer-tests/harness/pch.h b/misc/buffer-tests/harness/pch.h new file mode 100755 index 0000000..05f3440 --- /dev/null +++ b/misc/buffer-tests/harness/pch.h @@ -0,0 +1,19 @@ +// Precompiled Headers. +// +// Unfortunate evil that speeds up compile times. In principle, compilation +// should still work if PCH is turned off. +// + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include