Skip to content

Commit c7248a0

Browse files
pmurdmitshur
authored andcommitted
[release-branch.go1.16] cmd/link: disable plugin support if cgo is disabled
Functional plugin support requires cgo to be enabled. Disable it if the environment has disabled cgo. This prevents unexpected linker failures when linking large binaries with cgo disabled which use the plugin package. Fixes #45832 Change-Id: Ib71f0e089f7373b7b3e3cd53da3612291e7bc473 Reviewed-on: https://go-review.googlesource.com/c/go/+/314449 Run-TryBot: Paul Murphy <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Lynn Boger <[email protected]> (cherry picked from commit 983dea9) Reviewed-on: https://go-review.googlesource.com/c/go/+/316329 Reviewed-by: Cherry Mui <[email protected]> Trust: Dmitri Shuralyov <[email protected]>
1 parent 04cd717 commit c7248a0

File tree

1 file changed

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

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,10 @@ func (ctxt *Link) loadlib() {
533533
// up symbol by name may not get expected result.
534534

535535
iscgo = ctxt.LibraryByPkg["runtime/cgo"] != nil
536-
ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil
536+
537+
// Plugins a require cgo support to function. Similarly, plugins may require additional
538+
// internal linker support on some platforms which may not be implemented.
539+
ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil && iscgo
537540

538541
// We now have enough information to determine the link mode.
539542
determineLinkMode(ctxt)

0 commit comments

Comments
 (0)