diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..4b4a967 --- /dev/null +++ b/Makefile @@ -0,0 +1,5 @@ +mockbuild: + centpkg mockbuild + +spectool: + spectool -g golang.spec diff --git a/golang.spec b/golang.spec index 25cd6d2..f3a1664 100644 --- a/golang.spec +++ b/golang.spec @@ -97,6 +97,12 @@ %global version %{go_version} %global pkg_release 1 +# 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} @@ -114,6 +120,7 @@ Source0: https://github.com/golang/go/archive/refs/tags/go%{version}.tar. Source1: https://github.com/golang-fips/go/archive/refs/tags/go%{version}-%{pkg_release}-openssl-fips.tar.gz # make possible to override default traceback level at build time by setting build tag rpm_crashtraceback Source2: fedora.go +Source3: https://github.com/llvm/llvm-project/archive/%{compiler_rt_go_race_sha}.tar.gz # The compiler is written in Go. Needs go(1.4+) compiler for build. # Actual Go based bootstrap compiler provided by above source. @@ -132,6 +139,10 @@ BuildRequires: openssl-devel # for tests BuildRequires: pcre-devel, glibc-static, perl +# Necessary for building llvm address sanitizer for Go race detector +BuildRequires: libstdc++-devel +BuildRequires: clang + Provides: go = %{version}-%{release} Requires: %{name}-bin = %{version}-%{release} Requires: %{name}-src = %{version}-%{release} @@ -270,6 +281,7 @@ popd sed -i '1s/$/ (%{?rhel:Red Hat} %{version}-%{release})/' VERSION cp %{SOURCE2} ./src/runtime/ +# If FIPS is enabled, install the FIPS source %build set -xe @@ -278,6 +290,16 @@ uname -a cat /proc/cpuinfo cat /proc/meminfo +# Build race detector .syso's from llvm sources +%global tsan_buildflags %(echo %{build_cflags} | sed 's/-mtls-dialect=gnu2//') +mkdir ../llvm +tar -xf %{SOURCE3} -C ../llvm +tsan_go_dir="../llvm/llvm-project-%{compiler_rt_go_race_sha}/compiler-rt/lib/tsan/go" +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 + # bootstrap compiler GOROOT %if !%{golang_bootstrap} export GOROOT_BOOTSTRAP=/