[libvirt] [PATCH 05/11] tests: Remove -module flag for mocks

Roman Bolshakov r.bolshakov at yadro.com
Wed Aug 21 16:13:17 UTC 2019


macOS has two kinds of loadable libraries: MH_BUNDLE, and MH_DYLIB.
bundle is used for plugins that are loaded with dlopen/dlsym/dlclose.
And there's no way to preload a bundle into an application. dynamic
linker (dyld) will reject it when finds it in DYLD_INSERT_LIBRARIES.

Unfortunately, a bundle is built if -module flag is provided to libtool.
The flag has been removed to build dylibs with ".dylib" suffix.

Signed-off-by: Roman Bolshakov <r.bolshakov at yadro.com>
---
 tests/Makefile.am | 2 +-
 tests/testutils.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 713dc30de3..460efb6b7b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -48,7 +48,7 @@ AM_CFLAGS = \
 AM_LDFLAGS = \
 	-export-dynamic
 
-MOCKLIBS_LDFLAGS = -module -avoid-version \
+MOCKLIBS_LDFLAGS = -avoid-version \
 	-rpath /evil/libtool/hack/to/force/shared/lib/creation \
 	$(MINGW_EXTRA_LDFLAGS)
 
diff --git a/tests/testutils.h b/tests/testutils.h
index e0fa2b2448..7660101991 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -119,8 +119,10 @@ int virTestMain(int argc,
 
 #ifdef __APPLE__
 # define PRELOAD_VAR "DYLD_INSERT_LIBRARIES"
+# define MOCK_EXT ".dylib"
 #else
 # define PRELOAD_VAR "LD_PRELOAD"
+# define MOCK_EXT ".so"
 #endif
 
 #define VIR_TEST_PRELOAD(lib) \
@@ -148,8 +150,6 @@ int virTestMain(int argc,
         return virTestMain(argc, argv, func, __VA_ARGS__, NULL); \
     }
 
-#define MOCK_EXT ".so"
-
 #define VIR_TEST_MOCK(mock) (abs_builddir "/.libs/lib" mock "mock" MOCK_EXT)
 
 virCapsPtr virTestGenericCapsInit(void);
-- 
2.22.0




More information about the libvir-list mailing list