Port: built-in plugins support for the macOS linker
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 17 Jul 2017 21:31:22 +0000 (17:31 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 19 Jul 2017 19:18:19 +0000 (15:18 -0400)
The macOS linker requires different options to force link all the
objects in a static archive, detect this at configure.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
cli/Makefile.am
configure.ac

index 3cd2a1168bf9c6aa760be97bb5d559672170d71a..195c878ad0b748a001a8a0e62a352370c49bc8dd 100644 (file)
@@ -63,7 +63,7 @@ if ENABLE_BUILT_IN_PLUGINS
 # binary that are filled by plugin objects. If the linker discards those
 # symbols because the CLI does not use them directly, the CLI reports
 # no plugins found (plugins are effectively not embedded).
-pluginarchive = -Wl,--whole-archive,$(PLUGINS_PATH)/$(1)/.libs/babeltrace-plugin-$(1).a,--no-whole-archive
+pluginarchive = $(LD_WHOLE_ARCHIVE)$(PLUGINS_PATH)/$(1)/.libs/babeltrace-plugin-$(1).a$(LD_NO_WHOLE_ARCHIVE)
 
 # Built-in plugins
 babeltrace_bin_LDFLAGS += $(call pluginarchive,ctf)
index 924f7975d3bf7e94eb0380fe48299a27ee166854..1fba17f4ccd84b21bfa0ad644572c49899c7f294 100644 (file)
@@ -159,6 +159,24 @@ AC_CHECK_HEADERS([ \
 AX_APPEND_LINK_FLAGS([-Wl,--no-as-needed], [LD_NO_AS_NEEDED])
 AC_SUBST([LD_NO_AS_NEEDED])
 
+# Check if the linker supports whole-archive
+AX_CHECK_LINK_FLAG([-Wl,--whole-archive,--no-whole-archive],
+  [
+    AC_SUBST([LD_WHOLE_ARCHIVE], [-Wl,--whole-archive,])
+    AC_SUBST([LD_NO_WHOLE_ARCHIVE], [,--no-whole-archive])
+  ],[
+    # Fallback to force_load for the macOS linker
+    AX_CHECK_LINK_FLAG([-Wl,-force_load],
+      [
+        AC_SUBST([LD_WHOLE_ARCHIVE], [-Wl,-force_load,])
+        AC_SUBST([LD_NO_WHOLE_ARCHIVE], [])
+      ],[
+        AC_MSG_WARN([Can't find a linker option to force the inclusion of the static plugin archive objects.])
+      ]
+    )
+  ]
+)
+
 # Initialize and configure libtool
 LT_INIT([win32-dll])
 
This page took 0.025056 seconds and 4 git commands to generate.