]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: Use flat namespace for libvirt on macOS
authorRoman Bolshakov <r.bolshakov@yadro.com>
Wed, 21 Aug 2019 16:13:19 +0000 (19:13 +0300)
committerDaniel P. Berrangé <berrange@redhat.com>
Fri, 23 Aug 2019 10:26:26 +0000 (11:26 +0100)
>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@yadro.com>
configure.ac
src/Makefile.am

index 6744ace5785890543bcf6c428df08803ed6c6418..a60543072dbb3a212cc1906de9cee6aa72a82b0f 100644 (file)
@@ -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
index 817a7ecf34645a2424e311ab64ecc723ab6c2bd9..adaf61350a441b5bc903b5327ae88fbf6da9cb31 100644 (file)
@@ -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) \