diff mbox series

go.bbclass: remove macro prefix maps on CGO_LDFLAGS

Message ID 20260127170344.2960247-2-rs@ti.com
State New
Headers show
Series go.bbclass: remove macro prefix maps on CGO_LDFLAGS | expand

Commit Message

Randolph Sapp Jan. 27, 2026, 5:03 p.m. UTC
From: Randolph Sapp <rs@ti.com>

Due to GCC behavior with LTO, prefix maps must be passed as part of
LDFLAGS for binary reproducibility for some packages [1]. Unfortunately
passing build paths as arguments to CGO_LDFLAGS changes intermediary
output hashes (content IDs) during Go builds [2].

CGO binaries do not currently support LTO, so right now we can safely
remove these prefixes for anything using the go.bbclass. This will need
to be reevaluated when LTO is enabled for CGO [3].

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101473
[2] https://github.com/golang/go/issues/77086
[3] https://github.com/golang/go/issues/43505

Signed-off-by: Randolph Sapp <rs@ti.com>
---

This also unblocks the previously posted emptty series.

 meta/classes-recipe/go.bbclass | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/go.bbclass b/meta/classes-recipe/go.bbclass
index b540471ba2..7dbd66c5ce 100644
--- a/meta/classes-recipe/go.bbclass
+++ b/meta/classes-recipe/go.bbclass
@@ -71,7 +71,11 @@  export CGO_ENABLED ?= "1"
 export CGO_CFLAGS ?= "${CFLAGS}"
 export CGO_CPPFLAGS ?= "${CPPFLAGS}"
 export CGO_CXXFLAGS ?= "${CXXFLAGS}"
-export CGO_LDFLAGS ?= "${LDFLAGS}"
+
+# remove build paths from LDFLAGS since this will change the content ID
+CGO_LDFLAGS ?= "${LDFLAGS}"
+CGO_LDFLAGS:remove = "${DEBUG_PREFIX_MAP}"
+export CGO_LDFLAGS
 
 GO_INSTALL ?= "${GO_IMPORT}/..."
 GO_INSTALL_FILTEROUT ?= "${GO_IMPORT}/vendor/"