Bug#985867: filter out GCC's lto flags for the skia build
Package: src:libreoffice
Version: 1:7.1.2~rc1-1
Tags: patch
When building LO with lto turned on (https://wiki.debian.org/ToolChain/LTO),
the build fails, because one module (skia) is still built with clang, apparently
for performance reasons. I didn't check if that's still needed for recent
compiler versions.
So just don't use the lto flags when building the skia module. The build system
already has a macro for that for cflags (gb_FilterOutClangCFLAGS), but is
lacking one for ldflags, and these targets seem to be autogenerated. I didn't
look into filtering this, and provided a wrapper for clang/clang++ instead.
Unsure if the change to gb_LTOFLAGS is really needed. The build is doing ok
without explicitly configuring with --enable-lto. Passing -fuse-linker-plugin
explicitly isn't needed since GCC 8, and I didn't see any rationale to set the
optimizations explicitly.
Matthias
* Fix lto build, avoiding to pass lto flags to the skia build.
diff -Nru libreoffice-7.1.2~rc1/debian/clang_wrapper libreoffice-7.1.2~rc1/debian/clang_wrapper
--- libreoffice-7.1.2~rc1/debian/clang_wrapper 1970-01-01 00:00:00.000000000 +0000
+++ libreoffice-7.1.2~rc1/debian/clang_wrapper 2021-03-25 07:17:38.000000000 +0000
@@ -0,0 +1,18 @@
+#! /usr/bin/python3
+
+import os
+import sys
+
+prog = os.path.join("/usr/bin", os.path.basename(sys.argv[0]))
+new_argv = []
+
+for arg in sys.argv[1:]:
+ if arg.startswith("-flto=") or arg == "-ffat-lto-objects":
+ continue
+ new_argv.append(arg)
+
+try:
+ os.execv(prog, new_argv)
+except FileNotFoundError:
+ print("unable to execute:", prog, new_argv)
+ sys.exit(1)
diff -Nru libreoffice-7.1.2~rc1/debian/patches/filter-out-lto-flags.diff libreoffice-7.1.2~rc1/debian/patches/filter-out-lto-flags.diff
--- libreoffice-7.1.2~rc1/debian/patches/filter-out-lto-flags.diff 1970-01-01 00:00:00.000000000 +0000
+++ libreoffice-7.1.2~rc1/debian/patches/filter-out-lto-flags.diff 2021-03-24 14:03:44.000000000 +0000
@@ -0,0 +1,16 @@
+--- a/solenv/gbuild/platform/com_GCC_defs.mk
++++ b/solenv/gbuild/platform/com_GCC_defs.mk
+@@ -180,10 +180,12 @@ gb_LTOFLAGS := -flto
+ gb_LTOPLUGINFLAGS := --plugin LLVMgold.so
+ endif
+ else
+-gb_LTOFLAGS := -flto$(if $(filter-out 0,$(PARALLELISM)),=$(PARALLELISM)) -fuse-linker-plugin -O2
++gb_LTOFLAGS := -flto=auto -ffat-lto-objects
+ endif
+ endif
+
++gb_FilterOutClangCFLAGS += -flto=auto -ffat-lto-objects
++
+ gb_LinkTarget_EXCEPTIONFLAGS := \
+ -DEXCEPTIONS_ON \
+ -fexceptions
diff -Nru libreoffice-7.1.2~rc1/debian/patches/series libreoffice-7.1.2~rc1/debian/patches/series
--- libreoffice-7.1.2~rc1/debian/patches/series 2021-03-12 09:31:16.000000000 +0000
+++ libreoffice-7.1.2~rc1/debian/patches/series 2021-03-24 13:59:07.000000000 +0000
@@ -52,3 +52,4 @@
replace-source-sans-in-templates.diff
add-yaru-theme.diff
yaru-ubuntu-default.diff
+filter-out-lto-flags.diff
diff -Nru libreoffice-7.1.2~rc1/debian/rules libreoffice-7.1.2~rc1/debian/rules
--- libreoffice-7.1.2~rc1/debian/rules 2021-03-12 09:31:16.000000000 +0000
+++ libreoffice-7.1.2~rc1/debian/rules 2021-03-25 07:17:38.000000000 +0000
@@ -1932,6 +1932,17 @@
bin/update_pch.sh
endif
+ # setup clang wrappers
+ mkdir -p debian/usr/bin
+ cp debian/clang_wrapper debian/usr/bin/clang
+ cp debian/clang_wrapper debian/usr/bin/clang++
+ifneq (,$(CLANG_VERSION))
+ ifneq ($(CLANG_VERSION),default)
+ cp debian/clang_wrapper debian/usr/bin/clang-$(CLANG_VERSION)
+ cp debian/clang_wrapper debian/usr/bin/clang++-$(CLANG_VERSION)
+ endif
+endif
+
# Ubuntu yaru icon theme links
ln -srf yaru/build/png icon-themes/yaru
ln -srf yaru/build/svg icon-themes/yaru_svg
Reply to: