Add golang-race package and delete bundled archives

* Build race detector objects from source
* Delete upstream race detector objects
* Delete unused boring binary blob

This means we will only ship the native copy of the thread
sanitizer on each arch.  Cross compiling with the race detector
enabled will not be supported.

Resolves: RHEL-33421
Resolves: RHEL-54335
This commit is contained in:
David Benoit 2024-05-17 12:51:53 -04:00
parent fa0e185f49
commit 839d034ba4
3 changed files with 59 additions and 19 deletions

1
.gitignore vendored
View File

@ -80,3 +80,4 @@
/go1.22.4-1-openssl-fips.tar.gz
/go1.22.5.tar.gz
/go1.22.5-1-openssl-fips.tar.gz
/51bfeff0e4b0757ff773da6882f4d538996c9b04.tar.gz

View File

@ -100,12 +100,9 @@
# LLVM source SHA for race detector build
%global compiler_rt_go_race_sha 51bfeff0e4b0757ff773da6882f4d538996c9b04
# For rpmdev-bumpspec and releng automation.
%global baserelease 3
Name: golang
Version: %{version}
Release: 1%{?dist}
Release: 2%{?dist}
Summary: The Go Programming Language
# source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
License: BSD and Public Domain
@ -146,6 +143,7 @@ BuildRequires: clang
Provides: go = %{version}-%{release}
Requires: %{name}-bin = %{version}-%{release}
Requires: %{name}-src = %{version}-%{release}
Requires: %{name}-race = %{version}-%{release}
Requires: openssl-devel
Requires: diffutils
@ -164,9 +162,6 @@ Obsoletes: %{name}-docs < 1.1-4
# RPM can't handle symlink -> dir with subpackages, so merge back
Obsoletes: %{name}-data < 1.1.1-4
# We don't build golang-race anymore, rhbz#2230705
Obsoletes: golang-race < 1.20.0
# These are the only RHEL/Fedora architectures that we compile this package for
ExclusiveArch: %{golang_arches}
@ -237,16 +232,6 @@ Summary: Golang shared object libraries
%{summary}.
%endif
%if %{race}
%package race
Summary: Golang std library with -race enabled
Requires: %{name} = %{version}-%{release}
%description race
%{summary}
%endif
%package -n go-toolset
Summary: Package that installs go-toolset
Requires: %{name} = %{version}-%{release}
@ -257,6 +242,14 @@ Requires: delve
%description -n go-toolset
This is the main package for go-toolset.
%package race
Summary: Race detetector library object files.
Requires: %{name} = %{version}-%{release}
%description race
Binary library objects for Go's race detector.
%prep
%setup -q -n go-go%{version}
@ -281,7 +274,11 @@ popd
sed -i '1s/$/ (%{?rhel:Red Hat} %{version}-%{release})/' VERSION
cp %{SOURCE2} ./src/runtime/
# If FIPS is enabled, install the FIPS source
# Delete the bundled race detector objects.
find ./src/runtime/race/ -name "race_*.syso" -exec rm {} \;
# Delete the boring binary blob. We use the system OpenSSL instead.
rm -rf src/crypto/internal/boring/syso
%build
set -xe
@ -295,11 +292,32 @@ cat /proc/meminfo
mkdir ../llvm
tar -xf %{SOURCE3} -C ../llvm
tsan_go_dir="../llvm/llvm-project-%{compiler_rt_go_race_sha}/compiler-rt/lib/tsan/go"
# The script uses uname -a and grep to set the GOARCH. This
# is unreliable and can get the wrong architecture in
# circumstances like cross-architecture emulation. We fix it
# by just reading GOARCH directly from Go.
export GOARCH=$(go env GOARCH)
%ifarch x86_64
pushd "${tsan_go_dir}"
CFLAGS="${tsan_buildflags}" CC=clang GOAMD64=v3 ./buildgo.sh
popd
cp "${tsan_go_dir}"/race_linux_amd64.syso ./src/runtime/race/internal/amd64v3/race_linux.syso
pushd "${tsan_go_dir}"
CFLAGS="${tsan_buildflags}" CC=clang GOAMD64=v1 ./buildgo.sh
popd
cp "${tsan_go_dir}"/race_linux_amd64.syso ./src/runtime/race/internal/amd64v1/race_linux.syso
%else
pushd "${tsan_go_dir}"
CFLAGS="${tsan_buildflags}" CC=clang ./buildgo.sh
popd
cp "${tsan_go_dir}"/race_linux_%{gohostarch}.syso ./src/runtime/race/race_linux_%{gohostarch}.syso
%endif
# bootstrap compiler GOROOT
%if !%{golang_bootstrap}
export GOROOT_BOOTSTRAP=/
@ -531,8 +549,13 @@ cd ..
# prelink blacklist
%{_sysconfdir}/prelink.conf.d
%files -f go-src.list src
%ifarch x86_64
%exclude %{goroot}/src/runtime/race/internal/amd64v1/race_linux.syso
%exclude %{goroot}/src/runtime/race/internal/amd64v3/race_linux.syso
%else
%exclude %{goroot}/src/runtime/race/race_linux_%{gohostarch}.syso
%endif
%files -f go-docs.list docs
@ -551,7 +574,22 @@ cd ..
%files -n go-toolset
%files race
%ifarch x86_64
%{goroot}/src/runtime/race/internal/amd64v1/race_linux.syso
%{goroot}/src/runtime/race/internal/amd64v3/race_linux.syso
%else
%{goroot}/src/runtime/race/race_linux_%{gohostarch}.syso
%endif
%changelog
* Wed Aug 14 2024 David Benoit <dbenoit@redhat.com> - 1.22.5-2
- Rebuild race detector archives from LLVM sources
- Add golang-race subpackage
- Resolves: RHEL-33421
- Remove unused crypto/internal/boring/syso package
- Resolves: RHEL-54335
* Thu Jul 11 2024 Archana <aravinda@redhat.com> - 1.22.5-1
- Rebase to Go1.22.5 to address CVE-2024-24791
- Resolves: RHEL-46973

View File

@ -1,2 +1,3 @@
SHA512 (go1.22.5.tar.gz) = e0208d239ce4a4965d3c33fe5befbb1e919a0a695c9ef87c9dfc42d8b888c34301a6eb06a848a4eb662459bc06445d2a1f07275aa5d5e4b0cadb83e0bca0cab7
SHA512 (go1.22.5-1-openssl-fips.tar.gz) = 230fa331c2470a7a42c916cd1bec79fa423e913d7722235b4386b0aaf678e9baefc71d5c201a6d2c63d5936d06f2756b945ba54513109b046d569daeecc1cef3
SHA512 (51bfeff0e4b0757ff773da6882f4d538996c9b04.tar.gz) = 1c00ffa4ef0b73ea8551ce949ddbfb2991474003ce3b55f0c51fde71bab0011a47d1ef38a5ed702aca9461eac160ca900ec6438cca29f8ebad532c2d9ccadb1d