Skip to content

cmd/go: permit additional cflags when compiling #60868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/cmd/go/internal/work/security.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ var validCompilerFlags = []*lazyregexp.Regexp{
re(`-f(no-)builtin-[a-zA-Z0-9_]*`),
re(`-f(no-)?common`),
re(`-f(no-)?constant-cfstrings`),
re(`-fdebug-prefix-map=([^@]+)=([^@]+)`),
re(`-fdiagnostics-show-note-include-stack`),
re(`-ffile-prefix-map=([^@]+)=([^@]+)`),
re(`-fno-canonical-system-headers`),
re(`-f(no-)?eliminate-unused-debug-types`),
re(`-f(no-)?exceptions`),
re(`-f(no-)?fast-math`),
Expand Down Expand Up @@ -114,6 +117,7 @@ var validCompilerFlags = []*lazyregexp.Regexp{
re(`-mthumb(-interwork)?`),
re(`-mthreads`),
re(`-mwindows`),
re(`-no-canonical-prefixes`),
re(`--param=ssp-buffer-size=[0-9]*`),
re(`-pedantic(-errors)?`),
re(`-pipe`),
Expand Down
26 changes: 26 additions & 0 deletions src/cmd/go/testdata/script/cgo_suspect_flag_force_external.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,32 @@ stderr preferlinkext
env CGO_CFLAGS=-fprofile-instr-generate
go build -x -n -o dummy.exe ./usesInternalCgo
stderr preferlinkext

# The -fdebug-prefix-map=path is permitted for internal linking.
env CGO_CFLAGS=-fdebug-prefix-map=/some/sandbox/execroot/workspace=/tmp/new
go build -x -n -o dummy.exe ./usesInternalCgo
! stderr preferlinkext
env CGO_CFLAGS=-fdebug-prefix-map=/Users/someone/.cache/bazel/_bazel_someone/3fa7e4650c43657ead684537951f49e2/sandbox/linux-sandbox/10/execroot/rules_go_static=.
go build -x -n -o dummy.exe ./usesInternalCgo
! stderr preferlinkext
# The -ffile-prefix-map=path is permitted for internal linking too.
env CGO_CFLAGS=-ffile-prefix-map=/Users/someone/.cache/bazel/_bazel_someone/3fa7e4650c43657ead684537951f49e2/sandbox/linux-sandbox/10/execroot/rules_go_static/bazel-out/aarch64-fastbuild-ST-b33d65c724e6/bin/external/io_bazel_rules_go/stdlib_=.
go build -x -n -o dummy.exe ./usesInternalCgo
! stderr preferlinkext
# Verifying that -fdebug-prefix-map=path, -ffile-prefix-map, -no-canonical-prefixes
# and -fno-canonical-systemd-headers are permitted for internal linking.
env CGO_CFLAGS=-fdebug-prefix-map=old=/tmp/new
go build -x -n -o dummy.exe ./usesInternalCgo
! stderr preferlinkext
env CGO_CFLAGS=-ffile-prefix-map=/Users/someone/_11233/things=new
go build -x -n -o dummy.exe ./usesInternalCgo
! stderr preferlinkext
env CGO_CFLAGS=-no-canonical-prefixes
go build -x -n -o dummy.exe ./usesInternalCgo
! stderr preferlinkext
env CGO_CFLAGS=-fno-canonical-system-headers
go build -x -n -o dummy.exe ./usesInternalCgo
! stderr preferlinkext
env CGO_CFLAGS=

[short] skip
Expand Down