diff options
author | Sören Tempel <soeren+git@soeren-tempel.net> | 2023-08-22 09:35:05 +0200 |
---|---|---|
committer | Sören Tempel <soeren+git@soeren-tempel.net> | 2023-08-22 09:35:05 +0200 |
commit | f21344fec95c820d9d1945e6bee27678268472f8 (patch) | |
tree | 8451bc8c8e0f5077079572d4ad92af4d222a8e9e | |
parent | 01b758eb87e0f049ff7e1fb5849e582b2a4e2cd7 (diff) |
community/go: enable support for toolchain downloading
Initially, toolchain downloading was disabled because it didn't work on
Alpine as many of the pre-built Go toolchain provided by Google are
dynamically linked against glibc. However, I recently became aware that,
starting with Go 1.21.0, the Go toolchain is a fully statically linked
binary. Thus, toolchain downloading will work on Alpine for Go >=1.21.0.
Automatic toolchain downloading will only fetch new toolchain, users can
explicitly request an older Go version via `GOTOOLCHAIN` in which case
it will not work on Alpine.
This commit removes our patch which forcefully disables the new Go
toolchain downloading feature. Note that, we still set `GOTOOLCHAIN`
to `local` in `go.env` (i.e. we won't attempt to download new
toolchain versions by default unless the users enables this explicitly).
4 files changed, 33 insertions, 86 deletions
diff --git a/community/go/0003-Prevent-Go-from-downloading-other-toolchain-versions.patch b/community/go/0003-Prevent-Go-from-downloading-other-toolchain-versions.patch deleted file mode 100644 index a515ddf1e30..00000000000 --- a/community/go/0003-Prevent-Go-from-downloading-other-toolchain-versions.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 3d87dbab87629c7f90253077d7833adc6e486cd3 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> -Date: Wed, 28 Jun 2023 15:01:04 +0200 -Subject: [PATCH] Prevent Go from downloading other toolchain versions - -Pre-built Go toolchain binaries are dynamically linked against glibc -and thus do not work on Alpine. Furthermore, we want to ensure that -users use the version of Go distributed with Alpine (i.e. including -our patches et cetera). - -For this reason, we disable downloading of Go toolchains entirely. -We update the default go.env to reflect that by setting GOTOOLCHAIN -to 'path'. - -See https://go.dev/doc/toolchain#select ---- - src/cmd/go/internal/toolchain/select.go | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/src/cmd/go/internal/toolchain/select.go b/src/cmd/go/internal/toolchain/select.go -index 8b1a0b94be..e9be0d720d 100644 ---- a/src/cmd/go/internal/toolchain/select.go -+++ b/src/cmd/go/internal/toolchain/select.go -@@ -256,8 +256,9 @@ func Exec(gotoolchain string) { - } - os.Setenv(countEnv, fmt.Sprint(count+1)) - -- env := cfg.Getenv("GOTOOLCHAIN") -- pathOnly := env == "path" || strings.HasSuffix(env, "+path") -+ // On Alpine, we don't allow downloading other toolchain since -+ // these are linked dynamically against glibc (i.e. do not work). -+ pathOnly := true - - // For testing, if TESTGO_VERSION is already in use - // (only happens in the cmd/go test binary) -@@ -290,7 +291,7 @@ func Exec(gotoolchain string) { - // GOTOOLCHAIN=auto looks in PATH and then falls back to download. - // GOTOOLCHAIN=path only looks in PATH. - if pathOnly { -- base.Fatalf("cannot find %q in PATH", gotoolchain) -+ base.Fatalf("cannot find %q in PATH and toolchain downloading not supported", gotoolchain) - } - - // Set up modules without an explicit go.mod, to download distribution. diff --git a/community/go/0003-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch b/community/go/0003-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch new file mode 100644 index 00000000000..db823307457 --- /dev/null +++ b/community/go/0003-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch @@ -0,0 +1,29 @@ +From 82ac7268f746c31d771e584c1c83f93890b33404 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> +Date: Tue, 11 Jul 2023 05:18:00 +0200 +Subject: [PATCH] go.env: Don't switch Go toolchain version as directed in + go.mod + +We want users and packages to use the version of Go that is provided +in our package repository. We don't want to download pre-built +toolchains from golang.org. + +Also note that prior to Go 1.21, pre-built Go binaries are linked +against glibc and hence do not work on Alpine. +--- + go.env | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/go.env b/go.env +index 6ff2b921d4..a106fb4638 100644 +--- a/go.env ++++ b/go.env +@@ -7,6 +7,5 @@ + GOPROXY=https://proxy.golang.org,direct + GOSUMDB=sum.golang.org + +-# Automatically download newer toolchains as directed by go.mod files. +-# See https://go.dev/doc/toolchain for details. +-GOTOOLCHAIN=auto ++# Don't attempt to switch to a newer toolchains by default. ++GOTOOLCHAIN=local diff --git a/community/go/0004-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch b/community/go/0004-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch deleted file mode 100644 index 6f366d580ed..00000000000 --- a/community/go/0004-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch +++ /dev/null @@ -1,34 +0,0 @@ -From b353968eec5fcbd0f402562306f32ac381470254 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net> -Date: Tue, 11 Jul 2023 15:41:42 +0200 -Subject: [PATCH] go.env: Don't switch Go toolchain version as directed in - go.mod - -Alpine Linux only supports toolchain versions in $PATH and does not -support the Go 1.21 toolchain downloading feature. As it is unlikely -that users will have multiple toolchains installed in $PATH, switching -toolchains by default is undesirable. - -Therefore, this patch restores the old pre <1.21 behavior where -the local toolchain was used by default even if a different version -was specified in go.mod. ---- - go.env | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/go.env b/go.env -index 6ff2b921d4..1ee5c16486 100644 ---- a/go.env -+++ b/go.env -@@ -7,6 +7,8 @@ - GOPROXY=https://proxy.golang.org,direct - GOSUMDB=sum.golang.org - --# Automatically download newer toolchains as directed by go.mod files. --# See https://go.dev/doc/toolchain for details. --GOTOOLCHAIN=auto -+# Don't automatically attempt to switch to a newer toolchain -+# as directed by go.mod files as Alpine does not support -+# toolchain downloading and hence can only retrieve toolchain -+# versions that are already in $PATH. -+GOTOOLCHAIN=local diff --git a/community/go/APKBUILD b/community/go/APKBUILD index 0121fc1878f..d81c3a70ad4 100644 --- a/community/go/APKBUILD +++ b/community/go/APKBUILD @@ -17,8 +17,7 @@ subpackages="$pkgname-doc" source="https://go.dev/dl/go$pkgver.src.tar.gz 0001-cmd-link-prefer-musl-s-over-glibc-s-ld.so-during-dyn.patch 0002-misc-cgo-test-enable-Test9400-on-Alpine-Linux-again.patch - 0003-Prevent-Go-from-downloading-other-toolchain-versions.patch - 0004-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch + 0003-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch tests-filter-overflow-gid.patch tests-unshare-enosys.patch @@ -188,10 +187,8 @@ prepare() { rm test/fixedbugs/bug513.go fi - # gccgo test failures are explained below, the gotoolchain_net - # test doesn't pass because we patch out toolchain downloading. - rm -f src/cmd/go/testdata/script/gccgo*.txt \ - src/cmd/go/testdata/script/gotoolchain_net.txt + # gccgo test failures are explained below. + rm -f src/cmd/go/testdata/script/gccgo*.txt } builddir="$srcdir"/go @@ -294,8 +291,7 @@ sha512sums=" da629fee156de6abbc5195f746e2fe4172a31b97eccd3871283c60452e81ac740533cc28ca68762ebc0ce48fb791dc527d3b7ebe7e1aee0f0b68868de736ed42 go1.21.0.src.tar.gz 34dbe032c5f08dd8a7aad36fc4d54e746a876fdadc25466888a2f04f5a9d53103190ebd68d3cf978d3a041976185e30ffb25611fb577d031c159810d2d4c7c41 0001-cmd-link-prefer-musl-s-over-glibc-s-ld.so-during-dyn.patch bac6d16401bb37e1894eebe4a5f46b103cdd8fb6128065a90048039f819b80be84c305cda39b209d79a35a2730463c657df6afcfb471ba14397fd79994c9be99 0002-misc-cgo-test-enable-Test9400-on-Alpine-Linux-again.patch -d005eb0ede010b62706eae574fca76b09c168bae0372c357cfe1fc0fca86f3f8f352b7521d9f3bc7312f4a37e515654cb03625e4ffa1faaea8657c95a101b4c9 0003-Prevent-Go-from-downloading-other-toolchain-versions.patch -a538c1e84c1e1509a38e96fcfe8b657e65bef104d2a47a368eb906f44015d317c537bf3680757ed06d77ec0f5767f6bd39db6b8796efe5b354f2880232ef0f9b 0004-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch +8061e4ef9d7dd31804bd8d98c95afa5dd82567940b3436f45f874e0419e324b49713d8a814df04617e575ec3c6155199c4661352ea8aef63ead81ca3020f3dc4 0003-go.env-Don-t-switch-Go-toolchain-version-as-directed.patch 9f656adb00d174aeae3fc09eeeba1931a290e8cf9e1d3f5e0f232dcf121d45dba04210f88afbb3915b0d7e21dad5c165de9307f4b53e33ba718d312153391571 tests-filter-overflow-gid.patch 6017caacf77c2911e9e882878fdaa2ed066b76b7e97b2ad776bc33d96b21cabc802966473946642c86a8f985c69adcc5e7ea61684f6d0dbacd468a6aad687229 tests-unshare-enosys.patch 4f3f9dfca1d5b9e8219475aea4b25784c7d9c65ade69e38df4210d8c0115fa62771ff44033bca26b4e53f4efcb350aa9fbbddb69780cdef47000a505ea81a79a tests-unset-GCCGO.patch |