Fabio, On Apr 3, 2013, at 11:10 , Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> wrote: > Hi Andrei, > > On 4/3/2013 8:35 AM, Andrei Belov wrote: >> Hello corosync users, >> >> here's the patch that makes possible to flawlessly build latest Corosync on SunOS 5.11 >> and Mac OS X 10.8.3 (as well as on earlier versions of both OSes). >> >> > > If you can change this: > > +case "$host_os" in > +*Linux*|*linux*|*bsd*) > > to detect if ld supports the options, then I am ok with it. > > I don´t want to see host_os detection anywhere near configure.ac, because: > > 1) a user might have a GNU toolchain on those OS´es and will want to use > them by default > 2) the ld in use on a systeam is strictly dependent on how gcc is built > (and we don´t know that upfront unless you want to write a very complex > check). > > We spent a huge amount of time moving to "detect features" vs > "hardcoding" because it´s a lot more flexible and lasts longer. this > approach is moving backwards. Thanks for the explanation - I see why this makes sense now. Please find the improved patch attached. I've just tested it on CentOS 6.0, SunOS 5.11 and Mac OS X 10.8.3, and it seems to work as expected. GCC versions are below: CentOS: gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) SunOS: gcc version 4.7.2 (GCC) Mac OS X: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
From 03a62de0635497ea65d38998d636e60e9bcff62c Mon Sep 17 00:00:00 2001 From: Andrei Belov <defanator@xxxxxxxxx> Date: Wed, 3 Apr 2013 12:46:47 +0400 Subject: [PATCH] Added checks for "--as-needed" and "--version-script" linker flags. This makes possible to build Corosync from sources on SunOS 5.11, Mac OS X 10.8.3 and probably other systems with non-GNU linker. --- configure.ac | 27 ++++++++++++++++++++++++++- lib/Makefile.am | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 52ad39b..5175f8b 100644 --- a/configure.ac +++ b/configure.ac @@ -610,6 +610,31 @@ if test "x${enable_secure_build}" = xyes; then fi fi +AC_CACHE_CHECK([whether $CC accepts "--as-needed"], [ap_cv_cc_as_needed], [ + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,--as-needed" + AC_TRY_RUN([static int foo[30000]; int main () { return 0; }], + [ap_cv_cc_as_needed=yes], [ap_cv_cc_as_needed=no], [ap_cv_cc_as_needed=yes]) + LDFLAGS=$save_LDFLAGS +]) +if test "$ap_cv_cc_as_needed" = "yes"; then + SEC_LDFLAGS="$SEC_LDFLAGS -Wl,--as-needed" +fi + +AC_CACHE_CHECK([whether $CC accepts "--version-script"], [ap_cv_cc_version_script], [ + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.versions" + echo "CONFTEST { };" >conftest.versions + AC_TRY_RUN([static int foo[30000]; int main () { return 0; }], + [ap_cv_cc_version_script=yes], [ap_cv_cc_version_script=no], [ap_cv_cc_version_script=yes]) + rm -f conftest.versions + LDFLAGS=$save_LDFLAGS +]) +if test "$ap_cv_cc_version_script" = "yes"; then + AC_SUBST(EXTRA_LDFLAGS, ["-Wl,--version-script=\$(srcdir)/lib\$(call get_libname,\$<).versions"]) +else + AC_SUBST(EXTRA_LDFLAGS, [""]) +fi # define global include dirs INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include -I\$(top_srcdir)/include" @@ -621,7 +646,7 @@ CFLAGS="$ENV_CFLAGS $lt_prog_compiler_pic $SEC_FLAGS $OPT_CFLAGS $GDB_FLAGS \ $WERROR_CFLAGS $NSS_CFLAGS $LIBQB_CFLAGS \ $SNMP_INCLUDES" CPPFLAGS="$ENV_CPPFLAGS $ANSI_CPPFLAGS $INCLUDE_DIRS" -LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS -Wl,--as-needed $COVERAGE_LDFLAGS" +LDFLAGS="$ENV_LDFLAGS $lt_prog_compiler_pic $SEC_LDFLAGS $COVERAGE_LDFLAGS" # substitute what we need: AC_SUBST([BASHPATH]) diff --git a/lib/Makefile.am b/lib/Makefile.am index 3bcdb2c..c5d4457 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -49,7 +49,7 @@ noinst_HEADERS = util.h # override global LIBS that pulls in lots of craft we don't need here LIBS = -version-number $(call get_soname,$<) \ - -Wl,-version-script=$(srcdir)/lib$(call get_libname,$<).versions \ + @EXTRA_LDFLAGS@ \ -lpthread \ $(top_builddir)/common_lib/libcorosync_common.la \ $(LIBQB_LIBS) -- 1.7.9.6 (Apple Git-31.1)
_______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss