You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2019/06/20 13:00:38 UTC

svn commit: r1861685 - in /httpd/httpd/trunk: Makefile.in build/config_vars.sh.in configure.in server/Makefile.in server/main.c

Author: jorton
Date: Thu Jun 20 13:00:37 2019
New Revision: 1861685

URL: http://svn.apache.org/viewvc?rev=1861685&view=rev
Log:
Add an --enable-reduced-exports configure option to link libmain.a
using ld's --whole-archive mode and avoid building exports.c entirely.
This reduces the size of a minimal httpd binary by 18% on Linux/x86_64
(687K to 560K) with no difference to the set of symbols available to
modules.

This option is only appropriate to use if using a shared libapr*
build, hence is non-default.

* configure.in: Add --enable-reduced-exports; disable httpdunit build
  if used.  Define AP_FORCE_EXPORTS if not enabled (default) in place
  of AP_USING_AUTOCONF.

* server/main.c (ap_suck_in_APR): Only build if AP_FORCE_EXPORTS is
  defined.

* Makefile.in: Link libmain.la using LIBMAIN_LIB.

* server/Makefile.in: Conditionally build exports.c into libmain.

Modified:
    httpd/httpd/trunk/Makefile.in
    httpd/httpd/trunk/build/config_vars.sh.in
    httpd/httpd/trunk/configure.in
    httpd/httpd/trunk/server/Makefile.in
    httpd/httpd/trunk/server/main.c

Modified: httpd/httpd/trunk/Makefile.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/Makefile.in?rev=1861685&r1=1861684&r2=1861685&view=diff
==============================================================================
--- httpd/httpd/trunk/Makefile.in (original)
+++ httpd/httpd/trunk/Makefile.in Thu Jun 20 13:00:37 2019
@@ -4,8 +4,13 @@ CLEAN_SUBDIRS = test
 
 PROGRAM_NAME         = $(progname)
 PROGRAM_SOURCES      = modules.c
-PROGRAM_LDADD        = buildmark.o $(HTTPD_LDFLAGS) $(PROGRAM_DEPENDENCIES) $(HTTPD_LIBS) $(EXTRA_LIBS) $(AP_LIBS) $(LIBS)
+PROGRAM_LDADD        = buildmark.o $(HTTPD_LDFLAGS) $(PROGRAM_LDDEPS) $(HTTPD_LIBS) $(EXTRA_LIBS) $(AP_LIBS) $(LIBS)
 PROGRAM_PRELINK      = $(COMPILE) -c $(top_srcdir)/server/buildmark.c
+PROGRAM_LDDEPS = \
+  $(BUILTIN_LIBS) \
+  $(MPM_LIB) \
+  $(LIBMAIN_LIB) \
+  os/$(OS_DIR)/libos.la
 PROGRAM_DEPENDENCIES = \
   $(BUILTIN_LIBS) \
   $(MPM_LIB) \

Modified: httpd/httpd/trunk/build/config_vars.sh.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/build/config_vars.sh.in?rev=1861685&r1=1861684&r2=1861685&view=diff
==============================================================================
--- httpd/httpd/trunk/build/config_vars.sh.in (original)
+++ httpd/httpd/trunk/build/config_vars.sh.in Thu Jun 20 13:00:37 2019
@@ -84,4 +84,6 @@ exec sed "
 /^APR_INCLUDEDIR.*$/s,.*,APR_INCLUDEDIR = ${APR_INCLUDEDIR},
 /^APU_INCLUDEDIR.*$/s,.*,APU_INCLUDEDIR = ${APU_INCLUDEDIR},
 /^LIBTOOL.*$/s,/[^ ]*/libtool \(.*\),${APR_LIBTOOL} @LTFLAGS@,
+/^EXPORTS_DOT_C/d
+/^LIBMAIN_LIB/d
 "

Modified: httpd/httpd/trunk/configure.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/configure.in?rev=1861685&r1=1861684&r2=1861685&view=diff
==============================================================================
--- httpd/httpd/trunk/configure.in (original)
+++ httpd/httpd/trunk/configure.in Thu Jun 20 13:00:37 2019
@@ -703,6 +703,28 @@ fi
 APACHE_SUBST(PICFLAGS)
 APACHE_SUBST(PILDFLAGS)
 
