Files
nixpkgs/pkgs/development/compilers/go/go-default-pie.patch
Luna Nova dbb57d8d86 go: only enable PIE by default when building for GOARCH matching target
We rely on teaching go to use the correct ELF interpreter
for PIE in a way that can't work for packages that 
go off and do their own GOARCH=something cross builds
without touching nixpkgs cross machinery,
so update the default pie patch to bake targetPlatform's
GOARCH and only activate for it.

tailscale works as a testcase for this as it cross compiles
many arches in tstest/archtest/qemu_test.go
2025-10-07 20:27:45 -07:00

14 lines
491 B
Diff

diff --git a/src/internal/platform/supported.go b/src/internal/platform/supported.go
index f9706a6988..abac42d550 100644
--- a/src/internal/platform/supported.go
+++ b/src/internal/platform/supported.go
@@ -249,7 +253,7 @@ func DefaultPIE(goos, goarch string, isRace bool) bool {
case "darwin":
return true
}
- return false
+ return goarch == "@GOARCH@" && BuildModeSupported("gc", "pie", goos, goarch)
}
// ExecutableHasDWARF reports whether the linked executable includes DWARF