[Spice-devel] [PATCH 1/7] Add configure-time check for -Wl, --version-script option

Dan McGee dpmcgee at gmail.com
Thu Feb 16 21:30:07 PST 2012


This is supported by the GNU linker, but not the Solaris linker, which
is used as the default on that platform even when compiling with GCC.
Omit passing the option to the linker on platforms that do not support
it.

Signed-off-by: Dan McGee <dpmcgee at gmail.com>
---
 configure.ac       |   10 ++++++++++
 server/Makefile.am |   12 ++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 1c15e74..b8acfa9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -518,6 +518,16 @@ fi
 AC_MSG_RESULT($have_gcc4)
 AC_SUBST(VISIBILITY_HIDDEN_CFLAGS)
 
+dnl ensure linker supports ---version-script option before using it
+AC_CACHE_CHECK([if -Wl,--version-script works], [spice_cv_ld_version_script],
+    [save_LDFLAGS="$LDFLAGS"
+     LDFLAGS="$LDFLAGS -Wl,--version-script=$srcdir/server/spice-server.syms"
+     AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+        [spice_cv_ld_version_script=yes], [spice_cv_ld_version_script=no])
+     LDFLAGS="$save_LDFLAGS"])
+AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT],
+    [test x"$spice_cv_ld_version_script" = xyes])
+
 AC_SUBST(SPICE_REQUIRES)
 AC_SUBST(SPICE_NONPKGCONFIG_CFLAGS)
 AC_SUBST(SPICE_NONPKGCONFIG_LIBS)
diff --git a/server/Makefile.am b/server/Makefile.am
index 1284704..a88e464 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -31,12 +31,16 @@ generated_marshallers.h: $(top_srcdir)/spice.proto
 
 lib_LTLIBRARIES = libspice-server.la
 
-libspice_server_la_LDFLAGS =						\
-	-version-number $(SPICE_LT_VERSION)				\
-	-Wl,--version-script=$(top_srcdir)/server/spice-server.syms	\
-	-no-undefined							\
+libspice_server_la_LDFLAGS =			\
+	-version-number $(SPICE_LT_VERSION)	\
+	-no-undefined				\
 	$(NULL)
 
+if HAVE_LD_VERSION_SCRIPT
+libspice_server_la_LDFLAGS += \
+	-Wl,--version-script=$(top_srcdir)/server/spice-server.syms
+endif
+
 libspice_server_la_LIBADD =				\
 	$(top_builddir)/common/libspice-common.la	\
 	$(CELT051_LIBS)					\
-- 
1.7.9.1



More information about the Spice-devel mailing list