[PATCH 07/11] build: Use flat namespace for libvirt on macOS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>From ld(1):

  By default all references resolved to a dynamic library record the
  library to which they were resolved. At runtime, dyld uses that
  information to directly resolve symbols. The alternative is to use the
  -flat_namespace option.  With flat namespace, the library is not
  recorded.  At runtime, dyld will search each dynamic library in load
  order when resolving symbols. This is slower, but more like how other
  operating systems resolve symbols.

That fixes the set of tests that preload a mock library to replace
library symbols:
  qemublocktest
  qemumonitorjsontest
  viriscsitest
  virmacmaptest
  virnetserverclienttest

Signed-off-by: Roman Bolshakov <r.bolshakov@xxxxxxxxx>
---
 configure.ac    | 1 +
 src/Makefile.am | 9 +++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index f41c6d5d86..852b464e97 100644
--- a/configure.ac
+++ b/configure.ac
@@ -212,6 +212,7 @@ fi
 
 AM_CONDITIONAL([WITH_LINUX], [test "$with_linux" = "yes"])
 AM_CONDITIONAL([WITH_FREEBSD], [test "$with_freebsd" = "yes"])
+AM_CONDITIONAL([WITH_MACOS], [test "$with_macos" = "yes"])
 
 # We don't support the daemon yet
 if test "$with_win" = "yes" ; then
diff --git a/src/Makefile.am b/src/Makefile.am
index 817a7ecf34..adaf61350a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -579,8 +579,13 @@ libvirt_la_LDFLAGS = \
 		-version-info $(LIBVIRT_VERSION_INFO) \
 		$(LIBVIRT_NODELETE) \
 		$(NO_UNDEFINED_LDFLAGS) \
-		$(AM_LDFLAGS) \
-		$(NULL)
+		$(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)
 libvirt_la_BUILT_LIBADD += ../gnulib/lib/libgnu.la
 libvirt_la_LIBADD += \
 		    $(DRIVER_MODULES_LIBS) \
-- 
2.22.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux