On Apr 3, 2013, at 13:12 , Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> wrote: > Hi Andrei, > > On 4/3/2013 10:55 AM, Andrei Belov wrote: > >>> 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) > > Much better patch, only a few minor bits: > > +if test "$ap_cv_cc_as_needed" = "yes"; then > + SEC_LDFLAGS="$SEC_LDFLAGS -Wl,--as-needed" > +fi > > please don´t overload SEC_LDFLAGS. SEC stands for SECURITY (see other > configure.ac bits related). > At that stage of the check you can simply add it to LD_FLAGS if it´s > supported. Oh, my fault with SEC - I thought it means SECondary. :) > For the --version-script: > > Please rename EXTRA_LDFLAGS to something more specific. Maybe > VERSCRIPT_LDFLAGS or something like that. this is merely to avoid > conflict with those distribution automatic build system that override > default LD_FLAGS via EXTRA_LDFLAGS and such, and to keep the variable > isolated. Changed to VERSCRIPT_LDFLAGS (VERSION_SCRIPT_LDFLAGS or LIB_VERSION_SCRIPT_LDFLAGS looks too long). > Nice work btw! Thanks! > > Fabio Third variant is attached.
From 171e2579e59ecdbd197376f0c0a23cad68c50f77 Mon Sep 17 00:00:00 2001 From: Andrei Belov <defanator@xxxxxxxxx> Date: Wed, 3 Apr 2013 13:36:53 +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 | 28 +++++++++++++++++++++++++++- lib/Makefile.am | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 52ad39b..643c558 100644 --- a/configure.ac +++ b/configure.ac @@ -610,6 +610,28 @@ 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 +]) + +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(VERSCRIPT_LDFLAGS, ["-Wl,--version-script=\$(srcdir)/lib\$(call get_libname,\$<).versions"]) +else + AC_SUBST(VERSCRIPT_LDFLAGS, [""]) +fi # define global include dirs INCLUDE_DIRS="$INCLUDE_DIRS -I\$(top_builddir)/include -I\$(top_srcdir)/include" @@ -621,7 +643,11 @@ 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" + +if test "$ap_cv_cc_as_needed" = "yes"; then + LDFLAGS="$LDFLAGS -Wl,--as-needed" +fi # substitute what we need: AC_SUBST([BASHPATH]) diff --git a/lib/Makefile.am b/lib/Makefile.am index 3bcdb2c..29cb59c 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 \ + @VERSCRIPT_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