Skip to content

Commit 0c7fcf6

Browse files
committed
cmd/link: explicitly disable PIE for windows/amd64 -race mode
Turn off PIE explicitly for windows/amd64 when -race is in effect, since at the moment the race detector runtime doesn't seem to handle PIE binaries correctly. Note that newer C compilers on windows produce PIE binaries by default, so the Go linker needs to explicitly turn off PIE when invoking the external linker in this case. Updates #53539. Change-Id: Ib990621f22cf61a5fa383584bab81d3dfd7552e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/415676 Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Than McIntosh <[email protected]> Reviewed-by: Alex Brainman <[email protected]>
1 parent eaf2125 commit 0c7fcf6

File tree

1 file changed

+13
-0
lines changed
  • src/cmd/link/internal/ld

1 file changed

+13
-0
lines changed

src/cmd/link/internal/ld/lib.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,10 +1426,23 @@ func (ctxt *Link) hostlink() {
14261426
argv = append(argv, "-Wl,-pagezero_size,4000000")
14271427
}
14281428
}
1429+
if *flagRace && ctxt.HeadType == objabi.Hwindows {
1430+
// Current windows/amd64 race detector tsan support
1431+
// library can't handle PIE mode (see #53539 for more details).
1432+
// For now, explicitly disable PIE (since some compilers
1433+
// default to it) if -race is in effect.
1434+
argv = addASLRargs(argv, false)
1435+
}
14291436
case BuildModePIE:
14301437
switch ctxt.HeadType {
14311438
case objabi.Hdarwin, objabi.Haix:
14321439
case objabi.Hwindows:
1440+
if *flagAslr && *flagRace {
1441+
// Current windows/amd64 race detector tsan support
1442+
// library can't handle PIE mode (see #53539 for more details).
1443+
// Disable alsr if -race in effect.
1444+
*flagAslr = false
1445+
}
14331446
argv = addASLRargs(argv, *flagAslr)
14341447
default:
14351448
// ELF.

0 commit comments

Comments
 (0)