+ap_reduced_exports=no
+EXPORTS_DOT_C=exports.c
+LIBMAIN_LIB=server/libmain.la
+APACHE_SUBST(EXPORTS_DOT_C)
+APACHE_SUBST(LIBMAIN_LIB)
+
+AC_ARG_ENABLE(reduced-exports,
+APACHE_HELP_STRING(--enable-reduced-exports,Reduce binary size if using shared APR libraries),
+[
+  if test "$enableval" = "yes" -a "$GCC" = "yes"; then
+    ap_reduced_exports=yes
+  fi
+])
+
+if test "$ap_reduced_exports" = "yes"; then
+  EXPORTS_DOT_C=
+  LIBMAIN_LIB="-Wl,--whole-archive,server/.libs/libmain.a,--no-whole-archive"
+  AC_MSG_NOTICE([Using reduced symbol exports])
+else
+  AC_DEFINE(AP_FORCE_EXPORTS, 1, [Force symbol exports for dependent libraries])
+fi
+
 AC_ARG_WITH(valgrind,
   [  --with-valgrind[[=DIR]]   Enable code to reduce valgrind false positives
                           (optionally: set path to valgrind headers) ],
@@ -722,7 +744,7 @@ AC_ARG_WITH(valgrind,
 dnl Enable the unit test executable if Check is installed.
 dnl TODO: at the moment, only pkg-config discovery is supported.
 AC_MSG_CHECKING([for Check to enable unit tests])
-if test "x$PKGCONFIG" != "x" && `$PKGCONFIG --atleast-version='0.9.12' check`; then
+if test "x$PKGCONFIG" != "x" -a "$AP_FORCE_EXPORTS" = "yes" && `$PKGCONFIG --atleast-version='0.9.12' check`; then
   UNITTEST_CFLAGS=`$PKGCONFIG --cflags check`
   UNITTEST_LIBS=`$PKGCONFIG --libs check`
   other_targets="$other_targets test/httpdunit"
@@ -864,9 +886,6 @@ APACHE_SUBST(AP_LIBS)
 APACHE_SUBST(AP_BUILD_SRCLIB_DIRS)
 APACHE_SUBST(AP_CLEAN_SRCLIB_DIRS)
 
-AC_DEFINE(AP_USING_AUTOCONF, 1,
-		[Using autoconf to configure Apache])
-
 if test "$SINGLE_LISTEN_UNSERIALIZED_ACCEPT" = "1"; then
     AC_DEFINE(SINGLE_LISTEN_UNSERIALIZED_ACCEPT, 1, 
               [This platform doesn't suffer from the thundering herd problem])

Modified: httpd/httpd/trunk/server/Makefile.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/Makefile.in?rev=1861685&r1=1861684&r2=1861685&view=diff
==============================================================================
--- httpd/httpd/trunk/server/Makefile.in (original)
+++ httpd/httpd/trunk/server/Makefile.in Thu Jun 20 13:00:37 2019
@@ -12,7 +12,7 @@ LTLIBRARY_SOURCES = \
 	connection.c listen.c util_mutex.c \
 	mpm_common.c mpm_unix.c mpm_fdqueue.c \
 	util_charset.c util_cookies.c util_debug.c util_xml.c \
-	util_filter.c util_pcre.c util_regex.c exports.c \
+	util_filter.c util_pcre.c util_regex.c $(EXPORTS_DOT_C) \
 	scoreboard.c error_bucket.c protocol.c core.c request.c provider.c \
 	eoc_bucket.c eor_bucket.c core_filters.c \
 	util_expr_parse.c util_expr_scan.c util_expr_eval.c \

Modified: httpd/httpd/trunk/server/main.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/main.c?rev=1861685&r1=1861684&r2=1861685&view=diff
==============================================================================
--- httpd/httpd/trunk/server/main.c (original)
+++ httpd/httpd/trunk/server/main.c Thu Jun 20 13:00:37 2019
@@ -861,7 +861,7 @@ static void usage(process_rec *process)
     return !OK;
 }
 
-#ifdef AP_USING_AUTOCONF
+#ifdef AP_FORCE_EXPORTS
 /* This ugly little hack pulls any function referenced in exports.c into
  * the web server.  exports.c is generated during the build, and it
  * has all of the APR functions specified by the apr/apr.exports and