From: Robin Dunn Date: Sat, 13 Sep 2003 00:01:49 +0000 (+0000) Subject: For OS X detect (based on gcc version) and use -single_module flag. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/439484990e52d31c980b6cde765f0990c04f9ef6 For OS X detect (based on gcc version) and use -single_module flag. Also removed the use of the flat namespace flags to prevent symbol name conflicts when an app loads other dynlibs (that may also contain libpng for example.) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23556 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/aclocal.m4 b/aclocal.m4 index 73259c5da7..415d17b6cf 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1278,7 +1278,26 @@ AC_DEFUN(AC_BAKEFILE_SHARED_LD, dnl or with a double stage link in order to create a single module dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved - cat <shared-ld-sh + dnl If using newer dev tools then there is a -single_module flag that + dnl we can use to do this, otherwise we'll need to use a helper + dnl script. Check the version of gcc to see which way we can go. + AC_CACHE_CHECK([for gcc 3.1 or later], wx_cv_gcc31, [ + AC_TRY_COMPILE([], + [ + #if (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)) + #error old gcc + #endif + ], + [ + wx_cv_gcc31=yes + ], + [ + wx_cv_gcc31=no + ] + ) + ]) + if test "$wx_cv_gcc31" = "no"; then + cat <shared-ld-sh #!/bin/sh #----------------------------------------------------------------------------- #-- Name: distrib/mac/shared-ld-sh @@ -1350,7 +1369,7 @@ fi # Link the shared library from the single module created # if test \${verbose} = 1; then - echo "cc \${linking_flag} master.\$\$.o \${args}" + echo "c++ \${linking_flag} master.\$\$.o \${args}" fi c++ \${linking_flag} master.\$\$.o \${args} status=\$? @@ -1365,17 +1384,21 @@ rm -f master.\$\$.o exit 0 EOF - chmod +x shared-ld-sh - - SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -undefined suppress -flat_namespace -o" - SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -undefined suppress -flat_namespace -o" + chmod +x shared-ld-sh + + dnl Use the shared-ld-sh helper script + SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -o" + SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -o" + else + dnl Use the -single_module flag and let the linker do it for us + SHARED_LD_CC="\${CXX} -dynamiclib -single_module -o" + SHARED_LD_MODULE_CC="\${CXX} -bundle -single_module -o" + fi SHARED_LD_CXX="$SHARED_LD_CC" SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC" PIC_FLAG="-dynamic -fPIC" dnl FIXME - what about C libs? Gilles says to use c++ because it doesn't dnl matter for C projects and matters for C++ ones - dnl FIXME - newer devel tools have linker flag to do this, the script - dnl is not necessary - detect! ;; *-*-aix* ) diff --git a/configure b/configure index 50da13b3f8..915749109b 100755 --- a/configure +++ b/configure @@ -34389,7 +34389,63 @@ echo "${ECHO_T}$bakefile_cv_prog_icc" >&6 CXXFLAGS="$CXXFLAGS -fno-common" - cat <shared-ld-sh + echo "$as_me:$LINENO: checking for gcc 3.1 or later" >&5 +echo $ECHO_N "checking for gcc 3.1 or later... $ECHO_C" >&6 +if test "${wx_cv_gcc31+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + #if (__GNUC__ < 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1)) + #error old gcc + #endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + + wx_cv_gcc31=yes + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + + wx_cv_gcc31=no + + +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +fi +echo "$as_me:$LINENO: result: $wx_cv_gcc31" >&5 +echo "${ECHO_T}$wx_cv_gcc31" >&6 + if test "$wx_cv_gcc31" = "no"; then + cat <shared-ld-sh #!/bin/sh #----------------------------------------------------------------------------- #-- Name: distrib/mac/shared-ld-sh @@ -34461,7 +34517,7 @@ fi # Link the shared library from the single module created # if test \${verbose} = 1; then - echo "cc \${linking_flag} master.\$\$.o \${args}" + echo "c++ \${linking_flag} master.\$\$.o \${args}" fi c++ \${linking_flag} master.\$\$.o \${args} status=\$? @@ -34476,14 +34532,18 @@ rm -f master.\$\$.o exit 0 EOF - chmod +x shared-ld-sh + chmod +x shared-ld-sh - SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -undefined suppress -flat_namespace -o" - SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -undefined suppress -flat_namespace -o" + SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -o" + SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -o" + else + SHARED_LD_CC="\${CXX} -dynamiclib -single_module -o" + SHARED_LD_MODULE_CC="\${CXX} -bundle -single_module -o" + fi SHARED_LD_CXX="$SHARED_LD_CC" SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC" PIC_FLAG="-dynamic -fPIC" - ;; + ;; *-*-aix* ) if test "x$GCC" != "xyes"; then