osc copypac from project:devel:gcc:next package:gcc13 revision:214

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gcc13?expand=0&rev=1
This commit is contained in:
Richard Biener 2022-12-02 08:29:05 +00:00 committed by Git OBS Bridge
commit 51237497eb
58 changed files with 36362 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,31 @@
IMPORTANT: Please change gcc.spec.in and then run ./pre_checkin.sh!
Do not change gcc.spec directly!
Since GCC comes with a testsuite that runs for quite a long time and
that test suite also contains some known failures, we should run the
testsuite of GCC whenever the compiler is changed to ensure a high
quality compiler.
The package is now split into multiple parts, gcc$VER,
gcc$VER-testresults and libffi$VER (plus various spec files for
cross and icecream cross compilers). The testsuite is run from
gcc$VER-testresults, a dummy package with the testresults, gcc$VER-testresults,
is generated from it which contains testing logfiles and summary.
Before checking in a new compiler, please do the following steps as QA
measure to check that the new compiler does not introduce any new
failures:
- Run mbuild for all archs for at least the gcc$VER and the gcc$VER-testresults
subpackages
- When mbuild is finished, call
/suse/rguenther/bin/compare-testresults.sh mbuild-directory
(for the gcc$VER-testresults build).
The output of that script should not show any failures. If it does,
please fix them or discuss this with the gcc package maintainers.
- Do not remove this file.
Thanks,
Your GCC packagers.

26
_constraints Normal file
View File

@ -0,0 +1,26 @@
<constraints>
<hardware>
<disk>
<size unit="G">26</size>
</disk>
<physicalmemory>
<size unit="G">4</size>
</physicalmemory>
<processors>4</processors>
<jobs>4</jobs>
</hardware>
<overwrite>
<conditions>
<arch>x86_64</arch>
<arch>ppc64le</arch>
<arch>aarch64</arch>
</conditions>
<hardware>
<memory>
<size unit="G">8</size>
</memory>
<processors>8</processors>
<jobs>8</jobs>
</hardware>
</overwrite>
</constraints>

30
_multibuild Normal file
View File

@ -0,0 +1,30 @@
<multibuild>
<flavor>gcc13-testresults</flavor>
<flavor>cross-aarch64-gcc13-bootstrap</flavor>
<flavor>cross-aarch64-gcc13</flavor>
<flavor>cross-riscv64-gcc13-bootstrap</flavor>
<flavor>cross-riscv64-gcc13</flavor>
<flavor>cross-arm-gcc13</flavor>
<flavor>cross-avr-gcc13-bootstrap</flavor>
<flavor>cross-avr-gcc13</flavor>
<flavor>cross-x86_64-gcc13</flavor>
<flavor>cross-s390x-gcc13</flavor>
<flavor>cross-sparc-gcc13</flavor>
<flavor>cross-sparc64-gcc13</flavor>
<flavor>cross-ppc64-gcc13</flavor>
<flavor>cross-ppc64le-gcc13</flavor>
<flavor>cross-m68k-gcc13</flavor>
<flavor>cross-mips-gcc13</flavor>
<flavor>cross-hppa-gcc13-bootstrap</flavor>
<flavor>cross-hppa-gcc13</flavor>
<flavor>cross-arm-none-gcc13-bootstrap</flavor>
<flavor>cross-arm-none-gcc13</flavor>
<flavor>cross-epiphany-gcc13-bootstrap</flavor>
<flavor>cross-epiphany-gcc13</flavor>
<flavor>cross-riscv64-elf-gcc13-bootstrap</flavor>
<flavor>cross-riscv64-elf-gcc13</flavor>
<flavor>cross-rx-gcc13-bootstrap</flavor>
<flavor>cross-rx-gcc13</flavor>
<flavor>cross-nvptx-gcc13</flavor>
<flavor>cross-amdgcn-gcc13</flavor>
</multibuild>

133
change_spec Normal file
View File

@ -0,0 +1,133 @@
#!/bin/bash
do_crosses=1
do_optional_compiler_languages=0
rm -f gcc*-testresults.spec gcc*-testresults.changes gcc*.spec cross*.spec cross*.changes
# Default is to generate the normal gcc package
# unless a parameter is given. In case that it is '-*',
# that parameter will be used as suffix for the package name
# and as suffix for the install path (/opt/gccSUFFIX)
# In case that it is '[0-9]*', that parameter will be used
# as a suffix for a versioned package name.
if [ $# -lt 1 ]; then
echo No package suffix given
outfile=gcc.spec
else
case $1 in
[0-9]*)
base_ver=$1
outfile=gcc$1.spec
;;
*)
echo Invalid package suffix
exit 1
;;
esac
fi
: > $outfile
if test "$do_optional_compiler_languages" = "1"; then
echo '%define build_optional_compiler_languages 1' >> $outfile
fi
sed -e 's%@base_ver@%'$base_ver'%g' \
gcc.spec.in \
| sed -n -e '{
/^# PACKAGE-BEGIN/h
/^# PACKAGE-BEGIN/,/^# PACKAGE-END/H
/^# PACKAGE-BEGIN/,/^# PACKAGE-END/!p
/^# PACKAGE-END/{g
s/@variant@//g
p
g
s/@variant@/-32bit/g
p
g
s/@variant@/-64bit/g
p
}
}' >> $outfile
echo '%define building_testsuite 1' > gcc$base_ver-testresults.spec
echo '%define run_tests 1' >> gcc$base_ver-testresults.spec
sed -e '/^# GCC-TESTSUITE-DELETE-BEGIN/,/^# GCC-TESTSUITE-DELETE-END/d;s/-n gcc@base_ver@-testresults$//g;s/^Name:[[:space:]]*gcc@base_ver@/Name: gcc@base_ver@-testresults/g' \
gcc.spec.in \
| sed -e 's%@base_ver@%'$base_ver'%g' \
>> gcc$base_ver-testresults.spec
echo '<multibuild>' > _multibuild
echo '<flavor>'gcc$base_ver-testresults'</flavor>' >> _multibuild
add_cross() {
local pkgname="$1"; shift
local rpmtarget="$1"; shift
local triplet="$1"; shift
echo "%define pkgname $pkgname" > $pkgname.spec
echo "%define cross_arch $rpmtarget" >> $pkgname.spec
echo "%define gcc_target_arch $triplet" >> $pkgname.spec
echo "$@" >> $pkgname.spec
{ sed -n -e '1,/SRC-COMMON-BEGIN/p' cross.spec.in
sed -n -e '/SRC-COMMON-BEGIN/,/SRC-COMMON-END/p' $outfile
sed -n -e '/SRC-COMMON-END/,/BUILD-COMMON-BEGIN/p' cross.spec.in
sed -n -e '/BUILD-COMMON-BEGIN/,/BUILD-COMMON-END/p' $outfile
sed -n -e '/BUILD-COMMON-END/,$p' cross.spec.in; } |
sed -e "s#@base_ver@#$base_ver#" \
-e "s/^\(ExclusiveArch.*\) $rpmtarget[^ \r]*/\1 /" \
>> $pkgname.spec
echo '<flavor>'$pkgname'</flavor>' >> _multibuild
}
add_newlib_cross() {
add_cross $1-bootstrap $2 $3 "%define gcc_target_newlib 1
%define gcc_libc_bootstrap 1"
add_cross $1 $2 $3 "%define gcc_target_newlib 1"
}
add_glibc_cross() {
add_cross $1-bootstrap $2 $3 "%define gcc_libc_bootstrap 1"
add_cross $1 $2 $3 "%define gcc_target_glibc 1"
}
# We now support "proper" cross-compilers to suse targets via a
# cross-glibc package, enable that via for example
#
# add_cross cross-aarch64-gcc$base_ver aarch64 aarch64-suse-linux
#
# For now keep the old way of doing things
if test "$do_crosses" = 1 ; then
add_glibc_cross cross-aarch64-gcc$base_ver aarch64 aarch64-suse-linux
add_glibc_cross cross-riscv64-gcc$base_ver riscv64 riscv64-suse-linux
add_cross cross-arm-gcc$base_ver arm arm-suse-linux-gnueabi %define gcc_icecream 1
add_cross cross-avr-gcc$base_ver-bootstrap avr avr "%define gcc_libc_bootstrap 1"
add_cross cross-avr-gcc$base_ver avr avr
add_cross cross-x86_64-gcc$base_ver x86_64 x86_64-suse-linux %define gcc_icecream 1
add_cross cross-s390x-gcc$base_ver s390x s390x-suse-linux %define gcc_icecream 1
add_cross cross-sparc-gcc$base_ver sparcv9 sparc-suse-linux %define gcc_icecream 1
add_cross cross-sparc64-gcc$base_ver sparc64 sparc64-suse-linux %define gcc_icecream 1
add_cross cross-ppc64-gcc$base_ver ppc64 powerpc64-suse-linux %define gcc_icecream 1
add_cross cross-ppc64le-gcc$base_ver ppc64le powerpc64le-suse-linux %define gcc_icecream 1
add_cross cross-m68k-gcc$base_ver m68k m68k-suse-linux %define gcc_icecream 1
add_cross cross-mips-gcc$base_ver mips mips-suse-linux %define gcc_icecream 1
add_cross cross-hppa-gcc$base_ver-bootstrap hppa hppa-suse-linux %define gcc_libc_bootstrap 1
add_cross cross-hppa-gcc$base_ver hppa hppa-suse-linux %define gcc_icecream 1
add_newlib_cross cross-arm-none-gcc$base_ver arm-none arm-none-eabi
add_newlib_cross cross-epiphany-gcc$base_ver epiphany epiphany-elf
#add_newlib_cross cross-nds32le-gcc$base_ver nds32le nds32le-elf
add_newlib_cross cross-riscv64-elf-gcc$base_ver riscv64 riscv64-elf
#add_newlib_cross cross-rl78-gcc$base_ver rl78 rl78-elf
add_newlib_cross cross-rx-gcc$base_ver rx rx-elf
fi
# the nvptx and amdgcn crosses are used for offloading
add_cross cross-nvptx-gcc$base_ver nvptx nvptx-none %define gcc_accel 1
add_cross cross-amdgcn-gcc$base_ver amdgcn amdgcn-amdhsa %define gcc_accel 1
for f in *.spec; do
sed -i -e '/^# .*-\(BEGIN\|END\)$/d' $f
done
echo '</multibuild>' >> _multibuild
osc service localrun format_spec_file

38
check-build.sh Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# Copyright (c) 2003,2005 SUSE Linux Products GmbH, Germany. All rights reserved.
#
# Authors: Thorsten Kukuk <kukuk@suse.de>
#
# this script use the following variable(s):
#
# - $BUILD_BASENAME
#
case $BUILD_BASENAME in
*ppc*)
# Our biarch 32-bit compiler needs to be build on a 64-bit machine,
# otherwise some configure checks fail.
# Note that we cannot use uname here since powerpc32 was invoked
# already.
grep 'series64\|ppc64' /proc/version > /dev/null
if [ $? -ne 0 ] ; then
echo "build does not work on `hostname` for gcc"
exit 1
fi
;;
*x86_64*)
#if [ `ulimit -v` -le 740000 ] ; then
# echo "build does not work on ("`hostname`" for gcc)"
# exit 1
#fi
if [ `getconf _NPROCESSORS_CONF` -lt 2 ] ; then
echo "build does not work on `hostname` for gcc"
exit 1
fi
;;
*)
;;
esac
exit 0

View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-aarch64-gcc13-bootstrap
%define cross_arch aarch64
%define gcc_target_arch aarch64-suse-linux
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-aarch64-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-aarch64-gcc13
%define cross_arch aarch64
%define gcc_target_arch aarch64-suse-linux
%define gcc_target_glibc 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-amdgcn-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-amdgcn-gcc13
%define cross_arch amdgcn
%define gcc_target_arch amdgcn-amdhsa
%define gcc_accel 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-arm-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-arm-gcc13
%define cross_arch arm
%define gcc_target_arch arm-suse-linux-gnueabi
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,989 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-arm-none-gcc13-bootstrap
%define cross_arch arm-none
%define gcc_target_arch arm-none-eabi
%define gcc_target_newlib 1
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-arm-none-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-arm-none-gcc13
%define cross_arch arm-none
%define gcc_target_arch arm-none-eabi
%define gcc_target_newlib 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-avr-gcc13-bootstrap
%define cross_arch avr
%define gcc_target_arch avr
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-avr-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-avr-gcc13
%define cross_arch avr
%define gcc_target_arch avr
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,989 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-epiphany-gcc13-bootstrap
%define cross_arch epiphany
%define gcc_target_arch epiphany-elf
%define gcc_target_newlib 1
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-epiphany-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-epiphany-gcc13
%define cross_arch epiphany
%define gcc_target_arch epiphany-elf
%define gcc_target_newlib 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-hppa-gcc13-bootstrap
%define cross_arch hppa
%define gcc_target_arch hppa-suse-linux
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-hppa-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-hppa-gcc13
%define cross_arch hppa
%define gcc_target_arch hppa-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-m68k-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-m68k-gcc13
%define cross_arch m68k
%define gcc_target_arch m68k-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-mips-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-mips-gcc13
%define cross_arch mips
%define gcc_target_arch mips-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-nvptx-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-nvptx-gcc13
%define cross_arch nvptx
%define gcc_target_arch nvptx-none
%define gcc_accel 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-ppc64-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-ppc64-gcc13
%define cross_arch ppc64
%define gcc_target_arch powerpc64-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-ppc64le-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-ppc64le-gcc13
%define cross_arch ppc64le
%define gcc_target_arch powerpc64le-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,989 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-riscv64-elf-gcc13-bootstrap
%define cross_arch riscv64
%define gcc_target_arch riscv64-elf
%define gcc_target_newlib 1
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-riscv64-elf-gcc13
%define cross_arch riscv64
%define gcc_target_arch riscv64-elf
%define gcc_target_newlib 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-riscv64-gcc13-bootstrap
%define cross_arch riscv64
%define gcc_target_arch riscv64-suse-linux
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-riscv64-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-riscv64-gcc13
%define cross_arch riscv64
%define gcc_target_arch riscv64-suse-linux
%define gcc_target_glibc 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

View File

@ -0,0 +1,989 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-rx-gcc13-bootstrap
%define cross_arch rx
%define gcc_target_arch rx-elf
%define gcc_target_newlib 1
%define gcc_libc_bootstrap 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-rx-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-rx-gcc13
%define cross_arch rx
%define gcc_target_arch rx-elf
%define gcc_target_newlib 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-s390x-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-s390x-gcc13
%define cross_arch s390x
%define gcc_target_arch s390x-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-sparc-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-sparc-gcc13
%define cross_arch sparcv9
%define gcc_target_arch sparc-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-sparc64-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-sparc64-gcc13
%define cross_arch sparc64
%define gcc_target_arch sparc64-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

988
cross-x86_64-gcc13.spec Normal file
View File

@ -0,0 +1,988 @@
#
# spec file
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define pkgname cross-x86_64-gcc13
%define cross_arch x86_64
%define gcc_target_arch x86_64-suse-linux
%define gcc_icecream 1
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
Requires: nvptx-tools
ExclusiveArch:
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
Requires: lld
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch:
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc13
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc13
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun):update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc13-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc13-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib13-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib13-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib13-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib13-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} 13 \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc13-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib13-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog

499
cross.spec.in Normal file
View File

@ -0,0 +1,499 @@
# nospeccleaner
%define build_cp 0%{!?gcc_accel:1}
%if 0%{?gcc_libc_bootstrap:1}
%define build_cp 0
%endif
%define build_ada 0
%define build_libjava 0
%define build_java 0
%define build_fortran 0%{?gcc_accel:1}
%define build_objc 0
%define build_objcp 0
%define build_go 0
%define build_nvptx 0
%define build_gcn 0
%define build_d 0
%define enable_plugins 0
%define build_jit 0
%define use_lto_bootstrap 0
%define binutils_target %{cross_arch}
%if "%{cross_arch}" == "armv7l" || "%{cross_arch}" == "armv7hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv6l" || "%{cross_arch}" == "armv6hl"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "armv5tel"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "arm-none"
%define binutils_target arm
%endif
%if "%{cross_arch}" == "riscv64-elf"
%define binutils_target riscv64
%endif
%if "%{cross_arch}" == "sparcv9"
%define binutils_target sparc
%endif
%define canonical_target %(echo %{binutils_target} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%if "%{binutils_target}" == "avr" || "%{binutils_target}" == "spu" || "%{binutils_target}" == "pru"
%define binutils_os %{canonical_target}
%else
%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx"
%define binutils_os %{canonical_target}-elf
%else
%if "%{binutils_target}" == "arm"
%define binutils_os %{canonical_target}-suse-linux-gnueabi
%else
%if 0%{?gcc_accel:1}
%define binutils_os %{gcc_target_arch}
%else
%define binutils_os %{canonical_target}-suse-linux
%endif
%endif
%endif
%endif
%if 0%{?gcc_icecream:1}
%define sysroot %{_prefix}/%{gcc_target_arch}
%else
# offloading builds newlib in-tree and can install in
# the GCC private path without extra sysroot
%if 0%{!?gcc_accel:1}
# use same sysroot as in binutils.spec
%define sysroot %{_prefix}/%{binutils_os}/sys-root
%endif
%endif
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
Name: %{pkgname}
# SRC-COMMON-BEGIN
# SRC-COMMON-END
%if "%{cross_arch}" != "nvptx"
%if "%{cross_arch}" != "amdgcn"
BuildRequires: cross-%{binutils_target}-binutils
Requires: cross-%{binutils_target}-binutils
%endif
%endif
%define hostsuffix %{nil}
%if 0%{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%else
BuildRequires: gcc-c++
%endif
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
BuildRequires: zlib-devel
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{!?gcc_icecream:1}
%if 0%{!?gcc_libc_bootstrap:1}
%if 0%{?gcc_target_newlib:1}
BuildRequires: cross-%cross_arch-newlib-devel
%endif
%if "%{cross_arch}" == "avr"
BuildRequires: avr-libc
%endif
%if 0%{?gcc_target_glibc:1}
BuildRequires: cross-%cross_arch-glibc-devel
Requires: cross-%cross_arch-glibc-devel
%endif
%endif
%if "%{cross_arch}" == "nvptx"
BuildRequires: nvptx-tools
Requires: nvptx-tools
Requires: cross-nvptx-newlib-devel >= %{version}-%{release}
ExclusiveArch: x86_64
%define nvptx_newlib 1
%endif
%if "%{cross_arch}" == "amdgcn"
# amdgcn uses the llvm assembler and linker
%if %{suse_version} < 1550
BuildRequires: llvm13
%else
BuildRequires: llvm
%endif
BuildRequires: lld
%if %{suse_version} < 1550
Requires: llvm13
%else
Requires: llvm
%endif
Requires: lld
Requires: cross-amdgcn-newlib-devel >= %{version}-%{release}
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
ExclusiveArch: x86_64
%else
ExclusiveArch: do-not-build
%endif
%define amdgcn_newlib 1
%endif
%endif
%if 0%{?gcc_icecream:1}%{?gcc_target_glibc:1}%{?gcc_libc_bootstrap:1}
ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64
%if "%{cross_arch}" == "pru"
ExclusiveArch: %arm
%endif
%endif
%define _binary_payload w.ufdio
# Obsolete cross-ppc-gcc49 from cross-ppc64-gcc49 which has
# file conflicts with it and is no longer packaged
%if "%pkgname" == "cross-ppc64-gcc49"
Obsoletes: cross-ppc-gcc49 <= 4.9.0+r209354
%endif
%if 0%{?gcc_target_newlib:1}%{?gcc_target_glibc:1}
# Generally only one cross for the same target triplet can be installed
# at the same time as we are populating a non-version-specific sysroot
Provides: %{gcc_target_arch}-gcc
Conflicts: %selfconflict %{gcc_target_arch}-gcc
%endif
%if 0%{?gcc_libc_bootstrap:1}
# The -bootstrap packages file-conflict with the non-bootstrap variants.
# Even if we don't actually (want to) distribute the bootstrap variants
# the following avoids repo-checker spamming us endlessly.
Conflicts: cross-%{cross_arch}-gcc@base_ver@
%endif
#!BuildIgnore: gcc-PIE
%if 0%{build_cp:1}
# The cross compiler only packages the arch specific c++ headers, so
# we need to depend on the host libstdc++ devel headers (we wouldn't need
# the libs, though)
Requires: libstdc++6-devel-gcc@base_ver@
%endif
AutoReqProv: off
BuildRequires: update-alternatives
Requires(post): update-alternatives
Requires(preun): update-alternatives
Summary: The GNU Compiler Collection targeting %{cross_arch}
License: GPL-3.0-or-later
%description
The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}.
%if 0%{?gcc_icecream:1}
Note this is only useful for building freestanding things like the
kernel since it fails to include target libraries and headers.
%endif
%if 0%{?gcc_libc_bootstrap:1}
This is a package that is necessary for bootstrapping another package
only, it is not intended for any other use.
%endif
# BUILD-COMMON-BEGIN
# BUILD-COMMON-END
%if 0%{!?gcc_icecream:1}
make %{?make_output_sync} %{?_smp_mflags}
%else
make %{?make_output_sync} %{?_smp_mflags} all-host
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%package -n cross-%cross_arch-gcc@base_ver@-icecream-backend
Summary: Icecream backend for the GNU C Compiler
Group: Development/Languages/C and C++
%description -n cross-%cross_arch-gcc@base_ver@-icecream-backend
This package contains the icecream environment for the GNU C Compiler
%endif
%if 0%{?nvptx_newlib:1}
%package -n cross-nvptx-newlib@base_ver@-devel
Summary: Newlib for the nvptx offload target
Group: Development/Languages/C and C++
Provides: cross-nvptx-newlib-devel = %{version}-%{release}
Conflicts: cross-nvptx-newlib-devel
%description -n cross-nvptx-newlib@base_ver@-devel
Newlib development files for the nvptx offload target compiler.
%endif
%if 0%{?amdgcn_newlib:1}
%package -n cross-amdgcn-newlib@base_ver@-devel
Summary: Newlib for the amdgcn offload target
Group: Development/Languages/C and C++
Provides: cross-amdgcn-newlib-devel = %{version}-%{release}
Conflicts: cross-amdgcn-newlib-devel
%description -n cross-amdgcn-newlib@base_ver@-devel
Newlib development files for the amdgcn offload target compiler.
%endif
%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version}
%install
cd obj-%{GCCDIST}
%if "%{TARGET_ARCH}" == "amdgcn"
# libtool needs to be able to call ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
# install and fixup host parts
make DESTDIR=$RPM_BUILD_ROOT install-host
rm -rf $RPM_BUILD_ROOT/%{targetlibsubdir}/install-tools
rm -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.la
# common fixup
rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a
# install and fixup target parts
%if 0%{?gcc_icecream:1}
# so expect the sysroot to be populated from natively built binaries
%else
# We want shared libraries to reside in the sysroot but the .so symlinks
# on the host. Once we have a cross target that has shared libs we need
# to manually fix up things here like we do for non-cross compilers
mkdir -p $RPM_BUILD_ROOT/%{?sysroot:%sysroot}
make DESTDIR=$RPM_BUILD_ROOT install-target
%if %{build_cp}
# So we installed libstdc++ headers into %prefix where they conflict
# with other host compilers. Rip out the non-target specific parts
# again. Note not all cross targets support libstdc++, so create the
# directory to make things easier.
mkdir -p $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version}
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -mindepth 1 -maxdepth 1 -type d -a -not -name %{gcc_target_arch} | xargs -r rm -r
find $RPM_BUILD_ROOT/%_prefix/include/c++/%{gcc_dir_version} -maxdepth 1 -type f | xargs -r rm
# And also remove installed pretty printers which conflict in similar ways
rm -rf $RPM_BUILD_ROOT/%{_datadir}/gcc%{binsuffix}
%endif
%endif
%if 0%{?binutils_os:1}
for prog in as ld; do
ln -s /usr/%{binutils_os}/bin/$prog $RPM_BUILD_ROOT%{targetlibsubdir}/
done
%endif
# remove docs
rm -rf $RPM_BUILD_ROOT%{_mandir}
rm -rf $RPM_BUILD_ROOT%{_infodir}
# for accelerators remove all frontends but lto1 and also install-tools
%if 0%{?gcc_accel:1}
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1
rm -f $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/cc1plus
rm -rf $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch}/install-tools
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}/install-tools
# also move things from target directories into the accel path since
# that is the place where we later search for (only)
( cd $RPM_BUILD_ROOT%{targetlibsubdir} && tar cf - . ) | ( cd $RPM_BUILD_ROOT%{libsubdir}/accel/%{gcc_target_arch} && tar xf - )
rm -rf $RPM_BUILD_ROOT%{targetlibsubdir}
%endif
# for amdgcn install the symlinks to the llvm tools
# follow alternatives symlinks to the hardcoded version requirement
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin
ln -s `readlink -f /usr/bin/llvm-ar` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar
ln -s `readlink -f /usr/bin/llvm-mc` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as
ln -s /usr/bin/lld $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld
ln -s `readlink -f /usr/bin/llvm-nm` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm
ln -s `readlink -f /usr/bin/llvm-ranlib` $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ranlib
ln -s %{_prefix}/amdgcn-amdhsa/bin/ar $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ar
ln -s %{_prefix}/amdgcn-amdhsa/bin/as $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-as
ln -s %{_prefix}/amdgcn-amdhsa/bin/ld $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ld
ln -s %{_prefix}/amdgcn-amdhsa/bin/nm $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-nm
ln -s %{_prefix}/amdgcn-amdhsa/bin/ranlib $RPM_BUILD_ROOT%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
# Build an icecream environment
# The assembler comes from the cross-binutils, and hence is _not_
# named funnily, not even on ppc, so there we need the original target
install -s -D %{_prefix}/bin/%{binutils_os}-as \
$RPM_BUILD_ROOT/env/usr/bin/as
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/g++
install -s $RPM_BUILD_ROOT/%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} \
$RPM_BUILD_ROOT/env/usr/bin/gcc
for back in cc1 cc1plus; do
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/$back \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/$back
done
if test -f $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so; then
install -s -D $RPM_BUILD_ROOT/%{targetlibsubdir}/liblto_plugin.so \
$RPM_BUILD_ROOT/env%{targetlibsubdir}/liblto_plugin.so
fi
# Make sure to also pull in all shared library requirements for the
# binaries we put into the environment which is operated by chrooting
# into it and execing the compiler
libs=`for bin in $RPM_BUILD_ROOT/env/usr/bin/* $RPM_BUILD_ROOT/env%{targetlibsubdir}/*; do \
ldd $bin | sed -n '\,^[^/]*\(/[^ ]*\).*,{ s//\1/; p; }' ;\
done | sort -u `
for lib in $libs; do
# Check wether the same library also exists in the parent directory,
# and prefer that on the assumption that it is a more generic one.
baselib=`echo "$lib" | sed 's,/[^/]*\(/[^/]*\)$,\1,'`
test -f "$baselib" && lib=$baselib
install -s -D $lib $RPM_BUILD_ROOT/env$lib
done
cd $RPM_BUILD_ROOT/env
tar --no-recursion --mtime @${SOURCE_DATE_EPOCH:-$(date +%s)} --format=gnu -cv `find *|LC_ALL=C sort` |\
gzip -n9 > ../%{name}_%{_arch}.tar.gz
cd ..
mkdir -p usr/share/icecream-envs
mv %{name}_%{_arch}.tar.gz usr/share/icecream-envs
rpm -q --changelog glibc > usr/share/icecream-envs/%{name}_%{_arch}.glibc
rpm -q --changelog binutils > usr/share/icecream-envs/%{name}_%{_arch}.binutils
rm -r env
%endif
# we provide update-alternatives for selecting a compiler version for
# crosses
%if 0%{!?gcc_accel:1}
mkdir -p %{buildroot}%{_sysconfdir}/alternatives
for ex in gcc cpp \
%if %{build_cp}
c++ g++ \
%endif
gcc-ar gcc-nm gcc-ranlib lto-dump \
%if 0%{!?gcc_libc_bootstrap:1}
gcov gcov-dump gcov-tool \
%endif
; do
ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \
%{buildroot}%{_bindir}/%{gcc_target_arch}-$ex
done
%post
%{_sbindir}/update-alternatives \
--install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} @base_ver@ \
--slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \
%if %{build_cp}
--slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \
%endif
--slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-lto-dump %{gcc_target_arch}-lto-dump %{_bindir}/%{gcc_target_arch}-lto-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \
%if 0%{!?gcc_libc_bootstrap:1}
--slave %{_bindir}/%{gcc_target_arch}-gcov %{gcc_target_arch}-gcov %{_bindir}/%{gcc_target_arch}-gcov%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-dump %{gcc_target_arch}-gcov-dump %{_bindir}/%{gcc_target_arch}-gcov-dump%{binsuffix} \
--slave %{_bindir}/%{gcc_target_arch}-gcov-tool %{gcc_target_arch}-gcov-tool %{_bindir}/%{gcc_target_arch}-gcov-tool%{binsuffix} \
%endif
%postun
if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then
%{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix}
fi
%endif
%files
%defattr(-,root,root)
%if 0%{?gcc_accel:1}
%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-*
%dir %{libsubdir}
%dir %{libsubdir}/accel
%{libsubdir}/accel/%{gcc_target_arch}
%else
%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-lto-dump%{binsuffix}
%if 0%{!?gcc_libc_bootstrap:1}
%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-gcov
%{_prefix}/bin/%{gcc_target_arch}-gcov-dump
%{_prefix}/bin/%{gcc_target_arch}-gcov-tool
%endif
%{_prefix}/bin/%{gcc_target_arch}-gcc
%{_prefix}/bin/%{gcc_target_arch}-cpp
%{_prefix}/bin/%{gcc_target_arch}-gcc-ar
%{_prefix}/bin/%{gcc_target_arch}-gcc-nm
%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib
%{_prefix}/bin/%{gcc_target_arch}-lto-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-cpp
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ar
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-nm
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcc-ranlib
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-lto-dump
%if 0%{!?gcc_libc_bootstrap:1}
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool
%endif
%if %{build_cp}
%{_prefix}/bin/%{gcc_target_arch}-c++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-g++%{binsuffix}
%{_prefix}/bin/%{gcc_target_arch}-c++
%{_prefix}/bin/%{gcc_target_arch}-g++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-c++
%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-g++
%if 0%{!?gcc_libc_bootstrap:1}
%if "%{cross_arch}" == "avr" || 0%{?gcc_target_newlib:1} || 0%{?gcc_target_glibc:1}
%{_prefix}/include/c++
%endif
%endif
%endif
%dir %{targetlibsubdir}
%dir %{_libdir}/gcc/%{gcc_target_arch}
%{targetlibsubdir}
%endif
%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} && 0%{?sysroot:1}
%{sysroot}
%endif
%if 0%{?gcc_icecream:%gcc_icecream}
%files -n cross-%cross_arch-gcc@base_ver@-icecream-backend
%defattr(-,root,root)
/usr/share/icecream-envs
%endif
%if 0%{?nvptx_newlib:1}
%files -n cross-nvptx-newlib@base_ver@-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%endif
%if 0%{?amdgcn_newlib:1}
%files -n cross-amdgcn-newlib@base_ver@-devel
%defattr(-,root,root)
%{_prefix}/%{gcc_target_arch}
%{_prefix}/bin/amdgcn-amdhsa-ar
%{_prefix}/bin/amdgcn-amdhsa-as
%{_prefix}/bin/amdgcn-amdhsa-ld
%{_prefix}/bin/amdgcn-amdhsa-nm
%{_prefix}/bin/amdgcn-amdhsa-ranlib
%endif
%changelog -n cross-%{pkgname}-gcc@base_ver@

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ba0d87466a51206a2bb2efe4e303572c6ab1d1ca6e0b7f9666773fd6a0794c69
size 84136016

51
gcc-add-defaultsspec.diff Normal file
View File

@ -0,0 +1,51 @@
Index: gcc/gcc.cc
===================================================================
--- gcc/gcc.cc.orig 2013-11-26 15:41:59.000000000 +0100
+++ gcc/gcc.cc 2013-11-26 16:40:35.780548125 +0100
@@ -258,6 +258,7 @@ static const char *replace_outfile_spec_
static const char *remove_outfile_spec_function (int, const char **);
static const char *version_compare_spec_function (int, const char **);
static const char *include_spec_function (int, const char **);
+static const char *include_noerr_spec_function (int, const char **);
static const char *find_file_spec_function (int, const char **);
static const char *find_plugindir_spec_function (int, const char **);
static const char *print_asm_header_spec_function (int, const char **);
@@ -1357,6 +1358,7 @@ static const struct spec_function static
{ "remove-outfile", remove_outfile_spec_function },
{ "version-compare", version_compare_spec_function },
{ "include", include_spec_function },
+ { "include_noerr", include_noerr_spec_function },
{ "find-file", find_file_spec_function },
{ "find-plugindir", find_plugindir_spec_function },
{ "print-asm-header", print_asm_header_spec_function },
@@ -6480,6 +6482,8 @@ main (int argc, char **argv)
if (access (specs_file, R_OK) == 0)
read_specs (specs_file, true, false);
+ do_self_spec ("%:include_noerr(defaults.spec)%(default_spec)");
+
/* Process any configure-time defaults specified for the command line
options, via OPTION_DEFAULT_SPECS. */
for (i = 0; i < ARRAY_SIZE (option_default_specs); i++)
@@ -8401,6 +8405,21 @@ get_random_number (void)
return ret ^ getpid ();
}
+static const char *
+include_noerr_spec_function (int argc, const char **argv)
+{
+ char *file;
+
+ if (argc != 1)
+ abort ();
+
+ file = find_a_file (&startfile_prefixes, argv[0], R_OK, 0);
+ if (file)
+ read_specs (file, FALSE, TRUE);
+
+ return NULL;
+}
+
/* %:compare-debug-dump-opt spec function. Save the last argument,
expected to be the last -fdump-final-insns option, or generate a
temporary. */

2860
gcc.spec.in Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
varasm.c: Always output flags in merged .section for LLVM assembler compatibility [PR97827]
For compatibility with LLVM 11's 'mc' assembler, the flags have to be
repeated every time. See also LLVM Bug 48201 for this issue and
https://reviews.llvm.org/D73999 for the patch causing the issue.
gcc/
PR target/97827
* varasm.c (default_elf_asm_named_section): Always output all
flags if SECTION_MERGE, even if already declared before.
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index 21be03aeba2..9cb46885aa5 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -6792,10 +6792,13 @@ default_elf_asm_named_section (const char *name, unsigned int flags,
/* If we have already declared this section, we can use an
abbreviated form to switch back to it -- unless this section is
part of a COMDAT groups or with SHF_GNU_RETAIN or with SHF_LINK_ORDER,
- in which case GAS requires the full declaration every time. */
+ in which case GAS requires the full declaration every time.
+ LLVM's MC linker requires that the
+ flags are identical, thus avoid the abbreviated form with MERGE. */
if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE))
&& !(flags & (SECTION_RETAIN | SECTION_LINK_ORDER))
- && (flags & SECTION_DECLARED))
+ && (flags & SECTION_DECLARED)
+ && !(flags & SECTION_MERGE))
{
fprintf (asm_out_file, "\t.section\t%s\n", name);
return;

View File

@ -0,0 +1,22 @@
diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 6d02a4a02..d77f66182 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -6413,9 +6413,17 @@ gcn_dwarf_register_span (rtx rtl)
return p;
}
+static void
+gcn_override_options_after_change (void)
+{
+ flag_reorder_blocks_and_partition = 0;
+}
+
/* }}} */
/* {{{ TARGET hook overrides. */
+#undef TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
+#define TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE gcn_override_options_after_change
#undef TARGET_ADDR_SPACE_ADDRESS_MODE
#define TARGET_ADDR_SPACE_ADDRESS_MODE gcn_addr_space_address_mode
#undef TARGET_ADDR_SPACE_DEBUG

View File

@ -0,0 +1,29 @@
diff --git a/gcc/defaults.h b/gcc/defaults.h
index 376687d91b1..613003eb14f 100644
--- a/gcc/defaults.h
+++ b/gcc/defaults.h
@@ -1444,7 +1444,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
/* When generating dwarf info, the default standard version we'll honor
and advertise in absence of -gdwarf-<N> on the command line. */
#ifndef DWARF_VERSION_DEFAULT
-#define DWARF_VERSION_DEFAULT 5
+#define DWARF_VERSION_DEFAULT 4
#endif
#ifndef USED_FOR_TARGET
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 09f7cf13eb6..dbc2cf5429a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10860,9 +10860,8 @@ possible.
@opindex gdwarf
Produce debugging information in DWARF format (if that is supported).
The value of @var{version} may be either 2, 3, 4 or 5; the default
-version for most targets is 5 (with the exception of VxWorks, TPF and
-Darwin/Mac OS X, which default to version 2, and AIX, which defaults
-to version 4).
+version for most targets is 4 (with the exception of VxWorks, TPF and
+Darwin/Mac OS X, which default to version 2).
Note that with DWARF Version 2, some ports require and always
use some non-conflicting DWARF 3 extensions in the unwind tables.

18
gcc13-rpmlintrc Normal file
View File

@ -0,0 +1,18 @@
# This line is mandatory to access the configuration functions
from Config import *
# gcc/gcc-c++ are devel packages even if not called -devel...
addFilter ("gcc.*devel-file-in-non-devel-package")
addFilter ("gcc.*devel-dependency glibc-devel")
addFilter ("gcc.*devel-dependency libstdc")
# libstdc++6-devel is the devel package of libstdc++6, no better name exists
# and we do package static libs and the .so links (but in a gcc versioned
# directory)
addFilter ("libstdc.*shlib-policy-missing-lib")
# We have names lib libgcc_s1-gcc7 for non-default GCCs
addFilter ("shlib-policy-name-error")
addFilter ("shlib-legacy-policy-name-error")
# Packages provide libgcc_s1 = $version and conflict with other providers
# of libgcc_s1
addFilter ("conflicts-with-provides")

View File

@ -0,0 +1,10 @@
# This line is mandatory to access the configuration functions
from Config import *
# Currently gotools.log contains $RPM_BUILD_ROOT and there's nothing
# to be done about that and neither do we care
addFilter ("gcc.*-testresults.*file-contains-buildroot")
# The package should _not_ be noarch, testresults differ from architecture
# to architecture
addFilter ("gcc.*-testresults.*no-binary")

948
gcc13-testresults.spec Normal file
View File

@ -0,0 +1,948 @@
#
# spec file for package gcc13-testresults
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%define building_testsuite 1
%define run_tests 1
#
# spec file for package gcc${version}
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
# nospeccleaner
%if !0%{?usrmerged}
%define _slibdir /%{_lib}
%define slibdir /lib
%define slibdir64 /lib64
%else
%define _slibdir %{_libdir}
%define slibdir %{_prefix}/lib
%define slibdir64 %{_prefix}/lib64
%endif
# Ada currently fails to build on a few platforms, enable it only
# on those that work
%if %{suse_version} >= 1310
%if %{suse_version} >= 1330
%define ada_arch %ix86 x86_64 ppc ppc64 ppc64le s390 s390x ia64 aarch64 riscv64
%else
%define ada_arch %ix86 x86_64 ppc ppc64 s390 ia64
%endif
%else
%define ada_arch %ix86 x86_64 ppc s390 ia64
%endif
%ifarch %ada_arch
%define build_ada 1
%else
%define build_ada 0
%endif
%define quadmath_arch %ix86 x86_64 ia64 ppc64le
%define tsan_arch x86_64 aarch64 ppc ppc64 ppc64le s390 s390x
%define asan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %sparc %arm aarch64 riscv64
%define hwasan_arch aarch64
%define itm_arch x86_64 %ix86 %arm aarch64 ppc ppc64 ppc64le riscv64 s390 s390x %sparc
%define atomic_arch x86_64 %ix86 %arm aarch64 ppc ppc64 ppc64le s390 s390x %sparc m68k ia64 riscv64
%define lsan_arch x86_64 aarch64 ppc ppc64 ppc64le s390 s390x
%define ubsan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %arm aarch64 riscv64
%if 0%{?build_libvtv:1}
%define vtv_arch x86_64 %ix86
%endif
%define build_cp 1
%define build_fortran 1
%define build_objc 1
%define build_objcp 1
%define build_go 1
%ifarch x86_64 %ix86 %arm aarch64 riscv64 s390x
%define build_d 1
%else
%define build_d 0
%endif
%if %{build_objcp}
%define build_cp 1
%define build_objc 1
%endif
# For optional compilers only build C, C++, Fortran, Ada and Go
%if 0%{?build_optional_compiler_languages:1}
%define build_objc 0
%define build_objcp 0
%define build_d 0
%endif
%ifarch x86_64
%define build_nvptx 1
%else
%define build_nvptx 0
%endif
%ifarch x86_64
# SLE12 does not fulfil build requirements for GCN, SLE15 SP1 does
# technically also SLE12 SP5 but do not bother there
%if %{suse_version} >= 1550 || 0%{?sle_version:%sle_version} >= 150100
%define build_gcn 1
%else
%define build_gcn 0
%endif
%else
%define build_gcn 0
%endif
%define use_lto_bootstrap 0
%ifarch x86_64 ppc64le s390x aarch64
%if %{suse_version} > 1500
%define use_lto_bootstrap 1
%endif
%endif
# Enable plugins just for Tumbleweed, not for SLES
%if 0%{!?sle_version:1}
%define enable_plugins 1
%define build_jit 1
%else
%define enable_plugins 0
%define build_jit 0
%endif
# FIXME: more once glibc 2.37 is released
%define glibc_version %(rpm -q glibc --qf '%%{VERSION}')
%define floatn_fixed_glibc %(case " %{glibc_version} " in (*9000*) echo 1;; (*) echo 0;; esac)
# Shared library SONAME versions
%ifarch hppa
%define libgcc_s 4
%else
%ifarch m68k
%define libgcc_s 2
%else
%define libgcc_s 1
%endif
%endif
%define libgomp_sover 1
%define libstdcxx_sover 6
%define libobjc_sover 4
%define libgfortran_sover 5
%define libquadmath_sover 0
%define libasan_sover 8
%define libtsan_sover 2
%define libhwasan_sover 0
%define libatomic_sover 1
%define libitm_sover 1
%define libubsan_sover 1
%define liblsan_sover 0
%define libvtv_sover 0
%define libgo_sover 21
%define libgphobos_sover 4
%define libgdruntime_sover 4
%define libgccjit_sover 0
# Shared library package suffix
# This is used for the "non-standard" set of libraries, the standard
# being defined by %%product_libs_gcc_ver, the GCC version that should
# provide un-suffixed shared library packages following the shared-library
# policy. Even suffixed variants should provide the shared-library policy
# mandated names and ensure they conflict with each other.
# Individual shared libraries can be directed to be built from individual
# gcc versions by defining %%product_libs_gcc_ver_libgcc_s1 for example,
# generally %%product_libs_gcc_ver_%%name%%sover, similarly.
%define itsme13 1
%define plv_ %{!?product_libs_gcc_ver:13}%{?product_libs_gcc_ver}
%define plv() %{expand:%%{!?itsme%{expand:%%{!?product_libs_gcc_ver_%{1}%{2}:%%{plv_}}%%{?product_libs_gcc_ver_%{1}%{2}}}:-gcc13}}
%define libgcc_s_suffix %{plv libgcc_s %{libgcc_s}}
%define libgomp_suffix %{plv libgomp %{libgomp_sover}}
%define libstdcxx_suffix %{plv libstdcxx %{libstdcxx_sover}}
%define libobjc_suffix %{plv libobjc %{libobjc_sover}}
%define libgfortran_suffix %{plv libgfortran %{libgfortran_sover}}
%define libquadmath_suffix %{plv libquadmath %{libquadmath_sover}}
%define libasan_suffix %{plv libasan %{libasan_sover}}
%define libtsan_suffix %{plv libtsan %{libtsan_sover}}
%define libhwasan_suffix %{plv libhwasan %{libhwasan_sover}}
%define libatomic_suffix %{plv libatomic %{libatomic_sover}}
%define libitm_suffix %{plv libitm %{libitm_sover}}
%define libubsan_suffix %{plv libubsan %{libubsan_sover}}
%define liblsan_suffix %{plv liblsan %{liblsan_sover}}
%define libvtv_suffix %{plv libvtv %{libvtv_sover}}
%define libgo_suffix %{plv libgo %{libgo_sover}}
%define libgphobos_suffix %{plv libgphobos %{libgphobos_sover}}
%define libgdruntime_suffix %{plv libgdruntime %{libgdruntime_sover}}
%define libgccjit_suffix %{plv libgccjit %{libgccjit_sover}}
# libFOO-devel package suffix
%define libdevel_suffix -gcc13
%if %{suse_version} >= 1220
%define selfconflict() %1
%else
%define selfconflict() otherproviders(%1)
%endif
%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64
URL: https://gcc.gnu.org/
Version: 13.0.0+git197173
Release: 0
%define gcc_dir_version %(echo %version | sed 's/+.*//' | cut -d '.' -f 1)
%define gcc_snapshot_revision %(echo %version | sed 's/[3-9]\.[0-9]\.[0-6]//' | sed 's/+/-/')
%define binsuffix -13
Name: gcc13-testresults
BuildRequires: xz
%if %{suse_version} > 1500
BuildRequires: libzstd-devel
%endif
# With generated files in src we could drop the following
BuildRequires: bison
BuildRequires: flex
BuildRequires: gettext-devel
%if %{suse_version} > 1220
BuildRequires: makeinfo
%else
BuildRequires: texinfo
%endif
# until here, but at least renaming and patching info files breaks this
BuildRequires: gcc-c++
BuildRequires: glibc-devel-32bit
BuildRequires: mpc-devel
BuildRequires: mpfr-devel
BuildRequires: perl
BuildRequires: zlib-devel
%if %{suse_version} >= 1500
# for SDT markers in the C++ unwinder and gdb breakpoints on exceptions
BuildRequires: systemtap-headers
%endif
%if %{suse_version} >= 1230
BuildRequires: isl-devel
%endif
%define hostsuffix %{nil}
%if %{build_ada}
%if 0%{?gcc_version:%{gcc_version}} > 13
%define hostsuffix %{binsuffix}
BuildRequires: gcc13-ada
BuildRequires: gcc13-c++
%else
%if %{suse_version} <= 1315
%define hostsuffix -7
BuildRequires: gcc7-ada
BuildRequires: gcc7-c++
%else
%define hostsuffix %{nil}
BuildRequires: gcc-ada
%endif
%endif
%endif
%if %{build_d}
%if %{suse_version} < 1550
BuildRequires: gcc11-d
BuildRequires: libstdc++6-devel-gcc11
%else
BuildRequires: gcc-d
%endif
%endif
# We now require a C++ 11 capable compiler for bootstrapping
%if %{suse_version} < 1220
%define hostsuffix -4.8
BuildRequires: gcc48-c++
%endif
%if 0%{?building_testsuite:1}
# For building the libstdc++ API reference
BuildRequires: doxygen
BuildRequires: graphviz
%endif
%ifarch ia64
BuildRequires: libunwind-devel
%endif
%if 0%{?run_tests:1}
BuildRequires: dejagnu
BuildRequires: expect
BuildRequires: gdb
%if %{build_go}
BuildRequires: netcfg
BuildRequires: procps
%endif
%if %{build_nvptx}
BuildRequires: cross-nvptx-gcc13
BuildRequires: cross-nvptx-newlib13-devel
%endif
%if %{build_gcn}
BuildRequires: cross-amdgcn-gcc13
BuildRequires: cross-amdgcn-newlib13-devel
%endif
%endif
#!BuildIgnore: gcc-PIE
%define separate_bi32 0
%define separate_bi64 0
%if 0%{!?disable_32bit:1}
%ifarch ppc sparcv9
%define separate_bi64 1
%endif
%ifarch x86_64 s390x ppc64 sparc64
%define separate_bi32 1
%endif
%define disable_multilib_arch %{nil}
%else
%define disable_multilib_arch ppc sparcv9 x86_64 s390x ppc64 sparc64
%endif
# Define two macros to trigger -32bit or -64bit package variants
%define separate_biarch 0
%if %{separate_bi32}
%define separate_biarch 1
%define separate_biarch_suffix -32bit
%endif
%if %{separate_bi64}
%define separate_biarch 1
%define separate_biarch_suffix -64bit
%endif
%ifarch aarch64 x86_64 ia64 s390x alpha ppc64 ppc64le sparc64
# 64-bit is primary build target
%define build_primary_64bit 1
%else
%define build_primary_64bit 0
%endif
%if !0%{?building_testsuite:1}
Requires: binutils
Requires: cpp13 = %{version}-%{release}
Requires: glibc-devel
Requires: libgcc_s%{libgcc_s} >= %{version}-%{release}
Requires: libgomp%{libgomp_sover} >= %{version}-%{release}
%ifarch %asan_arch
Requires: libasan%{libasan_sover} >= %{version}-%{release}
%endif
%ifarch %tsan_arch
%if %{build_primary_64bit}
Requires: libtsan%{libtsan_sover} >= %{version}-%{release}
%endif
%endif
%ifarch %hwasan_arch
Requires: libhwasan%{libhwasan_sover} >= %{version}-%{release}
%endif
%ifarch %atomic_arch
Requires: libatomic%{libatomic_sover} >= %{version}-%{release}
%endif
%ifarch %itm_arch
Requires: libitm%{libitm_sover} >= %{version}-%{release}
%endif
%ifarch %lsan_arch
%if %{build_primary_64bit}
Requires: liblsan%{liblsan_sover} >= %{version}-%{release}
%endif
%endif
%ifarch %ubsan_arch
Requires: libubsan%{libubsan_sover} >= %{version}-%{release}
%endif
%ifarch %vtv_arch
Requires: libvtv%{libvtv_sover} >= %{version}-%{release}
%endif
Suggests: gcc13-info gcc13-locale
%endif
%if %{suse_version} < 1310
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%endif
Group: Development/Languages/C and C++
Source: gcc-%{version}.tar.xz
Source1: change_spec
Source2: gcc13-rpmlintrc
Source3: gcc13-testresults-rpmlintrc
Source4: README.First-for.SuSE.packagers
Source5: newlib-4.2.0.20211231.tar.xz
Patch2: gcc-add-defaultsspec.diff
Patch5: tls-no-direct.diff
Patch6: gcc43-no-unwind-tables.diff
Patch7: gcc48-libstdc++-api-reference.patch
Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch
Patch15: gcc7-avoid-fixinc-error.diff
Patch16: gcc9-reproducible-builds.patch
Patch17: gcc9-reproducible-builds-buildid-for-checksum.patch
Patch18: gcc10-amdgcn-llvm-as.patch
Patch19: gcc11-gdwarf-4-default.patch
Patch20: gcc11-amdgcn-disable-hot-cold-partitioning.patch
# A set of patches from the RH srpm
Patch51: gcc41-ppc32-retaddr.patch
# Some patches taken from Debian
Patch60: gcc44-textdomain.patch
Patch61: gcc44-rename-info-files.patch
Summary: Testsuite results
License: SUSE-Public-Domain
Group: Development/Languages/C and C++
%description
Results from running the gcc and target library testsuites.
# Define the canonical target and host architecture
# %%gcc_target_arch is supposed to be the full target triple
# %%cross_arch is supposed to be the rpm target variant arch
# %%TARGET_ARCH will be the canonicalized target CPU part
# %%HOST_ARCH will be the canonicalized host CPU part
%if 0%{?gcc_target_arch:1}
%define TARGET_ARCH %(echo %{cross_arch} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%else
%define TARGET_ARCH %(echo %{_target_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%endif
%if 0%{?disable_32bit:1}
%define biarch 0
%else
%define biarch %(case " %{biarch_targets} " in (*" %{TARGET_ARCH} "*) echo 1;; (*) echo 0;; esac)
%endif
%define HOST_ARCH %(echo %{_host_cpu} | sed -e "s/i.86/i586/;s/ppc/powerpc/;s/sparc64.*/sparc64/;s/sparcv.*/sparc/;")
%ifarch ppc
%define GCCDIST powerpc64-suse-linux
%else
%ifarch %sparc
%define GCCDIST sparc64-suse-linux
%else
%ifarch %arm
%define GCCDIST %{HOST_ARCH}-suse-linux-gnueabi
%else
%define GCCDIST %{HOST_ARCH}-suse-linux
%endif
%endif
%endif
%define libsubdir %{_libdir}/gcc/%{GCCDIST}/%{gcc_dir_version}
%define gxxinclude %{_prefix}/include/c++/%{gcc_dir_version}
# Versionspecific directories
%define versmainlibdir %{libsubdir}
%define versmainlibdirbi32 %{libsubdir}/32
%define versmainlibdirbi64 %{libsubdir}/64
%ifarch ppc
%define versmainlibdirbi32 %{libsubdir}
%define versmainlibdirbi64 %{libsubdir}/64
%endif
%if %{build_primary_64bit}
%define versmainlibdirbi %{versmainlibdirbi32}
%else
%define versmainlibdirbi %{versmainlibdirbi64}
%endif
%define mainlibdir %{_libdir}
%define mainlibdirbi32 %{_prefix}/lib
%define mainlibdirbi64 %{_prefix}/lib64
%if %{build_primary_64bit}
%define mainlibdirbi %{mainlibdirbi32}
%else
%define mainlibdirbi %{mainlibdirbi64}
%endif
# Now define a few macros that make it easy to package libs and
# related files just to the right package, without caring for the
# exact path the files are in.
# %%mainlib package X from all dirs that belong to the main package
# %%biarchlib package X from all dirs that belong to the -32/64bit package
%define mainlib() %{mainlibdir}/%1\
%{nil}
%define biarchlib() %{nil}
%if %{biarch}
%if !%{separate_biarch}
%define mainlib() %{mainlibdir}/%1\
%{mainlibdirbi}/%1\
%{nil}
%else
%define biarchlib() %{mainlibdirbi}/%1\
%{nil}
%endif
%endif
%define versmainlib() %{versmainlibdir}/%1\
%{nil}
%define versbiarchlib() %{nil}
%if %{biarch}
%if !%{separate_biarch}
%define versmainlib() %{versmainlibdir}/%1\
%{versmainlibdirbi}/%1\
%{nil}
%else
%define versbiarchlib() %{versmainlibdirbi}/%1\
%{nil}
%endif
%endif
%if 0%{suse_version} >= 1500
# Synchronize output by lines, useful for configure output
%define make_output_sync -Oline
%endif
%prep
%if 0%{?nvptx_newlib:1}%{?amdgcn_newlib:1}
%setup -q -n gcc-%{version} -a 5
ln -s newlib-4.2.0.20211231/newlib .
%else
%setup -q -n gcc-%{version}
%endif
#test patching start
%patch2
%patch5
%patch6
%patch7
%patch11
%patch15
%patch16
%patch17 -p1
# These patches are needed only for llvm11
%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550
%patch18 -p1
%patch20 -p1
%endif
# In SLE15 and earlier default to dwarf4, not dwarf5
%if %{suse_version} < 1550
%patch19 -p1
%endif
%patch51
%patch60 -p1
%patch61
#test patching end
%build
%define _lto_cflags %{nil}
# Avoid rebuilding of generated files
contrib/gcc_update --touch
# SLE11 does not allow empty rpms
%if %{suse_version} < 1310
echo "This is a dummy package to provide a dependency." > README
%endif
rm -rf obj-%{GCCDIST}
mkdir obj-%{GCCDIST}
cd obj-%{GCCDIST}
RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE"
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'`
%ifarch %ix86
# -mcpu is superceded by -mtune but -mtune is not supported by
# our bootstrap compiler. -mcpu gives a warning that stops
# the build process, so remove it for now. Also remove all other
# -march and -mtune flags. They are superseeded by proper
# default compiler settings now.
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'`
%endif
%ifarch s390 s390x
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'`
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'`
%endif
%if 0%{?gcc_target_arch:1}
# Kill all -march/tune/cpu because that screws building the target libs
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'`
%endif
# Replace 2 spaces by one finally
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'`
languages=c
%if %{build_cp}
languages=$languages,c++
%endif
%if %{build_objc}
languages=$languages,objc
%endif
%if %{build_fortran}
languages=$languages,fortran
%endif
%if %{build_objcp}
languages=$languages,obj-c++
%endif
%if %{build_ada}
languages=$languages,ada
%endif
%if %{build_go}
languages=$languages,go
%endif
%if %{build_d}
languages=$languages,d
%endif
%if %{build_jit}
languages=$languages,jit
%endif
# In general we want to ship release checking enabled compilers
# which is the default for released compilers
#ENABLE_CHECKING="--enable-checking=yes"
ENABLE_CHECKING="--enable-checking=release"
#ENABLE_CHECKING=""
# Work around tail/head -1 changes
export _POSIX2_VERSION=199209
%if "%{TARGET_ARCH}" == "amdgcn"
mkdir -p target-tools/bin
ln -s /usr/bin/llvm-ar target-tools/bin/amdgcn-amdhsa-ar
ln -s /usr/bin/llvm-mc target-tools/bin/amdgcn-amdhsa-as
ln -s /usr/bin/lld target-tools/bin/amdgcn-amdhsa-ld
ln -s /usr/bin/llvm-nm target-tools/bin/amdgcn-amdhsa-nm
ln -s /usr/bin/llvm-ranlib target-tools/bin/amdgcn-amdhsa-ranlib
export PATH="`pwd`/target-tools/bin:$PATH"
%endif
%if "%{hostsuffix}" != ""
mkdir -p host-tools/bin
# Using the host gnatmake like
# CC="gcc%%{hostsuffix}" GNATBIND="gnatbind%%{hostsuffix}"
# GNATMAKE="gnatmake%%{hostsuffix}"
# doesn't work due to PR33857, so an un-suffixed gnatmake has to be
# available
%if %{build_ada}
cp -a /usr/bin/gnatmake%{hostsuffix} host-tools/bin/gnatmake
cp -a /usr/bin/gnatlink%{hostsuffix} host-tools/bin/gnatlink
cp -a /usr/bin/gnatbind%{hostsuffix} host-tools/bin/gnatbind
%endif
cp -a /usr/bin/gcc%{hostsuffix} host-tools/bin/gcc
cp -a /usr/bin/g++%{hostsuffix} host-tools/bin/g++
ln -sf /usr/%{_lib} host-tools/%{_lib}
export PATH="`pwd`/host-tools/bin:$PATH"
%endif
%if %{build_d} && %{suse_version} < 1550
# We are using gcc11-d to bootstrap d
export GDC=gdc-11
%endif
# libsanitizer needs <crypt.h> and since the glibc/libxcrypt split
# we don't have that yet in a pure cross environment
%if 0%{?gcc_target_arch:1}
CONFARGS="$CONFARGS --disable-libsanitizer"
%endif
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \
TCFLAGS="$RPM_OPT_FLAGS" \
../configure \
--prefix=%{_prefix} \
--infodir=%{_infodir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--libexecdir=%{_libdir} \
--enable-languages=$languages \
%if %{build_nvptx} || %{build_gcn}
--enable-offload-targets=\
%if %{build_nvptx}
nvptx-none,\
%endif
%if %{build_gcn}
amdgcn-amdhsa,\
%endif
--enable-offload-defaulted \
%endif
%if %{build_nvptx}
--without-cuda-driver \
%endif
%if %{build_jit}
--enable-host-shared \
%endif
$ENABLE_CHECKING \
--disable-werror \
--with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \
--enable-ssp \
--disable-libssp \
%if 0%{!?build_libvtv:1}
--disable-libvtv \
%endif
%if 0%{suse_version} >= 1500
--enable-cet=auto \
%else
--disable-cet \
%endif
--disable-libcc1 \
%if %{enable_plugins}
--enable-plugin \
%else
--disable-plugin \
%endif
--with-bugurl="https://bugs.opensuse.org/" \
--with-pkgversion="SUSE Linux" \
%if 0%{?sysroot:1}
--with-slibdir=%{sysroot}/%{_lib} \
%else
--with-slibdir=/%{_lib} \
%endif
--with-system-zlib \
--enable-libstdcxx-allocator=new \
--disable-libstdcxx-pch \
%if 0%{suse_version} <= 1320
--with-default-libstdcxx-abi=gcc4-compatible \
%endif
%if %{build_d}
--enable-libphobos \
%endif
--enable-version-specific-runtime-libs \
--with-gcc-major-version-only \
%if 0%{!?gcc_target_arch:1}
--enable-linker-build-id \
%else
%if 0%{?gcc_target_glibc:1}
--enable-linker-build-id \
%endif
%endif
--enable-linux-futex \
%if %{suse_version} >= 1315
%ifarch %ix86 x86_64 ppc ppc64 ppc64le %arm aarch64 s390 s390x %sparc
--enable-gnu-indirect-function \
%endif
%endif
--program-suffix=%{binsuffix} \
%ifarch %{disable_multilib_arch}
--disable-multilib \
%endif
%if 0%{!?gcc_target_arch:1}
%ifarch ia64
--with-system-libunwind \
%else
--without-system-libunwind \
%endif
%endif
%if 0%{?gcc_target_arch:1}
--program-prefix=%{gcc_target_arch}- \
--target=%{gcc_target_arch} \
--disable-nls \
%if 0%{?sysroot:1}
--with-sysroot=%sysroot \
%endif
%if 0%{?build_sysroot:1}
--with-build-sysroot=%{build_sysroot} \
%else
%if 0%{?sysroot:1}
--with-build-sysroot=%{sysroot} \
%endif
%endif
%if 0%{?binutils_os:1}
--with-build-time-tools=/usr/%{binutils_os}/bin \
%endif
%if 0%{?gcc_target_newlib}
--with-newlib \
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov \
%endif
%else
%if 0%{?gcc_libc_bootstrap:1}
--disable-gcov --disable-threads --disable-shared \
--disable-libmudflap --disable-libssp --disable-libgomp \
--disable-libquadmath --disable-libatomic \
--without-headers --with-newlib \
%endif
%endif
%if "%{TARGET_ARCH}" == "spu"
--with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \
--with-newlib \
%endif
%if "%{TARGET_ARCH}" == "nvptx"
--enable-as-accelerator-for=%{GCCDIST} \
--disable-sjlj-exceptions \
--enable-newlib-io-long-long \
%endif
%if "%{TARGET_ARCH}" == "amdgcn"
--enable-as-accelerator-for=%{GCCDIST} \
--enable-libgomp \
%endif
%if "%{TARGET_ARCH}" == "avr"
--enable-lto \
--without-gxx-include-dir \
--with-native-system-header-dir=/include \
%endif
%endif
%if "%{TARGET_ARCH}" == "arm-none"
--enable-multilib \
--with-multilib-list=aprofile,rmprofile \
--disable-decimal-float \
--disable-libffi \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath \
--disable-shared \
--disable-threads \
--disable-tls \
%endif
%if "%{TARGET_ARCH}" == "armv6hl" || "%{TARGET_ARCH}" == "arm"
--with-cpu=arm1176jzf-s \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv2 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "armv7hl"
--with-cpu=generic-armv7-a \
--with-float=hard \
--with-abi=aapcs-linux \
--with-fpu=vfpv3-d16 \
--disable-sjlj-exceptions \
%endif
%if "%{TARGET_ARCH}" == "aarch64"
--enable-fix-cortex-a53-835769 \
--enable-fix-cortex-a53-843419 \
%endif
%if "%{TARGET_ARCH}" == "powerpc64le"
%if %{suse_version} >= 1350
--with-cpu=power8 \
--with-tune=power9 \
%else
%if %{suse_version} >= 1315 && %{suse_version} != 1320
--with-cpu=power8 \
--with-tune=power8 \
%else
--with-cpu=power7 \
--with-tune=power7 \
%endif
%endif
%if %{suse_version} > 1500
--with-long-double-format=ieee \
%else
--with-long-double-format=ibm \
%endif
--enable-secureplt \
--with-long-double-128 \
--enable-targets=powerpcle-linux \
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64"
%if "%{TARGET_ARCH}" == "powerpc"
--with-cpu=default32 \
%endif
--with-cpu-64=power4 \
--enable-secureplt \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc64"
--with-cpu=ultrasparc \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "sparc"
--with-cpu=v8 \
--with-long-double-128 \
%endif
%if "%{TARGET_ARCH}" == "i586"
%if 0%{?sle_version:%sle_version} >= 150000
--with-arch-32=x86-64 \
%else
--with-arch-32=i586 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "x86_64"
%ifnarch %{disable_multilib_arch}
--enable-multilib \
--with-arch-32=x86-64 \
%endif
--with-tune=generic \
%endif
%if "%{TARGET_ARCH}" == "s390"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "s390x"
%if %{suse_version} >= 1310
--with-tune=zEC12 --with-arch=z196 \
%else
--with-tune=z9-109 --with-arch=z900 \
%endif
--with-long-double-128 \
--enable-decimal-float \
%endif
%if "%{TARGET_ARCH}" == "m68k"
--disable-multilib \
%endif
%if "%{TARGET_ARCH}" == "riscv64"
--disable-multilib \
%endif
%if %{use_lto_bootstrap} && !0%{?building_testsuite:1}
--with-build-config=bootstrap-lto-lean \
--enable-link-mutex \
%endif
%ifarch riscv64
--enable-link-mutex \
%endif
$CONFARGS \
--build=%{GCCDIST} \
--host=%{GCCDIST} || \
{
rc=$?;
echo "------- BEGIN config.log ------";
%{__cat} config.log;
echo "------- END config.log ------";
exit $rc;
}
STAGE1_FLAGS="-g -O2"
%if 0%{?do_profiling} && !0%{?building_testsuite:1}
%ifarch x86_64 %ix86 ppc64le s390x aarch64
%define use_pgo_bootstrap 1
%endif
%endif
%{?use_pgo_bootstrap:setarch `arch` -R} make %{?make_output_sync} %{?use_pgo_bootstrap:profiledbootstrap} STAGE1_CFLAGS="$STAGE1_FLAGS" BOOT_CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags}
make info
%if 0%{?run_tests:1}
echo "Run testsuite"
(make -C %{GCCDIST}/libstdc++-v3 check-abi || true)
mv %{GCCDIST}/libstdc++-v3/testsuite/libstdc++.log %{GCCDIST}/libstdc++-v3/testsuite/libstdc++-abi.log
mv %{GCCDIST}/libstdc++-v3/testsuite/libstdc++.sum %{GCCDIST}/libstdc++-v3/testsuite/libstdc++-abi.sum
# asan needs a whole shadow address space
ulimit -v unlimited || true
make -k check %{?_smp_mflags} || true
mkdir ../testresults
../contrib/test_summary | tee ../testresults/test_summary.txt
%endif
%install
# Make sure libtool re-linking libasan at install time doesn't drop the
# libstdc++ reference to make asan of C++ modules in python work
export SUSE_ASNEEDED=0
export NO_BRP_CHECK_BYTECODE_VERSION=true
cd obj-%{GCCDIST}
%if 0%{?run_tests:1}
cp `find . -name "*.sum"` ../testresults/
cp `find . -name "*.log" \! -name "config.log" | grep -v 'acats.\?/tests' | grep -v libbacktrace` ../testresults/
chmod 644 ../testresults/*
%endif
%if 0%{?run_tests:1}
%files
%defattr(-,root,root)
%doc testresults/test_summary.txt
%doc testresults/*.sum
%doc testresults/*.log
%endif
%changelog

122
gcc13.changes Normal file
View File

@ -0,0 +1,122 @@
-------------------------------------------------------------------
Thu Dec 1 22:09:49 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to de144fdab17dbbb64ccb540056ab78b4ffb3fbbc, git197173.
-------------------------------------------------------------------
Thu Dec 1 13:59:05 UTC 2022 - Martin Liška <mliska@suse.cz>
- Depend on at least LLVM 13 for GCN cross compiler.
-------------------------------------------------------------------
Thu Dec 1 05:34:47 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to 4304e09a1617bcf1c87f5bc96017ae5017379d75, git197155.
-------------------------------------------------------------------
Thu Dec 1 05:33:14 UTC 2022 - Martin Liška <mliska@suse.cz>
- Rebase gcc44-rename-info-files.patch.
-------------------------------------------------------------------
Wed Nov 30 22:09:37 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to d13c359a49291f0a1206adbad4065677010b7e4b, git197143.
-------------------------------------------------------------------
Tue Nov 29 07:06:11 UTC 2022 - Richard Biener <rguenther@suse.com>
- Sync changes from gcc12 package
- Update embedded newlib to version 4.2.0
* includes newlib-4.1.0-aligned_alloc.patch
- Allow cross-pru-gcc12-bootstrap for armv7l architecture.
PRU architecture is used for real-time MCUs embedded into TI
armv7l and aarch64 SoCs. We need to have cross-pru-gcc12 for
armv7l in order to build both host applications and PRU firmware
during the same build.
-------------------------------------------------------------------
Mon Nov 28 22:09:40 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to 2b0ae7fb91f64fb005abf7d7903fd4c0764bb45c, git197102.
-------------------------------------------------------------------
Tue Nov 22 07:14:27 UTC 2022 - Martin Liška <mliska@suse.cz>
- Handle new libstdc++exp.a lib.
-------------------------------------------------------------------
Mon Nov 21 22:09:43 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to 5c0d171f67d082c353ddc319859111d3b9126c17, git196938.
-------------------------------------------------------------------
Tue Nov 8 11:32:46 UTC 2022 - Martin Liška <mliska@suse.cz>
- Add 2 new headers.
-------------------------------------------------------------------
Mon Nov 7 23:58:33 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to b457b779427b0f7b3fbac447811c9c52db5bc79e, git196485.
-------------------------------------------------------------------
Tue Sep 27 15:32:26 UTC 2022 - Martin Liška <mliska@suse.cz>
- Revert --disable-fixincludes due to float128 needed fix.
-------------------------------------------------------------------
Tue Sep 27 15:14:40 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to 0b2706ac0e6d6b990d789325f9e081dfe4501f4f, git195623.
-------------------------------------------------------------------
Wed Aug 31 20:02:34 UTC 2022 - Martin Liška <mliska@suse.cz>
- Start using --disable-fixincludes.
-------------------------------------------------------------------
Wed Aug 31 20:04:10 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to be9dd80f9334800300a80268dbb92cf3fafcfcf8, git195041.
-------------------------------------------------------------------
Mon Aug 8 18:33:26 UTC 2022 - Martin Liška <mliska@suse.cz>
- Fix workaround for obs-service-format_spec_file.
- Bump version in gcc.spec.in.
-------------------------------------------------------------------
Fri Aug 5 21:07:30 UTC 2022 - Martin Liška <mliska@suse.cz>
- Bump to cc01a27db5411a4fe354a97b7c86703c5bc81243, git194700.
-------------------------------------------------------------------
Thu Apr 28 15:36:41 UTC 2022 - Martin Liška <mliska@suse.cz>
- New package, inherits from gcc12
- Take patches inherited from GCC 12.
* gcc-add-defaultsspec.diff, add the ability to provide a specs
file that is read by default
* tls-no-direct.diff, avoid direct %fs references on x86 to not
slow down Xen
* gcc43-no-unwind-tables.diff, do not produce unwind tables for
CRT files
* gcc41-ppc32-retaddr.patch, fix expansion of __builtin_return_addr
for ppc, just a testcase
* gcc44-textdomain.patch, make translation files version specific
and adjust textdomain to find them
* gcc44-rename-info-files.patch, fix cross-references in info files
when renaming them to be version specific
* gcc48-libstdc++-api-reference.patch, fix link in the installed
libstdc++ html documentation
* gcc48-remove-mpfr-2.4.0-requirement.patch, make GCC work with
earlier mpfr versions on old products
* gcc5-no-return-gcc43-workaround.patch, make build work with
host gcc 4.3
* gcc7-remove-Wexpansion-to-defined-from-Wextra.patch, removes
new warning from -Wextra
* gcc7-avoid-fixinc-error.diff
* gcc9-reproducible-builds-buildid-for-checksum.patch
* gcc9-reproducible-builds.patch
* gcc10-amdgcn-llvm-as.patch

3650
gcc13.spec Normal file

File diff suppressed because it is too large Load Diff

91
gcc41-ppc32-retaddr.patch Normal file
View File

@ -0,0 +1,91 @@
2005-11-28 Jakub Jelinek <jakub@redhat.com>
* config/rs6000/rs6000.c (rs6000_return_addr): If COUNT == 0,
read word RETURN_ADDRESS_OFFSET bytes above arg_pointer_rtx
instead of doing an extran indirection from frame_pointer_rtx.
* gcc.dg/20051128-1.c: New test.
#Index: gcc/config/rs6000/rs6000.cc
#===================================================================
#--- gcc/config/rs6000/rs6000.cc.orig 2013-11-26 15:42:33.000000000 +0100
#+++ gcc/config/rs6000/rs6000.cc 2013-11-26 16:44:14.566089231 +0100
#@@ -20878,18 +20878,22 @@ rs6000_return_addr (int count, rtx frame
if (count != 0
|| ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN) && flag_pic))
{
+ rtx x;
cfun->machine->ra_needs_full_frame = 1;
- return
- gen_rtx_MEM
- (Pmode,
- memory_address
- (Pmode,
- plus_constant (Pmode,
- copy_to_reg
- (gen_rtx_MEM (Pmode,
- memory_address (Pmode, frame))),
- RETURN_ADDRESS_OFFSET)));
+ if (count == 0)
+ {
+ gcc_assert (frame == frame_pointer_rtx);
+ x = arg_pointer_rtx;
+ }
+ else
+ {
+ x = memory_address (Pmode, frame);
+ x = copy_to_reg (gen_rtx_MEM (Pmode, x));
+ }
+
+ x = plus_constant (Pmode, x, RETURN_ADDRESS_OFFSET);
+ return gen_rtx_MEM (Pmode, memory_address (Pmode, x));
}
cfun->machine->ra_need_lr = 1;
Index: gcc/testsuite/gcc.dg/20051128-1.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gcc/testsuite/gcc.dg/20051128-1.c 2013-11-26 16:44:14.566089231 +0100
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fpic" } */
+
+extern void exit (int);
+extern void abort (void);
+
+int b;
+
+struct A
+{
+ void *pad[147];
+ void *ra, *h;
+ long o;
+};
+
+void
+__attribute__((noinline))
+foo (struct A *a, void *x)
+{
+ __builtin_memset (a, 0, sizeof (a));
+ if (!b)
+ exit (0);
+}
+
+void
+__attribute__((noinline))
+bar (void)
+{
+ struct A a;
+
+ __builtin_unwind_init ();
+ foo (&a, __builtin_return_address (0));
+}
+
+int
+main (void)
+{
+ bar ();
+ abort ();
+ return 0;
+}

View File

@ -0,0 +1,13 @@
Index: libgcc/Makefile.in
===================================================================
--- libgcc/Makefile.in.orig 2015-12-14 11:33:03.225790694 +0100
+++ libgcc/Makefile.in 2015-12-17 15:09:45.415136693 +0100
@@ -301,7 +301,7 @@ CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
$(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
-fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
-fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
- $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY)
+ $(INHIBIT_LIBC_CFLAGS) $(USE_TM_CLONE_REGISTRY) -fno-unwind-tables -fno-asynchronous-unwind-tables
# Extra flags to use when compiling crt{begin,end}.o.
CRTSTUFF_T_CFLAGS =

View File

@ -0,0 +1,708 @@
#! /bin/sh -e
# DP: Allow transformations on info file names. Reference the
# DP: transformed info file names in the texinfo files.
dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
pdir="-d $3"
dir="$3/"
elif [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch)
patch $pdir -f --no-backup-if-mismatch -p0 < $0
;;
-unpatch)
patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
esac
exit 0
gcc/ChangeLog:
2004-02-17 Matthias Klose <doko@debian.org>
* Makefile.in: Allow transformations on info file names.
Define MAKEINFODEFS, macros to pass transformated info file
names to makeinfo.
* doc/cpp.texi: Use macros defined in MAKEINFODEFS for references.
* doc/cppinternals.texi: Likewise.
* doc/extend.texi: Likewise.
* doc/gcc.texi: Likewise.
* doc/gccint.texi: Likewise.
* doc/invoke.texi: Likewise.
* doc/libgcc.texi: Likewise.
* doc/makefile.texi: Likewise.
* doc/passes.texi: Likewise.
* doc/sourcebuild.texi: Likewise.
* doc/standards.texi: Likewise.
* doc/trouble.texi: Likewise.
gcc/fortran/ChangeLog:
* Make-lang.in: Allow transformations on info file names.
Pass macros of transformated info file defined in MAKEINFODEFS
names to makeinfo.
* gfortran.texi: Use macros defined in MAKEINFODEFS for references.
gcc/java/ChangeLog:
* Make-lang.in: Allow transformations on info file names.
Pass macros of transformated info file defined in MAKEINFODEFS
names to makeinfo.
* gcj.texi: Use macros defined in MAKEINFODEFS for references.
---
gcc/Makefile.in | 74 ++++++++++++++++++++++++++++++++++++----------
gcc/ada/gnat-style.texi | 2 -
gcc/ada/gnat_rm.texi | 2 -
gcc/ada/gnat_ugn.texi | 2 -
gcc/doc/cpp.texi | 2 -
gcc/doc/cppinternals.texi | 2 -
gcc/doc/extend.texi | 2 -
gcc/doc/gcc.texi | 8 ++--
gcc/doc/gccint.texi | 4 +-
gcc/doc/install.texi | 2 -
gcc/doc/invoke.texi | 10 +++---
gcc/doc/libgcc.texi | 2 -
gcc/doc/makefile.texi | 2 -
gcc/doc/passes.texi | 2 -
gcc/doc/standards.texi | 4 +-
gcc/fortran/Make-lang.in | 11 +++---
gcc/fortran/gfortran.texi | 2 -
gcc/java/Make-lang.in | 19 +++++++++--
gcc/java/gcj.texi | 20 ++++++------
libgomp/Makefile.am | 13 ++++----
libgomp/Makefile.in | 14 ++++----
libgomp/libgomp.texi | 2 -
22 files changed, 131 insertions(+), 70 deletions(-)
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in.orig
+++ gcc/Makefile.in
@@ -3306,8 +3306,29 @@ install-no-fixedincludes:
doc: $(BUILD_INFO) $(GENERATED_MANPAGES)
-INFOFILES = doc/cpp.info doc/gcc.info doc/gccint.info \
- doc/gccinstall.info doc/cppinternals.info
+INFO_CPP_NAME = $(shell echo cpp|sed '$(program_transform_name)')
+INFO_GCC_NAME = $(shell echo gcc|sed '$(program_transform_name)')
+INFO_GXX_NAME = $(shell echo g++|sed '$(program_transform_name)')
+INFO_GCCINT_NAME = $(shell echo gccint|sed '$(program_transform_name)')
+INFO_GCCINSTALL_NAME = $(shell echo gccinstall|sed '$(program_transform_name)')
+INFO_CPPINT_NAME = $(shell echo cppinternals|sed '$(program_transform_name)')
+
+INFO_FORTRAN_NAME = $(shell echo gfortran|sed '$(program_transform_name)')
+INFO_GCJ_NAME = $(shell echo gcj|sed '$(program_transform_name)')
+INFO_GDC_NAME = $(shell echo gdc|sed '$(program_transform_name)')
+
+INFOFILES = doc/$(INFO_CPP_NAME).info doc/$(INFO_GCC_NAME).info \
+ doc/$(INFO_GCCINT_NAME).info \
+ doc/$(INFO_GCCINSTALL_NAME).info doc/$(INFO_CPPINT_NAME).info
+
+MAKEINFODEFS = -D 'fncpp $(INFO_CPP_NAME)' -D 'fngcc $(INFO_GCC_NAME)' \
+ -D 'fngxx $(INFO_GXX_NAME)' \
+ -D 'fngccint $(INFO_GCCINT_NAME)' \
+ -D 'fngccinstall $(INFO_GCCINSTALL_NAME)' \
+ -D 'fncppint $(INFO_CPPINT_NAME)' \
+ -D 'fngfortran $(INFO_FORTRAN_NAME)' \
+ -D 'fngcj $(INFO_GCJ_NAME)' \
+ -D 'fngdc $(INFO_GDC_NAME)'
info: $(INFOFILES) lang.info @GENINSRC@ srcinfo lang.srcinfo
@@ -3363,21 +3384,41 @@ gcc-vers.texi: $(BASEVER) $(DEVPHASE)
# patterns. To use them, put each of the specific targets with its
# specific dependencies but no build commands.
-doc/cpp.info: $(TEXI_CPP_FILES)
-doc/gcc.info: $(TEXI_GCC_FILES)
-doc/gccint.info: $(TEXI_GCCINT_FILES)
-doc/cppinternals.info: $(TEXI_CPPINT_FILES)
-
+# Generic entry to handle info files, which are not renamed (currently Ada)
doc/%.info: %.texi
if [ x$(BUILD_INFO) = xinfo ]; then \
$(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
-I $(gcc_docdir)/include -o $@ $<; \
fi
+doc/$(INFO_CPP_NAME).info: $(TEXI_CPP_FILES)
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
+ -I $(gcc_docdir)/include -o $@ $<; \
+ fi
+
+doc/$(INFO_GCC_NAME).info: $(TEXI_GCC_FILES)
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
+ -I $(gcc_docdir)/include -o $@ $<; \
+ fi
+
+doc/$(INFO_GCCINT_NAME).info: $(TEXI_GCCINT_FILES)
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
+ -I $(gcc_docdir)/include -o $@ $<; \
+ fi
+
+doc/$(INFO_CPPINT_NAME).info: $(TEXI_CPPINT_FILES)
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
+ -I $(gcc_docdir)/include -o $@ $<; \
+ fi
+
# Duplicate entry to handle renaming of gccinstall.info
-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
+doc/$(INFO_GCCINSTALL_NAME).info: $(TEXI_GCCINSTALL_FILES)
if [ x$(BUILD_INFO) = xinfo ]; then \
- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
+ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
-I $(gcc_docdir)/include -o $@ $<; \
fi
@@ -3787,11 +3828,11 @@ install-driver: installdirs xgcc$(exeext
# $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir
# to do the install.
install-info:: doc installdirs \
- $(DESTDIR)$(infodir)/cpp.info \
- $(DESTDIR)$(infodir)/gcc.info \
- $(DESTDIR)$(infodir)/cppinternals.info \
- $(DESTDIR)$(infodir)/gccinstall.info \
- $(DESTDIR)$(infodir)/gccint.info \
+ $(DESTDIR)$(infodir)/$(INFO_CPP_NAME).info \
+ $(DESTDIR)$(infodir)/$(INFO_GCC_NAME).info \
+ $(DESTDIR)$(infodir)/$(INFO_CPPINT_NAME).info \
+ $(DESTDIR)$(infodir)/$(INFO_GCCINSTALL_NAME).info \
+ $(DESTDIR)$(infodir)/$(INFO_GCCINT_NAME).info \
lang.install-info
$(DESTDIR)$(infodir)/%.info: doc/%.info installdirs
@@ -4030,8 +4071,11 @@ uninstall: lang.uninstall
-rm -rf $(DESTDIR)$(bindir)/$(GCOV_INSTALL_NAME)$(exeext)
-rm -rf $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext)
-rm -rf $(DESTDIR)$(man1dir)/cpp$(man1ext)
- -rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
- -rm -f $(DESTDIR)$(infodir)/cppinternals.info* $(DESTDIR)$(infodir)/gccint.info*
+ -rm -f $(DESTDIR)$(infodir)/$(INFO_CPP_NAME).info*
+ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCC_NAME).info*
+ -rm -f $(DESTDIR)$(infodir)/$(INFO_CPPINT_NAME).info*
+ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINT_NAME).info*
+ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINSTALL_NAME).info*
for i in ar nm ranlib ; do \
install_name=`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ;\
target_install_name=$(target_noncanonical)-`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ; \
Index: gcc/ada/gnat-style.texi
===================================================================
--- gcc/ada/gnat-style.texi.orig
+++ gcc/ada/gnat-style.texi
@@ -12,7 +12,7 @@
@finalout
@dircategory GNU Ada Tools
@direntry
-* gnat-style: (gnat-style.info). gnat-style
+* gnat-style: (gnat-style-12.info). gnat-style
@end direntry
@c %**end of header
Index: gcc/ada/gnat_rm.texi
===================================================================
--- gcc/ada/gnat_rm.texi.orig
+++ gcc/ada/gnat_rm.texi
@@ -12,7 +12,7 @@
@finalout
@dircategory GNU Ada Tools
@direntry
-* gnat_rm: (gnat_rm.info). gnat_rm
+* GNAT Reference Manual: (gnat_rm-12). Reference Manual for GNU Ada tools.
@end direntry
@c %**end of header
Index: gcc/ada/gnat_ugn.texi
===================================================================
--- gcc/ada/gnat_ugn.texi.orig
+++ gcc/ada/gnat_ugn.texi
@@ -12,7 +12,7 @@
@finalout
@dircategory GNU Ada Tools
@direntry
-* gnat_ugn: (gnat_ugn.info). gnat_ugn
+* User's Guide: (gnat_ugn-12).
@end direntry
@c %**end of header
Index: gcc/d/Make-lang.in
===================================================================
--- gcc/d/Make-lang.in.orig
+++ gcc/d/Make-lang.in
@@ -240,10 +240,11 @@ D_TEXI_FILES = \
$(gcc_docdir)/include/gcc-common.texi \
gcc-vers.texi
-doc/gdc.info: $(D_TEXI_FILES)
+INFO_GDC_NAME = $(shell echo gdc|sed '$(program_transform_name)')
+doc/$(INFO_GDC_NAME).info: $(D_TEXI_FILES)
if test "x$(BUILD_INFO)" = xinfo; then \
- rm -f doc/gdc.info*; \
- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
+ rm -f doc/$(INFO_GDC_NAME).info*; \
+ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
-I $(gcc_docdir)/include -o $@ $<; \
else true; fi
@@ -273,11 +274,11 @@ gdc.pod: d/gdc.texi
d.all.cross: gdc-cross$(exeext)
d.start.encap: gdc$(exeext)
d.rest.encap:
-d.info: doc/gdc.info
+d.info: doc/$(INFO_GDC_NAME).info
d.dvi: doc/gdc.dvi
d.pdf: doc/gdc.pdf
d.html: $(build_htmldir)/gdc/index.html
-d.srcinfo: doc/gdc.info
+d.srcinfo: doc/$(INFO_GDC_NAME).info
-cp -p $^ $(srcdir)/doc
d.srcextra:
@@ -314,7 +315,7 @@ d.install-common: installdirs
d.install-plugin:
-d.install-info: $(DESTDIR)$(infodir)/gdc.info
+d.install-info: $(DESTDIR)$(infodir)/$(INFO_GDC_NAME).info
d.install-pdf: doc/gdc.pdf
@$(NORMAL_INSTALL)
@@ -364,7 +365,7 @@ d.uninstall:
-rm -rf $(DESTDIR)$(bindir)/$(D_INSTALL_NAME)$(exeext)
-rm -rf $(DESTDIR)$(man1dir)/$(D_INSTALL_NAME)$(man1ext)
-rm -rf $(DESTDIR)$(bindir)/$(D_TARGET_INSTALL_NAME)$(exeext)
- -rm -rf $(DESTDIR)$(infodir)/gdc.info*
+ -rm -rf $(DESTDIR)$(infodir)/$(INFO_GDC_NAME).info*
# Clean hooks.
Index: gcc/d/gdc.texi
===================================================================
--- gcc/d/gdc.texi.orig
+++ gcc/d/gdc.texi
@@ -36,7 +36,7 @@ man page gfdl(7).
@format
@dircategory Software development
@direntry
-* gdc: (gdc). A GCC-based compiler for the D language
+* @value{fngdc}: (@value{fngdc}). A GCC-based compiler for the D language
@end direntry
@end format
Index: gcc/doc/cpp.texi
===================================================================
--- gcc/doc/cpp.texi.orig
+++ gcc/doc/cpp.texi
@@ -50,7 +50,7 @@ This manual contains no Invariant Sectio
@ifinfo
@dircategory Software development
@direntry
-* Cpp: (cpp). The GNU C preprocessor.
+* @value{fncpp}: (@value{fncpp}). The GNU C preprocessor.
@end direntry
@end ifinfo
Index: gcc/doc/cppinternals.texi
===================================================================
--- gcc/doc/cppinternals.texi.orig
+++ gcc/doc/cppinternals.texi
@@ -7,7 +7,7 @@
@ifinfo
@dircategory Software development
@direntry
-* Cpplib: (cppinternals). Cpplib internals.
+* @value{fncppint}: (@value{fncppint}). Cpplib internals.
@end direntry
@end ifinfo
Index: gcc/doc/extend.texi
===================================================================
--- gcc/doc/extend.texi.orig
+++ gcc/doc/extend.texi
@@ -24506,7 +24506,7 @@ want to write code that checks whether t
test for the GNU compiler the same way as for C programs: check for a
predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
test specifically for GNU C++ (@pxref{Common Predefined Macros,,
-Predefined Macros,cpp,The GNU C Preprocessor}).
+Predefined Macros,@value{fncpp},The GNU C Preprocessor}).
@menu
* C++ Volatiles:: What constitutes an access to a volatile object.
Index: gcc/doc/gcc.texi
===================================================================
--- gcc/doc/gcc.texi.orig
+++ gcc/doc/gcc.texi
@@ -63,12 +63,12 @@ Texts being (a) (see below), and with th
@ifnottex
@dircategory Software development
@direntry
-* gcc: (gcc). The GNU Compiler Collection.
-* g++: (gcc). The GNU C++ compiler.
-* gcov: (gcc) Gcov. @command{gcov}---a test coverage program.
-* gcov-tool: (gcc) Gcov-tool. @command{gcov-tool}---an offline gcda profile processing program.
-* gcov-dump: (gcc) Gcov-dump. @command{gcov-dump}---an offline gcda and gcno profile dump tool.
-* lto-dump: (gcc) lto-dump. @command{lto-dump}---Tool for
+* @value{fngcc}: (@value{fngcc}). The GNU Compiler Collection.
+* @value{fngxx}: (@value{fngcc}). The GNU C++ compiler.
+* gcov: (@value{fngcc}) Gcov. @command{gcov}---a test coverage program.
+* gcov-tool: (@value{fngcc}) Gcov-tool. @command{gcov-tool}---an offline gcda profile processing program.
+* gcov-dump: (@value{fngcc}) Gcov-dump. @command{gcov-dump}---an offline gcda and gcno profile dump tool.
+* lto-dump: (@value{fngcc}) Lto-dump. @command{lto-dump}---Tool for
dumping LTO object files.
@end direntry
This file documents the use of the GNU compilers.
@@ -129,7 +129,7 @@ version @value{version-GCC}.
The internals of the GNU compilers, including how to port them to new
targets and some information about how to write front ends for new
languages, are documented in a separate manual. @xref{Top,,
-Introduction, gccint, GNU Compiler Collection (GCC) Internals}.
+Introduction, @value{fngccint}, GNU Compiler Collection (GCC) Internals}.
@menu
* G++ and GCC:: You can compile C or C++ programs.
Index: gcc/doc/gccint.texi
===================================================================
--- gcc/doc/gccint.texi.orig
+++ gcc/doc/gccint.texi
@@ -49,7 +49,7 @@ Texts being (a) (see below), and with th
@ifnottex
@dircategory Software development
@direntry
-* gccint: (gccint). Internals of the GNU Compiler Collection.
+* @value{fngccint}: (@value{fngccint}). Internals of the GNU Compiler Collection.
@end direntry
This file documents the internals of the GNU compilers.
@sp 1
@@ -81,7 +81,7 @@ write front ends for new languages. It
@value{VERSION_PACKAGE}
@end ifset
version @value{version-GCC}. The use of the GNU compilers is documented in a
-separate manual. @xref{Top,, Introduction, gcc, Using the GNU
+separate manual. @xref{Top,, Introduction, @value{fngcc}, Using the GNU
Compiler Collection (GCC)}.
This manual is mainly a reference manual rather than a tutorial. It
Index: gcc/doc/install.texi
===================================================================
--- gcc/doc/install.texi.orig
+++ gcc/doc/install.texi
@@ -89,7 +89,7 @@ Free Documentation License}''.
@end ifinfo
@dircategory Software development
@direntry
-* gccinstall: (gccinstall). Installing the GNU Compiler Collection.
+* @value{fngccinstall}: (@value{fngccinstall}). Installing the GNU Compiler Collection.
@end direntry
@c Part 3 Titlepage and Copyright
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi.orig
+++ gcc/doc/invoke.texi
@@ -16744,7 +16744,7 @@ One of the standard libraries bypassed b
@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
which GCC uses to overcome shortcomings of particular machines, or special
needs for some languages.
-(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
+(@xref{Interface,,Interfacing to GCC Output,@value{fngccint},GNU Compiler
Collection (GCC) Internals},
for more discussion of @file{libgcc.a}.)
In most cases, you need @file{libgcc.a} even when you want to avoid
@@ -16860,7 +16860,7 @@ or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
This ensures that you have no unresolved references to internal GCC
library subroutines.
(An example of such an internal subroutine is @code{__main}, used to ensure C++
-constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
+constructors are called; @pxref{Collect2,,@code{collect2}, @value{fngccint},
GNU Compiler Collection (GCC) Internals}.)
@item -nostdlib++
@@ -34229,7 +34229,7 @@ Note that you can also specify places to
@option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
take precedence over places specified using environment variables, which
in turn take precedence over those specified by the configuration of GCC@.
-@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
+@xref{Driver,, Controlling the Compilation Driver @file{gcc}, @value{fngccint},
GNU Compiler Collection (GCC) Internals}.
@table @env
@@ -34409,7 +34409,7 @@ the headers it contains change.
A precompiled header file is searched for when @code{#include} is
seen in the compilation. As it searches for the included file
-(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
+(@pxref{Search Path,,Search Path,@value{fncpp},The C Preprocessor}) the
compiler looks for a precompiled header in each directory just before it
looks for the include file in that directory. The name searched for is
the name specified in the @code{#include} with @samp{.gch} appended. If
Index: gcc/doc/libgcc.texi
===================================================================
--- gcc/doc/libgcc.texi.orig
+++ gcc/doc/libgcc.texi
@@ -24,7 +24,7 @@ that needs them.
GCC will also generate calls to C library routines, such as
@code{memcpy} and @code{memset}, in some cases. The set of routines
that GCC may possibly use is documented in @ref{Other
-Builtins,,,gcc, Using the GNU Compiler Collection (GCC)}.
+Builtins,,,@value{fngcc}, Using the GNU Compiler Collection (GCC)}.
These routines take arguments and return values of a specific machine
mode, not a specific C type. @xref{Machine Modes}, for an explanation
Index: gcc/fortran/Make-lang.in
===================================================================
--- gcc/fortran/Make-lang.in.orig
+++ gcc/fortran/Make-lang.in
@@ -116,7 +116,8 @@ fortran.tags: force
cd $(srcdir)/fortran; $(ETAGS) -o TAGS.sub *.cc *.h; \
$(ETAGS) --include TAGS.sub --include ../TAGS.sub
-fortran.info: doc/gfortran.info doc/gfc-internals.info
+INFO_FORTRAN_NAME = $(shell echo gfortran|sed '$(program_transform_name)')
+fortran.info: doc/$(INFO_FORTRAN_NAME).info
F95_DVIFILES = doc/gfortran.dvi
@@ -199,10 +200,10 @@ GFORTRAN_TEXI = \
$(srcdir)/doc/include/gcc-common.texi \
gcc-vers.texi
-doc/gfortran.info: $(GFORTRAN_TEXI)
+doc/$(INFO_FORTRAN_NAME).info: $(GFORTRAN_TEXI)
if [ x$(BUILD_INFO) = xinfo ]; then \
rm -f doc/gfortran.info-*; \
- $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
+ $(MAKEINFO) $(MAKEINFODEFS) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
-o $@ $<; \
else true; fi
@@ -267,7 +268,7 @@ fortran.install-common: install-finclude
fortran.install-plugin:
-fortran.install-info: $(DESTDIR)$(infodir)/gfortran.info
+fortran.install-info: $(DESTDIR)$(infodir)/$(INFO_FORTRAN_NAME).info
fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext)
@@ -285,7 +286,7 @@ fortran.uninstall:
rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \
rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
- rm -rf $(DESTDIR)$(infodir)/gfortran.info*
+ rm -rf $(DESTDIR)$(infodir)/$(INFO_FORTRAN_NAME).info*
#
# Clean hooks:
Index: gcc/fortran/gfortran.texi
===================================================================
--- gcc/fortran/gfortran.texi.orig
+++ gcc/fortran/gfortran.texi
@@ -101,7 +101,7 @@ Texts being (a) (see below), and with th
@ifinfo
@dircategory Software development
@direntry
-* gfortran: (gfortran). The GNU Fortran Compiler.
+* @value{fngfortran}: (@value{fngfortran}). The GNU Fortran Compiler.
@end direntry
This file documents the use and the internals of
the GNU Fortran compiler, (@command{gfortran}).
Index: libffi/Makefile.am
===================================================================
--- libffi/Makefile.am.orig
+++ libffi/Makefile.am
@@ -28,6 +28,8 @@ TEXINFO_TEX = ../gcc/doc/include/texin
# Defines info, dvi, pdf and html targets
MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include
info_TEXINFOS = doc/libffi.texi
+INFO_LIBFFI_NAME = $(shell echo libffi | sed '${program_transform_name}')
+INFO_DEPS = doc/$(INFO_LIBFFI_NAME).info
# AM_CONDITIONAL on configure option --generated-files-in-srcdir
if GENINSRC
@@ -45,14 +47,14 @@ endif
all-local: $(STAMP_GENINSRC)
-stamp-geninsrc: doc/libffi.info
- cp -p $(top_builddir)/doc/libffi.info $(srcdir)/doc/libffi.info
+stamp-geninsrc: doc/$(INFO_LIBFFI_NAME).info
+ cp -p $(top_builddir)/doc/$(INFO_LIBFFI_NAME).info $(srcdir)/doc/libffi.info
@touch $@
-doc/libffi.info: $(STAMP_BUILD_INFO)
+doc/$(INFO_LIBFFI_NAME).info: $(STAMP_BUILD_INFO)
stamp-build-info: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp)
- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)/doc -o doc/libffi.info $(srcdir)/doc/libffi.texi
+ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -D 'fnlibffi $(INFO_LIBFFI_NAME)' -I $(srcdir)/doc -o doc/$(INFO_LIBFFI_NAME).info $(srcdir)/doc/libffi.texi
@touch $@
CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO)
Index: libffi/Makefile.in
===================================================================
--- libffi/Makefile.in.orig
+++ libffi/Makefile.in
@@ -249,7 +249,8 @@ AM_V_texidevnull = $(am__v_texidevnull_@
am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@)
am__v_texidevnull_0 = > /dev/null
am__v_texidevnull_1 =
-INFO_DEPS = doc/libffi.info
+INFO_LIBFFI_NAME = $(shell echo libffi | sed '${program_transform_name}')
+INFO_DEPS = doc/$(INFO_LIBFFI_NAME).info
am__TEXINFO_TEX_DIR = $(srcdir)/../gcc/doc/include
DVIS = doc/libffi.dvi
PDFS = doc/libffi.pdf
@@ -473,6 +474,8 @@ TEXINFO_TEX = ../gcc/doc/include/texinfo
# Defines info, dvi, pdf and html targets
MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include
info_TEXINFOS = doc/libffi.texi
+INFO_LIBFFI_NAME = $(shell echo libffi | sed '${program_transform_name}')
+INFO_DEPS = doc/$(INFO_LIBFFI_NAME).info
@GENINSRC_FALSE@STAMP_GENINSRC =
# AM_CONDITIONAL on configure option --generated-files-in-srcdir
@@ -1906,14 +1909,15 @@ uninstall-am: uninstall-dvi-am uninstall
all-local: $(STAMP_GENINSRC)
-stamp-geninsrc: doc/libffi.info
- cp -p $(top_builddir)/doc/libffi.info $(srcdir)/doc/libffi.info
+$(srcdir)/doc/libffi.info: stamp-geninsrc
+stamp-geninsrc: doc/$(INFO_LIBFFI_NAME).info
+ cp -p $(top_builddir)/doc/$(INFO_LIBFFI_NAME).info $(srcdir)/doc/libffi.info
@touch $@
-doc/libffi.info: $(STAMP_BUILD_INFO)
+doc/$(INFO_LIBFFI_NAME).info: $(STAMP_BUILD_INFO)
stamp-build-info: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp)
- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)/doc -o doc/libffi.info $(srcdir)/doc/libffi.texi
+ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -D 'fnlibffi $(INFO_LIBFFI_NAME)' -I $(srcdir)/doc -o doc/$(INFO_LIBFFI_NAME).info $(srcdir)/doc/libffi.texi
@touch $@
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@libffi.map-sun : libffi.map $(top_srcdir)/../contrib/make_sunver.pl \
@LIBFFI_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBFFI_BUILD_VERSIONED_SHLIB_TRUE@ $(libffi_la_OBJECTS) $(libffi_la_LIBADD)
Index: libffi/doc/libffi.texi
===================================================================
--- libffi/doc/libffi.texi.orig
+++ libffi/doc/libffi.texi
@@ -43,7 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN
@dircategory Development
@direntry
-* libffi: (libffi). Portable foreign function interface library.
+* libffi: (@value{fnlibffi}). Portable foreign-function interface library.
@end direntry
@titlepage
Index: libgomp/Makefile.am
===================================================================
--- libgomp/Makefile.am.orig
+++ libgomp/Makefile.am
@@ -129,14 +129,17 @@ endif
all-local: $(STAMP_GENINSRC)
-stamp-geninsrc: libgomp.info
- cp -p $(top_builddir)/libgomp.info $(srcdir)/libgomp.info
+INFO_LIBGOMP_NAME = $(shell echo libgomp|sed '$(program_transform_name)')
+stamp-geninsrc: $(INFO_LIBGOMP_NAME).info
+ cp -p $(top_builddir)/$(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.info
@touch $@
-libgomp.info: $(STAMP_BUILD_INFO)
+libgomp.info: $(INFO_LIBGOMP_NAME).info
+ cp $(INFO_LIBGOMP_NAME).info libgomp.info
+$(STAMP_BUILD_INFO).info: $(STAMP_BUILD_INFO)
stamp-build-info: libgomp.texi
- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libgomp.info $(srcdir)/libgomp.texi
+ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o $(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.texi
@touch $@
Index: libgomp/Makefile.in
===================================================================
--- libgomp/Makefile.in.orig
+++ libgomp/Makefile.in
@@ -618,6 +618,7 @@ info_TEXINFOS = libgomp.texi
# AM_CONDITIONAL on configure check ACX_CHECK_PROG_VER([MAKEINFO])
@BUILD_INFO_TRUE@STAMP_BUILD_INFO = stamp-build-info
+INFO_LIBGOMP_NAME = $(shell echo libgomp|sed '$(program_transform_name)')
CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO)
MAINTAINERCLEANFILES = $(srcdir)/libgomp.info
MULTISRCTOP =
@@ -1398,15 +1399,16 @@ env.lo: libgomp_f.h
env.o: libgomp_f.h
all-local: $(STAMP_GENINSRC)
-
-stamp-geninsrc: libgomp.info
- cp -p $(top_builddir)/libgomp.info $(srcdir)/libgomp.info
+stamp-geninsrc: $(INFO_LIBGOMP_NAME).info
+ cp -p $(top_builddir)/$(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.info
@touch $@
-libgomp.info: $(STAMP_BUILD_INFO)
+libgomp.info: $(INFO_LIBGOMP_NAME).info
+ cp $(INFO_LIBGOMP_NAME).info libgomp.info
+$(INFO_LIBGOMP_NAME).info: $(STAMP_BUILD_INFO)
stamp-build-info: libgomp.texi
- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libgomp.info $(srcdir)/libgomp.texi
+ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -D 'fnlibgomp $(INFO_LIBGOMP_NAME)' -I $(srcdir) -o $(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.texi
@touch $@
# target overrides
Index: libgomp/libgomp.texi
===================================================================
--- libgomp/libgomp.texi.orig
+++ libgomp/libgomp.texi
@@ -31,7 +31,7 @@ texts being (a) (see below), and with th
@ifinfo
@dircategory GNU Libraries
@direntry
-* libgomp: (libgomp). GNU Offloading and Multi Processing Runtime Library.
+* @value{fnlibgomp}: (@value{fnlibgomp}). GNU Offloading and Multi Processing Runtime Library.
@end direntry
This manual documents libgomp, the GNU Offloading and Multi Processing
Index: libitm/libitm.texi
===================================================================
--- libitm/libitm.texi.orig
+++ libitm/libitm.texi
@@ -20,7 +20,7 @@ Free Documentation License''.
@ifinfo
@dircategory GNU Libraries
@direntry
-* libitm: (libitm). GNU Transactional Memory Library
+* libitm: (libitm-6). GNU Transactional Memory Library
@end direntry
This manual documents the GNU Transactional Memory Library.
Index: libquadmath/libquadmath.texi
===================================================================
--- libquadmath/libquadmath.texi.orig
+++ libquadmath/libquadmath.texi
@@ -25,7 +25,7 @@ copy and modify this GNU manual.
@ifinfo
@dircategory GNU Libraries
@direntry
-* libquadmath: (libquadmath). GCC Quad-Precision Math Library
+* libquadmath: (libquadmath-6). GCC Quad-Precision Math Library
@end direntry
This manual documents the GCC Quad-Precision Math Library API.

115
gcc44-textdomain.patch Normal file
View File

@ -0,0 +1,115 @@
#! /bin/sh -e
# DP: Set gettext's domain and textdomain to the versioned package name.
dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
pdir="-d $3"
dir="$3/"
elif [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch)
patch $pdir -f --no-backup-if-mismatch -p0 < $0
;;
-unpatch)
patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
esac
exit 0
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 0fe2ba241..86e5fb9e7 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -4303,8 +4303,8 @@ install-po:
dir=$(localedir)/$$lang/LC_MESSAGES; \
echo $(mkinstalldirs) $(DESTDIR)$$dir; \
$(mkinstalldirs) $(DESTDIR)$$dir || exit 1; \
- echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc.mo; \
- $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc.mo; \
+ echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc-13.mo; \
+ $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc-13.mo; \
done
# Rule for regenerating the message template (gcc.pot).
diff --git a/gcc/intl.cc b/gcc/intl.cc
index e8108b7dc..62895c11f 100644
--- a/gcc/intl.cc
+++ b/gcc/intl.cc
@@ -55,8 +55,8 @@ gcc_init_libintl (void)
setlocale (LC_ALL, "");
#endif
- (void) bindtextdomain ("gcc", LOCALEDIR);
- (void) textdomain ("gcc");
+ (void) bindtextdomain ("gcc-13", LOCALEDIR);
+ (void) textdomain ("gcc-13");
/* Opening quotation mark. */
open_quote = _("`");
diff --git a/libcpp/Makefile.in b/libcpp/Makefile.in
index 5fbba9b9c..c37bc6bcf 100644
--- a/libcpp/Makefile.in
+++ b/libcpp/Makefile.in
@@ -49,6 +49,7 @@ LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
PACKAGE = @PACKAGE@
+PACKAGE_SUFFIX = -13
RANLIB = @RANLIB@
SHELL = @SHELL@
USED_CATALOGS = @USED_CATALOGS@
@@ -76,8 +77,10 @@ INCLUDES = -I$(srcdir) -I. -I$(srcdir)/../include @INCINTL@ \
ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(PICFLAG) \
$(CET_HOST_FLAGS)
+ALL_CFLAGS += -DPACKAGE_SUFFIX=\"$(strip $(PACKAGE_SUFFIX))\"
ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(NOEXCEPTION_FLAGS) $(INCLUDES) \
$(CPPFLAGS) $(PICFLAG) $(CET_HOST_FLAGS)
+ALL_CXXFLAGS += -DPACKAGE_SUFFIX=\"$(strip $(PACKAGE_SUFFIX))\"
# The name of the compiler to use.
COMPILER = $(CXX)
@@ -166,8 +169,8 @@ install-strip install: all installdirs
else continue; \
fi; \
dir=$(localedir)/$$lang/LC_MESSAGES; \
- echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
- $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
+ echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE)$(PACKAGE_SUFFIX).mo; \
+ $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE)$(PACKAGE_SUFFIX).mo; \
done
mostlyclean:
diff --git a/libcpp/init.cc b/libcpp/init.cc
index 63124c816..4471ff358 100644
--- a/libcpp/init.cc
+++ b/libcpp/init.cc
@@ -167,7 +167,7 @@ init_library (void)
init_trigraph_map ();
#ifdef ENABLE_NLS
- (void) bindtextdomain (PACKAGE, LOCALEDIR);
+ (void) bindtextdomain (PACKAGE PACKAGE_SUFFIX, LOCALEDIR);
#endif
}
}
diff --git a/libcpp/system.h b/libcpp/system.h
index 0a0629d55..6fc28a651 100644
--- a/libcpp/system.h
+++ b/libcpp/system.h
@@ -284,7 +284,7 @@ extern int errno;
#endif
#ifndef _
-# define _(msgid) dgettext (PACKAGE, msgid)
+# define _(msgid) dgettext (PACKAGE PACKAGE_SUFFIX, msgid)
#endif
#ifndef N_

View File

@ -0,0 +1,14 @@
Index: libstdc++-v3/doc/html/index.html
===================================================================
--- libstdc++-v3/doc/html/index.html (revision 210144)
+++ libstdc++-v3/doc/html/index.html (working copy)
@@ -18,7 +18,7 @@
</p></li><li class="listitem"><p>
<a class="link" href="faq.html" title="Frequently Asked Questions">Frequently Asked Questions</a>
</p></li><li class="listitem"><p>
- <a class="link" href="api.html" title="The GNU C++ Library API Reference">API and Source Documentation</a>
+ <a class="link" href="api/index.html" title="The GNU C++ Library API Reference">API and Source Documentation</a>
</p></li></ul></div><p>
</p></div></div></div><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="book"><a href="manual/index.html">The GNU C++ Library Manual</a></span></dt><dd><dl><dt><span class="part"><a href="manual/intro.html">I.
Introduction

View File

@ -0,0 +1,18 @@
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in (revision 255776)
+++ gcc/Makefile.in (working copy)
@@ -3066,13 +3066,6 @@ stmp-fixinc: gsyslimits.h macro_list fix
sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \
multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \
fix_dir=include-fixed$${multi_dir}; \
- if ! $(inhibit_libc) && test ! -d ${BUILD_SYSTEM_HEADER_DIR}; then \
- echo The directory that should contain system headers does not exist: >&2 ; \
- echo " ${BUILD_SYSTEM_HEADER_DIR}" >&2 ; \
- tooldir_sysinc=`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`; \
- if test "x${BUILD_SYSTEM_HEADER_DIR}" = "x$${tooldir_sysinc}"; \
- then sleep 1; else exit 1; fi; \
- fi; \
$(mkinstalldirs) $${fix_dir}; \
chmod a+rx $${fix_dir} || true; \
(TARGET_MACHINE='$(target)'; srcdir=`cd $(srcdir); ${PWD_COMMAND}`; \

View File

@ -0,0 +1,13 @@
Index: gcc/c-family/c.opt
===================================================================
--- gcc/c-family/c.opt (revision 246224)
+++ gcc/c-family/c.opt (working copy)
@@ -596,7 +596,7 @@ C ObjC C++ ObjC++ Var(warn_double_promot
Warn about implicit conversions from \"float\" to \"double\".
Wexpansion-to-defined
-C ObjC C++ ObjC++ CPP(warn_expansion_to_defined) CppReason(CPP_W_EXPANSION_TO_DEFINED) Var(cpp_warn_expansion_to_defined) Init(0) Warning EnabledBy(Wextra || Wpedantic)
+C ObjC C++ ObjC++ CPP(warn_expansion_to_defined) CppReason(CPP_W_EXPANSION_TO_DEFINED) Var(cpp_warn_expansion_to_defined) Init(0) Warning EnabledBy(Wpedantic)
Warn if \"defined\" is used outside #if.
Wimplicit-function-declaration

View File

@ -0,0 +1,116 @@
Use the binaries build-id as checksum for PCH purposes.
diff --git a/gcc/c-family/c-pch.cc b/gcc/c-family/c-pch.cc
index 2cafa1387bb..7f51f977378 100644
--- a/gcc/c-family/c-pch.cc
+++ b/gcc/c-family/c-pch.cc
@@ -64,6 +64,66 @@ static FILE *pch_outfile;
static const char *get_ident (void);
+#if _GNU_SOURCE
+#include <link.h>
+
+#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1))
+
+static int
+get_build_id_1 (struct dl_phdr_info *info, size_t, void *data)
+{
+ for (unsigned i = 0; i < info->dlpi_phnum; ++i)
+ {
+ if (info->dlpi_phdr[i].p_type != PT_NOTE)
+ continue;
+ ElfW(Nhdr) *nhdr
+ = (ElfW(Nhdr) *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr);
+ ptrdiff_t size = info->dlpi_phdr[i].p_filesz;
+ ptrdiff_t align = info->dlpi_phdr[i].p_align;
+ if (align != 8)
+ align = 4;
+ while (size >= (ptrdiff_t)sizeof (ElfW(Nhdr)))
+ {
+ if (nhdr->n_type == NT_GNU_BUILD_ID
+ && nhdr->n_namesz == 4
+ && strncmp ((char *)nhdr
+ + sizeof (ElfW(Nhdr)),
+ "GNU", 4) == 0
+ && nhdr->n_descsz >= 16)
+ {
+ memcpy (data,
+ (char *)nhdr
+ + ALIGN (sizeof (ElfW(Nhdr))
+ + nhdr->n_namesz, align), 16);
+ return 1;
+ }
+ size_t offset = (ALIGN (sizeof (ElfW(Nhdr))
+ + nhdr->n_namesz, align)
+ + ALIGN(nhdr->n_descsz, align));
+ nhdr = (ElfW(Nhdr) *)((char *)nhdr + offset);
+ size -= offset;
+ }
+ }
+
+ return 0;
+}
+
+static const unsigned char *
+get_build_id ()
+{
+ static unsigned char build_id[16];
+ if (!dl_iterate_phdr (get_build_id_1, build_id))
+ return NULL;
+ return build_id;
+}
+#else
+static const unsigned char *
+get_build_id ()
+{
+ return NULL;
+}
+#endif
+
/* Compute an appropriate 8-byte magic number for the PCH file, so that
utilities like file(1) can identify it, and so that GCC can quickly
ignore non-PCH files and PCH files that are of a completely different
@@ -118,8 +178,11 @@ pch_init (void)
}
target_validity = targetm.get_pch_validity (&v.target_data_length);
+ const unsigned char *chksum = get_build_id ();
+ if (!chksum)
+ chksum = executable_checksum;
if (fwrite (partial_pch, IDENT_LENGTH, 1, f) != 1
- || fwrite (executable_checksum, 16, 1, f) != 1
+ || fwrite (chksum, 16, 1, f) != 1
|| fwrite (&v, sizeof (v), 1, f) != 1
|| fwrite (target_validity, v.target_data_length, 1, f) != 1)
fatal_error (input_location, "cannot write to %s: %m", pch_file);
@@ -234,7 +297,10 @@ c_common_valid_pch (cpp_reader *pfile, const char *name, int fd)
cpp_warning (pfile, CPP_W_INVALID_PCH, "%s: not a PCH file", name);
return 2;
}
- if (memcmp (ident + IDENT_LENGTH, executable_checksum, 16) != 0)
+ const unsigned char *chksum = get_build_id ();
+ if (!chksum)
+ chksum = executable_checksum;
+ if (memcmp (ident + IDENT_LENGTH, chksum, 16) != 0)
{
cpp_warning (pfile, CPP_W_INVALID_PCH,
"%s: created by a different GCC executable", name);
diff --git a/gcc/genchecksum.cc b/gcc/genchecksum.cc
index 47280f5147b..bcfdcacf954 100644
--- a/gcc/genchecksum.cc
+++ b/gcc/genchecksum.cc
@@ -113,8 +113,13 @@ main (int argc, char ** argv)
puts ("#include \"config.h\"");
puts ("#include \"system.h\"");
fputs ("EXPORTED_CONST unsigned char executable_checksum[16] = { ", stdout);
+#if _GNU_SOURCE
+ for (i = 0; i < 16; i++)
+ printf ("0x%02x%s", 0, i == 15 ? " };\n" : ", ");
+#else
for (i = 0; i < 16; i++)
printf ("0x%02x%s", result[i], i == 15 ? " };\n" : ", ");
+#endif
return 0;
}

View File

@ -0,0 +1,15 @@
Avoid leaking current data on generated file for Ada.
Index: gcc/ada/gcc-interface/Makefile.in
===================================================================
--- gcc/ada/gcc-interface/Makefile.in (revision 268977)
+++ gcc/ada/gcc-interface/Makefile.in (working copy)
@@ -2407,6 +2407,7 @@ $(RTSDIR)/s-oscons.ads: ../stamp-gnatlib
$(OSCONS_CPP) ; \
$(OSCONS_EXTRACT) ; \
../bldtools/oscons/xoscons s-oscons)
+ touch -r $(fsrcpfx)ada/gsocket.h $@
gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR) $(RTSDIR)/s-oscons.ads
test -f $(RTSDIR)/s-oscons.ads || exit 1

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a7b82049dd8fec877427a55a38bfb70cc1c0f7d845e458f31ff5c99ec82763c9
size 5709228

31
pre_checkin.sh Normal file
View File

@ -0,0 +1,31 @@
#!/bin/bash
# This script is called automatically during autobuild checkin.
case $0 in
\./*)
here=$PWD
;;
*/*)
here=${0%/*}
;;
*)
here=$PWD
;;
esac
case ${here##*/} in
gcc*.*)
# Handle maintainance projects with .$REPO suffix
suffix=${here##*/}
suffix=${suffix%%\.*}
set ${suffix#gcc}
;;
gcc-*)
suffix=${here##*/}
set ${suffix#*-}-
;;
gcc[0-9]*)
suffix=${here##*/}
set ${suffix#gcc}
;;
esac
. ${here}/change_spec

20
tls-no-direct.diff Normal file
View File

@ -0,0 +1,20 @@
For i?86 negative offsets to %fs segment accesses cause a hypervisor
trap for Xen. Avoid this by making accesses indirect.
??? Note that similar to the behavior on SLE11 this only affects
the compiler built on %ix86, not that on x86_64, even with -m32.
Index: gcc/config/i386/linux.h
===================================================================
--- gcc/config/i386/linux.h.orig 2015-12-17 15:07:37.785650062 +0100
+++ gcc/config/i386/linux.h 2015-12-17 15:08:06.393983290 +0100
@@ -24,3 +24,9 @@ along with GCC; see the file COPYING3.
#undef MUSL_DYNAMIC_LINKER
#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
+
+/* This slows down Xen, so take a very small general performance hit
+ for not accessing the %fs segment with negative offsets by making
+ GCC not emit direct accesses to %fs at all. */
+#undef TARGET_TLS_DIRECT_SEG_REFS_DEFAULT
+#define TARGET_TLS_DIRECT_SEG_REFS_DEFAULT 0