diff options
author | Peter Foley <pefoley2@pefoley.com> | 2016-01-15 11:34:20 -0500 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-01-18 08:31:09 +0000 |
commit | 0533b155354f086aa8dc1de06c7db92d3f3be4f5 (patch) | |
tree | 3e8832618f7835540845a3970025853cbfbfc6f5 | |
parent | 19167ea31383cb91c1563ba2d4bb7708eea8afc1 (diff) |
Wrappers for LTO
When building with GCC, the gcc-ar, gcc-ranlib, and gcc-nm wrappers
must be used for the linker to properly resolve symbols from static
libraries containing LTO objects.
Likewise, clang requires the llvm-ar, llvm-ranlib, and llvm-nm
wrappers.
Change-Id: I539017b6da7732f998a49820dc01d0e6b302952a
Reviewed-on: https://gerrit.libreoffice.org/21502
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | configure.ac | 13 | ||||
-rw-r--r-- | solenv/gbuild/platform/com_GCC_defs.mk | 1 | ||||
-rw-r--r-- | solenv/gbuild/platform/unxgcc.mk | 4 |
3 files changed, 13 insertions, 5 deletions
diff --git a/configure.ac b/configure.ac index 39f61c1f1140..3750beb5b312 100644 --- a/configure.ac +++ b/configure.ac @@ -5163,10 +5163,17 @@ if test "$_os" != "WINNT" -o "$WITH_MINGW" = "yes"; then # /path/to/compiler/foo-gcc" you need to set the AR etc env vars # explicitly. Or put /path/to/compiler in PATH yourself. - AC_CHECK_TOOL(AR,ar) - AC_CHECK_TOOL(NM,nm) + # Use wrappers for LTO + if test "$ENABLE_LTO" == "TRUE" -a "$COM_IS_CLANG" != "TRUE"; then + AC_CHECK_TOOL(AR,gcc-ar) + AC_CHECK_TOOL(NM,gcc-nm) + AC_CHECK_TOOL(RANLIB,gcc-ranlib) + else + AC_CHECK_TOOL(AR,ar) + AC_CHECK_TOOL(NM,nm) + AC_CHECK_TOOL(RANLIB,ranlib) + fi AC_CHECK_TOOL(OBJDUMP,objdump) - AC_CHECK_TOOL(RANLIB,ranlib) AC_CHECK_TOOL(READELF,readelf) AC_CHECK_TOOL(STRIP,strip) if test "$_os" = "WINNT"; then diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index 3f7960550cef..877f5021c73f 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -130,6 +130,7 @@ gb_CFLAGS_COMMON += -std=gnu89 ifeq ($(ENABLE_LTO),TRUE) ifeq ($(COM_IS_CLANG),TRUE) gb_LTOFLAGS := -flto +gb_LTOPLUGINFLAGS := --plugin LLVMgold.so else gb_LTOFLAGS := -flto=$(PARALLELISM) -fuse-linker-plugin -O2 endif diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index 6cd206c711e8..7e43ce35cc25 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -145,7 +145,7 @@ $(call gb_Helper_abbreviate_dirs,\ $(if $(SOVERSIONSCRIPT),&& ln -sf ../../program/$(notdir $(1)) $(ILIBTARGET))) $(if $(filter Library,$(TARGETTYPE)), $(call gb_Helper_abbreviate_dirs,\ $(READELF) -d $(1) | grep SONAME > $(WORKDIR)/LinkTarget/$(2).exports.tmp; \ - $(NM) --dynamic --extern-only --defined-only --format=posix $(1) \ + $(NM) $(gb_LTOPLUGINFLAGS) --dynamic --extern-only --defined-only --format=posix $(1) \ | cut -d' ' -f1-2 \ >> $(WORKDIR)/LinkTarget/$(2).exports.tmp && \ $(call gb_Helper_replace_if_different_and_touch,$(WORKDIR)/LinkTarget/$(2).exports.tmp, \ @@ -155,7 +155,7 @@ endef define gb_LinkTarget__command_staticlink $(call gb_Helper_abbreviate_dirs,\ rm -f $(1) && \ - $(gb_AR) -rsu $(1) \ + $(gb_AR) $(gb_LTOPLUGINFLAGS) -rsu $(1) \ $(if $(LD_PLUGIN),--plugin $(LD_PLUGIN)) \ $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ |