aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-06-22 14:31:34 -0700
committerMike Frysinger <vapier@gentoo.org>2012-07-03 00:38:40 -0400
commitb9cfa0a10decdbe659447a221a0634f2b78943b0 (patch)
tree47aa5b2a61934e7f85100e43515e6e889e436995
parentsb_printf: expand feature set slightly and fix testing (diff)
downloadsandbox-b9cfa0a10decdbe659447a221a0634f2b78943b0.tar.gz
sandbox-b9cfa0a10decdbe659447a221a0634f2b78943b0.tar.bz2
sandbox-b9cfa0a10decdbe659447a221a0634f2b78943b0.zip
precompile headers.h to speed up build slightly
Since all system headers are included by way of headers.h, we can pre-compile this to speed up the build up a bit. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am30
-rw-r--r--configure.ac6
-rw-r--r--libsandbox/Makefile.am2
-rw-r--r--libsandbox/headers.h1
-rw-r--r--libsandbox/libsandbox.c7
-rw-r--r--libsbutil/Makefile.am1
-rw-r--r--libsbutil/headers.h1
-rw-r--r--tests/Makefile.am2
9 files changed, 39 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 502b3a1..4d34aee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
a.out
*~
+*.gch
*.lo
*.la
*.o
@@ -21,6 +22,7 @@ core
.gdbinit
/aclocal.m4
+/ar-lib
/autom4te.cache/
/build/
/compile
diff --git a/Makefile.am b/Makefile.am
index e326b23..475c8c0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,6 @@
ACLOCAL_AMFLAGS = -I m4
MAKEFLAGS = --no-print-directory
+AM_CPPFLAGS = $(SANDBOX_DEFINES)
SUBDIRS = \
scripts \
@@ -10,12 +11,35 @@ SUBDIRS = \
src \
tests
-libsandbox: libsbutil
-src: libsbutil
-tests: src
+SANDBOX_PCH = headers.h.gch libsandbox/headers.h.gch libsbutil/headers.h.gch
+BUILT_SOURCES = $(SANDBOX_PCH)
+noinst_LTLIBRARIES = libpch.la
+nodist_libpch_la_SOURCES = $(SANDBOX_PCH)
+GCH_CP = ( \
+ src=`dirname $@`/.libs/`basename $@`.o; \
+ test -e "$$src" || src=$@.o; \
+ cp $$src $@ \
+ )
+# This is built as PIC
+$(builddir)/libsbutil/headers.h.gch: headers.h
+ $(AM_V_GEN)$(LTCOMPILE) -c -o $@.o $< && $(GCH_CP)
+# This is built as PIC + exceptions
+$(builddir)/libsandbox/headers.h.gch: headers.h
+ $(AM_V_GEN)$(LTCOMPILE) -c -o $@.o $< $(CFLAG_EXCEPTIONS) && $(GCH_CP)
+# This is built w/out PIC
+$(builddir)/headers.h.gch: headers.h
+ $(AM_V_GEN)$(COMPILE) -c -o $@.o $< && $(GCH_CP)
+
+libsbutil: libsbutil/headers.h.gch
+libsandbox: libsbutil libsandbox/headers.h.gch
+src: libsbutil headers.h.gch
+tests: src headers.h.gch
EXTRA_DIST = headers.h localdecls.h ChangeLog.0
+CLEANFILES = $(SANDBOX_PCH)
+DISTCLEANFILES = $(CLEANFILES)
+
ChangeLog:
touch ChangeLog
diff --git a/configure.ac b/configure.ac
index 573e412..a6fcd5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,11 +19,14 @@ AC_MSG_CHECKING([environment state])
env 1>&AS_MESSAGE_LOG_FD
AC_MSG_RESULT([ok])
-dnl Checks for programs.
+dnl Check for compiler and features first.
AC_PROG_CC
AM_PROG_CC_C_O
AC_ISC_POSIX
AC_USE_SYSTEM_EXTENSIONS
+
+dnl Checks for programs.
+AM_PROG_AR
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_AWK
@@ -371,6 +374,7 @@ AC_SUBST([CFLAG_EXCEPTIONS])
CPPFLAGS="$CPPFLAGS -D_REENTRANT"
AX_CFLAGS_WARN_ALL
AC_DEFUN([SB_CHECK_CFLAG],[AX_CHECK_COMPILE_FLAG([$1],[CFLAGS="$CFLAGS $1"])])
+SB_CHECK_CFLAG([-Winvalid-pch])
SB_CHECK_CFLAG([-fdata-sections])
SB_CHECK_CFLAG([-ffunction-sections])
AC_DEFUN([SB_CHECK_LDFLAG],[AX_CHECK_LINK_FLAG([-Wl,$1],[LDFLAGS="$LDFLAGS -Wl,$1"])])
diff --git a/libsandbox/Makefile.am b/libsandbox/Makefile.am
index dc45618..2eb8da1 100644
--- a/libsandbox/Makefile.am
+++ b/libsandbox/Makefile.am
@@ -83,7 +83,7 @@ else
$(AM_V_GEN)t= f= header=$@; $(TRACE_MAKE_HEADER)
endif
-EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) $(TRACE_FILES)
+EXTRA_DIST = $(SYMBOLS_FILE) $(SYMBOLS_WRAPPERS) $(SB_NR_FILE) $(TRACE_FILES) headers.h
CLEANFILES = libsandbox.map sb_nr.h symbols.h trace_syscalls*.h
DISTCLEANFILES = $(CLEANFILES)
diff --git a/libsandbox/headers.h b/libsandbox/headers.h
new file mode 100644
index 0000000..7fcc3b2
--- /dev/null
+++ b/libsandbox/headers.h
@@ -0,0 +1 @@
+#include "../headers.h"
diff --git a/libsandbox/libsandbox.c b/libsandbox/libsandbox.c
index 60d4614..2096b06 100644
--- a/libsandbox/libsandbox.c
+++ b/libsandbox/libsandbox.c
@@ -10,14 +10,7 @@
* as some of the InstallWatch code was used.
*/
-#define open xxx_open
-#define open64 xxx_open64
-
#include "headers.h"
-
-#undef open
-#undef open64
-
#include "sbutil.h"
#include "libsandbox.h"
#include "wrappers.h"
diff --git a/libsbutil/Makefile.am b/libsbutil/Makefile.am
index 49a7d3b..a93b95c 100644
--- a/libsbutil/Makefile.am
+++ b/libsbutil/Makefile.am
@@ -44,3 +44,4 @@ libsbutil_la_SOURCES = \
src/dynbuf.c \
$(LOCAL_INCLUDES)
+EXTRA_DIST = headers.h
diff --git a/libsbutil/headers.h b/libsbutil/headers.h
new file mode 100644
index 0000000..7fcc3b2
--- /dev/null
+++ b/libsbutil/headers.h
@@ -0,0 +1 @@
+#include "../headers.h"
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a923ddc..cd8f9c2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -5,7 +5,7 @@ EXTRA_DIST = atlocal.in package.m4.in $(AT_FILES) $(TESTSUITE) \
test-skel-0.c \
tests.h
-AM_CPPFLAGS = -I$(top_srcdir)
+AM_CPPFLAGS = -I$(top_srcdir) $(SANDBOX_DEFINES)
check_PROGRAMS = \
get-group \