aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2021-10-27 14:29:29 -0400
committerBryan C. Mills <bcmills@google.com>2021-10-27 20:03:17 +0000
commit68bd5121ee8954cfd7e3f7edb5d035f0e8b1bccc (patch)
treebe75f58e79a1c5126e119f2dc5245edcd0974ba0 /src
parentffd2284db06d433d60aa75ea413f407b90e583b6 (diff)
downloadgo-68bd5121ee8954cfd7e3f7edb5d035f0e8b1bccc.tar.xz
cmd/go: remove support for -buildmode=shared
It never worked in module mode (or with a read-only GOROOT). A proposal to drop it was filed (and approved) in https://golang.org/issue/47788. Fixes #47788 Change-Id: I0c12f38eb0c5dfe9384fbdb49ed202301fa4273d Reviewed-on: https://go-review.googlesource.com/c/go/+/359096 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/dist/test.go9
-rw-r--r--src/cmd/go/alldocs.go9
-rw-r--r--src/cmd/go/internal/help/helpdoc.go5
-rw-r--r--src/cmd/go/internal/list/list.go3
-rw-r--r--src/cmd/go/internal/work/build.go3
-rw-r--r--src/cmd/go/internal/work/init.go31
-rw-r--r--src/cmd/go/testdata/script/list_linkshared.txt16
-rw-r--r--src/cmd/internal/sys/supported.go7
8 files changed, 23 insertions, 60 deletions
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 5935011e19..87238cc74f 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -762,9 +762,6 @@ func (t *tester) registerTests() {
if t.supportedBuildmode("c-shared") {
t.registerHostTest("testcshared", "../misc/cgo/testcshared", "misc/cgo/testcshared", ".")
}
- if t.supportedBuildmode("shared") {
- t.registerTest("testshared", "../misc/cgo/testshared", t.goTest(), t.timeout(600), ".")
- }
if t.supportedBuildmode("plugin") {
t.registerTest("testplugin", "../misc/cgo/testplugin", t.goTest(), t.timeout(600), ".")
}
@@ -1047,12 +1044,6 @@ func (t *tester) supportedBuildmode(mode string) bool {
return true
}
return false
- case "shared":
- switch pair {
- case "linux-386", "linux-amd64", "linux-arm", "linux-arm64", "linux-ppc64le", "linux-s390x":
- return true
- }
- return false
case "plugin":
// linux-arm64 is missing because it causes the external linker
// to crash, see https://golang.org/issue/17138
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go
index 9d8c321307..685ccac826 100644
--- a/src/cmd/go/alldocs.go
+++ b/src/cmd/go/alldocs.go
@@ -162,9 +162,6 @@
// flags has a similar effect.
// -ldflags '[pattern=]arg list'
// arguments to pass on each go tool link invocation.
-// -linkshared
-// build code that will be linked against shared libraries previously
-// created with -buildmode=shared.
// -mod mode
// module download mode to use: readonly, vendor, or mod.
// By default, if a vendor directory is present and the go version in go.mod
@@ -778,7 +775,6 @@
// Name string // package name
// Doc string // package documentation string
// Target string // install path
-// Shlib string // the shared library that contains this package (only set when -linkshared)
// Goroot bool // is this package in the Go root?
// Standard bool // is this package part of the standard Go library?
// Stale bool // would 'go install' do anything for this package?
@@ -1799,11 +1795,6 @@
// non-main packages are built into .a files (the default
// behavior).
//
-// -buildmode=shared
-// Combine all the listed non-main packages into a single shared
-// library that will be used when building with the -linkshared
-// option. Packages named main are ignored.
-//
// -buildmode=exe
// Build the listed main packages and everything they import into
// executables. Packages not named main are ignored.
diff --git a/src/cmd/go/internal/help/helpdoc.go b/src/cmd/go/internal/help/helpdoc.go
index 035235fe1b..2bb3584eba 100644
--- a/src/cmd/go/internal/help/helpdoc.go
+++ b/src/cmd/go/internal/help/helpdoc.go
@@ -726,11 +726,6 @@ are:
non-main packages are built into .a files (the default
behavior).
- -buildmode=shared
- Combine all the listed non-main packages into a single shared
- library that will be used when building with the -linkshared
- option. Packages named main are ignored.
-
-buildmode=exe
Build the listed main packages and everything they import into
executables. Packages not named main are ignored.
diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go
index 8c85ddcf21..f23fbe5fea 100644
--- a/src/cmd/go/internal/list/list.go
+++ b/src/cmd/go/internal/list/list.go
@@ -23,8 +23,8 @@ import (
"cmd/go/internal/load"
"cmd/go/internal/modinfo"
"cmd/go/internal/modload"
- "cmd/go/internal/work"
"cmd/go/internal/str"
+ "cmd/go/internal/work"
)
var CmdList = &base.Command{
@@ -56,7 +56,6 @@ to -f '{{.ImportPath}}'. The struct being passed to the template is:
Name string // package name
Doc string // package documentation string
Target string // install path
- Shlib string // the shared library that contains this package (only set when -linkshared)
Goroot bool // is this package in the Go root?
Standard bool // is this package part of the standard Go library?
Stale bool // would 'go install' do anything for this package?
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index 9d0ad27f0d..e39ffcbd50 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -116,9 +116,6 @@ and test commands:
flags has a similar effect.
-ldflags '[pattern=]arg list'
arguments to pass on each go tool link invocation.
- -linkshared
- build code that will be linked against shared libraries previously
- created with -buildmode=shared.
-mod mode
module download mode to use: readonly, vendor, or mod.
By default, if a vendor directory is present and the go version in go.mod
diff --git a/src/cmd/go/internal/work/init.go b/src/cmd/go/internal/work/init.go
index 4dbbd2a13f..b2ee00d53c 100644
--- a/src/cmd/go/internal/work/init.go
+++ b/src/cmd/go/internal/work/init.go
@@ -246,16 +246,20 @@ func buildModeInit() {
}
ldBuildmode = "pie"
case "shared":
- pkgsFilter = pkgsNotMain
- if gccgo {
- codegenArg = "-fPIC"
- } else {
- codegenArg = "-dynlink"
- }
- if cfg.BuildO != "" {
- base.Fatalf("-buildmode=shared and -o not supported together")
+ if cfg.Goos == "linux" {
+ switch cfg.Goarch {
+ case "386", "amd64", "arm", "arm64", "ppc64le", "s390x":
+ // -buildmode=shared was supported on these platforms at one point, but
+ // never really worked in module mode.
+ // Support was officially dropped as of Go 1.18.
+ // (See https://golang.org/issue/47788.)
+ base.Fatalf("-buildmode=shared no longer supported as of Go 1.18")
+
+ // TODO(#47788): Remove supporting code for -buildmode=shared.
+ // (For the Go 1.18 release, we will keep most of the code around but
+ // disabled to avoid merge conflicts in case we need to revert quickly.)
+ }
}
- ldBuildmode = "shared"
case "plugin":
pkgsFilter = oneMainPkg
if gccgo {
@@ -274,6 +278,15 @@ func buildModeInit() {
}
if cfg.BuildLinkshared {
+ if cfg.Goos == "linux" {
+ switch cfg.Goarch {
+ case "386", "amd64", "arm", "arm64", "ppc64le", "s390x":
+ base.Fatalf("-linkshared no longer supported as of Go 1.18")
+ // TODO(#47788): Remove supporting code for linkshared.
+ // (For the Go 1.18 release, we will keep most of the code around but
+ // disabled to avoid merge conflicts in case we need to revert quickly.)
+ }
+ }
if !sys.BuildModeSupported(cfg.BuildToolchainName, "shared", cfg.Goos, cfg.Goarch) {
base.Fatalf("-linkshared not supported on %s/%s\n", cfg.Goos, cfg.Goarch)
}
diff --git a/src/cmd/go/testdata/script/list_linkshared.txt b/src/cmd/go/testdata/script/list_linkshared.txt
deleted file mode 100644
index baae1e2be8..0000000000
--- a/src/cmd/go/testdata/script/list_linkshared.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-env GO111MODULE=on
-
-# golang.org/issue/35759: 'go list -linkshared'
-# panicked if invoked on a test-only package.
-
-[!buildmode:shared] skip
-
-go list -f '{{.ImportPath}}: {{.Target}} {{.Shlib}}' -linkshared .
-stdout '^example.com: $'
-
--- go.mod --
-module example.com
-
-go 1.14
--- x.go --
-package x
diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go
index e6c56fbc56..473e390587 100644
--- a/src/cmd/internal/sys/supported.go
+++ b/src/cmd/internal/sys/supported.go
@@ -109,13 +109,6 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
}
return false
- case "shared":
- switch platform {
- case "linux/386", "linux/amd64", "linux/arm", "linux/arm64", "linux/ppc64le", "linux/s390x":
- return true
- }
- return false
-
case "plugin":
switch platform {
case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "linux/s390x", "linux/ppc64le",