From 9bc09df8737b80e6a7c29ae15f25d59160684365 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Thu, 30 Apr 2020 14:34:33 +0200 Subject: [PATCH] configure: introduce FLAT_NAMESPACE_FLAGS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set FLAT_NAMESPACE_FLAGS to -Wl,-flat_namespace in configure only for macOS and use it unconditionally in Makefiles. Signed-off-by: Pavel Hrdina Reviewed-by: Ján Tomko Reviewed-by: Michal Privoznik --- configure.ac | 13 +++++++++++++ src/Makefile.am | 10 +++------- tests/Makefile.am | 7 +++---- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 61d43c1a63..fb18c5b52e 100644 --- a/configure.ac +++ b/configure.ac @@ -189,6 +189,19 @@ esac AC_MSG_RESULT([$VERSION_SCRIPT_FLAGS]) AC_SUBST([VERSION_SCRIPT_FLAGS]) +dnl macOS has two-level namespaces by default. +dnl Override it to allow symbol replacement with DYLD_INSERT_LIBRARIES +case "$host" in + *-*-darwin*) + FLAT_NAMESPACE_FLAGS=-Wl,-flat_namespace + ;; + * ) + FLAT_NAMESPACE_FLAGS="" + ;; +esac +AC_MSG_RESULT([$FLAT_NAMESPACE_FLAGS]) +AC_SUBST([FLAT_NAMESPACE_FLAGS]) + dnl Specify if we rely on ifconfig instead of iproute2 (e.g. in case dnl we're working on BSD) want_ifconfig=no diff --git a/src/Makefile.am b/src/Makefile.am index 447cff8165..b893f4179e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -431,13 +431,9 @@ libvirt_la_LDFLAGS = \ -version-info $(LIBVIRT_VERSION_INFO) \ $(LIBVIRT_NODELETE) \ $(NO_UNDEFINED_LDFLAGS) \ - $(AM_LDFLAGS) -if WITH_MACOS -# macOS has two-level namespaces by default. -# Override it to allow symbol replacement with DYLD_INSERT_LIBRARIES -libvirt_la_LDFLAGS += -Wl,-flat_namespace -endif WITH_MACOS -libvirt_la_LDFLAGS += $(NULL) + $(FLAT_NAMESPACE_FLAGS) \ + $(AM_LDFLAGS) \ + $(NULL) libvirt_la_LIBADD += \ $(DLOPEN_LIBS) libvirt_la_CFLAGS = -DIN_LIBVIRT $(AM_CFLAGS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 65d1ceeefd..06d70ab559 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -55,10 +55,9 @@ MOCKLIBS_LDFLAGS = -avoid-version \ DRIVERLIB_LDFLAGS = \ -avoid-version \ -rpath /evil/libtool/hack/to/force/shared/lib/creation \ - $(MINGW_EXTRA_LDFLAGS) -if WITH_MACOS -DRIVERLIB_LDFLAGS += -Wl,-flat_namespace -endif WITH_MACOS + $(MINGW_EXTRA_LDFLAGS) \ + $(FLAT_NAMESPACE_FLAGS) \ + $(NULL) PROBES_O = if WITH_DTRACE_PROBES