Repository navigation
cmd/link: linkerFlagSupported drops trailing arguments from multi-word CC when probing linker flags #81163
Description
Go version
go version go1.28-devel_2117d7cf9f Wed Aug 26 21:30:33 2026 -0700 linux/ppc64le
Output of go env in your module/workspace:
GOARCH='ppc64le'
GOHOSTARCH='ppc64le'
GOOS='linux'
CGO_ENABLED='1'
CC='gcc'
CXX='g++'
GOPPC64='power10'
GOVERSION='go1.28-devel_2117d7cf9f Wed Aug 26 21:30:33 2026 -0700'
GOEXPERIMENT=''
GOFLAGS=''
GOTOOLCHAIN='local'
clang version 21.1.8 (Red Hat, Inc. 21.1.8-2.el9)
Target: ppc64le-redhat-linux-gnuWhat did you do?
This was first observed in the Go CI/CD builder on ppc64le POWER10, and I then reproduced it locally on a POWER10 system using current Go master. Link
On a ppc64le POWER10 system, I checked out current Go master and ran the full test suite with GOPPC64=power10.
The failure reproduces locally in:
TestScript/cgo_path_space_quote
I then reproduced the test directly with:
GOPPC64=power10 ./bin/go test cmd/go \
-run='TestScript/cgo_path_space_quote' \
-count=1 -vThe test sets CC to a wrapper executable whose path contains spaces, followed by clang, for example:
"/tmp/.../program files/which cc" clang
I also verified independently that the compiler supports the Power10 flag:
clang -m64 -mcpu=power10 /tmp/p10.c -o /tmp/p10
echo $?which returns:
0
What did you see happen?
TestScript/cgo_path_space_quote fails during go run . with:
# test
.../pkg/tool/linux_ppc64le/link: The external toolchain does not support -mcpu=power10. This is required to externally link GOPPC64 >= power10
The test itself successfully preserves the multi-word CC value:
"/tmp/.../program files/which cc" clang
To inspect the Power10 capability probe, I temporarily instrumented linkerFlagSupported. The failing probe executed:
DEBUG linkerFlagSupported: flag="-mcpu=power10"
cmd=["/tmp/.../program files/which cc"
"-m64"
"-o" "..."
"-mcpu=power10"
".../trivial.c"]
The trailing clang argument from CC is missing.
The corresponding call site passes only argv[0]:
linkerFlagSupported(ctxt.Arch, argv[0], "", "-mcpu=power10")while linkerFlagSupported later executes:
exec.Command(linker, flags...)As a result, the wrapper is invoked without the trailing compiler argument, causing the flag probe to return false.
The compiler itself does support the flag:
$ clang -m64 -mcpu=power10 /tmp/p10.c -o /tmp/p10
$ echo $?
0
What did you expect to see?
TestScript/cgo_path_space_quote should pass when CC contains a quoted executable path followed by additional arguments.
In this case, the external linker command is effectively:
"/tmp/.../program files/which cc" clang
Flag probing should preserve the complete external linker command, including the trailing clang argument.
The Power10 capability probe should therefore invoke the wrapper with clang before -mcpu=power10, detect that the compiler supports the flag, and allow go run . to complete successfully.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
jkrishmys commentedon Aug 27, 2026
cc @golang/ppc64
jkrishmys commentedon Aug 27, 2026
Also reproduced on ppc64le POWER9 (first observed in Go CI/CD dashboard ).
In
TestScript/cgo_path_space_quote, the same multi-wordCCtruncation affects the-no-pie/-nopieprobes.The test sets:
but inside
go run ., the probes are executed as:The trailing
clangargument is missing in both cases.On this POWER9 system, Clang defaults to PIE:
while
-no-pieproduces:Since both
-no-pieand-nopieprobes falsely fail, the external link proceeds without either flag. The resulting executable then fails at load time with:The same missing trailing compiler argument is also visible in the probes for
-Wl,--build-id=...,-Wl,--export-dynamic-symbol=main,-Qunused-arguments, and-Wl,--compress-debug-sections=zlib.So the issue is not limited to the Power10
-mcpu=power10check; the samelinkerFlagSupportedargument loss affects multiple generic flag probes.[-]cmd/link: linkerFlagSupported drops trailing arguments from multi-word CC, causing false "-mcpu=power10" unsupported error on ppc64le[/-][+]cmd/link: linkerFlagSupported drops trailing arguments from multi-word CC when probing linker flags[/+]gabyhelp commentedon Aug 27, 2026
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
cmd/link: preserve extra CC arguments when probing linker flags
cmd/link: preserve extra CC arguments when probing linker flags
cmd/link: preserve extra CC arguments when probing linker flags
cmd/link: preserve extra CC arguments when probing linker flags
cmd/link: preserve extra CC arguments when probing linker flags
cmd/link: preserve extra CC arguments when probing linker flags
KingLizard1020 commentedon Sep 9, 2026
A proposed fix is in #81410. The linker now passes the full CC / -extld command when probing flags, so wrapper-prefixed compilers are no longer dropped.
gopherbot commentedon Sep 9, 2026
Change https://go.dev/cl/829964 mentions this issue:
cmd/link: preserve extra CC arguments when probing linker flagsianlancetaylor commentedon Sep 10, 2026
I suspect that this is fixed by https://go.dev/cl/823024.