[tor-commits] [tor/release-0.4.5] configure: Fix the --enable-static-tor switch

dgoulet at torproject.org dgoulet at torproject.org
Tue Dec 8 14:15:28 UTC 2020


commit c618c4f27986825df2026fb22b8ee222edd1afa1
Author: David Goulet <dgoulet at torproject.org>
Date:   Wed Nov 18 11:24:38 2020 -0500

    configure: Fix the --enable-static-tor switch
    
    The "-static" compile flag was set globally which means that all autoconf test
    were attempting to be built statically and lead to failures of detecting
    OpenSSL libraries and others.
    
    This commit adds this flag only to the "tor" binary build.
    
    There is also a fix on where to find libevent.a since it is using libtool, it
    is in .libs/.
    
    At this commit, there are still warnings being emitted that informs the user
    that the built binary must still be linked dynamically with glibc.
    
    Fixes #40111
    
    Signed-off-by: David Goulet <dgoulet at torproject.org>
---
 changes/ticket40111 | 7 +++++++
 configure.ac        | 5 +++--
 src/app/include.am  | 6 ++++--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/changes/ticket40111 b/changes/ticket40111
new file mode 100644
index 0000000000..a82ca0d489
--- /dev/null
+++ b/changes/ticket40111
@@ -0,0 +1,7 @@
+  o Minor bugfixes (configure, build):
+    - Fix the --enable-static-tor switch to properly set the -static compile
+      option onto the tor binary only. Fixes bug 40111; bugfix on
+      0.2.3.1-alpha.
+    - Path to static libevent has been fixed as well which affects the
+      --enable-static-libevent to behave correctly now. The .a file is in
+      .libs/ of libevent repository, not at the root.
diff --git a/configure.ac b/configure.ac
index 6eb09db429..83f6ad1821 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,8 +129,9 @@ if test "$enable_static_tor" = "yes"; then
   enable_static_libevent="yes";
   enable_static_openssl="yes";
   enable_static_zlib="yes";
-  CFLAGS="$CFLAGS -static"
+  TOR_STATIC_LDFLAGS="-static"
 fi
+AC_SUBST(TOR_STATIC_LDFLAGS)
 
 if test "$enable_system_torrc" = "no"; then
   AC_DEFINE(DISABLE_SYSTEM_TORRC, 1,
@@ -953,7 +954,7 @@ if test "$enable_static_libevent" = "yes"; then
    if test "$tor_cv_library_libevent_dir" = "(system)"; then
      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
    else
-     TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/libevent.a $STATIC_LIBEVENT_FLAGS"
+     TOR_LIBEVENT_LIBS="$TOR_LIBDIR_libevent/.libs/libevent.a $STATIC_LIBEVENT_FLAGS"
    fi
 else
      if test "x$ac_cv_header_event2_event_h" = "xyes"; then
diff --git a/src/app/include.am b/src/app/include.am
index b81fad0276..8bb315fff1 100644
--- a/src/app/include.am
+++ b/src/app/include.am
@@ -14,7 +14,8 @@ src_app_tor_SOURCES = src/app/main/tor_main.c
 # This seems to matter nowhere but on windows, but I assure you that it
 # matters a lot there, and is quite hard to debug if you forget to do it.
 
-src_app_tor_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@
+src_app_tor_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
+	@TOR_LDFLAGS_libevent@ @TOR_STATIC_LDFLAGS@
 src_app_tor_LDADD = libtor.a \
 	$(rust_ldadd) \
 	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
@@ -26,7 +27,8 @@ if COVERAGE_ENABLED
 src_app_tor_cov_SOURCES = $(src_app_tor_SOURCES)
 src_app_tor_cov_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
 src_app_tor_cov_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
-src_app_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@
+src_app_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
+	@TOR_LDFLAGS_libevent@ @TOR_STATIC_LDFALGS@
 src_app_tor_cov_LDADD = src/test/libtor-testing.a \
 	@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
 	@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \





More information about the tor-commits mailing list