You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cgo/out: include path to line macros to avoid build tmp directory being embedded
When the external linker is used the work directory of the compiler is
embedded into compressed sections of the LTO objects. Making them
unreproducible between builds.
The culprit seems to be fact that the line macros uses bare symbol
names, and GCC prepends each symbol with current directory when
compiling.
These files are included when building the final build id stamped into
the binary, thus they should be identical between builds.
Reproduction of the issue:
$ CGO_CFLAGS='-flto' go build -work -trimpath -ldflags '-linkmode=external' main.go
WORK=/tmp/go-build2408155205
$ cd /tmp/go-build2408155205/b001
$ objdump -h ./_x002.o | grep GoStringLen
7 .gnu.lto__GoStringLen.0.6b7d5558e3553715 0000013b 0000000000000000 0000000000000000 0000009c 2**0
$ objcopy ./_x002.o /dev/null --dump-section .gnu.lto__GoStringLen.0.6b7d5558e3553715=GoStringLen.zst
$ unzstd ./GoStringLen.zst
$ strings GoStringLen
/tmp/go-build2408155205/b001
cgo-builtin-prolog
0 commit comments