Repository navigation
cmd/link: windows/arm64 internal linking rejects Clang COFF NODUPLICATES and ASSOCIATIVE sections #81365
Description
Go version
go version go1.27.1 darwin/arm64 (Homebrew)
Clang 23.1.0, targeting aarch64-pc-windows-msvc.
Output of go env in your module/workspace:
GO111MODULE='off'
GOARCH='arm64'
GOARM64='v8.0'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOOS='windows'
GOEXE='.exe'
GOEXPERIMENT=''
GOFLAGS=''
GOFIPS140='off'
GOTOOLCHAIN='local'
GOVERSION='go1.27.1'
GOWORK='off'
CGO_ENABLED='0'
What did you do?
This reproduces with stock Go on macOS ARM64, without a Windows SDK or CGo
environment. It was reduced from conda-forge/go-feedstock#339.
Create this layout:
repro/
functions.c
smoke/
main.go
functions.c:
__declspec(noinline) int repro_leaf(int n) { return n + 1; }
__declspec(noinline) int repro_nonleaf(int n) {
return repro_leaf(n) + 1;
}smoke/main.go:
package main
func main() {}From repro/, using Clang and llvm-readobj 23.1.0:
clang --target=aarch64-pc-windows-msvc -O2 -ffunction-sections \
-c functions.c -o smoke/repro_windows_arm64.syso
llvm-readobj --symbols --relocations --unwind smoke/repro_windows_arm64.syso
cd smoke
GOENV=off GOTOOLCHAIN=local GOWORK=off \
GOOS=windows GOARCH=arm64 CGO_ENABLED=0 GO111MODULE=off \
go build -ldflags=-linkmode=internal -o repro.exe .What did you see happen?
The stock linker exits with status 1:
internal error: unsupported COMDAT selection strategy found in path=<archive>(repro_windows_ar) sec=4 strategy=1 idx=6, please file a bug
Clang emits NODUPLICATES (1) .text sections and ASSOCIATIVE (5)
.xdata/.pdata sections referring to the non-leaf function's .text.
A diagnostic linker patched to support NODUPLICATES reaches strategy 5:
internal error: unsupported COMDAT selection strategy found in path=<archive>(repro_windows_ar) sec=5 strategy=5 idx=12, please file a bug
Stock Go stops at strategy 1; the second error is from the patched linker.
At inspected master commit
714d9afb66994e987aa715e088279e75efcec315,
the loader still accepts only ANY and SAME_SIZE. I have not built and run tip.
What did you expect to see?
Support for these COFF sections, or clarification of whether they are outside
the supported internal-linker subset. This reports missing support, not a regression.
The scope is section loading and association. ARM64 host unwind data also needs
to be preserved; merely accepting strategy 5 is insufficient. Generating unwind
metadata for Go frames is separate work (#57302).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
JunyangShao commentedon Sep 11, 2026
@golang/compiler
cherrymui commentedon Sep 11, 2026
cc @golang/windows
cherrymui commentedon Sep 15, 2026
Thanks for the report. The internal linking mode is not the default and has limited support of C objects. Could you just use the default external linking mode?
I'll also note that the support of MSVC objects is also very limited.
Thanks.
ClayWarren commentedon Sep 15, 2026
Thanks. External linking works for our CGo use case. We encountered this while running the full Go test suite, which explicitly exercises internal linking. Is that test coverage intended to apply to MSVC-target Clang, or should those tests be excluded for this toolchain?
cherrymui commentedon Sep 15, 2026
Okay, thanks. For Windows, the supported C toolchain is MinGW based clang, which includes internal linking support. We have limited support of MSVC-target clang, but not internal linking for the moment. (There are a few other known issues, like debug info doesn't work.) Thanks.