From 7ddbed5dfbbe9050e48b5fd531d4e2e6f23125a5 Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Sat, 9 Apr 2022 15:11:36 -0700 Subject: [PATCH] always build shared libs --- configure | 237 +++--------------------------------------------------- 1 file changed, 10 insertions(+), 227 deletions(-) diff --git a/configure b/configure index d7dbc0f..5ff47a8 100755 --- a/configure +++ b/configure @@ -11405,7 +11405,7 @@ SHLIB_INSTALL_NAME_FLAG="-install_name " CFLAGS_FOR_PIC="-fpic -DMR_PIC" EXT_FOR_PIC_OBJECTS=pic_o -EXT_FOR_SHARED_LIB=$LIB_SUFFIX +EXT_FOR_SHARED_LIB=so USE_DLLS=no # The following variables specify options to $LINK_SHARED_OBJ to # allow/disallow unresolved symbols when building shared libraries. @@ -11414,241 +11414,24 @@ ERROR_UNDEFINED="" DEFAULT_LINKAGE="shared" if test "$mercury_cv_enable_shared_libs" = "yes"; then - case "$host" in - i*86-*-linux|i*86-*-linux-gnu|x86_64-*-linux*) - case "$ac_cv_c_compiler_gnu" in - yes) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - EXT_FOR_SHARED_LIB=so - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports --no-undefined" >&5 -$as_echo_n "checking if linker supports --no-undefined... " >&6; } - rm -f conftest* - if test "$mercury_cv_thread_local_storage" = yes; then - # --no-undefined doesn't work with TLS - # and older versions of glibc. - echo "__thread int x; - int main(void) { return x; }" > conftest.c - $CC -Wl,--no-undefined -fPIC -shared \ - -o conftest conftest.c 2>/dev/null - else - echo "int main(void) { return 0; }" > conftest.c - $CC -Wl,--no-undefined -o conftest conftest.c - fi - if test -f conftest; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - ERROR_UNDEFINED="-Wl,--no-undefined" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld-linux.so" >&5 -$as_echo_n "checking for ld-linux.so... " >&6; } - rm -f conftest* - echo "int main(void) { return 0; }" > conftest.c - $CC -o conftest conftest.c - ld_linux=`ldd ./conftest | \ - awk '/ld-linux/{print $1;}'` - case $ld_linux in - /lib/ld-linux.so*) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_linux" >&5 -$as_echo "$ld_linux" >&6; } - SHARED_LIBS="$SHARED_LIBS $ld_linux" - SHARED_LIBS_SH="$SHARED_LIBS_SH $ld_linux" - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - fi - rm -f conftest* - ;; - *) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac + SHARED_LIBS="$SHARED_LIBS $ld_linux" + SHARED_LIBS_SH="$SHARED_LIBS_SH $ld_linux" - # On x86_64 machines we use -fPIC rather than -fpic - # in order to avoid limits on the size of the global - # offset table implied by the latter. - case "$host" in - x86_64-*-linux*) - CFLAGS_FOR_PIC="-fPIC -DMR_PIC" - ;; - esac - ;; - m68*-linux|m68*-linux-gnu) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - EXT_FOR_SHARED_LIB=so - ;; - aarch64*-linux|aarch64*-linux-gnu) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - # On aarch64 machines we must use -fPIC rather than -fpic in order - # to avoid limits on the size of the global offset table. + # On x86_64 machines we use -fPIC rather than -fpic + # in order to avoid limits on the size of the global + # offset table implied by the latter. + case "$host" in + x86_64-*-linux*) CFLAGS_FOR_PIC="-fPIC -DMR_PIC" - EXT_FOR_SHARED_LIB=so - ;; - *-freebsd*) - # Tested on FreeBSD 10.1 i386/amd64. - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - EXT_FOR_SHARED_LIB=so - ;; - *-openbsd*) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - EXT_FOR_SHARED_LIB=so - ;; - i*86-*-solaris2.*) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - - # XXX For Solaris/SPARC, we don't link in libgcc.a. - # Why not? Do we need to do the same thing for Solaris/x86? - #SHARED_LIBS="$(MATH_LIB) -lc" # don't link in libgcc.a - #SHARED_LIBS_SH="$MATH_LIB -lc" # don't link in libgcc.a - - # XXX We need -mimpure-text because libraries such as - # libreadline.a might be installed with only the .a rather - # than the .so, and not compiled with -fpic, - # and we need to link against them when creating shared libs. - LINK_SHARED_OBJ="$CC -shared -mimpure-text" - LINK_SHARED_OBJ_SH="$CC -shared -mimpure-text" - - # XXX We should use the following. - # However, this causes problems on mundroo.cs.mu.oz.au, - # due to the readline library being installed only as - # libreadline.a, with no corresponding libreadline.so. - #ERROR_UNDEFINED="-Wl,-z,defs" - - EXE_RPATH_OPT="-R" - EXE_RPATH_SEP=" -R" - SHLIB_RPATH_OPT="-R" - SHLIB_RPATH_SEP=" -R" - EXT_FOR_SHARED_LIB=so - DEFAULT_LINKAGE=static - ;; - sparc-sun-solaris2.*) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SHARED_LIBS="$(MATH_LIB) -lc" # don't link in libgcc.a - SHARED_LIBS_SH="$MATH_LIB -lc" # don't link in libgcc.a - LINK_SHARED_OBJ="$CC -shared -mimpure-text" - LINK_SHARED_OBJ_SH="$CC -shared -mimpure-text" - ERROR_UNDEFINED="-Wl,-z,defs" - EXE_RPATH_OPT="-R" - EXE_RPATH_SEP=" -R" - SHLIB_RPATH_OPT="-R" - SHLIB_RPATH_SEP=" -R" - CFLAGS_FOR_PIC="-fpic -DMR_PIC" # used only for libgc.{a,so} - EXT_FOR_PIC_OBJECTS=o - - # Note that despite the above definition of CFLAGS_FOR_PIC, - # we don't use `-fpic' for shared libraries on Solaris - # (the definition of EXT_FOR_PIC_OBJECTS=o means that - # CFLAGS_FOR_PIC will be used only for building libgc.a - # and libgc.so.) - # - # The reason for this is that shared libraries work without it - # (well, at least they are shared on disk -- although the code is - # not shared at runtime), and using `-fpic' would reduce efficiency. - # - # It works because the Solaris dynamic linker will actually do - # the fixups at runtime for non-PIC code. (The code is mapped - # copy-on-write, and when the linker does the fixups, it gets copied. - # Hence the lack of runtime sharing.) We need to link with - # `gcc -shared -mimpure-text' rather than `gcc -shared', because - # `gcc -shared' passes `-z text' to the linker, which causes it to - # report an error if any runtime fixups would be needed. - # - # If you *do* use `-fpic', you must also use `-DMR_PIC'. - # - # See runtime/mercury_goto.h for the code that handles PIC on SPARCs. - # Note that mixing PIC and non-PIC code is fine on SPARCs. - - EXT_FOR_SHARED_LIB=so - ;; - *-cygwin*) - # Disabled for now, since it hasn't been tested. - # xxx_MSG_RESULT(yes) - # EXT_FOR_SHARED_LIB=dll - # USE_DLLS=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled for now because it is untested" >&5 -$as_echo "disabled for now because it is untested" >&6; } - - CFLAGS_FOR_PIC= - EXT_FOR_PIC_OBJECTS=o - DEFAULT_LINKAGE=static - ;; - *mingw*) - # disabled for now, since it hasn't been tested - # xxx_MSG_RESULT(yes) - # EXT_FOR_SHARED_LIB=dll - # USE_DLLS=yes - { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled for now because it is untested" >&5 -$as_echo "disabled for now because it is untested" >&6; } - - CFLAGS_FOR_PIC= - EXT_FOR_PIC_OBJECTS=o - DEFAULT_LINKAGE=static - ;; - *apple*darwin*) - # If the compiler is gcc or clang then use Darwin style dynamic - # linking. Otherwise use static linking. - case "$C_COMPILER_TYPE" in - gcc*|clang*) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - SHLIB_USE_INSTALL_NAME="--shlib-linker-use-install-name" - SHLIB_INSTALL_NAME_FLAG="-install_name " - EXT_FOR_SHARED_LIB=dylib - CFLAGS_FOR_PIC="-fPIC -DMR_PIC" - ERROR_UNDEFINED="-undefined error" - # The MACOSX_DEPLOYMENT_TARGET environment variable needs to be - # set so we can use the `-undefined dynamic_lookup' option. - SET_MACOSX_DEPLOYMENT_TARGET="\ - MACOSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET; \ - export MACOSX_DEPLOYMENT_TARGET" - - LINK_SHARED_OBJ="$CC -multiply_defined suppress \ - -dynamiclib -single_module" - LINK_SHARED_OBJ_SH="$CC -multiply_defined \ - suppress -dynamiclib -single_module" - ALLOW_UNDEFINED="-undefined dynamic_lookup" - ;; - - *) - CFLAGS_FOR_PIC= - EXT_FOR_PIC_OBJECTS=o - DEFAULT_LINKAGE=static - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - ;; - esac ;; arm*-linux|arm*-linux-gnu) - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - EXT_FOR_SHARED_LIB=so # One can build gcc with a default PIC register other than sl # so let's force it. If you change this, # update MR_ARM_PIC_REG in runtime/mercury_goto.h as well. CFLAGS_FOR_PIC="-mpic-register=sl $CFLAGS_FOR_PIC" ;; - *) - # CFLAGS_FOR_PIC is used by boehm_gc/Makefile when creating libgc.a. - # If the system doesn't support shared libraries, - # then we should set it to empty, not `-fpic'. - CFLAGS_FOR_PIC= - EXT_FOR_PIC_OBJECTS=o - DEFAULT_LINKAGE=static - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } + aarch64*-linux|aarch64*-linux-gnu) + CFLAGS_FOR_PIC="-mpic-register=sl $CFLAGS_FOR_PIC" ;; esac else -- 2.35.1