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:
Makefile — build-native target (native Windows build)
Makefile — build-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.
Context
Go 1.26 (introduced via #391) regressed
-buildmode=c-sharedfor windows/amd64 when the output filename contains dots (e.g.helm-windows-4.0-amd64.dll). The newpeCreateExportFileincmd/link/internal/ld/pe.goemits aLIBRARYdirective in the generatedexport_file.defusingfilepath.Base(outopt)verbatim, which GNUld(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-circuitspeCreateExportFileentirely (see theslices.Contains(flagExtldflags, ...)guard inpe.go), so the broken.defis 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:
Makefile—build-nativetarget (native Windows build)Makefile—build-native-cross-platformtarget (xgo cross-build, Windows targets only)Removal criteria
Remove the workaround when either:
At that point, drop the
--export-all-symbolsldflags additions and re-merge the xgo invocation into a single call.