Skip to content

Remove Go 1.26 Windows c-shared linker workaround once golang/go#78238 is fixed #392

@manusa

Description

@manusa

Context

Go 1.26 (introduced via #391) regressed -buildmode=c-shared for windows/amd64 when the output filename contains dots (e.g. helm-windows-4.0-amd64.dll). The new peCreateExportFile in cmd/link/internal/ld/pe.go emits a LIBRARY directive in the generated export_file.def using filepath.Base(outopt) verbatim, which GNU ld (mingw-w64 binutils) rejects with:

```
ld.exe: export_file.def:1: syntax error
ld.exe: export_file.def: file format not recognized; treating as linker script
```

Upstream tracker: golang/go#78238 — open, fix milestone Go 1.27, no backport to 1.26.x announced.

Workaround in this repo

We pass -extldflags '-Wl,--export-all-symbols' to the Go linker for Windows targets only. That short-circuits peCreateExportFile entirely (see the slices.Contains(flagExtldflags, ...) guard in pe.go), so the broken .def is never generated. Side effect: the DLL re-exports all Go symbols rather than just the //export-marked ones — same behavior as Go 1.25 had by default, fine for our JNA consumers.

Applied in:

  • Makefilebuild-native target (native Windows build)
  • Makefilebuild-native-cross-platform target (xgo cross-build, Windows targets only)

Removal criteria

Remove the workaround when either:

At that point, drop the --export-all-symbols ldflags additions and re-merge the xgo invocation into a single call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions