1- %global bootstrap_pre_1_20_compiler_version 20230802.5
2- %global bootstrap_post_1_20_compiler_version 20240321.6
31%global goroot %{_libdir }/golang
42%global gopath %{_datadir }/gocode
3+ %global ms_go_filename go1.22.3-20240507.3.src.tar.gz
4+ %global ms_go_revision 1
55%ifarch aarch64
66%global gohostarch arm64
77%else
1414%define __find_requires %{nil }
1515Summary: Go
1616Name: msft-golang
17- Version: 1.22.2
17+ Version: 1.22.3
1818Release: 1%{?dist }
1919License: BSD
2020Vendor: Microsoft Corporation
2121Distribution: Mariner
2222Group: System Environment/Security
2323URL: https://github.com/microsoft/go
24- Source0: https://github.com/microsoft/go/releases/download/v1.22.2-1/go1.22.2-20240403.7.src.tar.gz
25- Source1: https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz
26- Source2: https://github.com/microsoft/go/releases/download/v1.19.12-1/go.%{bootstrap_pre_1_20_compiler_version }.src.tar.gz
27- Source3: https://github.com/microsoft/go/releases/download/v1.21.8-3/go.%{bootstrap_post_1_20_compiler_version }.src.tar.gz
24+ Source0: https://github.com/microsoft/go/releases/download/v%{version }-%{ms_go_revision }/%{ms_go_filename }
25+ # bootstrap 00, same content as https://dl.google.com/go/go1.4-bootstrap-20171003.tar.gz
26+ Source1: https://github.com/microsoft/go/releases/download/v1.4.0-1/go1.4-bootstrap-20171003.tar.gz
27+ # bootstrap 01
28+ Source2: https://github.com/microsoft/go/releases/download/v1.19.12-1/go.20230802.5.src.tar.gz
29+ # bootstrap 02
30+ Source3: https://github.com/microsoft/go/releases/download/v1.20.14-1/go.20240206.2.src.tar.gz
2831Patch0: go14_bootstrap_aarch64.patch
2932Conflicts: go
3033Conflicts: golang
@@ -36,51 +39,47 @@ Go is an open source programming language that makes it easy to build simple, re
3639# Setup go 1.4 bootstrap source
3740tar xf %{SOURCE1 } --no-same-owner
3841patch -Np1 --ignore-whitespace < %{PATCH0 }
39- mv -v go go-bootstrap
42+ mv -v go go-bootstrap-00
43+
44+ tar xf %{SOURCE2 } --no-same-owner
45+ mv -v go go-bootstrap-01
46+
47+ tar xf %{SOURCE3 } --no-same-owner
48+ mv -v go go-bootstrap-02
4049
4150%setup -q -n go
4251
4352%build
44- # Go >= 1.20, < 1.22 bootstraps with go >= 1.17 and
45- # go >= 1.22 bootstraps with go >= 1.20.6.
46- # This condition makes go compiler >= 1.20 build a 4 step process:
47- # - Build the bootstrap compiler 1.4 (bootstrap bits in c)
48- # - Use the 1.4 compiler to build the %%{bootstrap_pre_1_20_compiler_version} compiler.
49- # - Use the %%{bootstrap_pre_1_20_compiler_version} compiler to build go %%{bootstrap_post_1_20_compiler_version} compiler.
50- # - Use the go %%{bootstrap_post_1_20_compiler_version} compiler to build the final go compiler.
51-
52- # Build go 1.4 bootstrap
53- pushd %{_topdir }/BUILD/go-bootstrap/src
54- CGO_ENABLED= 0 ./make.bash
55- popd
56- mv -v %{_topdir }/BUILD/go-bootstrap %{_libdir }/golang
57- export GOROOT= %{_libdir }/golang
58-
59- # Use go1.4 bootstrap to compile go.%%{bootstrap_pre_1_20_compiler_version} (C bootstrap)
60- export GOROOT_BOOTSTRAP= %{_libdir }/golang
61- mkdir -p %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version }
62- tar xf %{SOURCE2 } -C %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version } --strip-components= 1
63- pushd %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version }/src
64- CGO_ENABLED= 0 ./make.bash
65- popd
66-
67- # Nuke the older go 1.4 bootstrap
68- rm -rf %{_libdir }/golang
69-
70- # Make go.%%{bootstrap_pre_1_20_compiler_version} as the new bootstrapper (Go boostrap)
71- mv -v %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version } %{_libdir }/golang
72-
73- # Build go %%{bootstrap_post_1_20_compiler_version}
74- export GOROOT_BOOTSTRAP= %{_libdir }/golang
75- mkdir -p %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version }
76- tar xf %{SOURCE3 } -C %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version } --strip-components= 1
77- pushd %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version }/src
78- CGO_ENABLED= 0 ./make.bash
79- popd
80- # Remove %%{bootstrap_pre_1_20_compiler_version} bootstrapper
81- rm -rf %{_libdir }/golang
82- # Make %%{bootstrap_post_1_20_compiler_version} as the new bootstrapper
83- mv -v %{_topdir }/BUILD/go.%{bootstrap_pre_1_20_compiler_version } %{_libdir }/golang
53+ # go 1.4 bootstraps with C.
54+ # go 1.20 bootstraps with go >= 1.17.13
55+ # go >= 1.22 bootstraps with go >= 1.20.14
56+ #
57+ # These conditions make building the current go compiler from C a multistep
58+ # process. Approximately once a year, the bootstrap requirement is moved
59+ # forward, adding another step.
60+ #
61+ # PS: Since go compiles fairly quickly, the extra overhead is around 2-3 minutes
62+ # on a reasonable machine.
63+
64+ # Use prev bootstrap to compile next bootstrap.
65+ function go_bootstrap() {
66+ local bootstrap= $1
67+ local new_root= %{_topdir }/BUILD/go-bootstrap-${bootstrap}
68+ (
69+ cd ${new_root}/src
70+ CGO_ENABLED= 0 ./make.bash
71+ )
72+ # Nuke the older bootstrapper
73+ rm -rf %{_libdir }/golang
74+ # Install the new bootstrapper
75+ mv -v $new_root %{_libdir }/golang
76+ export GOROOT= %{_libdir }/golang
77+ export GOROOT_BOOTSTRAP= %{_libdir }/golang
78+ }
79+
80+ go_bootstrap 00
81+ go_bootstrap 01
82+ go_bootstrap 02
8483
8584# Build current go version
8685export GOHOSTOS= linux
@@ -91,9 +90,10 @@ export GOROOT="`pwd`"
9190export GOPATH= %{gopath }
9291export GOROOT_FINAL= %{_bindir }/go
9392rm -f %{gopath }/src/runtime/*.c
94- pushd src
95- ./make.bash --no-clean
96- popd
93+ (
94+ cd src
95+ ./make.bash --no-clean
96+ )
9797
9898%install
9999
153153%{_bindir }/*
154154
155155%changelog
156+ * Wed May 15 2024 Muhammad Falak <mwani@microsoft.com> - 1.22.3-1
157+ - Introduce function in spec to simplify bootstrapping
158+ - Bump version to 1.22.3
159+
156160* Mon Apr 15 2024 Muhammad Falak <mwani@microsoft.com> - 1.22.2-1
157161- Bump version to 1.22.2
158162
171175
172176* Wed Aug 16 2023 Brian Fjeldstad <bfjelds@microsoft.com> - 1.19.12-1
173177- Upgrade to 1.19.12 to fix CVE-2023-39533
174-
178+ 1.22.2
175179* Tue Jun 06 2023 Bala <balakumaran.kannan@microsoft.com> - 1.19.10-1
176180- Upgrade to 1.19.10 to fix CVE-2023-29404
177181
0 commit comments