Linux/GCC and Precompiled headers

95 views
Skip to first unread message

Jeffrey Walton

unread,
Oct 7, 2010, 5:01:05 PM10/7/10
to Crypto++ Users
Hi All,

Does anyone have any experience with Linux/GCC precompiled headers? I
found no difference (makefile mods attached) - each took exactly 2:11
(m:s).

Any ideas? Or is this a GCC rabbit hole?

Jeff

jeffrey@bruno:~/cryptopp$ cat GNUmakefile.diff

Index: GNUmakefile
===================================================================
--- GNUmakefile (revision 521)
+++ GNUmakefile (working copy)
@@ -131,9 +131,12 @@
TESTIMPORTOBJS = $(TESTOBJS:.o=.import.o)
DLLTESTOBJS = dlltest.dllonly.o

-all: cryptest.exe
+all: precompile cryptest.exe

-test: cryptest.exe
+precompile: pch.h
+ $(CXX) $(CXXFLAGS) pch.h -o pch.h.gch
+
+test: precompile cryptest.exe
./cryptest.exe v

clean:
@@ -153,7 +156,7 @@
libcryptopp.so: $(LIBOBJS)
$(CXX) -shared -o $@ $(LIBOBJS)

-cryptest.exe: libcryptopp.a $(TESTOBJS)
+cryptest.exe: precompile libcryptopp.a $(TESTOBJS)
$(CXX) -o $@ $(CXXFLAGS) $(TESTOBJS) -L. -lcryptopp $(LDFLAGS) $(LDLIBS)

nolib: $(OBJS) # makes it faster to test changes

Jeffrey Walton

unread,
Oct 8, 2010, 5:39:33 AM10/8/10
to Crypto++ Users
The feature works much better with:

CXXFLAGS = -DNDEBUG -g -O2 -DUSE_PRECOMPILED_HEADERS=1

I also added <string>, <algorithm>, and <memory> to the list in pch.h.

Using precompiled headers on a particular Core 2 Duo (circa mid-2008)
reduced compile times by 38% (3 min, 51 sec versus 2 min, 22 sec).

Jeff

Jason Smethers

unread,
Oct 9, 2010, 12:18:34 PM10/9/10
to cryptop...@googlegroups.com
Have not used precompiled headers with gcc, but I do get great results
using ccache and -j JOBS=NCPU in gmake with any project. Something like
10% to 20% of original time to compile after caching is pretty typically.

Jason

Reply all
Reply to author
Forward
0 new messages