public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
* [PATCH] gcc: fix buildpaths QA with LTO
@ 2026-03-25 11:39 Patrick Williams
  2026-03-25 11:46 ` Patrick Williams
  0 siblings, 1 reply; 7+ messages in thread
From: Patrick Williams @ 2026-03-25 11:39 UTC (permalink / raw)
  To: openembedded-core; +Cc: Patrick Williams

When LTO is enabled, due to a gcc bug[1], the linker needs the same
flags in DEBUG_PREFIX_MAP as the compiler.  Without this the buildpaths
QA failure can occur due to unstripped build directory strings in the
DWARF data.

With GCC 15.2 this can be noticed by setting many meson-built packages,
such as systemd, with:

    EXTRA_OEMESON:append:class-target = " -Db_lto=true"

Add the DEBUG_PREFIX_MAP to the TARGET_LDFLAGS for gcc.

While the lto.inc enables LTO across the whole image, some packages
either manually enable LTO on their own or downstream recipe
maintainers have explicitly set LTO in specific packages, so it is not
sufficient to set this in lto.inc only.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109805

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
---
 meta/classes/toolchain/gcc.bbclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meta/classes/toolchain/gcc.bbclass b/meta/classes/toolchain/gcc.bbclass
index 0ed49ba892..2df5281ee2 100644
--- a/meta/classes/toolchain/gcc.bbclass
+++ b/meta/classes/toolchain/gcc.bbclass
@@ -32,4 +32,9 @@ PREFERRED_PROVIDER_virtual/nativesdk-compilerlibs:class-cross-canadian = "native
 
 DEBUG_PREFIX_MAP_EXTRA = "-fcanon-prefix-map"
 
+# GCC possibly injects build strings when using LTO unless DEBUG_PREFIX_MAP
+# flags are given:
+#   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109805
+TARGET_LDFLAGS:append:class-target = " ${DEBUG_PREFIX_MAP}"
+
 TCOVERRIDE = "toolchain-gcc"
-- 
2.52.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-03-25 14:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 11:39 [PATCH] gcc: fix buildpaths QA with LTO Patrick Williams
2026-03-25 11:46 ` Patrick Williams
2026-03-25 12:34   ` [OE-core] " Richard Purdie
2026-03-25 12:44     ` Patrick Williams
2026-03-25 12:53       ` Richard Purdie
2026-03-25 13:09         ` Patrick Williams
2026-03-25 14:25           ` Richard Purdie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox