From 2b43a5a92beff21ae306397987b568ceb41ef718 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 6 Jun 2019 05:14:32 -0700 Subject: [PATCH] configure: Add --enable-compact for the smallest possible building and linking. --- configure.ac | 49 ++++++++++++++++++++++++++++++++++++------- construct/Makefile.am | 1 - ircd/Makefile.am | 1 - modules/Makefile.am | 1 - 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 2ed2600ad..e31daa8b4 100644 --- a/configure.ac +++ b/configure.ac @@ -155,6 +155,22 @@ AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [Enable debugging suite fo AM_CONDITIONAL([DEBUG], [[[[ "$DEBUG" = "1" ]]]]) +dnl +dnl Compactness +dnl + +AC_MSG_CHECKING(Optimize for size; strip symbols; force no debugging) +AC_ARG_ENABLE(compact, AC_HELP_STRING([--enable-compact], [Optimize for size and compactness]), +[ + AC_MSG_RESULT([yes]) + AC_SUBST(COMPACT, 1) + RB_DEFINE_UNQUOTED([COMPACT], [1], [Not configured for compactness when lit.]) +], [ + AC_MSG_RESULT([no]) +]) + +AM_CONDITIONAL([COMPACT], [[[[ "$COMPACT" = "1" ]]]]) + dnl dnl Explicit assert switch for still using assert() without --enable-debug dnl @@ -267,10 +283,18 @@ AC_ARG_WITH(optimize-level, AC_HELP_STRING([--with-optimize-level[[[=3]]]], [Exp ], [ AM_COND_IF(OPTIMIZE, [ - optimize_level="3" - AC_MSG_RESULT([no, but --enable-optimize has implied level -O$optimize_level]) - AC_SUBST(OPTIMIZE_LEVEL, $optimize_level) - RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], [$optimize_level], [Explicitly set release mode optimization]) + AM_COND_IF(COMPACT, + [ + optimize_level="s" + AC_MSG_RESULT([no, but --enable-optimize and --enable-compact means -O$optimize_level]) + AC_SUBST(OPTIMIZE_LEVEL, $optimize_level) + RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], [$optimize_level], [Implicitly set release mode optimization]) + ], [ + optimize_level="3" + AC_MSG_RESULT([no, but --enable-optimize has implied level -O$optimize_level]) + AC_SUBST(OPTIMIZE_LEVEL, $optimize_level) + RB_DEFINE_UNQUOTED([OPTIMIZE_LEVEL], [$optimize_level], [Explicitly set release mode optimization]) + ]) ], [ AM_COND_IF(DEBUG, [ @@ -501,9 +525,14 @@ AM_COND_IF([DEBUG], CXXFLAGS+=" -fvar-tracking" CXXFLAGS+=" -fvar-tracking-assignments" ], [ - dnl Note these flags are unreliable with LTO - CXXFLAGS+=" -g" - CXXFLAGS+=" -ggdb" + AM_COND_IF([COMPACT], + [ + + ], [ + dnl Note these flags are unreliable with LTO + CXXFLAGS+=" -g" + CXXFLAGS+=" -ggdb" + ]) ]) dnl Creates an ELF section in the output which contains a list of @@ -1625,6 +1654,12 @@ AC_SUBST(EXTRA_CXXFLAGS) AC_SUBST(EXTRA_LDFLAGS) AC_SUBST(EXTRA_LIBS) +AM_COND_IF([COMPACT], +[ + EXTRA_LDFLAGS+=" -Wl,--strip-all" + EXTRA_LDFLAGS+=" -Wl,--gc-sections" +]) + AM_COND_IF([MINGW], [ diff --git a/construct/Makefile.am b/construct/Makefile.am index a9580cb23..e3976ba3e 100644 --- a/construct/Makefile.am +++ b/construct/Makefile.am @@ -28,7 +28,6 @@ AM_LDFLAGS = \ -Wl,--detect-odr-violations \ -Wl,--unresolved-symbols=report-all \ -Wl,--allow-shlib-undefined \ - -Wl,--gc-sections \ -Wl,--dynamic-list-data \ -Wl,--dynamic-list-cpp-new\ -Wl,--dynamic-list-cpp-typeinfo \ diff --git a/ircd/Makefile.am b/ircd/Makefile.am index 50139e404..5b218e1a3 100644 --- a/ircd/Makefile.am +++ b/ircd/Makefile.am @@ -40,7 +40,6 @@ AM_LDFLAGS = \ -Wl,--unresolved-symbols=report-all \ -Wl,--no-undefined-version \ -Wl,--weak-unresolved-symbols \ - -Wl,--no-gc-sections \ -Wl,--icf=all \ -Wl,--rosegment \ -Wl,--gdb-index \ diff --git a/modules/Makefile.am b/modules/Makefile.am index 4b2c2bd56..a9838454e 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -38,7 +38,6 @@ AM_LDFLAGS = \ -Wl,--warn-execstack \ -Wl,--detect-odr-violations \ -Wl,--allow-shlib-undefined \ - -Wl,--gc-sections \ -Wl,--icf=all \ -Wl,--gdb-index \ -Wl,-z,lazy \