From: Paul E. Murphy Date: Tue, 27 Apr 2021 20:05:51 +0000 (-0500) Subject: cmd/link: disable plugin support if cgo is disabled X-Git-Tag: go1.17beta1~408 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=983dea90c169930e35721232afe39fd4e3fbe4a6;p=gostls13.git 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 Reviewed-by: Cherry Zhang TryBot-Result: Go Bot Trust: Lynn Boger --- diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index adf1669cf2..043bf5a35e 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -539,7 +539,10 @@ func (ctxt *Link) loadlib() { // up symbol by name may not get expected result. iscgo = ctxt.LibraryByPkg["runtime/cgo"] != nil - ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil + + // Plugins a require cgo support to function. Similarly, plugins may require additional + // internal linker support on some platforms which may not be implemented. + ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil && iscgo // We now have enough information to determine the link mode. determineLinkMode(ctxt)