From a235abc1ef99d4f414a465e07fd19aeac28aa663 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Tue, 11 Oct 2022 09:16:43 +0200 Subject: [PATCH] Only enable LTO for some archs --- debian/changelog | 6 ++++++ debian/rules | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/debian/changelog b/debian/changelog index 05ac410e..6d32076d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +llvm-toolchain-15 (1:15.0.2-2~exp5) experimental; urgency=medium + + * Only enable LTO for some archs + + -- Sylvestre Ledru Tue, 11 Oct 2022 09:15:56 +0200 + llvm-toolchain-15 (1:15.0.2-2~exp4) experimental; urgency=medium * Only ship libbolt_rt_hugify.a & libbolt_rt_instr.a on amd64 diff --git a/debian/rules b/debian/rules index 893d5afc..74e0c3b0 100755 --- a/debian/rules +++ b/debian/rules @@ -395,17 +395,15 @@ ifneq (,$(filter $(DEB_HOST_ARCH_OS),linux)) STAGE_2_CMAKE_EXTRA += -DLLVM_USE_PERF=ON -DLLVM_ENABLE_LIBPFM=ON endif +LTO_ENABLE=no # Only enable it for archs supporting gold ifneq (,$(filter $(DEB_HOST_ARCH),$(BINUTILS_GOLD_ARCHS))) -# armhf is not yet quite ready for Thin, it FTBFS -# see https://buildd.debian.org/status/fetch.php?pkg=llvm-toolchain-8&arch=armhf&ver=1%3A8.0.1%7E%2Brc2-1%7Eexp1&stamp=1560334266&raw=0 -ifeq (,$(filter $(DEB_HOST_ARCH), armhf)) -# Use BOOTSTRAP_LLVM_ENABLE_LTO to make sure that it isn't used -# when running stage1 with gcc -# For now, disable ThinLTO usage because: -# * LLVM_ENABLE_LTO doesn't work with gcc >= 9 (option not accepted) -# * BOOTSTRAP_LLVM_ENABLE_LTO is producing some large binary -# See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=943623 +# LTO requires a bunch of memory. Don't do it everywhere +LTO_DISABLE_ARCHS := i386 armhf s390x ppc64 x32 +ifeq (,$(filter-out $(LTO_DISABLE_ARCHS), $(DEB_HOST_ARCH))) + LTO_ENABLE=no +else + LTO_ENABLE=yes STAGE_2_CMAKE_EXTRA += -DLLVM_ENABLE_LTO="On" endif endif @@ -477,6 +475,7 @@ preconfigure: @echo "PATH=$(PATH)" @echo "LD_LIBRARY_PATH=$(LD_LIBRARY_PATH)" @echo "LIBFUZZER_ENABLE=$(LIBFUZZER_ENABLE)" + @echo "LTO_ENABLE=$(LTO_ENABLE)" @echo "COMPILER_RT_WASM_ENABLE=$(COMPILER_RT_WASM_ENABLE)" for f in debian/*.in; do \ @@ -822,8 +821,10 @@ override_dh_auto_install: # Clean up temporary files to make sure the install works rm -rf $(find $(TARGET_BUILD) -wholename '*CMakeFiles*' -not -name CMakeLists.txt -a -name "*.dir" -type d) +ifeq (${LTO_ENABLE},yes) # with LTO, .a contains llvm ir instead of native code. So, recompile them NJOBS="$(NJOBS)" P_TO_LLVM="$(CURDIR)" VERSION=$(LLVM_VERSION) bash debian/llvm-compile-lto-elf.sh $(CXXFLAGS_EXTRA) +endif # install/fast enables a make install without recompiling temporary files LD_LIBRARY_PATH=$(STAGE_2_LIB_DIR):$$LD_LIBRARY_PATH DESTDIR=$(DEB_INST)/ ninja -C $(TARGET_BUILD) $(VERBOSE) stage2-install