Skip to content

Commit 983dea9

Browse files
pmurlaboger
authored andcommitted
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 #45564 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]>
1 parent 214c8dd commit 983dea9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

  • src/cmd/link/internal/ld

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

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

541541
iscgo = ctxt.LibraryByPkg["runtime/cgo"] != nil
542-
ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil
542+
543+
// Plugins a require cgo support to function. Similarly, plugins may require additional
544+
// internal linker support on some platforms which may not be implemented.
545+
ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil && iscgo
543546

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

0 commit comments

Comments
 (0)