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
{{ message }}
Repository navigation
cmd/compile, cmd/asm, cmd/cgo: -trimpath with relative paths has no effect #77216
The flag -trimpath=. has no effect because relative paths are not resolved.
This forces build systems to generate commands with absolute paths in the -trimpath flag:
$ go tool compile -trimpath=$(pwd) foo/foo.go && go tool objdump foo.o
TEXT <unlinkable>.Foo(SB) foo/foo.go # trimmed
$ go tool compile -trimpath=. foo/foo.go && go tool objdump foo.o
TEXT <unlinkable>.Foo(SB) /Users/user/project/foo/foo.go # not trimmed
Why this matters
Build systems like Buck generate build actions that are independent from the host machine. Using -trimpath=$(pwd) embeds the absolute path into the build action, breaking reproducibility across different executor machines. With -trimpath=., build actions remain portable and produce identical artifacts regardless of where they run.
Currently, we work around this by using wrapper scripts for the compiler that resolve absolute paths on the build machine. This adds unnecessary latency and complexity.
Proposed fix
In cmd/internal/objabi/line.go, convert relative prefixes to absolute:
Activity
gopherbot commentedon Jan 16, 2026
Change https://go.dev/cl/737140 mentions this issue:
cmd/internal/objabi: resolve relative paths in -trimpath flagprattmic commentedon Jan 28, 2026
cc @golang/compiler @cherrymui
podtserkovskiy commentedon Mar 23, 2026
Hi folks, CL 737140 stalled in the review for a while. Would anyone be able to take another look when you have a moment?
podtserkovskiy commentedon Apr 21, 2026
Closing as discussed https://go-review.googlesource.com/c/go/+/737140/comment/209d87c7_0237cef8/