From 39eaeb4e24b51c8a8132bff7b976e39ce1d6e1ee Mon Sep 17 00:00:00 2001 From: Joey Riches Date: Sun, 19 May 2024 22:45:02 +0100 Subject: [PATCH 1/2] examine.py: Strip lto bytecode from static archives LTO Bytecode is non portable. Let's build everything with fat lto objects then strip the bytecode after the fact. Note: only clang 18 supports fat lto objects --- ypkg2/examine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ypkg2/examine.py b/ypkg2/examine.py index ceba38e..ba84f19 100644 --- a/ypkg2/examine.py +++ b/ypkg2/examine.py @@ -293,7 +293,7 @@ def strip_file(context, pretty, file, magic_string, mode=None): elif mode == "ko": flags = "-g --strip-unneeded" elif mode == "ar": - flags = "--strip-debug" + flags = "--strip-debug -p -R .gnu.lto_* -R .gnu.debuglto_* -R .llvm.lto -N __gnu_lto_v1" if context.spec.pkg_clang: cmd = "{} llvm-objcopy {} \"{}\"" try: From 517eb60522aa085338b4e9374d5a0c871c7718c3 Mon Sep 17 00:00:00 2001 From: Joey Riches Date: Mon, 27 May 2024 17:05:13 +0100 Subject: [PATCH 2/2] ypkgcontext: Build with ffat-lto-objects when using LTO In the rare case we have to ship any static files, ensure we build with fat LTO objects so we ship actually usable static files as LTO bytecode is non-portable. Any LTO bytecode will be manually stripped from archive files. --- ypkg2/ypkgcontext.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ypkg2/ypkgcontext.py b/ypkg2/ypkgcontext.py index dbfd06d..a67daa0 100644 --- a/ypkg2/ypkgcontext.py +++ b/ypkg2/ypkgcontext.py @@ -41,10 +41,10 @@ SIZE_FLAGS_CLANG = "-O2" # Allow optimizing for LTO -LTO_FLAGS = "-flto=auto" +LTO_FLAGS = "-flto=auto -ffat-lto-objects" # Allow optimizing for thin-lto -THIN_LTO_FLAGS = "-flto=thin" +THIN_LTO_FLAGS = "-flto=thin -ffat-lto-objects" # Allow optimizing for ICF all (identical code folding) ICF_ALL_FLAGS = "-Wl,--icf=all"