Skip to content

Commit 4127df6

Browse files
Holger Hans Peter Freytherzecke
Holger Hans Peter Freyther
authored andcommitted
cmd/go: Don't prefer external linking when using bazel
The -fdebug-prefix-map= option is passed by bazelbuild/rules_go when building cgo code. This option impacts the generation of the debug symbols but has no effect on linking. Add it to the allow-list to not prefer external linking. Fixes: #60865
1 parent 261e267 commit 4127df6

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/cmd/go/internal/work/security.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ var validCompilerFlags = []*lazyregexp.Regexp{
5959
re(`-f(no-)builtin-[a-zA-Z0-9_]*`),
6060
re(`-f(no-)?common`),
6161
re(`-f(no-)?constant-cfstrings`),
62+
re(`-fdebug-prefix-map=(.+)`),
6263
re(`-fdiagnostics-show-note-include-stack`),
6364
re(`-f(no-)?eliminate-unused-debug-types`),
6465
re(`-f(no-)?exceptions`),

src/cmd/go/testdata/script/cgo_suspect_flag_force_external.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ stderr preferlinkext
5555
env CGO_CFLAGS=-fprofile-instr-generate
5656
go build -x -n -o dummy.exe ./usesInternalCgo
5757
stderr preferlinkext
58+
env CGO_CFLAGS=-fdebug-prefix-map=/some/sandbox/execroot/workspace=/tmp/new
59+
go build -x -n -o dummy.exe ./usesInternalCgo
60+
! stderr preferlinkext
5861
env CGO_CFLAGS=
5962

6063
[short] skip

0 commit comments

Comments
 (0)