From: Michael Jeanson Date: Mon, 17 Jul 2017 21:31:22 +0000 (-0400) Subject: Port: built-in plugins support for the macOS linker X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=1244e79400a1d53db89f095c079b56a752cf66ea Port: built-in plugins support for the macOS linker 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 Signed-off-by: Jérémie Galarneau --- diff --git a/cli/Makefile.am b/cli/Makefile.am index 3cd2a116..195c878a 100644 --- a/cli/Makefile.am +++ b/cli/Makefile.am @@ -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) diff --git a/configure.ac b/configure.ac index 924f7975..1fba17f4 100644 --- a/configure.ac +++ b/configure.ac @@ -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])