Skip to content

cmd/link: windows/arm64 internal linking rejects Clang COFF NODUPLICATES and ASSOCIATIVE sections #81365

Open

Description

@ClayWarren

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).

Activity

  1. JunyangShao commented on Sep 11, 2026

    @JunyangShao
    Contributor

    @golang/compiler

  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Sep 11, 2026
  3. cherrymui commented on Sep 11, 2026

    @cherrymui
    Member

    cc @golang/windows

  4. added
    FeatureRequestIssues asking for a new feature that does not need a proposal.
    on Sep 15, 2026
  5. cherrymui commented on Sep 15, 2026

    @cherrymui
    Member

    -ldflags=-linkmode=internal

    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.

  6. added this to the Unplanned milestone on Sep 15, 2026
  7. ClayWarren commented on Sep 15, 2026

    @ClayWarren
    Author

    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?

  8. cherrymui commented on Sep 15, 2026

    @cherrymui
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.OS-Windowscompiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions