Blame packages/g/go1.17/go1.17.spec

7c80ab
#
7c80ab
# spec file for package go1.17
7c80ab
#
d023e4
# Copyright (c) 2022 SUSE LLC
7c80ab
#
7c80ab
# All modifications and additions to the file contributed by third parties
7c80ab
# remain the property of their copyright owners, unless otherwise agreed
7c80ab
# upon. The license for this file, and modifications and additions to the
7c80ab
# file, is the same license as for the pristine package itself (unless the
7c80ab
# license for the pristine package is not an Open Source License, in which
7c80ab
# case the license is the MIT License). An "Open Source License" is a
7c80ab
# license that conforms to the Open Source Definition (Version 1.9)
7c80ab
# published by the Open Source Initiative.
7c80ab
7c80ab
# Please submit bugfixes or comments via https://bugs.opensuse.org/
7c80ab
#
7c80ab
# nodebuginfo
7c80ab
7c80ab
7c80ab
# strip will cause Go's .a archives to become invalid because strip appears to
7c80ab
# reassemble the archive incorrectly. This is a known issue upstream
7c80ab
# (https://github.com/golang/go/issues/17890), but we have to deal with it in
7c80ab
# the meantime.
7c80ab
%undefine _build_create_debug
7c80ab
%define __arch_install_post export NO_BRP_STRIP_DEBUG=true NO_BRP_AR=true
7c80ab
7c80ab
%if 0%{?suse_version} == 1315
7c80ab
%define gcc_go_version 6
7c80ab
%define go_bootstrap_version go1.4
7c80ab
%else
7c80ab
%ifarch riscv64
7c80ab
%define go_bootstrap_version go1.14
7c80ab
%else
7c80ab
%define go_bootstrap_version go1.9
7c80ab
%endif
7c80ab
%if 0%{?sle_version} == 150000
7c80ab
# SLE15 or Leap 15.x
7c80ab
%define gcc_go_version 7
7c80ab
%else
7c80ab
%define gcc_go_version 9
7c80ab
%endif
7c80ab
%endif
7c80ab
7c80ab
# By default use go and not gccgo
7c80ab
%bcond_with    gccgo
7c80ab
7c80ab
# The fallback boostrap method via %%{go_bootstrap_version} would work for Leap
7c80ab
# but we don't have %%{go_bootstrap_version} in there. Same for SLE15+
7c80ab
#if ( 0%{?suse_version} < 1550 && 0%{?is_opensuse} ) || ( 0%{?suse_version} >= 1500 && ! 0%{?is_opensuse} )
7c80ab
#bcond_without gccgo
7c80ab
#endif
7c80ab
7c80ab
# The fallback bootstrap method via go1.4 doesn't work
7c80ab
# for aarch64 nor ppc64le because go 1.4 did not support that architecture.
7c80ab
%if 0%{?suse_version} == 1315
7c80ab
%ifarch aarch64 ppc64le ppc64 s390x
7c80ab
%bcond_without gccgo
7c80ab
%endif
7c80ab
%endif
7c80ab
7c80ab
# gccgo on ppc64le with default PIE enabled fails with:
7c80ab
# error while loading shared libraries:
7c80ab
# R_PPC64_ADDR16_HA re10143fb0c for symbol `' out of range
7c80ab
# track https://github.com/golang/go/issues/28531
7c80ab
# linuxppc-dev discussion:
7c80ab
# "PIE binaries are no longer mapped below 4 GiB on ppc64le"
7c80ab
# https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-November/180862.html
7c80ab
%ifarch ppc64le
7c80ab
#!BuildIgnore: gcc-PIE
7c80ab
%endif
7c80ab
7c80ab
# Build go-race only on platforms where it's supported (both amd64 and aarch64
7c80ab
# requires SLE15-or-later because of C++14, and ppc64le doesn't build at all
7c80ab
# on openSUSE yet).
7c80ab
%if 0%{?suse_version} >= 1500 || 0%{?sle_version} >= 150000
7c80ab
%define tsan_arch x86_64 aarch64
7c80ab
%else
7c80ab
# Cannot use {nil} here (ifarch doesn't like it) so just make up a fake
7c80ab
# architecture that no build will ever match.
7c80ab
%define tsan_arch openSUSE_FAKE_ARCH
7c80ab
%endif
7c80ab
7c80ab
# Go has precompiled versions of LLVM's compiler-rt inside their source code.
7c80ab
# We cannot ship pre-compiled binaries so we have to recompile said source,
7c80ab
# however they vendor specific commits from upstream. This value comes from
7c80ab
# src/runtime/race/README (and we verify that it matches in check).
7c80ab
#
7c80ab
# In order to update the TSAN version, modify _service. See boo#1052528 for
7c80ab
# more details.
7c80ab
%define tsan_commit 89f7ccea6f6488c443655880229c54db1f180153
7c80ab
7c80ab
%define go_api 1.17
7c80ab
7c80ab
# shared library support
7c80ab
%if "%{rpm_vercmp %{go_api} 1.5}" > "0"
7c80ab
%if %{with gccgo}
7c80ab
%define with_shared 1
7c80ab
%else
7c80ab
%ifarch %ix86 %arm x86_64 aarch64
7c80ab
%define with_shared 1
7c80ab
%else
7c80ab
%define with_shared 0
7c80ab
%endif
7c80ab
%endif
7c80ab
%else
7c80ab
%define with_shared 0
7c80ab
%endif
7c80ab
%ifarch ppc64
7c80ab
%define with_shared 0
7c80ab
%endif
7c80ab
# setup go_arch (BSD-like scheme)
7c80ab
%ifarch %ix86
7c80ab
%define go_arch 386
7c80ab
%endif
7c80ab
%ifarch x86_64
7c80ab
%define go_arch amd64
7c80ab
%endif
7c80ab
%ifarch aarch64
7c80ab
%define go_arch arm64
7c80ab
%endif
7c80ab
%ifarch %arm
7c80ab
%define go_arch arm
7c80ab
%endif
7c80ab
%ifarch ppc64
7c80ab
%define go_arch ppc64
7c80ab
%endif
7c80ab
%ifarch ppc64le
7c80ab
%define go_arch ppc64le
7c80ab
%endif
7c80ab
%ifarch s390x
7c80ab
%define go_arch s390x
7c80ab
%endif
7c80ab
%ifarch riscv64
7c80ab
%define go_arch riscv64
7c80ab
%endif
7c80ab
7c80ab
Name:           go1.17
Bernhard M. Wiedemann f155be
Version:        1.17.7
7c80ab
Release:        0
7c80ab
Summary:        A compiled, garbage-collected, concurrent programming language
7c80ab
License:        BSD-3-Clause
7c80ab
Group:          Development/Languages/Other
7c80ab
URL:            http://golang.org
7c80ab
Source:         http://golang.org/dl/go%{version}.src.tar.gz
7c80ab
Source1:        go-rpmlintrc
7c80ab
Source4:        README.SUSE
7c80ab
Source6:        go.gdbinit
7c80ab
# We have to compile TSAN ourselves. boo#1052528
7c80ab
Source100:      llvm-%{tsan_commit}.tar.xz
7c80ab
# PATCH-FIX-UPSTREAM marguerite@opensuse.org - find /usr/bin/go-5 when bootstrapping with gcc5-go
7c80ab
Patch8:         gcc6-go.patch
7c80ab
Patch9:         gcc7-go.patch
7c80ab
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
7c80ab
# boostrap
7c80ab
%if %{with gccgo}
7c80ab
%ifnarch s390 s390x
7c80ab
BuildRequires:  binutils-gold
7c80ab
%endif
7c80ab
BuildRequires:  gcc%{gcc_go_version}-go
7c80ab
%else
7c80ab
# no gcc-go
7c80ab
BuildRequires:  %{go_bootstrap_version}
7c80ab
%endif
7c80ab
BuildRequires:  fdupes
7c80ab
Recommends:     %{name}-doc = %{version}
7c80ab
%ifarch %{tsan_arch}
7c80ab
# Needed to compile compiler-rt/TSAN.
7c80ab
BuildRequires:  gcc-c++
7c80ab
%endif
7c80ab
#BNC#818502 debug edit tool of rpm fails on i586 builds
7c80ab
BuildRequires:  rpm >= 4.11.1
7c80ab
# Needed on arm aarch64 to avoid
7c80ab
# collect2: fatal error: cannot find 'ld'-
7c80ab
%ifarch %arm aarch64
7c80ab
BuildRequires:  binutils-gold
7c80ab
%endif
7c80ab
Requires(post): update-alternatives
7c80ab
Requires(postun):update-alternatives
7c80ab
# Needed on arm aarch64 to avoid
7c80ab
# collect2: fatal error: cannot find 'ld'-
7c80ab
%ifarch %arm aarch64
7c80ab
%if 0%{?is_opensuse}
7c80ab
Requires:       binutils-gold
7c80ab
%else
7c80ab
Recommends:     binutils-gold
7c80ab
%endif
7c80ab
%endif
7c80ab
Requires:       gcc
7c80ab
Provides:       go = %{version}
7c80ab
Provides:       go-devel = go%{version}
7c80ab
Provides:       go-devel-static = go%{version}
7c80ab
Provides:       golang(API) = %{go_api}
7c80ab
Obsoletes:      go-devel < go%{version}
7c80ab
# go-vim/emacs were separate projects starting from 1.4
7c80ab
Obsoletes:      go-emacs <= 1.3.3
7c80ab
Obsoletes:      go-vim <= 1.3.3
7c80ab
ExclusiveArch:  %ix86 x86_64 %arm aarch64 ppc64 ppc64le s390x riscv64
7c80ab
7c80ab
%description
7c80ab
Go is an expressive, concurrent, garbage collected systems programming language
7c80ab
that is type safe and memory safe. It has pointers but no pointer arithmetic.
7c80ab
Go has fast builds, clean syntax, garbage collection, methods for any type, and
7c80ab
run-time reflection. It feels like a dynamic language but has the speed and
7c80ab
safety of a static language.
7c80ab
7c80ab
%package doc
7c80ab
Summary:        Go documentation
7c80ab
Group:          Documentation/Other
7c80ab
Requires:       %{name} = %{version}
7c80ab
Provides:       go-doc = %{version}
7c80ab
7c80ab
%description doc
7c80ab
Go examples and documentation.
7c80ab
7c80ab
%ifarch %{tsan_arch}
7c80ab
# boo#1052528
7c80ab
%package race
7c80ab
Summary:        Go runtime race detector
7c80ab
Group:          Development/Languages/Other
7c80ab
URL:            https://compiler-rt.llvm.org/
7c80ab
Requires:       %{name} = %{version}
7c80ab
Supplements:    %{name} = %{version}
7c80ab
ExclusiveArch:  %{tsan_arch}
7c80ab
7c80ab
%description race
7c80ab
Go runtime race detector libraries. Install this package if you wish to use the
7c80ab
-race option, in order to detect race conditions present in your Go programs.
7c80ab
%endif
7c80ab
7c80ab
%prep
7c80ab
%ifarch %{tsan_arch}
7c80ab
# compiler-rt (from LLVM)
7c80ab
%setup -q -T -b 100 -n llvm-%{tsan_commit}
7c80ab
%endif
7c80ab
# go
7c80ab
%setup -q -n go
7c80ab
%if %{with gccgo}
7c80ab
%if 0%{?gcc_go_version} == 6
7c80ab
%patch8 -p1
7c80ab
%endif
7c80ab
%if 0%{?gcc_go_version} == 7
7c80ab
%patch9 -p1
7c80ab
%endif
7c80ab
%endif
7c80ab
7c80ab
cp %{SOURCE4} .
7c80ab
7c80ab
%build
7c80ab
# Remove the pre-included .sysos, to avoid shipping things we didn't compile
7c80ab
# (which is against the openSUSE guidelines for packaging).
7c80ab
find . -type f -name '*.syso' -print -delete
7c80ab
7c80ab
# First, compile LLVM's TSAN, and replace the built-in with it. We can only do
7c80ab
# this for amd64.
7c80ab
%ifarch %{tsan_arch}
7c80ab
TSAN_DIR="../llvm-%{tsan_commit}/compiler-rt/lib/tsan/go"
7c80ab
pushd "$TSAN_DIR"
7c80ab
./buildgo.sh
7c80ab
popd
7c80ab
cp -v "$TSAN_DIR/race_linux_%{go_arch}.syso" src/runtime/race/
7c80ab
%endif
7c80ab
7c80ab
# Now, compile Go.
7c80ab
%if %{with gccgo}
7c80ab
export GOROOT_BOOTSTRAP=%{_prefix}
7c80ab
%else
7c80ab
export GOROOT_BOOTSTRAP=%{_libdir}/%{go_bootstrap_version}
7c80ab
%endif
7c80ab
# Ensure ARM arch is set properly - boo#1169832
7c80ab
%ifarch armv6l armv6hl
7c80ab
export GOARCH=arm
7c80ab
export GOARM=6
7c80ab
%endif
7c80ab
%ifarch armv7l armv7hl
7c80ab
export GOARCH=arm
7c80ab
export GOARM=7
7c80ab
%endif
7c80ab
export GOROOT="`pwd`"
7c80ab
export GOROOT_FINAL=%{_libdir}/go/%{go_api}
7c80ab
export GOBIN="$GOROOT/bin"
7c80ab
mkdir -p "$GOBIN"
7c80ab
cd src
7c80ab
HOST_EXTRA_CFLAGS="%{optflags} -Wno-error" ./make.bash -v
7c80ab
7c80ab
cd ../
7c80ab
%ifarch %{tsan_arch}
7c80ab
# Install TSAN-friendly version of the std libraries.
7c80ab
bin/go install -race std
7c80ab
%endif
7c80ab
7c80ab
%if %{with_shared}
7c80ab
bin/go install -buildmode=shared -linkshared std
7c80ab
%endif
7c80ab
7c80ab
%check
7c80ab
%ifarch %{tsan_arch}
7c80ab
# Make sure that we have the right TSAN checked out.
7c80ab
grep "^race_linux_%{go_arch}.syso built with LLVM %{tsan_commit}" src/runtime/race/README
7c80ab
%endif
7c80ab
7c80ab
%install
7c80ab
export GOROOT="%{buildroot}%{_libdir}/go/%{go_api}"
7c80ab
7c80ab
# locations for third party libraries, see README-openSUSE for info about locations.
7c80ab
install -d  %{buildroot}%{_datadir}/go/%{go_api}/contrib
7c80ab
install -d  $GOROOT/contrib/pkg/linux_%{go_arch}
7c80ab
ln -s %{_libdir}/go/%{go_api}/contrib/pkg/ %{buildroot}%{_datadir}/go/%{go_api}/contrib/pkg
7c80ab
install -d  %{buildroot}%{_datadir}/go/%{go_api}/contrib/cmd
7c80ab
install -d  %{buildroot}%{_datadir}/go/%{go_api}/contrib/src
7c80ab
ln -s %{_datadir}/go/%{go_api}/contrib/src/ %{buildroot}%{_libdir}/go/%{go_api}/contrib/src
7c80ab
install -Dm644 README.SUSE $GOROOT/contrib/
7c80ab
ln -s %{_libdir}/go/%{go_api}/contrib/README.SUSE %{buildroot}%{_datadir}/go/%{go_api}/contrib/README.SUSE
7c80ab
7c80ab
# source files for go install, godoc, etc
7c80ab
install -d %{buildroot}%{_datadir}/go/%{go_api}
7c80ab
for ext in *.{go,c,h,s,S,py,syso}; do
7c80ab
  find src -name ${ext} -exec install -Dm644 \{\} %{buildroot}%{_datadir}/go/%{go_api}/\{\} \;
7c80ab
done
7c80ab
# executable bash scripts called by go tool, etc
7c80ab
find src -name "*.bash" -exec install -Dm655 \{\} %{buildroot}%{_datadir}/go/%{go_api}/\{\} \;
7c80ab
7c80ab
mkdir -p $GOROOT/src
7c80ab
for i in $(ls %{buildroot}/usr/share/go/%{go_api}/src);do
7c80ab
  ln -s /usr/share/go/%{go_api}/src/$i $GOROOT/src/$i
7c80ab
done
7c80ab
# add lib files that are needed (such as the timezone database).
7c80ab
install -d $GOROOT/lib
7c80ab
find lib -type f -exec install -D -m644 {} $GOROOT/{} \;
7c80ab
7c80ab
# copy document templates, packages, obj libs and command utilities
7c80ab
mkdir -p $GOROOT/bin
7c80ab
# remove bootstrap
7c80ab
rm -rf pkg/bootstrap
7c80ab
mv pkg $GOROOT
7c80ab
mv bin/* $GOROOT/bin
7c80ab
mkdir -p $GOROOT/misc/trace
7c80ab
mv misc/trace/* $GOROOT/misc/trace
7c80ab
# add wasm (Web Assembly) boo#1139210
7c80ab
mkdir -p $GOROOT/misc/wasm
7c80ab
mv misc/wasm/* $GOROOT/misc/wasm
7c80ab
rm -f %{buildroot}%{_bindir}/{hgpatch,quietgcc}
7c80ab
7c80ab
# gdbinit
7c80ab
install -Dm644 %{SOURCE6} $GOROOT/bin/gdbinit.d/go.gdb
7c80ab
%if "%{_lib}" == "lib64"
7c80ab
sed -i "s/lib/lib64/" $GOROOT/bin/gdbinit.d/go.gdb
7c80ab
sed -i "s/\$go_api/%{go_api}/" $GOROOT/bin/gdbinit.d/go.gdb
7c80ab
%endif
7c80ab
7c80ab
# update-alternatives
7c80ab
 mkdir -p %{buildroot}%{_sysconfdir}/alternatives
7c80ab
 mkdir -p %{buildroot}%{_bindir}
7c80ab
 mkdir -p %{buildroot}%{_sysconfdir}/profile.d
7c80ab
 mkdir -p %{buildroot}%{_sysconfdir}/gdbinit.d
7c80ab
 touch %{buildroot}%{_sysconfdir}/alternatives/{go,gofmt,go.gdb}
7c80ab
 ln -sf %{_sysconfdir}/alternatives/go %{buildroot}%{_bindir}/go
7c80ab
 ln -sf %{_sysconfdir}/alternatives/gofmt %{buildroot}%{_bindir}/gofmt
7c80ab
 ln -sf %{_sysconfdir}/alternatives/go.gdb %{buildroot}%{_sysconfdir}/gdbinit.d/go.gdb
7c80ab
7c80ab
# documentation and examples
7c80ab
# fix documetation permissions (rpmlint warning)
7c80ab
find doc/ misc/ -type f -exec chmod 0644 '{}' +
7c80ab
# remove unwanted arch-dependant binaries (rpmlint warning)
7c80ab
rm -rf misc/cgo/test/{_*,*.o,*.out,*.6,*.8}
7c80ab
# prepare go-doc
7c80ab
mkdir -p %{buildroot}%{_docdir}/go/%{go_api}
7c80ab
cp -r AUTHORS CONTRIBUTORS CONTRIBUTING.md LICENSE PATENTS README.md README.SUSE %{buildroot}%{_docdir}/go/%{go_api}
7c80ab
cp -r doc/* %{buildroot}%{_docdir}/go/%{go_api}
7c80ab
7c80ab
%fdupes -s %{buildroot}%{_prefix}
7c80ab
7c80ab
%post
7c80ab
7c80ab
update-alternatives \
7c80ab
  --install %{_bindir}/go go %{_libdir}/go/%{go_api}/bin/go $((20+$(echo %{go_api} | cut -d. -f2))) \
7c80ab
  --slave %{_bindir}/gofmt gofmt %{_libdir}/go/%{go_api}/bin/gofmt \
7c80ab
  --slave %{_sysconfdir}/gdbinit.d/go.gdb go.gdb %{_libdir}/go/%{go_api}/bin/gdbinit.d/go.gdb
7c80ab
7c80ab
%postun
7c80ab
if [ $1 -eq 0 ] ; then
7c80ab
	update-alternatives --remove go %{_libdir}/go/%{go_api}/bin/go
7c80ab
fi
7c80ab
7c80ab
%files
7c80ab
%{_bindir}/go
7c80ab
%{_bindir}/gofmt
7c80ab
%dir %{_libdir}/go
7c80ab
%{_libdir}/go/%{go_api}
7c80ab
%dir %{_datadir}/go
7c80ab
%{_datadir}/go/%{go_api}
7c80ab
%dir %{_sysconfdir}/gdbinit.d/
7c80ab
%config %{_sysconfdir}/gdbinit.d/go.gdb
7c80ab
%ghost %{_sysconfdir}/alternatives/go
7c80ab
%ghost %{_sysconfdir}/alternatives/gofmt
7c80ab
%ghost %{_sysconfdir}/alternatives/go.gdb
7c80ab
%dir %{_docdir}/go
7c80ab
%dir %{_docdir}/go/%{go_api}
7c80ab
%doc %{_docdir}/go/%{go_api}/AUTHORS
7c80ab
%doc %{_docdir}/go/%{go_api}/CONTRIBUTORS
7c80ab
%doc %{_docdir}/go/%{go_api}/CONTRIBUTING.md
7c80ab
%doc %{_docdir}/go/%{go_api}/PATENTS
7c80ab
%doc %{_docdir}/go/%{go_api}/README.md
7c80ab
%doc %{_docdir}/go/%{go_api}/README.SUSE
7c80ab
%if 0%{?suse_version} < 1500
7c80ab
%doc %{_docdir}/go/%{go_api}/LICENSE
7c80ab
%else
7c80ab
%license %{_docdir}/go/%{go_api}/LICENSE
7c80ab
%endif
7c80ab
7c80ab
# We don't include TSAN in the main Go package.
7c80ab
%ifarch %{tsan_arch}
7c80ab
%exclude %{_datadir}/go/%{go_api}/src/runtime/race/race_linux_%{go_arch}.syso
7c80ab
%endif
7c80ab
7c80ab
%files doc
7c80ab
%defattr(-,root,root,-)
7c80ab
%doc %{_docdir}/go/%{go_api}/*.html
7c80ab
7c80ab
%ifarch %{tsan_arch}
7c80ab
%files race
7c80ab
%{_datadir}/go/%{go_api}/src/runtime/race/race_linux_%{go_arch}.syso
7c80ab
%endif
7c80ab
7c80ab
%changelog