|
|
352cd3 |
From 983dea90c169930e35721232afe39fd4e3fbe4a6 Mon Sep 17 00:00:00 2001
|
|
|
352cd3 |
From: Paul E. Murphy <murp@ibm.com>
|
|
|
352cd3 |
Date: Tue, 27 Apr 2021 15:05:51 -0500
|
|
|
352cd3 |
Subject: [PATCH] cmd/link: disable plugin support if cgo is disabled
|
|
|
352cd3 |
|
|
|
352cd3 |
Functional plugin support requires cgo to be enabled. Disable
|
|
|
352cd3 |
it if the environment has disabled cgo.
|
|
|
352cd3 |
|
|
|
352cd3 |
This prevents unexpected linker failures when linking large
|
|
|
352cd3 |
binaries with cgo disabled which use the plugin package.
|
|
|
352cd3 |
|
|
|
352cd3 |
Fixes #45564
|
|
|
352cd3 |
|
|
|
352cd3 |
Change-Id: Ib71f0e089f7373b7b3e3cd53da3612291e7bc473
|
|
|
352cd3 |
Reviewed-on: https://go-review.googlesource.com/c/go/+/314449
|
|
|
352cd3 |
Run-TryBot: Paul Murphy <murp@ibm.com>
|
|
|
352cd3 |
Reviewed-by: Cherry Zhang <cherryyz@google.com>
|
|
|
352cd3 |
TryBot-Result: Go Bot <gobot@golang.org>
|
|
|
352cd3 |
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
|
|
|
352cd3 |
---
|
|
|
352cd3 |
|
|
|
352cd3 |
diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go
|
|
|
352cd3 |
index adf1669..043bf5a 100644
|
|
|
352cd3 |
--- a/src/cmd/link/internal/ld/lib.go
|
|
|
352cd3 |
+++ b/src/cmd/link/internal/ld/lib.go
|
|
|
352cd3 |
@@ -539,7 +539,10 @@
|
|
|
352cd3 |
// up symbol by name may not get expected result.
|
|
|
352cd3 |
|
|
|
352cd3 |
iscgo = ctxt.LibraryByPkg["runtime/cgo"] != nil
|
|
|
352cd3 |
- ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil
|
|
|
352cd3 |
+
|
|
|
352cd3 |
+ // Plugins a require cgo support to function. Similarly, plugins may require additional
|
|
|
352cd3 |
+ // internal linker support on some platforms which may not be implemented.
|
|
|
352cd3 |
+ ctxt.canUsePlugins = ctxt.LibraryByPkg["plugin"] != nil && iscgo
|
|
|
352cd3 |
|
|
|
352cd3 |
// We now have enough information to determine the link mode.
|
|
|
352cd3 |
determineLinkMode(ctxt)
|