Skip to content

Commit ee5369b

Browse files
committed
cmd/link: add LIBRARY statement only with -buildmode=cshared
When creating a .def file for Windows linking, add a LIBRARY statement only when building a DLL with -buildmode=cshared. That statement is documented to instruct the linker to create a DLL, overriding any other flag that might indicate building an executable. Fixes #75734 Change-Id: I0231435df70b71a493a39deb639f6328a8e354f6 Reviewed-on: https://go-review.googlesource.com/c/go/+/708815 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Dominic Della Valle <ddvpublic@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 1bca4c1 commit ee5369b

File tree

1 file changed

+3
-1
lines changed
  • src/cmd/link/internal/ld

1 file changed

+3
-1
lines changed

src/cmd/link/internal/ld/pe.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1758,7 +1758,9 @@ func peCreateExportFile(ctxt *Link, libName string) (fname string) {
17581758
fname = filepath.Join(*flagTmpdir, "export_file.def")
17591759
var buf bytes.Buffer
17601760

1761-
fmt.Fprintf(&buf, "LIBRARY %s\n", libName)
1761+
if ctxt.BuildMode == BuildModeCShared {
1762+
fmt.Fprintf(&buf, "LIBRARY %s\n", libName)
1763+
}
17621764
buf.WriteString("EXPORTS\n")
17631765

17641766
ldr := ctxt.loader

0 commit comments

Comments
 (0)