[m-rev.] for review: Do not define _DYNAMIC when linking statically on Linux.

Peter Wang novalazy at gmail.com
Fri Jan 12 15:48:33 AEDT 2018


We used to manually define the symbol _DYNAMIC (to zero) when
statically linking on Linx to avoid undefined references to _DYNAMIC
from boehm_gc/dyn_load.c. That has been unnecessary since gc5.0alpha3
when dyn_load.c declared _DYNAMIC as a weak symbol.

When a program is statically linked to musl, _DYNAMIC is defined with a
non-zero address. Forcing its address to zero caused the program to
crash during GC initialisation. Fixed now.

configure.ac:
    As above.
---
 configure.ac | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/configure.ac b/configure.ac
index fcd1f526b..e72add40e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4686,20 +4686,6 @@ case "$C_COMPILER_TYPE" in
         ;;
 esac
 case "$FULLARCH" in
-    *-linux*)
-        # On Linux, if we're linking statically, we need to pass
-        # `-defsym _DYNAMIC=0' to the linker, to avoid undefined references
-        # to _DYNAMIC in boehm_gc/dyn_load.c. (We might eventually need
-        # similar treatment for other OSs too.)
-        case "$C_COMPILER_TYPE" in
-            gcc*)
-                LD_STATIC_FLAGS="-static -Wl,-defsym -Wl,_DYNAMIC=0"
-                ;;
-            clang*)
-                LD_STATIC_FLAGS="-static -Wl,-defsym -Wl,_DYNAMIC=0"
-                ;;
-        esac
-        ;;
     *-sun-solaris*)
         case "$COMPILER" in
             cc)
-- 
2.15.1



More information about the reviews mailing list