build: Use -Bsymbolic-functions by default if available
authorColin Walters <walters@verbum.org>
Tue, 4 Dec 2012 17:46:04 +0000 (12:46 -0500)
committerColin Walters <walters@verbum.org>
Tue, 4 Dec 2012 17:46:52 +0000 (12:46 -0500)
Using -Bsymbolic-functions to avoid internal PLT indirection is an
easy win.  This is the same code that both GLib and GTK+ have.

https://bugzilla.gnome.org/show_bug.cgi?id=689648

configure.ac

index 540603a..1bb1716 100644 (file)
@@ -653,6 +653,27 @@ fi
 AC_SUBST(LIBRARY_LIBTOOL_OPTIONS)
 AC_SUBST(MODULE_LIBTOOL_OPTIONS)
 
+dnl
+dnl Check for -Bsymbolic-functions linker flag used to avoid
+dnl intra-library PLT jumps, if available.
+dnl
+AC_ARG_ENABLE(Bsymbolic,
+              [AS_HELP_STRING([--disable-Bsymbolic],
+                              [avoid linking with -Bsymbolic])],,
+              [SAVED_LDFLAGS="${LDFLAGS}"
+               AC_MSG_CHECKING([for -Bsymbolic-functions linker flag])
+               LDFLAGS=-Wl,-Bsymbolic-functions
+               AC_TRY_LINK([], [int main (void) { return 0; }],
+                           AC_MSG_RESULT(yes)
+                           enable_Bsymbolic=yes,
+                           AC_MSG_RESULT(no)
+                           enable_Bsymbolic=no)
+               LDFLAGS="${SAVED_LDFLAGS}"])
+
+if test "x${enable_Bsymbolic}" = "xyes"; then
+  LIBRARY_LIBTOOL_OPTIONS="$LIBRARY_LIBTOOL_OPTIONS -Wl,-Bsymbolic-functions"
+fi
+
 dnl ********************************************************
 dnl * See whether we need to load our modules as .la files *
 dnl ********************************************************