Skip to content

Commit adce7f1

Browse files
committed
cmd/link: support .def file with MSVC clang toolchain
lld-link supports .def file, but requires a "-def:" (or "/def:") flag. (MinGW linker, on the other hand, requires no flag.) Pass the flag when using MSVC-based toolchain. CL originally authored by Chressie Himpel. Change-Id: I8c327ab48d36b0bcbb1d127cff544ffdb06be38e Reviewed-on: https://go-review.googlesource.com/c/go/+/708716 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Chressie Himpel <[email protected]>
1 parent d5b9503 commit adce7f1

File tree

1 file changed

+6
-2
lines changed
  • src/cmd/link/internal/ld

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,9 +1787,13 @@ func (ctxt *Link) hostlink() {
17871787
case ctxt.IsAIX():
17881788
fileName := xcoffCreateExportFile(ctxt)
17891789
argv = append(argv, "-Wl,-bE:"+fileName)
1790-
case ctxt.IsWindows() && !slices.Contains(flagExtldflags, "-Wl,--export-all-symbols"):
1790+
case ctxt.IsWindows() && !slices.Contains(flagExtldflags, wlPrefix+"export-all-symbols"):
17911791
fileName := peCreateExportFile(ctxt, filepath.Base(outopt))
1792-
argv = append(argv, fileName)
1792+
prefix := ""
1793+
if isMSVC {
1794+
prefix = "-Wl,-def:"
1795+
}
1796+
argv = append(argv, prefix+fileName)
17931797
}
17941798

17951799
const unusedArguments = "-Qunused-arguments"

0 commit comments

Comments
 (0)