From 3b68b0eb13dcbf216e525b5a9111f41ab8454af8fb741c4cf216e62be5985a2a Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 16 Oct 2024 13:39:17 +0000 Subject: [PATCH 1/2] - Add gcc13-pr116657.patch to fix for parsing tzdata 2024b [gcc#116657] OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gcc13?expand=0&rev=114 --- .gitattributes | 23 + .gitignore | 1 + README.First-for.SuSE.packagers | 31 + _constraints | 26 + _multibuild | 35 + change_spec | 135 + check-build.sh | 38 + cross-aarch64-gcc13-bootstrap.spec | 1086 +++++ cross-aarch64-gcc13.spec | 1086 +++++ cross-amdgcn-gcc13.spec | 1086 +++++ cross-arm-gcc13.spec | 1086 +++++ cross-arm-none-gcc13-bootstrap.spec | 1087 +++++ cross-arm-none-gcc13.spec | 1086 +++++ cross-avr-gcc13-bootstrap.spec | 1086 +++++ cross-avr-gcc13.spec | 1086 +++++ cross-bpf-gcc13.spec | 1086 +++++ cross-epiphany-gcc13-bootstrap.spec | 1087 +++++ cross-epiphany-gcc13.spec | 1086 +++++ cross-hppa-gcc13-bootstrap.spec | 1086 +++++ cross-hppa-gcc13.spec | 1086 +++++ cross-m68k-gcc13.spec | 1086 +++++ cross-mips-gcc13.spec | 1086 +++++ cross-nvptx-gcc13.spec | 1086 +++++ cross-ppc64-gcc13.spec | 1086 +++++ cross-ppc64le-gcc13-bootstrap.spec | 1086 +++++ cross-ppc64le-gcc13.spec | 1086 +++++ cross-pru-gcc13-bootstrap.spec | 1087 +++++ cross-pru-gcc13.spec | 1086 +++++ cross-riscv64-elf-gcc13-bootstrap.spec | 1087 +++++ cross-riscv64-elf-gcc13.spec | 1086 +++++ cross-riscv64-gcc13-bootstrap.spec | 1086 +++++ cross-riscv64-gcc13.spec | 1086 +++++ cross-rx-gcc13-bootstrap.spec | 1087 +++++ cross-rx-gcc13.spec | 1086 +++++ cross-s390x-gcc13-bootstrap.spec | 1086 +++++ cross-s390x-gcc13.spec | 1086 +++++ cross-sparc-gcc13.spec | 1086 +++++ cross-sparc64-gcc13.spec | 1086 +++++ cross-x86_64-gcc13.spec | 1086 +++++ cross.spec.in | 530 +++ gcc-13.3.1+git8964.tar.xz | 3 + gcc-add-defaultsspec.diff | 51 + gcc.spec.in | 3179 +++++++++++++ gcc10-amdgcn-llvm-as.patch | 31 + ...amdgcn-disable-hot-cold-partitioning.patch | 22 + gcc11-gdwarf-4-default.patch | 29 + gcc13-amdgcn-remove-fiji.patch | 310 ++ gcc13-bsc1216664.patch | 58 + gcc13-pr101523.patch | 46 + gcc13-pr116657.patch | 566 +++ gcc13-pr88345-min-func-alignment.diff | 158 + gcc13-rpmlintrc | 19 + ...000-Adjust-fpatchable-function-entry.patch | 265 ++ ...-sanitizer-remove-crypt-interception.patch | 142 + gcc13-testresults-rpmlintrc | 10 + gcc13-testresults.spec | 1026 ++++ gcc13.changes | 519 ++ gcc13.spec | 4166 +++++++++++++++++ gcc41-ppc32-retaddr.patch | 91 + gcc43-no-unwind-tables.diff | 13 + gcc44-rename-info-files.patch | 708 +++ gcc44-textdomain.patch | 115 + gcc48-libstdc++-api-reference.patch | 14 + gcc7-avoid-fixinc-error.diff | 18 + ...ve-Wexpansion-to-defined-from-Wextra.patch | 13 + ...oducible-builds-buildid-for-checksum.patch | 116 + gcc9-reproducible-builds.patch | 15 + gdcflags.patch | 57 + newlib-4.3.0.20230120.tar.xz | 3 + pre_checkin.sh | 31 + tls-no-direct.diff | 20 + 71 files changed, 47390 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 README.First-for.SuSE.packagers create mode 100644 _constraints create mode 100644 _multibuild create mode 100644 change_spec create mode 100644 check-build.sh create mode 100644 cross-aarch64-gcc13-bootstrap.spec create mode 100644 cross-aarch64-gcc13.spec create mode 100644 cross-amdgcn-gcc13.spec create mode 100644 cross-arm-gcc13.spec create mode 100644 cross-arm-none-gcc13-bootstrap.spec create mode 100644 cross-arm-none-gcc13.spec create mode 100644 cross-avr-gcc13-bootstrap.spec create mode 100644 cross-avr-gcc13.spec create mode 100644 cross-bpf-gcc13.spec create mode 100644 cross-epiphany-gcc13-bootstrap.spec create mode 100644 cross-epiphany-gcc13.spec create mode 100644 cross-hppa-gcc13-bootstrap.spec create mode 100644 cross-hppa-gcc13.spec create mode 100644 cross-m68k-gcc13.spec create mode 100644 cross-mips-gcc13.spec create mode 100644 cross-nvptx-gcc13.spec create mode 100644 cross-ppc64-gcc13.spec create mode 100644 cross-ppc64le-gcc13-bootstrap.spec create mode 100644 cross-ppc64le-gcc13.spec create mode 100644 cross-pru-gcc13-bootstrap.spec create mode 100644 cross-pru-gcc13.spec create mode 100644 cross-riscv64-elf-gcc13-bootstrap.spec create mode 100644 cross-riscv64-elf-gcc13.spec create mode 100644 cross-riscv64-gcc13-bootstrap.spec create mode 100644 cross-riscv64-gcc13.spec create mode 100644 cross-rx-gcc13-bootstrap.spec create mode 100644 cross-rx-gcc13.spec create mode 100644 cross-s390x-gcc13-bootstrap.spec create mode 100644 cross-s390x-gcc13.spec create mode 100644 cross-sparc-gcc13.spec create mode 100644 cross-sparc64-gcc13.spec create mode 100644 cross-x86_64-gcc13.spec create mode 100644 cross.spec.in create mode 100644 gcc-13.3.1+git8964.tar.xz create mode 100644 gcc-add-defaultsspec.diff create mode 100644 gcc.spec.in create mode 100644 gcc10-amdgcn-llvm-as.patch create mode 100644 gcc11-amdgcn-disable-hot-cold-partitioning.patch create mode 100644 gcc11-gdwarf-4-default.patch create mode 100644 gcc13-amdgcn-remove-fiji.patch create mode 100644 gcc13-bsc1216664.patch create mode 100644 gcc13-pr101523.patch create mode 100644 gcc13-pr116657.patch create mode 100644 gcc13-pr88345-min-func-alignment.diff create mode 100644 gcc13-rpmlintrc create mode 100644 gcc13-rs6000-Adjust-fpatchable-function-entry.patch create mode 100644 gcc13-sanitizer-remove-crypt-interception.patch create mode 100644 gcc13-testresults-rpmlintrc create mode 100644 gcc13-testresults.spec create mode 100644 gcc13.changes create mode 100644 gcc13.spec create mode 100644 gcc41-ppc32-retaddr.patch create mode 100644 gcc43-no-unwind-tables.diff create mode 100644 gcc44-rename-info-files.patch create mode 100644 gcc44-textdomain.patch create mode 100644 gcc48-libstdc++-api-reference.patch create mode 100644 gcc7-avoid-fixinc-error.diff create mode 100644 gcc7-remove-Wexpansion-to-defined-from-Wextra.patch create mode 100644 gcc9-reproducible-builds-buildid-for-checksum.patch create mode 100644 gcc9-reproducible-builds.patch create mode 100644 gdcflags.patch create mode 100644 newlib-4.3.0.20230120.tar.xz create mode 100644 pre_checkin.sh create mode 100644 tls-no-direct.diff diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/README.First-for.SuSE.packagers b/README.First-for.SuSE.packagers new file mode 100644 index 0000000..4275407 --- /dev/null +++ b/README.First-for.SuSE.packagers @@ -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. diff --git a/_constraints b/_constraints new file mode 100644 index 0000000..bfb946f --- /dev/null +++ b/_constraints @@ -0,0 +1,26 @@ + + + + 26 + + + 4 + + 4 + 4 + + + + x86_64 + ppc64le + aarch64 + + + + 8 + + 8 + 8 + + + diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..16ce003 --- /dev/null +++ b/_multibuild @@ -0,0 +1,35 @@ + +gcc13-testresults +cross-aarch64-gcc13-bootstrap +cross-aarch64-gcc13 +cross-riscv64-gcc13-bootstrap +cross-riscv64-gcc13 +cross-s390x-gcc13-bootstrap +cross-s390x-gcc13 +cross-ppc64le-gcc13-bootstrap +cross-ppc64le-gcc13 +cross-arm-gcc13 +cross-avr-gcc13-bootstrap +cross-avr-gcc13 +cross-pru-gcc13-bootstrap +cross-pru-gcc13 +cross-x86_64-gcc13 +cross-sparc-gcc13 +cross-sparc64-gcc13 +cross-ppc64-gcc13 +cross-m68k-gcc13 +cross-mips-gcc13 +cross-hppa-gcc13-bootstrap +cross-hppa-gcc13 +cross-arm-none-gcc13-bootstrap +cross-arm-none-gcc13 +cross-epiphany-gcc13-bootstrap +cross-epiphany-gcc13 +cross-riscv64-elf-gcc13-bootstrap +cross-riscv64-elf-gcc13 +cross-rx-gcc13-bootstrap +cross-rx-gcc13 +cross-nvptx-gcc13 +cross-amdgcn-gcc13 +cross-bpf-gcc13 + diff --git a/change_spec b/change_spec new file mode 100644 index 0000000..066845e --- /dev/null +++ b/change_spec @@ -0,0 +1,135 @@ +#!/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 +echo ''gcc$base_ver-testresults'' >> _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 ''$pkgname'' >> _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_glibc_cross cross-s390x-gcc$base_ver s390x s390x-suse-linux +add_glibc_cross cross-ppc64le-gcc$base_ver ppc64le powerpc64le-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_newlib_cross cross-pru-gcc$base_ver pru pru +add_cross cross-x86_64-gcc$base_ver x86_64 x86_64-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-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 +add_cross cross-bpf-gcc$base_ver bpf bpf-none + +for f in *.spec; do + sed -i -e '/^# .*-\(BEGIN\|END\)$/d' $f +done + +echo '' >> _multibuild + +osc service localrun format_spec_file diff --git a/check-build.sh b/check-build.sh new file mode 100644 index 0000000..d08e7ec --- /dev/null +++ b/check-build.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Copyright (c) 2003,2005 SUSE Linux Products GmbH, Germany. All rights reserved. +# +# Authors: Thorsten Kukuk +# +# 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 + diff --git a/cross-aarch64-gcc13-bootstrap.spec b/cross-aarch64-gcc13-bootstrap.spec new file mode 100644 index 0000000..409cda2 --- /dev/null +++ b/cross-aarch64-gcc13-bootstrap.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-aarch64-gcc13.spec b/cross-aarch64-gcc13.spec new file mode 100644 index 0000000..0361e5e --- /dev/null +++ b/cross-aarch64-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-amdgcn-gcc13.spec b/cross-amdgcn-gcc13.spec new file mode 100644 index 0000000..4a8c2ad --- /dev/null +++ b/cross-amdgcn-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-arm-gcc13.spec b/cross-arm-gcc13.spec new file mode 100644 index 0000000..38b5929 --- /dev/null +++ b/cross-arm-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-arm-none-gcc13-bootstrap.spec b/cross-arm-none-gcc13-bootstrap.spec new file mode 100644 index 0000000..701a8d0 --- /dev/null +++ b/cross-arm-none-gcc13-bootstrap.spec @@ -0,0 +1,1087 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-arm-none-gcc13.spec b/cross-arm-none-gcc13.spec new file mode 100644 index 0000000..f95a62f --- /dev/null +++ b/cross-arm-none-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-avr-gcc13-bootstrap.spec b/cross-avr-gcc13-bootstrap.spec new file mode 100644 index 0000000..cc8cfd1 --- /dev/null +++ b/cross-avr-gcc13-bootstrap.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-avr-gcc13.spec b/cross-avr-gcc13.spec new file mode 100644 index 0000000..4a5ae36 --- /dev/null +++ b/cross-avr-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-bpf-gcc13.spec b/cross-bpf-gcc13.spec new file mode 100644 index 0000000..7249a2c --- /dev/null +++ b/cross-bpf-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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-bpf-gcc13 +%define cross_arch bpf +%define gcc_target_arch bpf-none + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-epiphany-gcc13-bootstrap.spec b/cross-epiphany-gcc13-bootstrap.spec new file mode 100644 index 0000000..d2e7f56 --- /dev/null +++ b/cross-epiphany-gcc13-bootstrap.spec @@ -0,0 +1,1087 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-epiphany-gcc13.spec b/cross-epiphany-gcc13.spec new file mode 100644 index 0000000..662a757 --- /dev/null +++ b/cross-epiphany-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-hppa-gcc13-bootstrap.spec b/cross-hppa-gcc13-bootstrap.spec new file mode 100644 index 0000000..7d51bcd --- /dev/null +++ b/cross-hppa-gcc13-bootstrap.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-hppa-gcc13.spec b/cross-hppa-gcc13.spec new file mode 100644 index 0000000..4873968 --- /dev/null +++ b/cross-hppa-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-m68k-gcc13.spec b/cross-m68k-gcc13.spec new file mode 100644 index 0000000..ddd0465 --- /dev/null +++ b/cross-m68k-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-mips-gcc13.spec b/cross-mips-gcc13.spec new file mode 100644 index 0000000..ef6b25c --- /dev/null +++ b/cross-mips-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-nvptx-gcc13.spec b/cross-nvptx-gcc13.spec new file mode 100644 index 0000000..b007bfe --- /dev/null +++ b/cross-nvptx-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-ppc64-gcc13.spec b/cross-ppc64-gcc13.spec new file mode 100644 index 0000000..36161e8 --- /dev/null +++ b/cross-ppc64-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-ppc64le-gcc13-bootstrap.spec b/cross-ppc64le-gcc13-bootstrap.spec new file mode 100644 index 0000000..c77c138 --- /dev/null +++ b/cross-ppc64le-gcc13-bootstrap.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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-bootstrap +%define cross_arch ppc64le +%define gcc_target_arch powerpc64le-suse-linux +%define gcc_libc_bootstrap 1 +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-ppc64le-gcc13.spec b/cross-ppc64le-gcc13.spec new file mode 100644 index 0000000..36c8610 --- /dev/null +++ b/cross-ppc64le-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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_target_glibc 1 +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-pru-gcc13-bootstrap.spec b/cross-pru-gcc13-bootstrap.spec new file mode 100644 index 0000000..be76dab --- /dev/null +++ b/cross-pru-gcc13-bootstrap.spec @@ -0,0 +1,1087 @@ +# +# spec file +# +# Copyright (c) 2024 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-pru-gcc13-bootstrap +%define cross_arch pru +%define gcc_target_arch pru +%define gcc_target_newlib 1 +%define gcc_libc_bootstrap 1 +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-pru-gcc13.spec b/cross-pru-gcc13.spec new file mode 100644 index 0000000..f73aade --- /dev/null +++ b/cross-pru-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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-pru-gcc13 +%define cross_arch pru +%define gcc_target_arch pru +%define gcc_target_newlib 1 +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-riscv64-elf-gcc13-bootstrap.spec b/cross-riscv64-elf-gcc13-bootstrap.spec new file mode 100644 index 0000000..4d8f398 --- /dev/null +++ b/cross-riscv64-elf-gcc13-bootstrap.spec @@ -0,0 +1,1087 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-riscv64-elf-gcc13.spec b/cross-riscv64-elf-gcc13.spec new file mode 100644 index 0000000..1998043 --- /dev/null +++ b/cross-riscv64-elf-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-riscv64-gcc13-bootstrap.spec b/cross-riscv64-gcc13-bootstrap.spec new file mode 100644 index 0000000..f7c39f7 --- /dev/null +++ b/cross-riscv64-gcc13-bootstrap.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-riscv64-gcc13.spec b/cross-riscv64-gcc13.spec new file mode 100644 index 0000000..2519785 --- /dev/null +++ b/cross-riscv64-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-rx-gcc13-bootstrap.spec b/cross-rx-gcc13-bootstrap.spec new file mode 100644 index 0000000..116ba69 --- /dev/null +++ b/cross-rx-gcc13-bootstrap.spec @@ -0,0 +1,1087 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-rx-gcc13.spec b/cross-rx-gcc13.spec new file mode 100644 index 0000000..cd07604 --- /dev/null +++ b/cross-rx-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-s390x-gcc13-bootstrap.spec b/cross-s390x-gcc13-bootstrap.spec new file mode 100644 index 0000000..daed67d --- /dev/null +++ b/cross-s390x-gcc13-bootstrap.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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-bootstrap +%define cross_arch s390x +%define gcc_target_arch s390x-suse-linux +%define gcc_libc_bootstrap 1 +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-s390x-gcc13.spec b/cross-s390x-gcc13.spec new file mode 100644 index 0000000..89628b4 --- /dev/null +++ b/cross-s390x-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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_target_glibc 1 +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-sparc-gcc13.spec b/cross-sparc-gcc13.spec new file mode 100644 index 0000000..ea53b27 --- /dev/null +++ b/cross-sparc-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-sparc64-gcc13.spec b/cross-sparc64-gcc13.spec new file mode 100644 index 0000000..c51f958 --- /dev/null +++ b/cross-sparc64-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross-x86_64-gcc13.spec b/cross-x86_64-gcc13.spec new file mode 100644 index 0000000..8ce345c --- /dev/null +++ b/cross-x86_64-gcc13.spec @@ -0,0 +1,1086 @@ +# +# spec file +# +# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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.3.1+git8964 +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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} +Requires: lld%{product_libs_llvm_ver} +# 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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +%endif +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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog diff --git a/cross.spec.in b/cross.spec.in new file mode 100644 index 0000000..0b62ef9 --- /dev/null +++ b/cross.spec.in @@ -0,0 +1,530 @@ +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%if 0%{?gcc_libc_bootstrap:1} || "%{cross_arch}" == "bpf" +%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 build_rust 0 +%define build_m2 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 "%{binutils_target}" == "bpf" +%define binutils_os %{canonical_target}-none +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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} +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: cross-%cross_arch-newlib-devel +Requires: cross-%cross_arch-newlib-devel +%endif +%if "%{cross_arch}" == "avr" +%if !0%{?is_opensuse} +ExclusiveArch: do-not-build +%endif +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +%if %{suse_version} < 1600 +ExclusiveArch: do-not-build +%endif +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 +%define product_libs_llvm_ver 13 +%else +BuildRequires: llvm%{product_libs_llvm_ver} +%endif +BuildRequires: lld%{product_libs_llvm_ver} +%if %{suse_version} < 1550 +Requires: llvm13 +%else +Requires: llvm%{product_libs_llvm_ver} +%endif +Requires: lld%{product_libs_llvm_ver} +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 "%{cross_arch}" == "pru" +ExclusiveArch: %arm +%endif +%if 0%{?gcc_target_glibc:1} +%ifarch %{cross_arch} +ExcludeArch: %{cross_arch} +%endif +%endif +%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} +ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 +%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 +%if 0%{!?gcc_accel:1} +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun): update-alternatives +%endif +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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" + 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 +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" + --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 + --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} + +%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} +%if "%{cross_arch}" == "amdgcn" +%{_prefix}/%{gcc_target_arch}/bin +%{_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 +%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} && "%{cross_arch}" != "bpf" +%{_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} && "%{cross_arch}" != "bpf" +%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} +%exclude %{_prefix}/%{gcc_target_arch}/bin +%endif + +%changelog -n cross-%{pkgname}-gcc@base_ver@ diff --git a/gcc-13.3.1+git8964.tar.xz b/gcc-13.3.1+git8964.tar.xz new file mode 100644 index 0000000..d4a72d5 --- /dev/null +++ b/gcc-13.3.1+git8964.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b28899078a9457c5e406db83d8e891ef71b5f2568998c0166f29f4619999ce33 +size 87282684 diff --git a/gcc-add-defaultsspec.diff b/gcc-add-defaultsspec.diff new file mode 100644 index 0000000..7ef8287 --- /dev/null +++ b/gcc-add-defaultsspec.diff @@ -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. */ diff --git a/gcc.spec.in b/gcc.spec.in new file mode 100644 index 0000000..cafb1bf --- /dev/null +++ b/gcc.spec.in @@ -0,0 +1,3179 @@ +# +# 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%{?suse_version} < 1550 +%define _slibdir /%{_lib} +%define slibdir /lib +%define slibdir64 /lib64 +%else +%define _slibdir %{_libdir} +%define slibdir %{_prefix}/lib +%define slibdir64 %{_prefix}/lib64 +%define usrmerged 1 +%endif + +%bcond_without bootstrap + +# 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 x86_64 +%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 + +%define build_m2 1 + +%if %{build_objcp} +%define build_cp 1 +%define build_objc 1 +%endif + +%define build_rust 0 + +# 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 +%define build_rust 0 +%define build_m2 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 %{with bootstrap} +%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 + +# Limit the number of parallel jobs to avoid OOM +%bcond_without limitbuild + +# 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 22 +%define libgphobos_sover 4 +%define libgdruntime_sover 4 +%define libgccjit_sover 0 +%define libm2_sover 18 + +# 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 itsme@base_ver@ 1 +%define plv_ %{!?product_libs_gcc_ver:@base_ver@}%{?product_libs_gcc_ver} +%define plv() %{expand:%%{!?itsme%{expand:%%{!?product_libs_gcc_ver_%{1}%{2}:%%{plv_}}%%{?product_libs_gcc_ver_%{1}%{2}}}:-gcc@base_ver@}} + +%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}} +%define libm2_suffix %{plv libm2 %{libm2_sover}} + + +# libFOO-devel package suffix +%define libdevel_suffix -gcc@base_ver@ + + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +# SRC-COMMON-BEGIN +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 13.3.1+git8964 +Release: 1 +%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 -@base_ver@ +# SRC-COMMON-END + +Name: gcc@base_ver@ +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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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}} > @base_ver@ +%define hostsuffix %{binsuffix} +BuildRequires: gcc@base_ver@-ada +BuildRequires: gcc@base_ver@-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 +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{?run_tests:1} +BuildRequires: dejagnu +BuildRequires: expect +BuildRequires: gdb +BuildRequires: timezone +%if %{build_go} +BuildRequires: procps +BuildRequires: netcfg +%endif +%if %{build_nvptx} +BuildRequires: cross-nvptx-gcc@base_ver@ +BuildRequires: cross-nvptx-newlib@base_ver@-devel +%endif +%if %{build_gcn} +BuildRequires: cross-amdgcn-gcc@base_ver@ +BuildRequires: cross-amdgcn-newlib@base_ver@-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 glibc-devel +Requires: cpp@base_ver@ = %{version}-%{release} +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: gcc@base_ver@-info gcc@base_ver@-locale +%endif + +# SRC-COMMON-BEGIN +%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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.patch + +# GCC-TESTSUITE-DELETE-BEGIN +# SRC-COMMON-END +License: GPL-3.0-or-later +Summary: The GNU C Compiler and Support Files + +%description +Core package for the GNU Compiler Collection, including the C language +frontend. + +Language frontends other than C are split to different sub-packages, +namely gcc-ada, gcc-c++, gcc-fortran, gcc-obj, gcc-obj-c++, gcc-go, +gcc-rust and gcc-m2. + + + +%package -n gcc@base_ver@-32bit +Summary: The GNU C Compiler 32bit support +Group: Development/Languages/C and C++ +Requires: gcc@base_ver@ = %{version}-%{release} +Requires: libgcc_s%{libgcc_s}-32bit >= %{version}-%{release} +Requires: libgomp%{libgomp_sover}-32bit >= %{version}-%{release} +%ifarch %asan_arch +Requires: libasan%{libasan_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %atomic_arch +Requires: libatomic%{libatomic_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %ubsan_arch +Requires: libubsan%{libubsan_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %vtv_arch +Requires: libvtv%{libvtv_sover}-32bit >= %{version}-%{release} +%endif +Requires: glibc-devel-32bit + +%description -n gcc@base_ver@-32bit +This package contains 32bit support for the GNU Compiler Collection. + +%package -n gcc@base_ver@-64bit +Summary: The GNU C Compiler 64bit support +Group: Development/Languages/C and C++ +Requires: gcc@base_ver@ = %{version}-%{release} +Requires: libgcc_s%{libgcc_s}-64bit >= %{version}-%{release} +Requires: libgomp%{libgomp_sover}-64bit >= %{version}-%{release} +%ifarch %asan_arch +Requires: libasan%{libasan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %tsan_arch +Requires: libtsan%{libtsan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %hwasan_arch +Requires: libhwasan%{libhwasan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %atomic_arch +Requires: libatomic%{libatomic_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %lsan_arch +Requires: liblsan%{liblsan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %ubsan_arch +Requires: libubsan%{libubsan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %vtv_arch +Requires: libvtv%{libvtv_sover}-64bit >= %{version}-%{release} +%endif +Requires: glibc-devel-64bit + +%description -n gcc@base_ver@-64bit +This package contains 64bit support for the GNU Compiler Collection. + + +%package devel +Summary: GCC plugins development enviroment +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc@base_ver@ = %{version}-%{release} +Requires: gmp-devel +Requires: mpc-devel + +%description devel +Files required for developing and compiling GCC plugins. + + +%package locale +Summary: Locale Data for the GNU Compiler Collection +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc@base_ver@ = %{version}-%{release} + +%description locale +Locale data for the GNU Compiler Collection (GCC) to give error message +in the current locale. + + +%package PIE +Summary: A default configuration to build all binaries in PIE mode +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@ = %{version}-%{release} + +%description PIE +This package contains a configuration file (spec) that changes the +compilers default setting to build all ELF binaries in the Position +Independend Executable (PIE) variant. This enables better address +space randomization (ASLR). + + +# PACKAGE-BEGIN +%package c++@variant@ +Summary: The GNU C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-c++ = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}@variant@ = %{version}-%{release} + +%description c++@variant@ +This package contains the GNU compiler for C++. +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}@variant@ +Summary: Include Files and Libraries mandatory for Development +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Requires: libstdc++%{libstdcxx_sover}@variant@ >= %{version}-%{release} +Requires: glibc-devel@variant@ +%ifarch ia64 +Requires: libunwind-devel +%endif + +%description -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}@variant@ +This package contains all the headers and libraries of the standard C++ +library. It is needed for compiling C++ code. +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}@variant@ +Summary: GDB pretty printers for the C++ standard library +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +# The -pp packages are tied to a specific shared library +Requires: libstdc++%{libstdcxx_sover}@variant@ = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} = %{version}-%{release} +Provides: libstdc++%{libstdcxx_sover}-pp@variant@ = %{version}-%{release} +# To allow updates from libstdc++6-pp-gccM to libstdc++6-pp we need +# enumerates Obsoletes, the separate -pp package was introduced with GCC9 +# and dropped somewhen during the GCC11 to GCC12 transition +Obsoletes: libstdc++6-pp-gcc9@variant@ libstdc++6-pp-gcc10@variant@ +Obsoletes: libstdc++6-pp-gcc11@variant@ +Provides: libstdc++6-pp-gcc9@variant@ libstdc++6-pp-gcc10@variant@ +Provides: libstdc++6-pp-gcc11@variant@ +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-pp@variant@ +# packageand() does not work with versioned specifications so the fallback +# is a Requires from libstdc++-devel to preserve previous behavior. +%if %{suse_version} >= 1500 +Supplements: (gdb and libstdc++%{libstdcxx_sover}@variant@ = %{version}-%{release}) +%endif + +%description -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}@variant@ +This package contains pretty printers for the C++ standard library usable +from GDB. +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}@variant@ +Summary: C compiler runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgcc_s%{libgcc_s}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgcc_s%{libgcc_s}@variant@ + +%description -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}@variant@ +Libgcc is needed for dynamically linked C programs. + +%post -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libgomp%{libgomp_sover}%{libgomp_suffix}@variant@ +Summary: The GNU compiler collection OpenMP runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgomp%{libgomp_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgomp%{libgomp_sover}@variant@ + +%description -n libgomp%{libgomp_sover}%{libgomp_suffix}@variant@ +This is the OpenMP runtime library needed by OpenMP enabled programs +that were built with the -fopenmp compiler option and by programs that +were auto-parallelized via the -ftree-parallelize-loops compiler +option. + + +%post -n libgomp%{libgomp_sover}%{libgomp_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libgomp%{libgomp_sover}%{libgomp_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}@variant@ +Summary: The standard C++ shared library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Suggests: libstdc++%{libstdcxx_sover}-locale +Provides: libstdc++%{libstdcxx_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}@variant@ +# Fallback for non-existing Supplements support +%if %{suse_version} < 1500 +Recommends: libstdc++%{libstdcxx_sover}-pp@variant@ = %{version}-%{release} +%endif +# The std::chrono timezone database is provided by timezone +# (/usr/share/zoneinfo/tzdata.zi), without that the tzdb is empty and +# will only provide UTC +Recommends: timezone + +%description -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}@variant@ +The standard C++ library, needed for dynamically linked C++ programs. + + +%post -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +%package -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale +Summary: Standard C++ Library Locales +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libstdc++%{libstdcxx_sover}-locale = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-locale + +%description -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale +The standard C++ library locale data. + + +%package info +Summary: Documentation for the GNU compiler collection +License: GFDL-1.2-only +Group: Documentation/Other +PreReq: %{install_info_prereq} +%if 0%{?suse_version} >= 1120 +BuildArch: noarch +%endif + +%description info +GNU info-pages for the GNU compiler collection covering both user-level +and internals documentation. + + +# PACKAGE-BEGIN +%package objc@variant@ +Summary: GNU Objective C Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-objc = %{version}-%{release} +Requires: libobjc%{libobjc_sover}@variant@ >= %{version}-%{release} + +%description objc@variant@ +This package contains the GNU Objective C compiler. Objective C is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libobjc%{libobjc_sover}%{libobjc_suffix}@variant@ +Summary: Library for the GNU Objective C Compiler +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Libraries/Other +Provides: libobjc%{libobjc_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libobjc%{libobjc_sover}@variant@ + +%description -n libobjc%{libobjc_sover}%{libobjc_suffix}@variant@ +The library for the GNU Objective C compiler. + +%post -n libobjc%{libobjc_sover}%{libobjc_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libobjc%{libobjc_sover}%{libobjc_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package obj-c++@variant@ +Summary: GNU Objective C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@-objc@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-c++@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-obj-c++ = %{version}-%{release} + +%description obj-c++@variant@ +This package contains the GNU Objective C++ compiler. Objective C++ is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. +# PACKAGE-END + + +%package -n cpp@base_ver@ +Summary: The GCC Preprocessor +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ + +%description -n cpp@base_ver@ +This Package contains just the preprocessor that is used by the X11 +packages. + + +# PACKAGE-BEGIN +%package ada@variant@ +Summary: GNU Ada Compiler Based on GCC (GNAT) +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-ada = %{version}-%{release} +Requires: libada@base_ver@@variant@ = %{version}-%{release} + +%description ada@variant@ +This package contains an Ada compiler and associated development +tools based on the GNU GCC technology. +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libada@base_ver@@variant@ +Summary: GNU Ada Runtime Libraries +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libgnarl-@base_ver@@variant@ = %{version}-%{release} +Conflicts: %selfconflict libgnarl-@base_ver@@variant@ +Provides: libgnat-@base_ver@@variant@ = %{version}-%{release} +Conflicts: %selfconflict libgnat-@base_ver@@variant@ + +%description -n libada@base_ver@@variant@ +This package contains the shared libraries required to run programs +compiled with the GNU Ada compiler (GNAT) if they are compiled to use +shared libraries. It also contains the shared libraries for the +Implementation of the Ada Semantic Interface Specification (ASIS), the +implementation of Distributed Systems Programming (GLADE) and the Posix +1003.5 Binding (Florist). + +%post -n libada@base_ver@@variant@ -p /sbin/ldconfig + +%postun -n libada@base_ver@@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package fortran@variant@ +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0-or-later +Group: Development/Languages/Fortran +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-fortran = %{version}-%{release} +Requires: libgfortran%{libgfortran_sover}@variant@ >= %{version}-%{release} +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover}@variant@ >= %{version}-%{release} +%endif + +%description fortran@variant@ +This is the Fortran compiler of the GNU Compiler Collection (GCC). +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}@variant@ +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/Fortran +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover}@variant@ >= %{version}-%{release} +%endif +Provides: libgfortran%{libgfortran_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgfortran%{libgfortran_sover}@variant@ + +%description -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}@variant@ +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). + +%post -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}@variant@ +Summary: The GNU Fortran Compiler Quadmath Runtime Library +License: LGPL-2.1-only +Group: Development/Languages/Fortran +Provides: libquadmath%{libquadmath_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libquadmath%{libquadmath_sover}@variant@ + +%description -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}@variant@ +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC) and quadruple precision floating point +operations. + +%post -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libitm%{libitm_sover}%{libitm_suffix}@variant@ +Summary: The GNU Compiler Transactional Memory Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libitm%{libitm_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libitm%{libitm_sover}@variant@ + +%description -n libitm%{libitm_sover}%{libitm_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fgnu-tm option of the GNU Compiler Collection (GCC). + +%post -n libitm%{libitm_sover}%{libitm_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libitm%{libitm_sover}%{libitm_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libasan%{libasan_sover}%{libasan_suffix}@variant@ +Summary: The GNU Compiler Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libasan%{libasan_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libasan%{libasan_sover}@variant@ + +%description -n libasan%{libasan_sover}%{libasan_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fsanitize=address option of the GNU Compiler Collection (GCC). + +%post -n libasan%{libasan_sover}%{libasan_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libasan%{libasan_sover}%{libasan_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libtsan%{libtsan_sover}%{libtsan_suffix}@variant@ +Summary: The GNU Compiler Thread Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libtsan%{libtsan_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libtsan%{libtsan_sover}@variant@ + +%description -n libtsan%{libtsan_sover}%{libtsan_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fsanitize=thread option of the GNU Compiler Collection (GCC). + +%post -n libtsan%{libtsan_sover}%{libtsan_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libtsan%{libtsan_sover}%{libtsan_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}@variant@ +Summary: The GNU Compiler Hardware-assisted Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libhwasan%{libhwasan_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libhwasan%{libhwasan_sover}@variant@ + +%description -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fsanitize=hwaddress option of the GNU Compiler Collection (GCC). + +%post -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libatomic%{libatomic_sover}%{libatomic_suffix}@variant@ +Summary: The GNU Compiler Atomic Operations Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Provides: libatomic%{libatomic_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libatomic%{libatomic_sover}@variant@ + +%description -n libatomic%{libatomic_sover}%{libatomic_suffix}@variant@ +The runtime library for atomic operations of the GNU Compiler Collection (GCC). + +%post -n libatomic%{libatomic_sover}%{libatomic_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libatomic%{libatomic_sover}%{libatomic_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n liblsan%{liblsan_sover}%{liblsan_suffix}@variant@ +Summary: The GNU Compiler Leak Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: liblsan%{liblsan_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict liblsan%{liblsan_sover}@variant@ + +%description -n liblsan%{liblsan_sover}%{liblsan_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fsanitize=leak option of the GNU Compiler Collection (GCC). + +%post -n liblsan%{liblsan_sover}%{liblsan_suffix}@variant@ -p /sbin/ldconfig + +%postun -n liblsan%{liblsan_sover}%{liblsan_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libubsan%{libubsan_sover}%{libubsan_suffix}@variant@ +Summary: The GNU Compiler Undefined Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libubsan%{libubsan_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libubsan%{libubsan_sover}@variant@ + +%description -n libubsan%{libubsan_sover}%{libubsan_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fsanitize=undefined option of the GNU Compiler Collection (GCC). + +%post -n libubsan%{libubsan_sover}%{libubsan_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libubsan%{libubsan_sover}%{libubsan_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libvtv%{libvtv_sover}%{libvtv_suffix}@variant@ +Summary: The GNU Compiler Vtable Verifier Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libvtv%{libvtv_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libvtv%{libvtv_sover}@variant@ + +%description -n libvtv%{libvtv_sover}%{libvtv_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fvtable-verify option of the GNU Compiler Collection (GCC). + +%post -n libvtv%{libvtv_sover}%{libvtv_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libvtv%{libvtv_sover}%{libvtv_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package go@variant@ +Summary: GNU Go Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-go = %{version}-%{release} +Requires: libgo%{libgo_sover}@variant@ >= %{version}-%{release} + +%description go@variant@ +This package contains a Go compiler and associated development +files based on the GNU GCC technology. +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libgo%{libgo_sover}%{libgo_suffix}@variant@ +Summary: GNU Go compiler runtime library +License: BSD-3-Clause +Group: Development/Languages/Other +Provides: libgo%{libgo_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgo%{libgo_sover}@variant@ + +%description -n libgo%{libgo_sover}%{libgo_suffix}@variant@ +Runtime library for the GNU Go language. + +%post -n libgo%{libgo_sover}%{libgo_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libgo%{libgo_sover}%{libgo_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +# PACKAGE-BEGIN +%package d@variant@ +Summary: GNU D Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-d = %{version}-%{release} +Requires: libgphobos%{libgphobos_sover}@variant@ >= %{version}-%{release} +Requires: libgdruntime%{libgdruntime_sover}@variant@ >= %{version}-%{release} + +%description d@variant@ +This package contains a D compiler and associated development +files based on the GNU GCC technology. +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}@variant@ +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgphobos%{libgphobos_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgphobos%{libgphobos_sover}@variant@ + +%description -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}@variant@ +Runtime library for the GNU D language. + +%post -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}@variant@ +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgdruntime%{libgdruntime_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgdruntime%{libgdruntime_sover}@variant@ + +%description -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}@variant@ +Runtime library for the GNU D language. + +%post -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +%package -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} +Summary: The GNU Compiler Collection JIT library +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Provides: libgccjit%{libgccjit_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgccjit%{libgccjit_sover} +# At runtime the JIT needs to be able to invoke the assembler and +# linker and find startfiles and libgcc. The built-in driver knows +# the compilers version install directory only so we require the +# respective compiler libgccjit was built from. +Requires: gcc@base_ver@ + +%description -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} +Support for embedding GCC inside programs and libraries + +%post -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} -p /sbin/ldconfig + +%postun -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} -p /sbin/ldconfig + +%package -n libgccjit%{libgccjit_sover}-devel%{libdevel_suffix} +Summary: Support for embedding GCC inside programs and libraries +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Provides: libgccjit%{libgccjit_sover}-devel = %{version}-%{release} +# Only one gccjit package can be installed at the same time since +# header files conflict +Conflicts: %selfconflict libgccjit%{libgccjit_sover}-devel +Requires: libgccjit%{libgccjit_sover} >= %{version}-%{release} + +%description -n libgccjit%{libgccjit_sover}-devel%{libdevel_suffix} +Package contains header files and documentation for GCC JIT front-end. + + +# PACKAGE-BEGIN +%package rust@variant@ +Summary: GNU Rust Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-rust = %{version}-%{release} + +%description rust@variant@ +This package contains a Rust compiler. +# PACKAGE-END + + +# PACKAGE-BEGIN +%package m2@variant@ +Summary: GNU Modula-2 Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc@base_ver@@variant@ = %{version}-%{release} +Requires: gcc@base_ver@-m2 = %{version}-%{release} +Requires: libm2log%{libm2_sover}@variant@ >= %{version}-%{release} +Requires: libm2cor%{libm2_sover}@variant@ >= %{version}-%{release} +Requires: libm2iso%{libm2_sover}@variant@ >= %{version}-%{release} +Requires: libm2pim%{libm2_sover}@variant@ >= %{version}-%{release} +Requires: libm2min%{libm2_sover}@variant@ >= %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}@variant@ = %{version}-%{release} + + +%description m2@variant@ +This package contains a Modula-2 compiler. +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libm2log%{libm2_sover}%{libm2_suffix}@variant@ +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2log%{libm2_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2log%{libm2_sover}@variant@ + +%description -n libm2log%{libm2_sover}%{libm2_suffix}@variant@ +Runtime library for the GNU Modula-2 language. + +%post -n libm2log%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libm2log%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libm2cor%{libm2_sover}%{libm2_suffix}@variant@ +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2cor%{libm2_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2cor%{libm2_sover}@variant@ + +%description -n libm2cor%{libm2_sover}%{libm2_suffix}@variant@ +Runtime library for the GNU Modula-2 language. + +%post -n libm2cor%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libm2cor%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libm2iso%{libm2_sover}%{libm2_suffix}@variant@ +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2iso%{libm2_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2iso%{libm2_sover}@variant@ + +%description -n libm2iso%{libm2_sover}%{libm2_suffix}@variant@ +Runtime library for the GNU Modula-2 language. + +%post -n libm2iso%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libm2iso%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libm2pim%{libm2_sover}%{libm2_suffix}@variant@ +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2pim%{libm2_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2pim%{libm2_sover}@variant@ + +%description -n libm2pim%{libm2_sover}%{libm2_suffix}@variant@ +Runtime library for the GNU Modula-2 language. + +%post -n libm2pim%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libm2pim%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +# PACKAGE-BEGIN +%package -n libm2min%{libm2_sover}%{libm2_suffix}@variant@ +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2min%{libm2_sover}@variant@ = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2min%{libm2_sover}@variant@ + +%description -n libm2min%{libm2_sover}%{libm2_suffix}@variant@ +Runtime library for the GNU Modula-2 language. + +%post -n libm2min%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libm2min%{libm2_sover}%{libm2_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +%package -n gcc@base_ver@-testresults +# GCC-TESTSUITE-DELETE-END +Summary: Testsuite results +License: SUSE-Public-Domain +Group: Development/Languages/C and C++ + +%description -n gcc@base_ver@-testresults +Results from running the gcc and target library testsuites. + + + +# SRC-COMMON-BEGIN + +# 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 %{_target_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} + +# SRC-COMMON-END + +# 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 + + +# BUILD-COMMON-BEGIN +%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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $CONFARGS \ + --build=%{GCCDIST} \ + --host=%{GCCDIST} || \ + { + rc=$?; + echo "------- BEGIN config.log ------"; + %{__cat} config.log; + echo "------- END config.log ------"; + exit $rc; + } + + +# BUILD-COMMON-END + +STAGE1_FLAGS="-g -O2" +%if 0%{?do_profiling} && !0%{?building_testsuite:1} +%ifarch x86_64 %ix86 ppc64le s390x aarch64 +%if %{with bootstrap} +%define use_pgo_bootstrap 1 +%endif +%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} +# GCC-TESTSUITE-DELETE-BEGIN +# Work around tail/head -1 changes +export _POSIX2_VERSION=199209 +export LIBRARY_PATH=%{buildroot}/%{libsubdir}:%{buildroot}/%{mainlibdirbi} + +%make_install + +# verify libasan really ended up with libstdc++ as NEEDED. +%ifarch %asan_arch + readelf -d %{buildroot}/%{versmainlibdir}/libasan.so.%{libasan_sover}* | grep 'NEEDED.*libstdc++' || exit 1 +%if %{biarch} + readelf -d %{buildroot}/%{versmainlibdirbi}/libasan.so.%{libasan_sover}* | grep 'NEEDED.*libstdc++' || exit 1 +%endif +%endif + +# Remove some useless .la files +for lib in libobjc libgfortran libquadmath libcaf_single \ + libgomp libgomp-plugin-hsa libstdc++ libsupc++ libgo \ + libasan libhwasan libatomic libitm libtsan liblsan libubsan libvtv \ + libstdc++fs libgomp-plugin-nvptx libgomp-plugin-gcn \ + libgdruntime libgphobos libstdc++exp \ + libm2cor libm2iso libm2log libm2min libm2pim; do + rm -f %{buildroot}/%{versmainlibdir}/$lib.la +%if %{biarch} + rm -f %{buildroot}/%{versmainlibdirbi}/$lib.la +%endif +done + +mkdir -p %{buildroot}/%{_libdir} +%if %{biarch} +%if %{build_primary_64bit} +mkdir -p %{buildroot}/%{_prefix}/lib +%else +mkdir -p %{buildroot}/%{_prefix}/lib64 +%endif +%endif + +%if %{build_cp} +# Merge multilib c++config.h to allow omitting the duplicate and +# identical other arch specific headers +dir_ml= +cxxconfig="`find %{GCCDIST}/libstdc++-v3/include -name c++config.h`" +for i in `find %{GCCDIST}/[36]*/libstdc++-v3/include -name c++config.h 2>/dev/null`; do + if ! diff -up $cxxconfig $i; then + file_32=x + file_64=x + case $i in + %{GCCDIST}/32/*) + file_32=$i + file_64=$cxxconfig + dir_ml=32 + ;; + %{GCCDIST}/64/*) + file_32=$cxxconfig + file_64=$i + dir_ml=64 + ;; + esac + if ! ( test -f "$file_32" && test -f "$file_64" ); then + echo "Urgs?" + exit 1 + fi + + cat > %{buildroot}/%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/bits/c++config.h < +#if __WORDSIZE == 32 +`cat $file_32` +#else +`cat $file_64` +#endif +#endif +EOF + break + fi +done +rm -rf %{buildroot}/%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/[36]* +if ! test -z "$dir_ml"; then + ln -s . %{buildroot}/%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/$dir_ml +fi +%endif + +# move shared libs from versionspecific dir to main libdir +for libname in \ +%if %{build_fortran} + libgfortran \ +%endif +%ifarch %quadmath_arch + libquadmath \ +%endif +%if %{build_objc} + libobjc \ +%endif +%if %{build_cp} + libstdc++ \ +%endif +%if %{build_go} + libgo \ +%endif +%if %{build_d} + libgdruntime \ + libgphobos \ +%endif + libgomp \ +%if %{build_nvptx} + libgomp-plugin-nvptx \ +%endif +%if %{build_gcn} + libgomp-plugin-gcn \ +%endif +%if %{build_m2} + libm2log \ + libm2cor \ + libm2iso \ + libm2pim \ + libm2min \ +%endif +%ifarch %atomic_arch + libatomic \ +%endif +%ifarch %itm_arch + libitm \ +%endif +%ifarch %asan_arch + libasan \ +%endif +%ifarch %tsan_arch + libtsan \ +%endif +%ifarch %lsan_arch + liblsan \ +%endif +%ifarch %ubsan_arch + libubsan \ +%endif +%ifarch %hwasan_arch + libhwasan \ +%endif +%ifarch %vtv_arch + libvtv \ +%endif + ; do + for lib in `find %{buildroot}/%{versmainlibdir} -maxdepth 1 -name $libname.so.*`; do + mv $lib %{buildroot}/%{mainlibdir}/ + done + if test -L %{buildroot}/%{versmainlibdir}/$libname.so; then + ln -sf %{mainlibdir}/`readlink %{buildroot}/%{versmainlibdir}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + %{buildroot}/%{versmainlibdir}/$libname.so + fi +%if %{biarch} + if test -d %{buildroot}/%{versmainlibdirbi}; then + for lib in `find %{buildroot}/%{versmainlibdirbi} -maxdepth 1 -name "$libname.so.*"`; do + mv $lib %{buildroot}/%{mainlibdirbi}/ + done + if test -L %{buildroot}/%{versmainlibdirbi}/$libname.so; then + ln -sf %{mainlibdirbi}/`readlink %{buildroot}/%{versmainlibdirbi}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + %{buildroot}/%{versmainlibdirbi}/$libname.so + fi + fi +%endif +done +%if %{build_cp} +# And we want to move the shlib gdb pretty printers to a more sane +# place so ldconfig does not complain +mkdir -p %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdir} +mv %{buildroot}/%{mainlibdir}/libstdc++.so.*-gdb.py %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdir}/ +sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdir}/libstdc++.so.*-gdb.py +%if %{biarch} + if test -d %{buildroot}/%{versmainlibdirbi}; then + mkdir -p %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdirbi} + mv %{buildroot}/%{mainlibdirbi}/libstdc++.so.*-gdb.py %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdirbi}/ + sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdirbi}/libstdc++.so.*-gdb.py + fi +%endif +%endif + +# Move libgcc_s around +if test -L %{buildroot}/%{_lib}/libgcc_s.so; then + rm -f %{buildroot}/%{_lib}/libgcc_s.so + ln -sf /%{_lib}/libgcc_s.so.%{libgcc_s} %{buildroot}/%{versmainlibdir}/libgcc_s.so +else + mv %{buildroot}/%{_lib}/libgcc_s.so %{buildroot}/%{versmainlibdir}/ +fi +chmod a+x %{buildroot}/%{_lib}/libgcc_s.so.%{libgcc_s} +%if 0%{?usrmerged} +mv %{buildroot}/%{_lib}/libgcc_s.so.%{libgcc_s} %{buildroot}/%{_slibdir}/libgcc_s.so.%{libgcc_s} +%endif +%if %{biarch} +%if %{build_primary_64bit} +if test -L %{buildroot}/lib/libgcc_s.so; then + rm -f %{buildroot}/lib/libgcc_s.so + ln -sf /lib/libgcc_s.so.%{libgcc_s} %{buildroot}/%{versmainlibdirbi32}/libgcc_s.so +else + mv %{buildroot}/lib/libgcc_s.so %{buildroot}/%{versmainlibdirbi32}/ +fi +ln -sf %{versmainlibdirbi32}/libgcc_s.so %{buildroot}/%{versmainlibdirbi32}/libgcc_s_32.so +chmod a+x %{buildroot}/lib/libgcc_s.so.%{libgcc_s} +%if 0%{?usrmerged} +mv %{buildroot}/lib/libgcc_s.so.%{libgcc_s} %{buildroot}/%{slibdir}/libgcc_s.so.%{libgcc_s} +%endif +%else +# 32-bit biarch systems +if test -L %{buildroot}/lib64/libgcc_s.so; then + rm -f %{buildroot}/lib64/libgcc_s.so + ln -sf /lib64/libgcc_s.so.%{libgcc_s} %{buildroot}/%{versmainlibdirbi64}/libgcc_s.so +else + mv %{buildroot}/lib64/libgcc_s.so %{buildroot}/%{versmainlibdirbi64}/ +fi +ln -sf %{versmainlibdirbi64}/libgcc_s.so %{buildroot}/%{versmainlibdirbi64}/libgcc_s_64.so +chmod a+x %{buildroot}/lib64/libgcc_s.so.%{libgcc_s} +%if 0%{?usrmerged} +mv %{buildroot}/lib64/libgcc_s.so.%{libgcc_s} %{buildroot}/%{slibdir64}/libgcc_s.so.%{libgcc_s} +%endif +%endif +%endif + +%if %{build_ada} +mv %{buildroot}/%{libsubdir}/adalib/lib*-*.so %{buildroot}/%{_libdir} +ln -sf %{_libdir}/libgnarl%{binsuffix}.so %{buildroot}/%{libsubdir}/adalib/libgnarl.so +ln -sf %{_libdir}/libgnat%{binsuffix}.so %{buildroot}/%{libsubdir}/adalib/libgnat.so +chmod a+x %{buildroot}/%{_libdir}/libgna*-*.so +%if %{biarch} +mv %{buildroot}/%{versmainlibdirbi}/adalib/lib*-*.so %{buildroot}/%{mainlibdirbi}/ +ln -sf %{mainlibdirbi}/libgnarl%{binsuffix}.so %{buildroot}/%{versmainlibdirbi}/adalib/libgnarl.so +ln -sf %{mainlibdirbi}/libgnat%{binsuffix}.so %{buildroot}/%{versmainlibdirbi}/adalib/libgnat.so +chmod a+x %{buildroot}/%{mainlibdirbi}/libgna*-*.so +%endif +%endif + +rm -f %{buildroot}/%{_prefix}/bin/c++%{binsuffix} + +# Remove some crap from the .la files: +for l in `find %{buildroot} -name '*.la'`; do + echo "changing $l" + sed -e '/^dependency_libs/s| -L%{_builddir}/[^ ]*||g' \ + -e '/^dependency_libs/s| -L/usr/%{GCCDIST}/bin||g' \ + -e '/^dependency_libs/s|-lm \(-lm \)*|-lm |' \ + -e '/^dependency_libs/s|-L[^ ]* ||g' \ +%if %{biarch} +%if %{build_primary_64bit} + -e '/^libdir/s|%{_libdir}/32|%{_prefix}/lib|' \ + -e '/^libdir/s|lib64/\.\./||' \ +%else + -e '/^libdir/s|%{_libdir}/64|%{_prefix}/lib64|' \ +%endif +%endif + < $l > $l.new + mv $l.new $l +done + +# The spec for the PIE subpackage +cat > %{buildroot}/%{libsubdir}/defaults.spec < ../floatn-fixes.list +# Whether floatn.h is fixed depends on the glibc version and architecture. +# For now keep it if it's there but in the end we want to fix glibc itself +# everywhere. +if test -f %{buildroot}/%{libsubdir}/include-fixed/bits/floatn.h; then + cat >> ../floatn-fixes.list <> ../floatn-fixes.list < gcc@base_ver@-locale.lang + +%post info +%install_info --info-dir=%{_infodir} %{_infodir}/cpp%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/cppinternals%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gcc%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gccint%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gccinstall%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/libgomp%{binsuffix}.info.gz +%ifarch %itm_arch +%install_info --info-dir=%{_infodir} %{_infodir}/libitm%{binsuffix}.info.gz +%endif +%if %{build_fortran} +%install_info --info-dir=%{_infodir} %{_infodir}/gfortran%{binsuffix}.info.gz +%ifarch %quadmath_arch +%install_info --info-dir=%{_infodir} %{_infodir}/libquadmath%{binsuffix}.info.gz +%endif +%endif +%if %{build_ada} +%install_info --info-dir=%{_infodir} %{_infodir}/gnat-style%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gnat_rm%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gnat_ugn%{binsuffix}.info.gz +%endif + +%preun info +%install_info_delete --info-dir=%{_infodir} %{_infodir}/cpp%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/cppinternals%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gcc%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gccint%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gccinstall%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/libgomp%{binsuffix}.info.gz +%ifarch %itm_arch +%install_info_delete --info-dir=%{_infodir} %{_infodir}/libitm%{binsuffix}.info.gz +%endif +%if %{build_fortran} +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gfortran%{binsuffix}.info.gz +%ifarch %quadmath_arch +%install_info_delete --info-dir=%{_infodir} %{_infodir}/libquadmath%{binsuffix}.info.gz +%endif +%endif +%if %{build_ada} +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gnat-style%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gnat_rm%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gnat_ugn%{binsuffix}.info.gz +%endif + +%files -f floatn-fixes.list +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%dir %{libsubdir}/include +%dir %{libsubdir}/include-fixed +%if %{biarch} +%if %{build_primary_64bit} +%dir %{libsubdir}/32 +%else +%dir %{libsubdir}/64 +%endif +%endif +%{_prefix}/bin/gcc%{binsuffix} +%{_prefix}/bin/%{GCCDIST}-gcc%{binsuffix} +%{_prefix}/bin/gcov%{binsuffix} +%{_prefix}/bin/gcov-dump%{binsuffix} +%{_prefix}/bin/gcov-tool%{binsuffix} +%{_prefix}/bin/gcc-ar%{binsuffix} +%{_prefix}/bin/gcc-nm%{binsuffix} +%{_prefix}/bin/gcc-ranlib%{binsuffix} +%{_prefix}/bin/lto-dump%{binsuffix} +%{libsubdir}/collect2 +%{libsubdir}/lto1 +%{libsubdir}/lto-wrapper +%{libsubdir}/liblto_plugin.so* +%{libsubdir}/include/limits.h +%{libsubdir}/include/syslimits.h +%{libsubdir}/include-fixed/README +%{libsubdir}/include/omp.h +%{libsubdir}/include/float.h +%{libsubdir}/include/iso646.h +%{libsubdir}/include/stdarg.h +%{libsubdir}/include/stdbool.h +%{libsubdir}/include/stdfix.h +%{libsubdir}/include/stddef.h +%{libsubdir}/include/unwind.h +%{libsubdir}/include/varargs.h +%{libsubdir}/include/stdint.h +%{libsubdir}/include/stdint-gcc.h +%{libsubdir}/include/stdnoreturn.h +%{libsubdir}/include/stdalign.h +%{libsubdir}/include/stdatomic.h +%{libsubdir}/include/openacc.h +%{libsubdir}/include/gcov.h +%{libsubdir}/include/acc_prof.h +%ifarch %sparc +%{libsubdir}/include/visintrin.h +%endif +%ifarch ppc ppc64 ppc64le +%{libsubdir}/include/altivec.h +%{libsubdir}/include/ppc-asm.h +%{libsubdir}/include/ppu_intrinsics.h +%{libsubdir}/include/si2vmx.h +%{libsubdir}/include/spu2vmx.h +%{libsubdir}/include/vec_types.h +%{libsubdir}/include/htmintrin.h +%{libsubdir}/include/htmxlintrin.h +%{libsubdir}/include/amo.h +%{libsubdir}/include/bmi2intrin.h +%{libsubdir}/include/bmiintrin.h +%{libsubdir}/include/emmintrin.h +%{libsubdir}/include/mm_malloc.h +%{libsubdir}/include/mmintrin.h +%{libsubdir}/include/x86intrin.h +%{libsubdir}/include/xmmintrin.h +%{libsubdir}/include/pmmintrin.h +%{libsubdir}/include/tmmintrin.h +%{libsubdir}/include/smmintrin.h +%{libsubdir}/include/rs6000-vecdefines.h +%{libsubdir}/include/immintrin.h +%{libsubdir}/include/nmmintrin.h +%{libsubdir}/include/x86gprintrin.h +%endif +%ifarch s390 s390x +%{libsubdir}/include/htmintrin.h +%{libsubdir}/include/htmxlintrin.h +%{libsubdir}/include/s390intrin.h +%{libsubdir}/include/vecintrin.h +%endif +%ifarch ia64 +%{libsubdir}/include/ia64intrin.h +%endif +%ifarch %arm +%{libsubdir}/include/mmintrin.h +%{libsubdir}/include/unwind-arm-common.h +%{libsubdir}/include/arm_cmse.h +%{libsubdir}/include/arm_mve.h +%{libsubdir}/include/arm_mve_types.h +%{libsubdir}/include/arm_cde.h +%endif +%ifarch %arm aarch64 +%{libsubdir}/include/arm_neon.h +%{libsubdir}/include/arm_acle.h +%{libsubdir}/include/arm_fp16.h +%{libsubdir}/include/arm_bf16.h +%endif +%ifarch aarch64 +%{libsubdir}/include/arm_sve.h +%endif +%ifarch riscv64 +%{libsubdir}/include/riscv_vector.h +%endif +%ifarch %ix86 x86_64 +%{libsubdir}/include/cross-stdarg.h +%{libsubdir}/include/cpuid.h +%{libsubdir}/include/mm3dnow.h +%{libsubdir}/include/mmintrin.h +%{libsubdir}/include/ammintrin.h +%{libsubdir}/include/bmmintrin.h +%{libsubdir}/include/emmintrin.h +%{libsubdir}/include/immintrin.h +%{libsubdir}/include/avxintrin.h +%{libsubdir}/include/pmmintrin.h +%{libsubdir}/include/xmmintrin.h +%{libsubdir}/include/tmmintrin.h +%{libsubdir}/include/nmmintrin.h +%{libsubdir}/include/smmintrin.h +%{libsubdir}/include/wmmintrin.h +%{libsubdir}/include/x86intrin.h +%{libsubdir}/include/ia32intrin.h +%{libsubdir}/include/mm_malloc.h +%{libsubdir}/include/fma4intrin.h +%{libsubdir}/include/xopintrin.h +%{libsubdir}/include/lwpintrin.h +%{libsubdir}/include/popcntintrin.h +%{libsubdir}/include/bmiintrin.h +%{libsubdir}/include/tbmintrin.h +%{libsubdir}/include/avx2intrin.h +%{libsubdir}/include/bmi2intrin.h +%{libsubdir}/include/fmaintrin.h +%{libsubdir}/include/lzcntintrin.h +%{libsubdir}/include/f16cintrin.h +%{libsubdir}/include/adxintrin.h +%{libsubdir}/include/fxsrintrin.h +%{libsubdir}/include/prfchwintrin.h +%{libsubdir}/include/rdseedintrin.h +%{libsubdir}/include/rtmintrin.h +%{libsubdir}/include/xsaveintrin.h +%{libsubdir}/include/xsaveoptintrin.h +%{libsubdir}/include/xtestintrin.h +%{libsubdir}/include/avx512cdintrin.h +%{libsubdir}/include/avx512erintrin.h +%{libsubdir}/include/avx512fintrin.h +%{libsubdir}/include/avx512pfintrin.h +%{libsubdir}/include/shaintrin.h +%{libsubdir}/include/avx512bwintrin.h +%{libsubdir}/include/avx512dqintrin.h +%{libsubdir}/include/avx512vlbwintrin.h +%{libsubdir}/include/avx512vldqintrin.h +%{libsubdir}/include/avx512vlintrin.h +%{libsubdir}/include/avx512ifmaintrin.h +%{libsubdir}/include/avx512ifmavlintrin.h +%{libsubdir}/include/avx512vbmiintrin.h +%{libsubdir}/include/avx512vbmivlintrin.h +%{libsubdir}/include/avx5124fmapsintrin.h +%{libsubdir}/include/avx5124vnniwintrin.h +%{libsubdir}/include/avx512vpopcntdqintrin.h +%{libsubdir}/include/avx512vbmi2intrin.h +%{libsubdir}/include/avx512vbmi2vlintrin.h +%{libsubdir}/include/avx512vnniintrin.h +%{libsubdir}/include/avx512vnnivlintrin.h +%{libsubdir}/include/avx512bitalgintrin.h +%{libsubdir}/include/avx512vpopcntdqvlintrin.h +%{libsubdir}/include/avx512bf16intrin.h +%{libsubdir}/include/avx512bf16vlintrin.h +%{libsubdir}/include/avx512vp2intersectintrin.h +%{libsubdir}/include/avx512vp2intersectvlintrin.h +%{libsubdir}/include/vpclmulqdqintrin.h +%{libsubdir}/include/enqcmdintrin.h +%{libsubdir}/include/cet.h +%{libsubdir}/include/vaesintrin.h +%{libsubdir}/include/clwbintrin.h +%{libsubdir}/include/clflushoptintrin.h +%{libsubdir}/include/xsavecintrin.h +%{libsubdir}/include/xsavesintrin.h +%{libsubdir}/include/mwaitxintrin.h +%{libsubdir}/include/clzerointrin.h +%{libsubdir}/include/pkuintrin.h +%{libsubdir}/include/sgxintrin.h +%{libsubdir}/include/cetintrin.h +%{libsubdir}/include/gfniintrin.h +%{libsubdir}/include/pconfigintrin.h +%{libsubdir}/include/wbnoinvdintrin.h +%{libsubdir}/include/movdirintrin.h +%{libsubdir}/include/cldemoteintrin.h +%{libsubdir}/include/waitpkgintrin.h +%{libsubdir}/include/serializeintrin.h +%{libsubdir}/include/tsxldtrkintrin.h +%{libsubdir}/include/amxbf16intrin.h +%{libsubdir}/include/amxint8intrin.h +%{libsubdir}/include/amxtileintrin.h +%{libsubdir}/include/x86gprintrin.h +%{libsubdir}/include/hresetintrin.h +%{libsubdir}/include/uintrintrin.h +%{libsubdir}/include/keylockerintrin.h +%{libsubdir}/include/avxvnniintrin.h +%{libsubdir}/include/mwaitintrin.h +%{libsubdir}/include/avx512fp16intrin.h +%{libsubdir}/include/avx512fp16vlintrin.h +%{libsubdir}/include/avxifmaintrin.h +%{libsubdir}/include/avxvnniint8intrin.h +%{libsubdir}/include/avxneconvertintrin.h +%{libsubdir}/include/amxfp16intrin.h +%{libsubdir}/include/cmpccxaddintrin.h +%{libsubdir}/include/prfchiintrin.h +%{libsubdir}/include/raointintrin.h +%{libsubdir}/include/amxcomplexintrin.h +%endif +%ifarch m68k +%{libsubdir}/include/math-68881.h +%endif +%ifarch %asan_arch +%{libsubdir}/include/sanitizer +%endif +%if %{build_fortran} +%{libsubdir}/include/ISO_Fortran_binding.h +%endif +%versmainlib *crt*.o +%versmainlib libgcc*.a +%versmainlib libgcov.a +%versmainlib libgcc_s*.so +%versmainlib libgomp.so +%versmainlib libgomp.a +%versmainlib libgomp.spec +%if %{build_nvptx} +%versmainlib libgomp-plugin-nvptx.so +%endif +%if %{build_gcn} +%versmainlib libgomp-plugin-gcn.so +%endif +%ifarch %itm_arch +%versmainlib libitm.so +%versmainlib libitm.a +%versmainlib libitm.spec +%endif +%ifarch %atomic_arch +%versmainlib libatomic.so +%versmainlib libatomic.a +%endif +%ifarch %asan_arch +%versmainlib libasan.so +%versmainlib libasan.a +%versmainlib libasan_preinit.o +%endif +%ifarch %tsan_arch +%if %build_primary_64bit +%versmainlib libtsan.so +%versmainlib libtsan.a +%versmainlib libtsan_preinit.o +%endif +%endif +%ifarch %lsan_arch +%if %build_primary_64bit +%versmainlib liblsan.so +%versmainlib liblsan.a +%versmainlib liblsan_preinit.o +%endif +%endif +%ifarch %ubsan_arch +%versmainlib libubsan.so +%versmainlib libubsan.a +%endif +%ifarch %hwasan_arch +%versmainlib libhwasan.so +%versmainlib libhwasan.a +%versmainlib libhwasan_preinit.o +%endif +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch %hwasan_arch +%versmainlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versmainlib libvtv.so +%versmainlib libvtv.a +%endif +%doc %{_mandir}/man1/gcc%{binsuffix}.1.gz +%doc %{_mandir}/man1/gcov%{binsuffix}.1.gz +%doc %{_mandir}/man1/gcov-dump%{binsuffix}.1.gz +%doc %{_mandir}/man1/gcov-tool%{binsuffix}.1.gz +%doc %{_mandir}/man1/lto-dump%{binsuffix}.1.gz + +%if %{separate_biarch} +%files -n gcc@base_ver@%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib *crt*.o +%versbiarchlib libgcc*.a +%versbiarchlib libgcov.a +%versbiarchlib libgcc_s*.so +%versbiarchlib libgomp.so +%versbiarchlib libgomp.a +%versbiarchlib libgomp.spec +# No 32-bit plugins for nvptx and gcn +%ifarch %itm_arch +%versbiarchlib libitm.so +%versbiarchlib libitm.a +%versbiarchlib libitm.spec +%endif +%ifarch %atomic_arch +%versbiarchlib libatomic.a +%versbiarchlib libatomic.so +%endif +%ifarch %asan_arch +%versbiarchlib libasan.a +%versbiarchlib libasan.so +%versbiarchlib libasan_preinit.o +%endif +%ifarch %ubsan_arch +%versbiarchlib libubsan.a +%versbiarchlib libubsan.so +%endif +%ifarch %tsan_arch +%if %separate_bi64 +%versbiarchlib libtsan.a +%versbiarchlib libtsan.so +%versbiarchlib libtsan_preinit.o +%endif +%endif +%ifarch %lsan_arch +%if %separate_bi64 +%versbiarchlib liblsan.a +%versbiarchlib liblsan.so +%versbiarchlib liblsan_preinit.o +%endif +%endif +# libhwasan.{a,so} is not built in 32-bit mode +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch %hwasan_arch +%versbiarchlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versbiarchlib libvtv.a +%versbiarchlib libvtv.so +%endif +%endif + +%if %{enable_plugins} +%files devel +%defattr(-,root,root) +%dir %{libsubdir}/plugin +%{libsubdir}/plugin +%if %{build_m2} +%exclude %{libsubdir}/plugin/m2rte.so +%endif +%endif + +%files locale -f gcc@base_ver@-locale.lang + +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale -f libstdc++.lang + +%files PIE +%defattr(-,root,root) +%dir %{libsubdir} +%{libsubdir}/defaults.spec + +%if %{build_cp} +%files c++ +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%{_prefix}/bin/g++%{binsuffix} +%doc %{_mandir}/man1/g++%{binsuffix}.1.gz +%{libsubdir}/cc1plus +%{libsubdir}/g++-mapper-server + +%if %{separate_biarch} +%files c++%{separate_biarch_suffix} +%defattr(-,root,root) +# empty - only for the dependency +%if %{suse_version} < 1310 +%doc README +%endif +%endif + +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix} +%defattr(-,root,root) +%mainlib libstdc++.so.%{libstdcxx_sover}* + +%if %{separate_biarch} +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libstdc++.so.%{libstdcxx_sover}* +%endif + +%files -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix} +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%versmainlib libstdc++.a +%versmainlib libstdc++fs.a +%versmainlib libstdc++exp.a +%versmainlib libstdc++.so +%versmainlib libsupc++.a +%{_prefix}/include/c++ + +%files -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} +%defattr(-,root,root) +%dir %{_datadir}/gdb +%dir %{_datadir}/gdb/auto-load +%dir %{_datadir}/gdb/auto-load%{_prefix} +%dir %{_datadir}/gdb/auto-load/%{mainlibdir} +%{_datadir}/gdb/auto-load/%{mainlibdir}/libstdc++.so.*-gdb.py +%{_datadir}/gcc%{binsuffix} + +%if %{separate_biarch} +%files -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%versbiarchlib libstdc++.a +%versbiarchlib libstdc++fs.a +%versbiarchlib libstdc++exp.a +%versbiarchlib libstdc++.so +%versbiarchlib libsupc++.a + +%files -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{_datadir}/gdb/auto-load/%{mainlibdirbi} +%{_datadir}/gdb/auto-load/%{mainlibdirbi}/libstdc++.so.*-gdb.py +%endif +%endif + +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix} +%defattr(-,root,root) +%{_slibdir}/libgcc_s.so.%{libgcc_s} +%if %{biarch} +%if %{build_primary_64bit} +%if !%{separate_bi32} +%{slibdir}/libgcc_s.so.%{libgcc_s} +%endif +%else +%if !%{separate_bi64} +%{slibdir64}/libgcc_s.so.%{libgcc_s} +%endif +%endif +%endif + +%if %{separate_bi64} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit +%defattr(-,root,root) +%{slibdir64}/libgcc_s.so.%{libgcc_s} +%endif + +%if %{separate_bi32} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit +%defattr(-,root,root) +%{slibdir}/libgcc_s.so.%{libgcc_s} +%endif + + +%files -n libgomp%{libgomp_sover}%{libgomp_suffix} +%defattr(-,root,root) +%mainlib libgomp.so.%{libgomp_sover}* +%if %{build_nvptx} +%mainlib libgomp-plugin-nvptx.so.%{libgomp_sover}* +%endif +%if %{build_gcn} +%mainlib libgomp-plugin-gcn.so.%{libgomp_sover}* +%endif + +%if %{separate_biarch} +%files -n libgomp%{libgomp_sover}%{libgomp_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgomp.so.%{libgomp_sover}* +%endif +# No 32-bit plugins for nvptx and gcn + + +%ifarch %asan_arch +%files -n libasan%{libasan_sover}%{libasan_suffix} +%defattr(-,root,root) +%mainlib libasan.so.%{libasan_sover}* + +%if %{separate_biarch} +%files -n libasan%{libasan_sover}%{libasan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libasan.so.%{libasan_sover}* +%endif +%endif + + +%ifarch %lsan_arch +%if %build_primary_64bit +%files -n liblsan%{liblsan_sover}%{liblsan_suffix} +%defattr(-,root,root) +%mainlib liblsan.so.%{liblsan_sover}* +%endif + +%if %{separate_biarch} && %{separate_bi64} +%files -n liblsan%{liblsan_sover}%{liblsan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib liblsan.so.%{liblsan_sover}* +%endif +%endif + + +%ifarch %tsan_arch +%if %build_primary_64bit +%files -n libtsan%{libtsan_sover}%{libtsan_suffix} +%defattr(-,root,root) +%mainlib libtsan.so.%{libtsan_sover}* +%endif + +%if %{separate_biarch} && %{separate_bi64} +%files -n libtsan%{libtsan_sover}%{libtsan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libtsan.so.%{libtsan_sover}* +%endif +%endif + +%ifarch %hwasan_arch +%files -n libhwasan%{libhwasan_sover}%{libhwasan_suffix} +%defattr(-,root,root) +%mainlib libhwasan.so.%{libhwasan_sover}* +%endif + + +%ifarch %atomic_arch +%files -n libatomic%{libatomic_sover}%{libatomic_suffix} +%defattr(-,root,root) +%mainlib libatomic.so.%{libatomic_sover}* + +%if %{separate_biarch} +%files -n libatomic%{libatomic_sover}%{libatomic_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libatomic.so.%{libatomic_sover}* +%endif +%endif + + +%ifarch %itm_arch +%files -n libitm%{libitm_sover}%{libitm_suffix} +%defattr(-,root,root) +%mainlib libitm.so.%{libitm_sover}* + +%if %{separate_biarch} +%files -n libitm%{libitm_sover}%{libitm_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libitm.so.%{libitm_sover}* +%endif +%endif + + +%ifarch %ubsan_arch +%files -n libubsan%{libubsan_sover}%{libubsan_suffix} +%defattr(-,root,root) +%mainlib libubsan.so.%{libubsan_sover}* + +%if %{separate_biarch} +%files -n libubsan%{libubsan_sover}%{libubsan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libubsan.so.%{libubsan_sover}* +%endif +%endif + + +%ifarch %vtv_arch +%files -n libvtv%{libvtv_sover}%{libvtv_suffix} +%defattr(-,root,root) +%mainlib libvtv.so.%{libvtv_sover}* + +%if %{separate_biarch} +%files -n libvtv%{libvtv_sover}%{libvtv_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libvtv.so.%{libvtv_sover}* +%endif + + +%endif + + +%if %{build_fortran} +%files fortran +%defattr(-,root,root) +%dir %{libsubdir}/finclude +%{_prefix}/bin/gfortran%{binsuffix} +%{libsubdir}/f951 +%{libsubdir}/finclude/* +%versmainlib libgfortran.a +%versmainlib libgfortran.so +%versmainlib libgfortran.spec +%versmainlib libcaf_single.a +%ifarch %quadmath_arch +%{libsubdir}/include/quadmath.h +%{libsubdir}/include/quadmath_weak.h +%versmainlib libquadmath.a +%versmainlib libquadmath.so +%endif +%doc %{_mandir}/man1/gfortran%{binsuffix}.1.gz + +%if %{separate_biarch} +%files fortran%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{versmainlibdirbi}/finclude +%{versmainlibdirbi}/finclude/* +%versbiarchlib libgfortran.a +%versbiarchlib libgfortran.so +%versbiarchlib libgfortran.spec +%versbiarchlib libcaf_single.a +%ifarch %quadmath_arch +%versbiarchlib libquadmath.a +%versbiarchlib libquadmath.so +%endif +%endif + +%files -n libgfortran%{libgfortran_sover}%{libgfortran_suffix} +%defattr(-,root,root) +%mainlib libgfortran.so.%{libgfortran_sover}* + +%if %{separate_biarch} +%files -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgfortran.so.%{libgfortran_sover}* +%endif + +%ifarch %quadmath_arch +%files -n libquadmath%{libquadmath_sover}%{libquadmath_suffix} +%defattr(-,root,root) +%mainlib libquadmath.so.%{libquadmath_sover}* + +%if %{separate_biarch} +%files -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libquadmath.so.%{libquadmath_sover}* +%endif +%endif +%endif + +%files info +%defattr(-,root,root) +%doc %{_infodir}/cpp%{binsuffix}.info*.gz +%doc %{_infodir}/cppinternals%{binsuffix}.info*.gz +%doc %{_infodir}/gcc%{binsuffix}.info*.gz +%doc %{_infodir}/gccint%{binsuffix}.info*.gz +%doc %{_infodir}/gccinstall%{binsuffix}.info*.gz +%doc %{_infodir}/libgomp%{binsuffix}.info*.gz +%ifarch %itm_arch +%doc %{_infodir}/libitm%{binsuffix}.info*.gz +%endif +%if %{build_fortran} +%doc %{_infodir}/gfortran%{binsuffix}.info*.gz +%ifarch %quadmath_arch +%doc %{_infodir}/libquadmath%{binsuffix}.info*.gz +%endif +%endif +%if %{build_ada} +%doc %{_infodir}/gnat-style%{binsuffix}.info*gz +%doc %{_infodir}/gnat_rm%{binsuffix}.info*gz +%doc %{_infodir}/gnat_ugn%{binsuffix}.info*gz +%endif +%if %{build_d} +%doc %{_infodir}/gdc%{binsuffix}.info*gz +%endif + +%files -n cpp@base_ver@ +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%{_prefix}/bin/cpp%{binsuffix} +%{libsubdir}/cc1 +%doc %{_mandir}/man1/cpp%{binsuffix}.1.gz + +%if %{build_objc} +%files objc +%defattr(-,root,root) +%{libsubdir}/cc1obj +%{libsubdir}/include/objc +%versmainlib libobjc.a +%versmainlib libobjc.so + +%if %{separate_biarch} +%files objc%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib libobjc.a +%versbiarchlib libobjc.so +%endif + +%files -n libobjc%{libobjc_sover}%{libobjc_suffix} +%defattr(-,root,root) +%mainlib libobjc.so.%{libobjc_sover}* + +%if %{separate_biarch} +%files -n libobjc%{libobjc_sover}%{libobjc_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libobjc.so.%{libobjc_sover}* +%endif +%endif + + +%if %{build_objcp} +%files obj-c++ +%defattr(-,root,root) +%{libsubdir}/cc1objplus + +%if %{separate_biarch} +%files obj-c++%{separate_biarch_suffix} +%defattr(-,root,root) +# empty - only for the dependency +%if %{suse_version} < 1310 +%doc README +%endif +%endif +%endif + + +%if %{build_ada} +%files ada +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%{_prefix}/bin/gnat* +%dir %{versmainlibdir}/adalib +%{versmainlibdir}/adainclude +%{versmainlibdir}/adalib/*.ali +%{versmainlibdir}/adalib/*.a +%{versmainlibdir}/adalib/libgnarl.so +%{versmainlibdir}/adalib/libgnat.so +%{versmainlibdir}/gnat1 +%{versmainlibdir}/ada_target_properties + +%if %{separate_biarch} +%files ada%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{versmainlibdirbi}/adalib +%{versmainlibdirbi}/adainclude +%{versmainlibdirbi}/adalib/*.ali +%{versmainlibdirbi}/adalib/*.a +%{versmainlibdirbi}/adalib/libgnarl.so +%{versmainlibdirbi}/adalib/libgnat.so +%{versmainlibdirbi}/ada_target_properties +%endif + +%files -n libada@base_ver@ +%defattr(-,root,root) +%mainlib libgnarl%{binsuffix}.so +%mainlib libgnat%{binsuffix}.so + +%if %{separate_biarch} +%files -n libada@base_ver@%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgnarl%{binsuffix}.so +%biarchlib libgnat%{binsuffix}.so +%endif +%endif + +%if %{build_go} +%files go +%defattr(-,root,root) +%{_prefix}/bin/gccgo%{binsuffix} +%{_prefix}/bin/go%{binsuffix} +%{_prefix}/bin/gofmt%{binsuffix} +%{libsubdir}/go1 +%versmainlib libgo.a +%versmainlib libgo.so +%versmainlib libgobegin.a +%versmainlib libgolibbegin.a +%versmainlibdir/buildid +%versmainlibdir/cgo +%dir %mainlibdir/go +%dir %mainlibdir/go/%{gcc_dir_version} +%mainlibdir/go/%{gcc_dir_version}/%{GCCDIST} +%doc %{_mandir}/man1/gccgo%{binsuffix}.1.gz +%doc %{_mandir}/man1/go%{binsuffix}.1.gz +%doc %{_mandir}/man1/gofmt%{binsuffix}.1.gz + +%if %{separate_biarch} +%files go%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib libgo.a +%versbiarchlib libgo.so +%versbiarchlib libgobegin.a +%versbiarchlib libgolibbegin.a +%dir %mainlibdirbi/go +%dir %mainlibdirbi/go/%{gcc_dir_version} +%mainlibdirbi/go/%{gcc_dir_version}/%{GCCDIST} +%endif + +%files -n libgo%{libgo_sover}%{libgo_suffix} +%defattr(-,root,root) +%mainlib libgo.so.%{libgo_sover}* + +%if %{separate_biarch} +%files -n libgo%{libgo_sover}%{libgo_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgo.so.%{libgo_sover}* +%endif +%endif + +%if %{build_d} +%files d +%defattr(-,root,root) +%{_prefix}/bin/gdc%{binsuffix} +%{libsubdir}/d21 +%versmainlib libgphobos.a +%versmainlib libgphobos.so +%versmainlib libgdruntime.a +%versmainlib libgdruntime.so +%versmainlib libgphobos.spec +%{versmainlibdir}/include/d +%doc %{_mandir}/man1/gdc%{binsuffix}.1.gz + +%if %{separate_biarch} +%files d%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib libgphobos.a +%versbiarchlib libgphobos.so +%versbiarchlib libgdruntime.a +%versbiarchlib libgdruntime.so +%versbiarchlib libgphobos.spec +%endif + +%files -n libgphobos%{libgphobos_sover}%{libgphobos_suffix} +%defattr(-,root,root) +%mainlib libgphobos.so.%{libgphobos_sover}* + +%if %{separate_biarch} +%files -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgphobos.so.%{libgphobos_sover}* +%endif + +%files -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix} +%defattr(-,root,root) +%mainlib libgdruntime.so.%{libgdruntime_sover}* + +%if %{separate_biarch} +%files -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgdruntime.so.%{libgdruntime_sover}* +%endif +%endif + +%if %{build_jit} +%files -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} +%defattr(-,root,root) +%{_prefix}/%{_lib}/libgccjit.so.%{libgccjit_sover}* + +%files -n libgccjit%{libgccjit_sover}-devel%{libdevel_suffix} +%defattr(-,root,root) +%doc gcc/jit/docs/examples +%{_prefix}/%{_lib}/libgccjit.so +%{_prefix}/include/libgccjit.h +%{_prefix}/include/libgccjit++.h +%{_infodir}/libgccjit.info.gz +%endif + +%if %{build_rust} +%files rust +%defattr(-,root,root) +%{_prefix}/bin/gccrs%{binsuffix} +%{libsubdir}/rust1 +%endif + +%if %{build_m2} +%files m2 +%defattr(-,root,root) +%{_prefix}/bin/gm2%{binsuffix} +%{libsubdir}/cc1gm2 +%if %{enable_plugins} +%{libsubdir}/plugin/m2rte.so +%endif +%{versmainlibdir}/m2 +%versmainlib libm2log.a +%versmainlib libm2log.so +%versmainlib libm2cor.a +%versmainlib libm2cor.so +%versmainlib libm2iso.a +%versmainlib libm2iso.so +%versmainlib libm2pim.a +%versmainlib libm2pim.so +%versmainlib libm2min.a +%versmainlib libm2min.so +%doc %{_mandir}/man1/gm2%{binsuffix}.1.gz + +%if %{separate_biarch} +%files m2%{separate_biarch_suffix} +%defattr(-,root,root) +%{versmainlibdirbi}/m2 +%versbiarchlib libm2log.a +%versbiarchlib libm2log.so +%versbiarchlib libm2cor.a +%versbiarchlib libm2cor.so +%versbiarchlib libm2iso.a +%versbiarchlib libm2iso.so +%versbiarchlib libm2pim.a +%versbiarchlib libm2pim.so +%versbiarchlib libm2min.a +%versbiarchlib libm2min.so +%endif + +%files -n libm2log%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2log.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2log%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2log.so.%{libm2_sover}* +%endif + +%files -n libm2cor%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2cor.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2cor%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2cor.so.%{libm2_sover}* +%endif + +%files -n libm2iso%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2iso.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2iso%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2iso.so.%{libm2_sover}* +%endif + +%files -n libm2pim%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2pim.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2pim%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2pim.so.%{libm2_sover}* +%endif + +%files -n libm2min%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2min.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2min%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2min.so.%{libm2_sover}* +%endif +%endif + +# GCC-TESTSUITE-DELETE-END + +%if 0%{?run_tests:1} +%files -n gcc@base_ver@-testresults +%defattr(-,root,root) +%doc testresults/test_summary.txt +%doc testresults/*.sum +%doc testresults/*.log +%endif + + +%changelog diff --git a/gcc10-amdgcn-llvm-as.patch b/gcc10-amdgcn-llvm-as.patch new file mode 100644 index 0000000..05a591d --- /dev/null +++ b/gcc10-amdgcn-llvm-as.patch @@ -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; diff --git a/gcc11-amdgcn-disable-hot-cold-partitioning.patch b/gcc11-amdgcn-disable-hot-cold-partitioning.patch new file mode 100644 index 0000000..7cd0561 --- /dev/null +++ b/gcc11-amdgcn-disable-hot-cold-partitioning.patch @@ -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 diff --git a/gcc11-gdwarf-4-default.patch b/gcc11-gdwarf-4-default.patch new file mode 100644 index 0000000..5f05147 --- /dev/null +++ b/gcc11-gdwarf-4-default.patch @@ -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- 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 04ca9d9b02b..944019edbc1 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -11255,9 +11255,8 @@ possible. + @itemx -gdwarf-@var{version} + 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. diff --git a/gcc13-amdgcn-remove-fiji.patch b/gcc13-amdgcn-remove-fiji.patch new file mode 100644 index 0000000..4412b46 --- /dev/null +++ b/gcc13-amdgcn-remove-fiji.patch @@ -0,0 +1,310 @@ +From 601796b14b5bab6715b0ddff23f6d998a310b507 Mon Sep 17 00:00:00 2001 +From: Andrew Stubbs +Date: Wed, 18 Oct 2023 16:59:42 +0100 +Subject: [PATCH 1/2] amdgcn: deprecate Fiji device and multilib +To: gcc-patches@gcc.gnu.org + +LLVM wants to remove it, which breaks our build. This patch means that +most users won't notice that change, when it comes, and those that do will +have chosen to enable Fiji explicitly. + +I'm selecting gfx900 as the new default as that's the least likely for users +to want, which means most users will specify -march explicitly, which means +we'll be free to change the default again, when we need to, without breaking +anybody's makefiles. + +gcc/ChangeLog: + + * config.gcc (amdgcn): Switch default to --with-arch=gfx900. + Implement support for --with-multilib-list. + * config/gcn/t-gcn-hsa: Likewise. + * doc/install.texi: Likewise. + * doc/invoke.texi: Mark Fiji deprecated. +--- + gcc/config.gcc | 14 +++++++++++++- + gcc/config/gcn/t-gcn-hsa | 8 ++++++-- + gcc/doc/install.texi | 17 ++++++++++++++++- + gcc/doc/invoke.texi | 4 +++- + 4 files changed, 38 insertions(+), 5 deletions(-) + +diff --git a/gcc/config.gcc b/gcc/config.gcc +index c3b73d05eb7..a662cfea03c 100644 +--- a/gcc/config.gcc ++++ b/gcc/config.gcc +@@ -4475,7 +4475,19 @@ case "${target}" in + ;; + esac + done +- [ "x$with_arch" = x ] && with_arch=fiji ++ [ "x$with_arch" = x ] && with_arch=gfx900 ++ ++ case "x${with_multilib_list}" in ++ x | xno) ++ TM_MULTILIB_CONFIG= ++ ;; ++ xdefault | xyes) ++ TM_MULTILIB_CONFIG=`echo "gfx900,gfx906,gfx908,gfx90a" | sed "s/${with_arch},\?//;s/,$//"` ++ ;; ++ *) ++ TM_MULTILIB_CONFIG="${with_multilib_list}" ++ ;; ++ esac + ;; + + hppa*-*-*) +diff --git a/gcc/config/gcn/t-gcn-hsa b/gcc/config/gcn/t-gcn-hsa +index ea27122e484..18db7075356 100644 +--- a/gcc/config/gcn/t-gcn-hsa ++++ b/gcc/config/gcn/t-gcn-hsa +@@ -42,8 +42,12 @@ ALL_HOST_OBJS += gcn-run.o + gcn-run$(exeext): gcn-run.o + +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $< -ldl + +-MULTILIB_OPTIONS = march=gfx900/march=gfx906/march=gfx908/march=gfx90a +-MULTILIB_DIRNAMES = gfx900 gfx906 gfx908 gfx90a ++empty := ++space := $(empty) $(empty) ++comma := , ++multilib_list := $(subst $(comma),$(space),$(TM_MULTILIB_CONFIG)) ++MULTILIB_OPTIONS = $(subst $(space),/,$(addprefix march=,$(multilib_list))) ++MULTILIB_DIRNAMES = $(multilib_list) + + gcn-tree.o: $(srcdir)/config/gcn/gcn-tree.cc + $(COMPILE) $< +diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi +index b30d3691fe6..5f55da89840 100644 +--- a/gcc/doc/install.texi ++++ b/gcc/doc/install.texi +@@ -1218,7 +1218,7 @@ sysv, aix. + @itemx --without-multilib-list + Specify what multilibs to build. @var{list} is a comma separated list of + values, possibly consisting of a single value. Currently only implemented +-for aarch64*-*-*, arm*-*-*, loongarch64-*-*, riscv*-*-*, sh*-*-* and ++for aarch64*-*-*, amdgcn*-*-*, arm*-*-*, loongarch64-*-*, riscv*-*-*, sh*-*-* and + x86-64-*-linux*. The accepted values and meaning for each target is given + below. + +@@ -1232,6 +1232,15 @@ default run-time library will be built. If @var{list} is + default set of libraries is selected based on the value of + @option{--target}. + ++@item amdgcn*-*-* ++@var{list} is a comma separated list of ISA names (allowed values: @code{fiji}, ++@code{gfx900}, @code{gfx906}, @code{gfx908}, @code{gfx90a}). It ought not ++include the name of the default ISA, specified via @option{--with-arch}. If ++@var{list} is empty, then there will be no multilibs and only the default ++run-time library will be built. If @var{list} is @code{default} or ++@option{--with-multilib-list=} is not specified, then the default set of ++libraries is selected. ++ + @item arm*-*-* + @var{list} is a comma separated list of @code{aprofile} and + @code{rmprofile} to build multilibs for A or R and M architecture +@@ -3876,6 +3885,12 @@ To run the binaries, install the HSA Runtime from the + @file{libexec/gcc/amdhsa-amdhsa/@var{version}/gcn-run} to launch them + on the GPU. + ++To enable support for GCN3 Fiji devices (gfx803), GCC has to be configured with ++@option{--with-arch=@code{fiji}} or ++@option{--with-multilib-list=@code{fiji},...}. Note that support for Fiji ++devices has been removed in ROCm 4.0 and support in LLVM is deprecated and will ++be removed in the future. ++ + @html +
+ @end html +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 792ce283bb9..5fd30cf5eae 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -20773,7 +20773,9 @@ are + + @table @samp + @item fiji +-Compile for GCN3 Fiji devices (gfx803). ++Compile for GCN3 Fiji devices (gfx803). Support deprecated; availablility ++depends on how GCC has been configured, see @option{--with-arch} and ++@option{--with-multilib-list}. + + @item gfx900 + Compile for GCN5 Vega 10 devices (gfx900). +-- +2.35.3 + + +From 4217f929357f23a94dec1d3946c84c6194ab385f Mon Sep 17 00:00:00 2001 +From: Tobias Burnus +Date: Mon, 22 Jan 2024 12:17:12 +0100 +Subject: [PATCH 2/2] [gcn] mkoffload: Fix linking with "-g"; fix file + deletion; improve diagnostic [PR111966] +To: gcc-patches@gcc.gnu.org + +With debugging enabled, '*.mkoffload.dbg.o' files are generated. The e_flags +header of all *.o files must be the same - otherwise, the linker complains. +Since r14-4734-g56ed1055b2f40ac162ae8d382280ac07a33f789f the -march= default +is now gfx900. If compiling without any -march= flag, the default value is +used by the compiler but not passed to mkoffload. Hence, mkoffload.cc's uses +its own default for march - unfortunately, it still had gfx803/fiji as default, +leading to the linker error: 'incompatible mach'. Solution: Update the +default to gfx900. + +While debugging it, I saw that /tmp/cc*.mkoffload.dbg.o kept accumulating; +there were a couple of issues with the handling: +* dbgobj was always added to files_to_cleanup +* If copy_early_debug_info returned true, dbgobj was added again + -> pointless and in theory a race if the same file was added in the + faction of a second. +* If copy_early_debug_info returned false, + - In exactly one case, it already deleted the file it self + (same potential race as above) + - The pointer dbgobj was freed - such that files_to_cleanup contained + a dangling pointer - probably the reason that stale files remained. +Solution: Only if copy_early_debug_info returns true, dbgobj is added to +files_to_cleanup. If it returns false, the file is unlinked before freeing +the pointer. + +When compiling, GCC warned about several fatal_error messages as having +no %<...%> or %qs quotes. This patch now silences several of those warnings +by using those quotes. + +gcc/ChangeLog: + + PR other/111966 + * config/gcn/mkoffload.cc (elf_arch): Change default to gfx900 + to match the compiler default. + (simple_object_copy_lto_debug_sections): Never unlink the outfile + on error as the caller does so. + (maybe_unlink, compile_native): Use %<...%> and %qs in fatal_error. + (main): Likewise. Fix 'mkoffload.dbg.o' cleanup. + +Signed-off-by: Tobias Burnus +--- + gcc/config/gcn/mkoffload.cc | 32 ++++++++++++++++---------------- + 1 file changed, 16 insertions(+), 16 deletions(-) + +diff --git a/gcc/config/gcn/mkoffload.cc b/gcc/config/gcn/mkoffload.cc +index 61bc9273077..57bda59d868 100644 +--- a/gcc/config/gcn/mkoffload.cc ++++ b/gcc/config/gcn/mkoffload.cc +@@ -113,7 +113,7 @@ static const char *gcn_dumpbase; + static struct obstack files_to_cleanup; + + enum offload_abi offload_abi = OFFLOAD_ABI_UNSET; +-uint32_t elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX803; // Default GPU architecture. ++uint32_t elf_arch = EF_AMDGPU_MACH_AMDGCN_GFX900; // Default GPU architecture. + uint32_t elf_flags = + (EF_AMDGPU_FEATURE_XNACK_ANY_V4 | EF_AMDGPU_FEATURE_SRAMECC_ANY_V4); + +@@ -144,7 +144,7 @@ maybe_unlink (const char *file) + if (!save_temps) + { + if (unlink_if_ordinary (file) && errno != ENOENT) +- fatal_error (input_location, "deleting file %s: %m", file); ++ fatal_error (input_location, "deleting file %qs: %m", file); + } + else if (verbose) + fprintf (stderr, "[Leaving %s]\n", file); +@@ -310,10 +310,7 @@ copy_early_debug_info (const char *infile, const char *outfile) + + errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err, true); + if (errmsg) +- { +- unlink_if_ordinary (outfile); +- return false; +- } ++ return false; + + simple_object_release_read (inobj); + close (infd); +@@ -769,7 +766,7 @@ compile_native (const char *infile, const char *outfile, const char *compiler, + const char *collect_gcc_options = getenv ("COLLECT_GCC_OPTIONS"); + if (!collect_gcc_options) + fatal_error (input_location, +- "environment variable COLLECT_GCC_OPTIONS must be set"); ++ "environment variable % must be set"); + + struct obstack argv_obstack; + obstack_init (&argv_obstack); +@@ -824,11 +821,11 @@ main (int argc, char **argv) + + obstack_init (&files_to_cleanup); + if (atexit (mkoffload_cleanup) != 0) +- fatal_error (input_location, "atexit failed"); ++ fatal_error (input_location, "% failed"); + + char *collect_gcc = getenv ("COLLECT_GCC"); + if (collect_gcc == NULL) +- fatal_error (input_location, "COLLECT_GCC must be set."); ++ fatal_error (input_location, "% must be set"); + const char *gcc_path = dirname (ASTRDUP (collect_gcc)); + const char *gcc_exec = basename (ASTRDUP (collect_gcc)); + +@@ -874,7 +871,7 @@ main (int argc, char **argv) + + if (!found) + fatal_error (input_location, +- "offload compiler %s not found", GCC_INSTALL_NAME); ++ "offload compiler %qs not found", GCC_INSTALL_NAME); + + /* We may be called with all the arguments stored in some file and + passed with @file. Expand them into argv before processing. */ +@@ -896,7 +893,7 @@ main (int argc, char **argv) + offload_abi = OFFLOAD_ABI_ILP32; + else + fatal_error (input_location, +- "unrecognizable argument of option " STR); ++ "unrecognizable argument of option %<" STR "%>"); + } + #undef STR + else if (strcmp (argv[i], "-fopenmp") == 0) +@@ -941,7 +938,8 @@ main (int argc, char **argv) + } + + if (!(fopenacc ^ fopenmp)) +- fatal_error (input_location, "either -fopenacc or -fopenmp must be set"); ++ fatal_error (input_location, ++ "either %<-fopenacc%> or %<-fopenmp%> must be set"); + + const char *abi; + switch (offload_abi) +@@ -993,7 +991,7 @@ main (int argc, char **argv) + + cfile = fopen (gcn_cfile_name, "w"); + if (!cfile) +- fatal_error (input_location, "cannot open '%s'", gcn_cfile_name); ++ fatal_error (input_location, "cannot open %qs", gcn_cfile_name); + + /* Currently, we only support offloading in 64-bit configurations. */ + if (offload_abi == OFFLOAD_ABI_LP64) +@@ -1057,7 +1055,6 @@ main (int argc, char **argv) + } + else + dbgobj = make_temp_file (".mkoffload.dbg.o"); +- obstack_ptr_grow (&files_to_cleanup, dbgobj); + + /* If the copy fails then just ignore it. */ + if (copy_early_debug_info (argv[ix], dbgobj)) +@@ -1066,7 +1063,10 @@ main (int argc, char **argv) + obstack_ptr_grow (&files_to_cleanup, dbgobj); + } + else +- free (dbgobj); ++ { ++ maybe_unlink (dbgobj); ++ free (dbgobj); ++ } + } + } + } +@@ -1140,7 +1140,7 @@ main (int argc, char **argv) + + out = fopen (gcn_s2_name, "w"); + if (!out) +- fatal_error (input_location, "cannot open '%s'", gcn_s2_name); ++ fatal_error (input_location, "cannot open %qs", gcn_s2_name); + + process_asm (in, out, cfile); + +-- +2.35.3 + diff --git a/gcc13-bsc1216664.patch b/gcc13-bsc1216664.patch new file mode 100644 index 0000000..ca468e1 --- /dev/null +++ b/gcc13-bsc1216664.patch @@ -0,0 +1,58 @@ +From 7562f089a190953b8ef615b90b7b0520e812a930 Mon Sep 17 00:00:00 2001 +From: Richard Biener +Date: Mon, 6 Nov 2023 11:31:40 +0100 +Subject: [PATCH] libstdc++/112351 - deal with __gthread_once failure during + locale init +To: gcc-patches@gcc.gnu.org + +The following makes the C++98 locale init path follow the way the +C++11 performs initialization. This way we deal with pthread_once +failing, falling back to non-threadsafe initialization which, given we +initialize from the library, should be serialized by the dynamic +loader already. + + PR libstdc++/112351 +libstdc++-v3/ + * src/c++98/locale.cc (locale::facet::_S_initialize_once): + Check whether _S_c_locale is already initialized. + (locale::facet::_S_get_c_locale): Always perform non-threadsafe + init when threadsafe init failed. +--- + libstdc++-v3/src/c++98/locale.cc | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/libstdc++-v3/src/c++98/locale.cc b/libstdc++-v3/src/c++98/locale.cc +index d308140bab7..1ef0c394cd7 100644 +--- a/libstdc++-v3/src/c++98/locale.cc ++++ b/libstdc++-v3/src/c++98/locale.cc +@@ -206,6 +206,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + void + locale::facet::_S_initialize_once() + { ++ // Need to check this because we could get called once from ++ // _S_get_c_locale() when the program is single-threaded, and then again ++ // (via __gthread_once) when it's multi-threaded. ++ if (_S_c_locale) ++ return; ++ + // Initialize the underlying locale model. + _S_create_c_locale(_S_c_locale, _S_c_name); + } +@@ -216,12 +222,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION + #ifdef __GTHREADS + if (__gthread_active_p()) + __gthread_once(&_S_once, _S_initialize_once); +- else + #endif +- { +- if (!_S_c_locale) +- _S_initialize_once(); +- } ++ if (__builtin_expect (!_S_c_locale, 0)) ++ _S_initialize_once(); + return _S_c_locale; + } + +-- +2.35.3 + diff --git a/gcc13-pr101523.patch b/gcc13-pr101523.patch new file mode 100644 index 0000000..48731bd --- /dev/null +++ b/gcc13-pr101523.patch @@ -0,0 +1,46 @@ +From 5729ffad4db78b26f0d1f658a9fd695be5970550 Mon Sep 17 00:00:00 2001 +From: Richard Biener +Date: Wed, 3 Apr 2024 12:58:26 +0200 +Subject: [PATCH] rtl-optimization/101523 - avoid re-combine after noop 2->2 + combination +To: gcc-patches@gcc.gnu.org + +The following avoids re-walking and re-combining the instructions +between i2 and i3 when the pattern of i2 doesn't change. + + PR rtl-optimization/101523 + * combine.cc (try_combine): When the pattern of i2 doesn't + change do not re-start combining at i2 or an earlier insn which + had links or notes added. +--- + gcc/combine.cc | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/gcc/combine.cc b/gcc/combine.cc +index a4479f8d836..ff25752cac4 100644 +--- a/gcc/combine.cc ++++ b/gcc/combine.cc +@@ -4186,6 +4186,10 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, + adjust_for_new_dest (i3); + } + ++ bool i2_unchanged = false; ++ if (rtx_equal_p (newi2pat, PATTERN (i2))) ++ i2_unchanged = true; ++ + /* We now know that we can do this combination. Merge the insns and + update the status of registers and LOG_LINKS. */ + +@@ -4752,6 +4756,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, + combine_successes++; + undo_commit (); + ++ if (i2_unchanged) ++ return i3; ++ + rtx_insn *ret = newi2pat ? i2 : i3; + if (added_links_insn && DF_INSN_LUID (added_links_insn) < DF_INSN_LUID (ret)) + ret = added_links_insn; +-- +2.35.3 + diff --git a/gcc13-pr116657.patch b/gcc13-pr116657.patch new file mode 100644 index 0000000..8a8add2 --- /dev/null +++ b/gcc13-pr116657.patch @@ -0,0 +1,566 @@ +From 5ceea2ac106d6dd1aa8175670b15a801316cf1c9 Mon Sep 17 00:00:00 2001 +From: Richard Biener +Date: Tue, 30 Apr 2024 09:52:13 +0100 +Subject: [PATCH] libstdc++: Fix std::chrono::tzdb to work with vanguard format +To: gcc-patches@gcc.gnu.org + +From: Jonathan Wakely + +I found some issues in the std::chrono::tzdb parser by testing the +tzdata "vanguard" format, which uses new features that aren't enabled in +the "main" and "rearguard" data formats. + +Since 2024a the keyword "minimum" is no longer valid for the FROM and TO +fields in a Rule line, which means that "m" is now a valid abbreviation +for "maximum". Previously we expected either "mi" or "ma". For backwards +compatibility, a FROM field beginning with "mi" is still supported and +is treated as 1900. The "maximum" keyword is only allowed in TO now, +because it makes no sense in FROM. To support these changes the +minmax_year and minmax_year2 classes for parsing FROM and TO are +replaced with a single years_from_to class that reads both fields. + +The vanguard format makes use of %z in Zone FORMAT fields, which caused +an exception to be thrown from ZoneInfo::set_abbrev because no % or / +characters were expected when a Zone doesn't use a named Rule. The +ZoneInfo::to(sys_info&) function now uses format_abbrev_str to replace +any %z with the current offset. Although format_abbrev_str also checks +for %s and STD/DST formats, those only make sense when a named Rule is +in effect, so won't occur when ZoneInfo::to(sys_info&) is used. + +Since making this change on trunk, the tzdata-2024b release started +using %z in the main format, not just vanguard. This makes a backport to +release branches necessary (see PR 116657). + +This change also implements a feature that has always been missing from +time_zone::_M_get_sys_info: finding the Rule that is active before the +specified time point, so that we can correctly handle %s in the FORMAT +for the first new sys_info that gets created. This requires implementing +a poorly documented feature of zic, to get the LETTERS field from a +later transition, as described at +https://mm.icann.org/pipermail/tz/2024-April/058891.html +In order for this to work we need to be able to distinguish an empty +letters field (as used by CE%sT where the variable part is either empty +or "S") from "the letters field is not known for this transition". The +tzdata file uses "-" for an empty letters field, which libstdc++ was +previously replacing with "" when the Rule was parsed. Instead, we now +preserve the "-" in the Rule object, so that "" can be used for the case +where we don't know the letters (and so need to decide it). + +libstdc++-v3/ChangeLog: + + * src/c++20/tzdb.cc (minmax_year, minmax_year2): Remove. + (years_from_to): New class replacing minmax_year and + minmax_year2. + (format_abbrev_str, select_std_or_dst_abbrev): Move earlier in + the file. Handle "-" for letters. + (ZoneInfo::to): Use format_abbrev_str to expand %z. + (ZoneInfo::set_abbrev): Remove exception. Change parameter from + reference to value. + (operator>>(istream&, Rule&)): Do not clear letters when it + contains "-". + (time_zone::_M_get_sys_info): Add missing logic to find the Rule + in effect before the time point. + * testsuite/std/time/tzdb/1.cc: Adjust for vanguard format using + "GMT" as the Zone name, not as a Link to "Etc/GMT". + * testsuite/std/time/time_zone/sys_info_abbrev.cc: New test. + +(cherry picked from commit 0ca8d56f2085715f27ee536c6c344bc47af49cdd) +--- + libstdc++-v3/src/c++20/tzdb.cc | 265 +++++++++++------- + .../std/time/time_zone/sys_info_abbrev.cc | 106 +++++++ + libstdc++-v3/testsuite/std/time/tzdb/1.cc | 6 +- + 3 files changed, 274 insertions(+), 103 deletions(-) + create mode 100644 libstdc++-v3/testsuite/std/time/time_zone/sys_info_abbrev.cc + +diff --git a/libstdc++-v3/src/c++20/tzdb.cc b/libstdc++-v3/src/c++20/tzdb.cc +index e058caf27d8..034e72f0274 100644 +--- a/libstdc++-v3/src/c++20/tzdb.cc ++++ b/libstdc++-v3/src/c++20/tzdb.cc +@@ -342,51 +342,103 @@ namespace std::chrono + friend istream& operator>>(istream&, on_day&); + }; + +- // Wrapper for chrono::year that reads a year, or one of the keywords +- // "minimum" or "maximum", or an unambiguous prefix of a keyword. +- struct minmax_year ++ // Wrapper for two chrono::year values, which reads the FROM and TO ++ // fields of a Rule line. The FROM field is a year and TO is a year or ++ // one of the keywords "maximum" or "only" (or an abbreviation of those). ++ // For backwards compatibility, the keyword "minimum" is recognized ++ // for FROM and interpreted as 1900. ++ struct years_from_to + { +- year& y; ++ year& from; ++ year& to; + +- friend istream& operator>>(istream& in, minmax_year&& y) ++ friend istream& operator>>(istream& in, years_from_to&& yy) + { +- if (ws(in).peek() == 'm') // keywords "minimum" or "maximum" ++ string s; ++ auto c = ws(in).peek(); ++ if (c == 'm') [[unlikely]] // keyword "minimum" + { +- string s; +- in >> s; // extract the rest of the word, but only look at s[1] +- if (s[1] == 'a') +- y.y = year::max(); +- else if (s[1] == 'i') +- y.y = year::min(); +- else +- in.setstate(ios::failbit); ++ in >> s; // extract the rest of the word ++ yy.from = year(1900); ++ } ++ else if (int num = 0; in >> num) [[likely]] ++ yy.from = year{num}; ++ ++ c = ws(in).peek(); ++ if (c == 'm') // keyword "maximum" ++ { ++ in >> s; // extract the rest of the word ++ yy.to = year::max(); ++ } ++ else if (c == 'o') // keyword "only" ++ { ++ in >> s; // extract the rest of the word ++ yy.to = yy.from; + } + else if (int num = 0; in >> num) +- y.y = year{num}; ++ yy.to = year{num}; ++ + return in; + } + }; + +- // As above for minmax_year, but also supports the keyword "only", +- // meaning that the TO year is the same as the FROM year. +- struct minmax_year2 ++ bool ++ select_std_or_dst_abbrev(string& abbrev, minutes save) + { +- minmax_year to; +- year from; ++ if (size_t pos = abbrev.find('/'); pos != string::npos) ++ { ++ // Select one of "STD/DST" for standard or daylight. ++ if (save == 0min) ++ abbrev.erase(pos); ++ else ++ abbrev.erase(0, pos + 1); ++ return true; ++ } ++ return false; ++ } + +- friend istream& operator>>(istream& in, minmax_year2&& y) +- { +- if (ws(in).peek() == 'o') // keyword "only" +- { +- string s; +- in >> s; // extract the whole keyword +- y.to.y = y.from; +- } +- else +- in >> std::move(y.to); +- return in; +- } +- }; ++ // Set the sys_info::abbrev string by expanding any placeholders. ++ void ++ format_abbrev_str(sys_info& info, string_view letters = {}) ++ { ++ if (size_t pos = info.abbrev.find('%'); pos != string::npos) ++ { ++ if (info.abbrev[pos + 1] == 's') ++ { ++ // Expand "%s" to the variable part, given by Rule::letters. ++ if (letters == "-") ++ info.abbrev.erase(pos, 2); ++ else ++ info.abbrev.replace(pos, 2, letters); ++ } ++ else if (info.abbrev[pos + 1] == 'z') ++ { ++ // Expand "%z" to the UT offset as +/-hh, +/-hhmm, or +/-hhmmss. ++ hh_mm_ss t(info.offset); ++ string z(1, "+-"[t.is_negative()]); ++ long val = t.hours().count(); ++ int digits = 2; ++ if (int m = t.minutes().count()) ++ { ++ digits = 4; ++ val *= 100; ++ val += m; ++ if (int s = t.seconds().count()) ++ { ++ digits = 6; ++ val *= 100; ++ val += s; ++ } ++ } ++ auto sval = std::to_string(val); ++ z += string(digits - sval.size(), '0'); ++ z += sval; ++ info.abbrev.replace(pos, 2, z); ++ } ++ } ++ else ++ select_std_or_dst_abbrev(info.abbrev, info.save); ++ } + + // A time zone information record. + // Zone NAME STDOFF RULES FORMAT [UNTIL] +@@ -462,6 +514,7 @@ namespace std::chrono + info.offset = offset(); + info.save = minutes(m_save); + info.abbrev = format(); ++ format_abbrev_str(info); // expand %z + return true; + } + +@@ -469,12 +522,9 @@ namespace std::chrono + friend class time_zone; + + void +- set_abbrev(const string& abbrev) ++ set_abbrev(string abbrev) + { +- // In practice, the FORMAT field never needs expanding here. +- if (abbrev.find_first_of("/%") != abbrev.npos) +- __throw_runtime_error("std::chrono::time_zone: invalid data"); +- m_buf = abbrev; ++ m_buf = std::move(abbrev); + m_pos = 0; + m_expanded = true; + } +@@ -544,9 +594,7 @@ namespace std::chrono + + // Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S + +- in >> quoted(rule.name) +- >> minmax_year{rule.from} +- >> minmax_year2{rule.to, rule.from}; ++ in >> quoted(rule.name) >> years_from_to{rule.from, rule.to}; + + if (char type; in >> type && type != '-') + in.setstate(ios::failbit); +@@ -557,7 +605,7 @@ namespace std::chrono + if (save_time.indicator != at_time::Wall) + { + // We don't actually store the save_time.indicator, because we +- // assume that it's always deducable from the actual offset value. ++ // assume that it's always deducible from the offset value. + auto expected = save_time.time == 0s + ? at_time::Standard + : at_time::Daylight; +@@ -567,8 +615,6 @@ namespace std::chrono + rule.save = save_time.time; + + in >> rule.letters; +- if (rule.letters == "-") +- rule.letters.clear(); + return in; + } + +@@ -714,58 +760,6 @@ namespace std::chrono + #endif // TZDB_DISABLED + }; + +-#ifndef TZDB_DISABLED +- namespace +- { +- bool +- select_std_or_dst_abbrev(string& abbrev, minutes save) +- { +- if (size_t pos = abbrev.find('/'); pos != string::npos) +- { +- // Select one of "STD/DST" for standard or daylight. +- if (save == 0min) +- abbrev.erase(pos); +- else +- abbrev.erase(0, pos + 1); +- return true; +- } +- return false; +- } +- +- // Set the sys_info::abbrev string by expanding any placeholders. +- void +- format_abbrev_str(sys_info& info, string_view letters = {}) +- { +- if (size_t pos = info.abbrev.find("%s"); pos != string::npos) +- { +- // Expand "%s" to the variable part, given by Rule::letters. +- info.abbrev.replace(pos, 2, letters); +- } +- else if (size_t pos = info.abbrev.find("%z"); pos != string::npos) +- { +- // Expand "%z" to the UT offset as +/-hh, +/-hhmm, or +/-hhmmss. +- hh_mm_ss t(info.offset); +- string z(1, "+-"[t.is_negative()]); +- long val = t.hours().count(); +- if (minutes m = t.minutes(); m != m.zero()) +- { +- val *= 100; +- val += m.count(); +- if (seconds s = t.seconds(); s != s.zero()) +- { +- val *= 100; +- val += s.count(); +- } +- } +- z += std::to_string(val); +- info.abbrev.replace(pos, 2, z); +- } +- else +- select_std_or_dst_abbrev(info.abbrev, info.save); +- } +- } +-#endif // TZDB_DISABLED +- + // Implementation of std::chrono::time_zone::get_info(const sys_time&) + sys_info + time_zone::_M_get_sys_info(sys_seconds tp) const +@@ -834,12 +828,72 @@ namespace std::chrono + info.abbrev = ri.format(); + + string_view letters; +- if (i != infos.begin()) ++ if (i != infos.begin() && i[-1].expanded()) ++ letters = i[-1].next_letters(); ++ ++ if (letters.empty()) + { +- if (i[-1].expanded()) +- letters = i[-1].next_letters(); +- // XXX else need to find Rule active before this time and use it +- // to know the initial offset, save, and letters. ++ sys_seconds t = info.begin - seconds(1); ++ const year_month_day date(chrono::floor(t)); ++ ++ // Try to find a Rule active before this time, to get initial ++ // SAVE and LETTERS values. There may not be a Rule for the period ++ // before the first DST transition, so find the earliest DST->STD ++ // transition and use the LETTERS from that. ++ const Rule* active_rule = nullptr; ++ sys_seconds active_rule_start = sys_seconds::min(); ++ const Rule* first_std = nullptr; ++ for (const auto& rule : rules) ++ { ++ if (rule.save == minutes(0)) ++ { ++ if (!first_std) ++ first_std = &rule; ++ else if (rule.from < first_std->from) ++ first_std = &rule; ++ else if (rule.from == first_std->from) ++ { ++ if (rule.start_time(rule.from, {}) ++ < first_std->start_time(first_std->from, {})) ++ first_std = &rule; ++ } ++ } ++ ++ year y = date.year(); ++ ++ if (y > rule.to) // rule no longer applies at time t ++ continue; ++ if (y < rule.from) // rule doesn't apply yet at time t ++ continue; ++ ++ sys_seconds rule_start; ++ ++ seconds offset{}; // appropriate for at_time::Universal ++ if (rule.when.indicator == at_time::Wall) ++ offset = info.offset; ++ else if (rule.when.indicator == at_time::Standard) ++ offset = ri.offset(); ++ ++ // Time the rule takes effect this year: ++ rule_start = rule.start_time(y, offset); ++ ++ if (rule_start >= t && rule.from < y) ++ { ++ // Try this rule in the previous year. ++ rule_start = rule.start_time(--y, offset); ++ } ++ ++ if (active_rule_start < rule_start && rule_start < t) ++ { ++ active_rule_start = rule_start; ++ active_rule = &rule; ++ } ++ } ++ ++ if (active_rule) ++ letters = active_rule->letters; ++ else if (first_std) ++ letters = first_std->letters; + } + + const Rule* curr_rule = nullptr; +@@ -2064,9 +2118,11 @@ namespace std::chrono + istringstream in2(std::move(rules)); + in2 >> rules_time; + inf.m_save = duration_cast(rules_time.time); ++ // If the FORMAT is "STD/DST" then we can choose the right one ++ // now, so that we store a shorter string. + select_std_or_dst_abbrev(fmt, inf.m_save); + } +- inf.set_abbrev(fmt); ++ inf.set_abbrev(std::move(fmt)); + } + + // YEAR [MONTH [DAY [TIME]]] +@@ -2077,7 +2133,12 @@ namespace std::chrono + abbrev_month m{January}; + int d = 1; + at_time t{}; ++ // XXX DAY should support ON format, e.g. lastSun or Sun>=8 + in >> m >> d >> t; ++ // XXX UNTIL field should be interpreted ++ // "using the rules in effect just before the transition" ++ // so might need to store as year_month_day and hh_mm_ss and only ++ // convert to a sys_time once we know the offset in effect. + inf.m_until = sys_days(year(y)/m.m/day(d)) + seconds(t.time); + } + else +diff --git a/libstdc++-v3/testsuite/std/time/time_zone/sys_info_abbrev.cc b/libstdc++-v3/testsuite/std/time/time_zone/sys_info_abbrev.cc +new file mode 100644 +index 00000000000..f1a8fff02f5 +--- /dev/null ++++ b/libstdc++-v3/testsuite/std/time/time_zone/sys_info_abbrev.cc +@@ -0,0 +1,106 @@ ++// { dg-do run { target c++20 } } ++// { dg-require-effective-target tzdb } ++// { dg-require-effective-target cxx11_abi } ++// { dg-xfail-run-if "no weak override on AIX" { powerpc-ibm-aix* } } ++ ++#include ++#include ++#include ++ ++static bool override_used = false; ++ ++namespace __gnu_cxx ++{ ++ const char* zoneinfo_dir_override() { ++ override_used = true; ++ return "./"; ++ } ++} ++ ++using namespace std::chrono; ++ ++void ++test_format() ++{ ++ std::ofstream("tzdata.zi") << R"(# version test_1 ++Zone Africa/Bissau -1:2:20 - LMT 1912 Ja 1 1u ++ -1 - %z 1975 ++ 0 - GMT ++Zon Some/Zone 1:2:3 - %z 1900 ++ 1:23:45 - %z 1950 ++Zo Another/Zone 1:2:3 - AZ0 1901 ++ 1 Roolz A%sZ 2000 ++ 1 Roolz SAZ/DAZ 2005 ++ 1 Roolz %z ++Rule Roolz 1950 max - April 1 2 1 D ++Rul Roolz 1950 max - Oct 1 1 0 S ++Z Strange/Zone 1 - X%sX 1980 ++ 1 - FOO/BAR 1990 ++ 2:00 - %zzz 1995 ++ 0:9 - %zzz 1996 ++ 0:8:7 - %zzz 1997 ++ 0:6:5.5 - %zzz 1998 ++)"; ++ ++ const auto& db = reload_tzdb(); ++ VERIFY( override_used ); // If this fails then XFAIL for the target. ++ VERIFY( db.version == "test_1" ); ++ ++ // Test formatting %z as ++ auto tz = locate_zone("Africa/Bissau"); ++ auto inf = tz->get_info(sys_days(1974y/1/1)); ++ VERIFY( inf.abbrev == "-01" ); ++ ++ tz = locate_zone("Some/Zone"); ++ inf = tz->get_info(sys_days(1899y/1/1)); ++ VERIFY( inf.abbrev == "+010203" ); ++ inf = tz->get_info(sys_days(1955y/1/1)); ++ VERIFY( inf.abbrev == "+012345" ); ++ ++ tz = locate_zone("Another/Zone"); ++ // Test formatting %s as the LETTER/S field from the active Rule. ++ inf = tz->get_info(sys_days(1910y/January/1)); ++ VERIFY( inf.abbrev == "ASZ" ); ++ inf = tz->get_info(sys_days(1950y/January/1)); ++ VERIFY( inf.abbrev == "ASZ" ); ++ inf = tz->get_info(sys_days(1950y/June/1)); ++ VERIFY( inf.abbrev == "ADZ" ); ++ inf = tz->get_info(sys_days(1999y/January/1)); ++ VERIFY( inf.abbrev == "ASZ" ); ++ inf = tz->get_info(sys_days(1999y/July/1)); ++ VERIFY( inf.abbrev == "ADZ" ); ++ // Test formatting STD/DST according to the active Rule. ++ inf = tz->get_info(sys_days(2000y/January/2)); ++ VERIFY( inf.abbrev == "SAZ" ); ++ inf = tz->get_info(sys_days(2001y/January/1)); ++ VERIFY( inf.abbrev == "SAZ" ); ++ inf = tz->get_info(sys_days(2001y/July/1)); ++ VERIFY( inf.abbrev == "DAZ" ); ++ // Test formatting %z as the offset determined by the active Rule. ++ inf = tz->get_info(sys_days(2005y/January/2)); ++ VERIFY( inf.abbrev == "+01" ); ++ inf = tz->get_info(sys_days(2006y/January/1)); ++ VERIFY( inf.abbrev == "+01" ); ++ inf = tz->get_info(sys_days(2006y/July/1)); ++ VERIFY( inf.abbrev == "+02" ); ++ ++ // Test formatting %z, %s and S/D for a Zone with no associated Rules. ++ tz = locate_zone("Strange/Zone"); ++ inf = tz->get_info(sys_days(1979y/January/1)); ++ VERIFY( inf.abbrev == "XX" ); // No Rule means nothing to use for %s. ++ inf = tz->get_info(sys_days(1981y/July/1)); ++ VERIFY( inf.abbrev == "FOO" ); // Always standard time means first string. ++ inf = tz->get_info(sys_days(1994y/July/1)); ++ VERIFY( inf.abbrev == "+02zz" ); ++ inf = tz->get_info(sys_days(1995y/July/1)); ++ VERIFY( inf.abbrev == "+0009zz" ); ++ inf = tz->get_info(sys_days(1996y/July/1)); ++ VERIFY( inf.abbrev == "+000807zz" ); ++ inf = tz->get_info(sys_days(1997y/July/1)); ++ VERIFY( inf.abbrev == "+000606zz" ); ++} ++ ++int main() ++{ ++ test_format(); ++} +diff --git a/libstdc++-v3/testsuite/std/time/tzdb/1.cc b/libstdc++-v3/testsuite/std/time/tzdb/1.cc +index 5f69e182603..73d316f5570 100644 +--- a/libstdc++-v3/testsuite/std/time/tzdb/1.cc ++++ b/libstdc++-v3/testsuite/std/time/tzdb/1.cc +@@ -40,11 +40,15 @@ test_locate() + const tzdb& db = get_tzdb(); + const time_zone* tz = db.locate_zone("GMT"); + VERIFY( tz != nullptr ); +- VERIFY( tz->name() == "Etc/GMT" ); + VERIFY( tz == std::chrono::locate_zone("GMT") ); + VERIFY( tz == db.locate_zone("Etc/GMT") ); + VERIFY( tz == db.locate_zone("Etc/GMT+0") ); + ++ // Since 2022f GMT is now a Zone and Etc/GMT a link instead of vice versa, ++ // but only when using the vanguard format. As of 2024a, the main and ++ // rearguard formats still have Etc/GMT as a Zone and GMT as a link. ++ VERIFY( tz->name() == "GMT" || tz->name() == "Etc/GMT" ); ++ + VERIFY( db.locate_zone(db.current_zone()->name()) == db.current_zone() ); + } + +-- +2.43.0 + diff --git a/gcc13-pr88345-min-func-alignment.diff b/gcc13-pr88345-min-func-alignment.diff new file mode 100644 index 0000000..fa99406 --- /dev/null +++ b/gcc13-pr88345-min-func-alignment.diff @@ -0,0 +1,158 @@ +From 441d0aa048a51d2e9c4f4227916d2a1a2f06b4e5 Mon Sep 17 00:00:00 2001 +From: Jan Hubicka +Date: Wed, 24 Jan 2024 18:13:17 +0100 +Subject: [PATCH] Add -fmin-function-alignmnet +To: gcc-patches@gcc.gnu.org + +-falign-functions is ignored in cold code, since it is an optimization intended to +improve instruction prefetch. In some case it is necessary to force alignment for +all functions, so this patch adds -fmin-function-alignment for this purpose. + +gcc/ChangeLog: + + PR middle-end/88345 + * common.opt: (flimit-function-alignment): Reorder alphabeticaly + (fmin-function-alignment): New parameter. + * doc/invoke.texi: (-fmin-function-alignment): Document. + (-falign-functions,-falign-loops,-falign-labels): Mention that + aglinments are ignored in cold code. + * varasm.cc (assemble_start_function): Handle min-function-alignment. + * lto-streamer.h (LTO_minor_version): Bump. +--- + gcc/common.opt | 10 +++++++--- + gcc/doc/invoke.texi | 18 +++++++++++++++++- + gcc/lto-streamer.h | 2 +- + gcc/varasm.cc | 5 +++++ + 4 files changed, 30 insertions(+), 5 deletions(-) + +diff --git a/gcc/common.opt b/gcc/common.opt +index 862c474d3c8..5d35391b99f 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -1027,9 +1027,6 @@ Align the start of functions. + falign-functions= + Common RejectNegative Joined Var(str_align_functions) Optimization + +-flimit-function-alignment +-Common Var(flag_limit_function_alignment) Optimization Init(0) +- + falign-jumps + Common Var(flag_align_jumps) Optimization + Align labels which are only reached by jumping. +@@ -2165,6 +2162,10 @@ fmessage-length= + Common RejectNegative Joined UInteger + -fmessage-length= Limit diagnostics to characters per line. 0 suppresses line-wrapping. + ++fmin-function-alignment= ++Common Joined RejectNegative UInteger Var(flag_min_function_alignment) Optimization ++Align the start of every function. ++ + fmodulo-sched + Common Var(flag_modulo_sched) Optimization + Perform SMS based modulo scheduling before the first scheduling pass. +@@ -2489,6 +2490,9 @@ starts and when the destructor finishes. + flifetime-dse= + Common Joined RejectNegative UInteger Var(flag_lifetime_dse) Optimization IntegerRange(0, 2) + ++flimit-function-alignment ++Common Var(flag_limit_function_alignment) Optimization Init(0) ++ + flive-patching + Common RejectNegative Alias(flive-patching=,inline-clone) Optimization + +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index b777fc92755..d39cb26326c 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -531,6 +531,7 @@ Objective-C and Objective-C++ Dialects}. + -falign-jumps[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] + -falign-labels[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] + -falign-loops[=@var{n}[:@var{m}:[@var{n2}[:@var{m2}]]]] ++-fmin-function-alignment=[@var{n}] + -fno-allocation-dce -fallow-store-data-races + -fassociative-math -fauto-profile -fauto-profile[=@var{path}] + -fauto-inc-dec -fbranch-probabilities +@@ -13650,6 +13651,9 @@ Align the start of functions to the next power-of-two greater than or + equal to @var{n}, skipping up to @var{m}-1 bytes. This ensures that at + least the first @var{m} bytes of the function can be fetched by the CPU + without crossing an @var{n}-byte alignment boundary. ++This is an optimization of code performance and alignment is ignored for ++functions considered cold. If alignment is required for all functions, ++use @option{-fmin-function-alignment}. + + If @var{m} is not specified, it defaults to @var{n}. + +@@ -13713,6 +13717,8 @@ Enabled at levels @option{-O2}, @option{-O3}. + Align loops to a power-of-two boundary. If the loops are executed + many times, this makes up for any execution of the dummy padding + instructions. ++This is an optimization of code performance and alignment is ignored for ++loops considered cold. + + If @option{-falign-labels} is greater than this value, then its value + is used instead. +@@ -13735,6 +13741,8 @@ Enabled at levels @option{-O2}, @option{-O3}. + Align branch targets to a power-of-two boundary, for branch targets + where the targets can only be reached by jumping. In this case, + no dummy operations need be executed. ++This is an optimization of code performance and alignment is ignored for ++jumps considered cold. + + If @option{-falign-labels} is greater than this value, then its value + is used instead. +@@ -13748,6 +13756,14 @@ The maximum allowed @var{n} option value is 65536. + + Enabled at levels @option{-O2}, @option{-O3}. + ++@opindex fmin-function-alignment=@var{n} ++@item -fmin-function-alignment ++Specify minimal alignment of functions to the next power-of-two greater than or ++equal to @var{n}. Unlike @option{-falign-functions} this alignment is applied ++also to all functions (even those considered cold). The alignment is also not ++affected by @option{-flimit-function-alignment} ++ ++ + @opindex fno-allocation-dce + @item -fno-allocation-dce + Do not remove unused C++ allocations in dead code elimination. +@@ -13844,7 +13860,7 @@ To use the link-time optimizer, @option{-flto} and optimization + options should be specified at compile time and during the final link. + It is recommended that you compile all the files participating in the + same link with the same options and also specify those options at +-link time. ++link time. + For example: + + @smallexample +diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h +index 75cebcd02d3..2827897cc7a 100644 +--- a/gcc/lto-streamer.h ++++ b/gcc/lto-streamer.h +@@ -122,7 +122,7 @@ along with GCC; see the file COPYING3. If not see + form followed by the data for the string. */ + + #define LTO_major_version GCC_major_version +-#define LTO_minor_version 1 ++#define LTO_minor_version 2 + + typedef unsigned char lto_decl_flags_t; + +diff --git a/gcc/varasm.cc b/gcc/varasm.cc +index cd0cd88321c..5de821b63e6 100644 +--- a/gcc/varasm.cc ++++ b/gcc/varasm.cc +@@ -1914,6 +1914,11 @@ assemble_start_function (tree decl, const char *fnname) + + /* Tell assembler to move to target machine's alignment for functions. */ + align = floor_log2 (align / BITS_PER_UNIT); ++ /* Handle forced alignment. This really ought to apply to all functions, ++ since it is used by patchable entries. */ ++ if (flag_min_function_alignment) ++ align = MAX (align, floor_log2 (flag_min_function_alignment)); ++ + if (align > 0) + { + ASM_OUTPUT_ALIGN (asm_out_file, align); +-- +2.35.3 + diff --git a/gcc13-rpmlintrc b/gcc13-rpmlintrc new file mode 100644 index 0000000..f40af91 --- /dev/null +++ b/gcc13-rpmlintrc @@ -0,0 +1,19 @@ +# 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") +# SLE12 rpmlint complains about valid SPDX licenses +addFilter ("invalid-license") diff --git a/gcc13-rs6000-Adjust-fpatchable-function-entry.patch b/gcc13-rs6000-Adjust-fpatchable-function-entry.patch new file mode 100644 index 0000000..fc4af5d --- /dev/null +++ b/gcc13-rs6000-Adjust-fpatchable-function-entry.patch @@ -0,0 +1,265 @@ +From 8926dc1cbe8fa3b9ae35bf03ec503bbc40f9cf37 Mon Sep 17 00:00:00 2001 +From: Giuliano Belinassi +Date: Thu, 25 Jul 2024 11:54:22 -0300 +Subject: [PATCH] Backport rs6000: Adjust -fpatchable-function-entry* support + for dual entry + +Original message: +As the discussion in PR112980, although the current +implementation for -fpatchable-function-entry* conforms +with the documentation (making N NOPs be consecutive), +it's inefficient for both kernel and userspace livepatching +(see comments in PR for the details). + +So this patch is to change the current implementation by +emitting the "before" NOPs before global entry point and +the "after" NOPs after local entry point. The new behavior +would not keep NOPs to be consecutive, so the documentation +is updated to emphasize this + +Backport to gcc-13 + +Authored-by: Kewen Lin +Backported-by: Giuliano Belinassi + + PR target/112980 + +gcc/ChangeLog: + + * config/rs6000/rs6000-logue.cc (rs6000_output_function_prologue): + Adjust the handling on patch area emitting with dual entry, remove + the restriction on "before" NOPs count, not emit "before" NOPs any + more but only emit "after" NOPs. + * config/rs6000/rs6000.cc (rs6000_print_patchable_function_entry): + Adjust by respecting cfun->machine->stop_patch_area_print. + (rs6000_elf_declare_function_name): For ELFv2 with dual entry, set + cfun->machine->stop_patch_area_print as true. + * config/rs6000/rs6000.h (struct machine_function): Remove member + global_entry_emitted, add new member stop_patch_area_print. + * doc/invoke.texi (option -fpatchable-function-entry): Adjust the + documentation for PowerPC ELFv2 dual entry. + +gcc/testsuite/ChangeLog: + + * c-c++-common/patchable_function_entry-default.c: Adjust. + * gcc.target/powerpc/pr99888-4.c: Likewise. + * gcc.target/powerpc/pr99888-5.c: Likewise. + * gcc.target/powerpc/pr99888-6.c: Likewise. + +Signed-off-by: Giuliano Belinassi +--- + gcc/config/rs6000/rs6000-logue.cc | 40 +++++-------------- + gcc/config/rs6000/rs6000.cc | 15 +++++-- + gcc/config/rs6000/rs6000.h | 10 +++-- + gcc/doc/invoke.texi | 8 ++-- + .../patchable_function_entry-default.c | 3 -- + gcc/testsuite/gcc.target/powerpc/pr99888-4.c | 4 +- + gcc/testsuite/gcc.target/powerpc/pr99888-5.c | 4 +- + gcc/testsuite/gcc.target/powerpc/pr99888-6.c | 4 +- + 8 files changed, 33 insertions(+), 55 deletions(-) + +diff --git a/gcc/config/rs6000/rs6000-logue.cc b/gcc/config/rs6000/rs6000-logue.cc +index 208404e6864..3835bc943ad 100644 +--- a/gcc/config/rs6000/rs6000-logue.cc ++++ b/gcc/config/rs6000/rs6000-logue.cc +@@ -4001,43 +4001,21 @@ rs6000_output_function_prologue (FILE *file) + fprintf (file, "\tadd 2,2,12\n"); + } + +- unsigned short patch_area_size = crtl->patch_area_size; +- unsigned short patch_area_entry = crtl->patch_area_entry; +- /* Need to emit the patching area. */ +- if (patch_area_size > 0) +- { +- cfun->machine->global_entry_emitted = true; +- /* As ELFv2 ABI shows, the allowable bytes between the global +- and local entry points are 0, 4, 8, 16, 32 and 64 when +- there is a local entry point. Considering there are two +- non-prefixed instructions for global entry point prologue +- (8 bytes), the count for patchable nops before local entry +- point would be 2, 6 and 14. It's possible to support those +- other counts of nops by not making a local entry point, but +- we don't have clear use cases for them, so leave them +- unsupported for now. */ +- if (patch_area_entry > 0) +- { +- if (patch_area_entry != 2 +- && patch_area_entry != 6 +- && patch_area_entry != 14) +- error ("unsupported number of nops before function entry (%u)", +- patch_area_entry); +- rs6000_print_patchable_function_entry (file, patch_area_entry, +- true); +- patch_area_size -= patch_area_entry; +- } +- } +- + fputs ("\t.localentry\t", file); + assemble_name (file, name); + fputs (",.-", file); + assemble_name (file, name); + fputs ("\n", file); + /* Emit the nops after local entry. */ +- if (patch_area_size > 0) +- rs6000_print_patchable_function_entry (file, patch_area_size, +- patch_area_entry == 0); ++ unsigned short patch_area_size = crtl->patch_area_size; ++ unsigned short patch_area_entry = crtl->patch_area_entry; ++ if (patch_area_size > patch_area_entry) ++ { ++ cfun->machine->stop_patch_area_print = false; ++ patch_area_size -= patch_area_entry; ++ rs6000_print_patchable_function_entry (file, patch_area_size, ++ patch_area_entry == 0); ++ } + } + + else if (rs6000_pcrel_p ()) +diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc +index 2b876c90e6f..a08ed7466dd 100644 +--- a/gcc/config/rs6000/rs6000.cc ++++ b/gcc/config/rs6000/rs6000.cc +@@ -14936,12 +14936,14 @@ rs6000_print_patchable_function_entry (FILE *file, + bool record_p) + { + bool global_entry_needed_p = rs6000_global_entry_point_prologue_needed_p (); +- /* For a function which needs global entry point, we will emit the +- patchable area before and after local entry point under the control of +- cfun->machine->global_entry_emitted, see the handling in function ++ /* For a function which needs global entry point, we will only emit the ++ patchable area after local entry point under the control of ++ !cfun->machine->stop_patch_area_print, see the handling in functions + rs6000_output_function_prologue. */ +- if (!global_entry_needed_p || cfun->machine->global_entry_emitted) ++ if (!cfun->machine->stop_patch_area_print) + default_print_patchable_function_entry (file, patch_area_size, record_p); ++ else ++ gcc_assert (global_entry_needed_p); + } + + enum rtx_code +@@ -21115,6 +21117,11 @@ rs6000_elf_declare_function_name (FILE *file, const char *name, tree decl) + fprintf (file, "\t.previous\n"); + } + ASM_OUTPUT_LABEL (file, name); ++ /* At this time, the "before" NOPs have been already emitted, ++ let's stop generic code from printing the "after" NOPs and ++ emit just after local entry later. */ ++ if (rs6000_global_entry_point_prologue_needed_p ()) ++ cfun->machine->stop_patch_area_print = true; + } + + static void rs6000_elf_file_end (void) ATTRIBUTE_UNUSED; +diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h +index 9f02025b0c8..ebe97beb182 100644 +--- a/gcc/config/rs6000/rs6000.h ++++ b/gcc/config/rs6000/rs6000.h +@@ -2437,10 +2437,12 @@ typedef struct GTY(()) machine_function + bool lr_is_wrapped_separately; + bool toc_is_wrapped_separately; + bool mma_return_type_error; +- /* Indicate global entry is emitted, only useful when the function requires +- global entry. It helps to control the patchable area before and after +- local entry. */ +- bool global_entry_emitted; ++ /* With ELFv2 ABI dual entry points being adopted, generic framework ++ targetm.asm_out.print_patchable_function_entry would generate "after" ++ NOPs before local entry, it is wrong. This flag is to stop it from ++ printing patch area before local entry, it is only useful when the ++ function requires dual entry points. */ ++ bool stop_patch_area_print; + } machine_function; + #endif + +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index b17d0cf9341..0cdc5ac8c61 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -17449,11 +17449,11 @@ If @code{N=0}, no pad location is recorded. + The NOP instructions are inserted at---and maybe before, depending on + @var{M}---the function entry address, even before the prologue. On + PowerPC with the ELFv2 ABI, for a function with dual entry points, +-the local entry point is this function entry address. ++@var{M} NOP instructions are inserted before the global entry point and ++@var{N} - @var{M} NOP instructions are inserted after the local entry ++point, which means the NOP instructions may not be consecutive. + +-The maximum value of @var{N} and @var{M} is 65535. On PowerPC with the +-ELFv2 ABI, for a function with dual entry points, the supported values +-for @var{M} are 0, 2, 6 and 14. ++The maximum value of @var{N} and @var{M} is 65535. + @end table + + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +index 3ccbafc87db..899938b4aa3 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,9 +1,6 @@ + /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ + /* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ +-/* See PR99888, one single preceding nop isn't allowed on powerpc_elfv2, +- so overriding with two preceding nops to make it pass there. */ +-/* { dg-additional-options "-fpatchable-function-entry=3,2" { target powerpc_elfv2 } } */ + /* { dg-final { scan-assembler-times "nop|NOP|SWYM" 3 { target { ! { alpha*-*-* riscv*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ + /* { dg-final { scan-assembler-times "nop\n" 3 { target riscv*-*-* } } } */ +diff --git a/gcc/testsuite/gcc.target/powerpc/pr99888-4.c b/gcc/testsuite/gcc.target/powerpc/pr99888-4.c +index 00a8d4d316e..6f23f2bb939 100644 +--- a/gcc/testsuite/gcc.target/powerpc/pr99888-4.c ++++ b/gcc/testsuite/gcc.target/powerpc/pr99888-4.c +@@ -2,12 +2,10 @@ + /* There is no global entry point prologue with pcrel. */ + /* { dg-options "-mno-pcrel -fpatchable-function-entry=1,1" } */ + +-/* Verify one error emitted for unexpected 1 nop before local +- entry. */ ++/* Verify there is no error with 1 nop before local entry. */ + + extern int a; + + int test (int b) { + return a + b; + } +-/* { dg-error "unsupported number of nops before function entry \\(1\\)" "" { target *-*-* } .-1 } */ +diff --git a/gcc/testsuite/gcc.target/powerpc/pr99888-5.c b/gcc/testsuite/gcc.target/powerpc/pr99888-5.c +index 39d3b4465f1..13f192ebd20 100644 +--- a/gcc/testsuite/gcc.target/powerpc/pr99888-5.c ++++ b/gcc/testsuite/gcc.target/powerpc/pr99888-5.c +@@ -2,12 +2,10 @@ + /* There is no global entry point prologue with pcrel. */ + /* { dg-options "-mno-pcrel -fpatchable-function-entry=7,3" } */ + +-/* Verify one error emitted for unexpected 3 nops before local +- entry. */ ++/* Verify no error emitted for 3 nops before local entry. */ + + extern int a; + + int test (int b) { + return a + b; + } +-/* { dg-error "unsupported number of nops before function entry \\(3\\)" "" { target *-*-* } .-1 } */ +diff --git a/gcc/testsuite/gcc.target/powerpc/pr99888-6.c b/gcc/testsuite/gcc.target/powerpc/pr99888-6.c +index c6c18dcc7ac..431c69cae9a 100644 +--- a/gcc/testsuite/gcc.target/powerpc/pr99888-6.c ++++ b/gcc/testsuite/gcc.target/powerpc/pr99888-6.c +@@ -2,8 +2,7 @@ + /* There is no global entry point prologue with pcrel. */ + /* { dg-options "-mno-pcrel" } */ + +-/* Verify one error emitted for unexpected 4 nops before local +- entry. */ ++/* Verify no error emitted for 4 nops before local entry. */ + + extern int a; + +@@ -11,4 +10,3 @@ __attribute__ ((patchable_function_entry (20, 4))) + int test (int b) { + return a + b; + } +-/* { dg-error "unsupported number of nops before function entry \\(4\\)" "" { target *-*-* } .-1 } */ +-- +2.45.2 + diff --git a/gcc13-sanitizer-remove-crypt-interception.patch b/gcc13-sanitizer-remove-crypt-interception.patch new file mode 100644 index 0000000..16f68c3 --- /dev/null +++ b/gcc13-sanitizer-remove-crypt-interception.patch @@ -0,0 +1,142 @@ +From b9ab7f38227b8980b09537ed1fc45632d7b4b0ea Mon Sep 17 00:00:00 2001 +From: Fangrui Song +Date: Fri, 28 Apr 2023 09:59:17 -0700 +Subject: [PATCH] Remove crypt and crypt_r interceptors +To: gcc-patches@gcc.gnu.org + +From Florian Weimer's D144073 + +> On GNU/Linux (glibc), the crypt and crypt_r functions are not part of the main shared object (libc.so.6), but libcrypt (with multiple possible sonames). The sanitizer libraries do not depend on libcrypt, so it can happen that during sanitizer library initialization, no real implementation will be found because the crypt, crypt_r functions are not present in the process image (yet). If its interceptors are called nevertheless, this results in a call through a null pointer when the sanitizer library attempts to forward the call to the real implementation. +> +> Many distributions have already switched to libxcrypt, a library that is separate from glibc and that can be build with sanitizers directly (avoiding the need for interceptors). This patch disables building the interceptor for glibc targets. + +Let's remove crypt and crypt_r interceptors (D68431) to fix issues with +newer glibc. + +For older glibc, msan will not know that an uninstrumented crypt_r call +initializes `data`, so there is a risk for false positives. However, with some +codebase survey, I think crypt_r uses are very few and the call sites typically +have a `memset(&data, 0, sizeof(data));` anyway. + +Fix https://github.com/google/sanitizers/issues/1365 +Related: https://bugzilla.redhat.com/show_bug.cgi?id=2169432 + +Reviewed By: #sanitizers, fweimer, thesamesam, vitalybuka + +Differential Revision: https://reviews.llvm.org/D149403 +--- + .../sanitizer_common_interceptors.inc | 37 ------------------- + .../sanitizer_platform_interceptors.h | 2 - + .../sanitizer_platform_limits_posix.cpp | 8 ---- + .../sanitizer_platform_limits_posix.h | 1 - + 4 files changed, 48 deletions(-) + +diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc +index ba4b80081f0..662c4199742 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc ++++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc +@@ -10187,41 +10187,6 @@ INTERCEPTOR(SSIZE_T, getrandom, void *buf, SIZE_T buflen, unsigned int flags) { + #define INIT_GETRANDOM + #endif + +-#if SANITIZER_INTERCEPT_CRYPT +-INTERCEPTOR(char *, crypt, char *key, char *salt) { +- void *ctx; +- COMMON_INTERCEPTOR_ENTER(ctx, crypt, key, salt); +- COMMON_INTERCEPTOR_READ_RANGE(ctx, key, internal_strlen(key) + 1); +- COMMON_INTERCEPTOR_READ_RANGE(ctx, salt, internal_strlen(salt) + 1); +- char *res = REAL(crypt)(key, salt); +- if (res != nullptr) +- COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, internal_strlen(res) + 1); +- return res; +-} +-#define INIT_CRYPT COMMON_INTERCEPT_FUNCTION(crypt); +-#else +-#define INIT_CRYPT +-#endif +- +-#if SANITIZER_INTERCEPT_CRYPT_R +-INTERCEPTOR(char *, crypt_r, char *key, char *salt, void *data) { +- void *ctx; +- COMMON_INTERCEPTOR_ENTER(ctx, crypt_r, key, salt, data); +- COMMON_INTERCEPTOR_READ_RANGE(ctx, key, internal_strlen(key) + 1); +- COMMON_INTERCEPTOR_READ_RANGE(ctx, salt, internal_strlen(salt) + 1); +- char *res = REAL(crypt_r)(key, salt, data); +- if (res != nullptr) { +- COMMON_INTERCEPTOR_WRITE_RANGE(ctx, data, +- __sanitizer::struct_crypt_data_sz); +- COMMON_INTERCEPTOR_INITIALIZE_RANGE(res, internal_strlen(res) + 1); +- } +- return res; +-} +-#define INIT_CRYPT_R COMMON_INTERCEPT_FUNCTION(crypt_r); +-#else +-#define INIT_CRYPT_R +-#endif +- + #if SANITIZER_INTERCEPT_GETENTROPY + INTERCEPTOR(int, getentropy, void *buf, SIZE_T buflen) { + void *ctx; +@@ -10772,8 +10737,6 @@ static void InitializeCommonInterceptors() { + INIT_GETUSERSHELL; + INIT_SL_INIT; + INIT_GETRANDOM; +- INIT_CRYPT; +- INIT_CRYPT_R; + INIT_GETENTROPY; + INIT_QSORT; + INIT_QSORT_R; +diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h +index 8307b1ec28b..d50166ee6ce 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_interceptors.h +@@ -571,8 +571,6 @@ + #define SANITIZER_INTERCEPT_FDEVNAME SI_FREEBSD + #define SANITIZER_INTERCEPT_GETUSERSHELL (SI_POSIX && !SI_ANDROID) + #define SANITIZER_INTERCEPT_SL_INIT (SI_FREEBSD || SI_NETBSD) +-#define SANITIZER_INTERCEPT_CRYPT (SI_POSIX && !SI_ANDROID) +-#define SANITIZER_INTERCEPT_CRYPT_R (SI_LINUX && !SI_ANDROID) + + #define SANITIZER_INTERCEPT_GETRANDOM \ + ((SI_LINUX && __GLIBC_PREREQ(2, 25)) || SI_FREEBSD) +diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp +index c85cf1626a7..bcbd143d19d 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp +@@ -176,10 +176,6 @@ typedef struct user_fpregs elf_fpregset_t; + # include "sanitizer_platform_interceptors.h" + # include "sanitizer_platform_limits_posix.h" + +-#if SANITIZER_INTERCEPT_CRYPT_R +-#include +-#endif +- + namespace __sanitizer { + unsigned struct_utsname_sz = sizeof(struct utsname); + unsigned struct_stat_sz = sizeof(struct stat); +@@ -283,10 +279,6 @@ namespace __sanitizer { + unsigned struct_statvfs64_sz = sizeof(struct statvfs64); + #endif // SANITIZER_LINUX && !SANITIZER_ANDROID + +-#if SANITIZER_INTERCEPT_CRYPT_R +- unsigned struct_crypt_data_sz = sizeof(struct crypt_data); +-#endif +- + #if SANITIZER_LINUX && !SANITIZER_ANDROID + unsigned struct_timex_sz = sizeof(struct timex); + unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds); +diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +index 44dd3d9e22d..29ebb304a9b 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +@@ -319,7 +319,6 @@ extern unsigned struct_msqid_ds_sz; + extern unsigned struct_mq_attr_sz; + extern unsigned struct_timex_sz; + extern unsigned struct_statvfs_sz; +-extern unsigned struct_crypt_data_sz; + #endif // SANITIZER_LINUX && !SANITIZER_ANDROID + + struct __sanitizer_iovec { +-- +2.35.3 + diff --git a/gcc13-testresults-rpmlintrc b/gcc13-testresults-rpmlintrc new file mode 100644 index 0000000..070221b --- /dev/null +++ b/gcc13-testresults-rpmlintrc @@ -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") diff --git a/gcc13-testresults.spec b/gcc13-testresults.spec new file mode 100644 index 0000000..aaca531 --- /dev/null +++ b/gcc13-testresults.spec @@ -0,0 +1,1026 @@ +# +# spec file for package gcc13-testresults +# +# Copyright (c) 2024 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%{?suse_version} < 1550 +%define _slibdir /%{_lib} +%define slibdir /lib +%define slibdir64 /lib64 +%else +%define _slibdir %{_libdir} +%define slibdir %{_prefix}/lib +%define slibdir64 %{_prefix}/lib64 +%define usrmerged 1 +%endif + +%bcond_without bootstrap + +# 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 x86_64 +%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 + +%define build_m2 1 + +%if %{build_objcp} +%define build_cp 1 +%define build_objc 1 +%endif + +%define build_rust 0 + +# 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 +%define build_rust 0 +%define build_m2 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 %{with bootstrap} +%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 + +# Limit the number of parallel jobs to avoid OOM +%bcond_without limitbuild + +# 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 22 +%define libgphobos_sover 4 +%define libgdruntime_sover 4 +%define libgccjit_sover 0 +%define libm2_sover 18 + +# 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}} +%define libm2_suffix %{plv libm2 %{libm2_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.3.1+git8964 +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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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 +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{?run_tests:1} +BuildRequires: dejagnu +BuildRequires: expect +BuildRequires: gdb +BuildRequires: timezone +%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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 +%if %{with bootstrap} +%define use_pgo_bootstrap 1 +%endif +%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 diff --git a/gcc13.changes b/gcc13.changes new file mode 100644 index 0000000..59cd35c --- /dev/null +++ b/gcc13.changes @@ -0,0 +1,519 @@ +------------------------------------------------------------------- +Wed Oct 16 13:32:36 UTC 2024 - Richard Biener + +- Add gcc13-pr116657.patch to fix for parsing tzdata 2024b [gcc#116657] + +------------------------------------------------------------------- +Wed Aug 7 09:32:00 UTC 2024 - Richard Biener + +- Update to gcc-13 branch head, 9d368828bd4d04ce507e02a581, git8964 + * includes fix for samba build with glibc 2.40 + +------------------------------------------------------------------- +Thu Jul 25 17:29:02 UTC 2024 - Giuliano Belinassi + +- Add gcc13-rs6000-Adjust-fpatchable-function-entry.patch to fix + the incorrect NOPs layout when -fpatchable-function-enry is passed + in ppc64le. + +------------------------------------------------------------------- +Tue May 21 08:56:28 UTC 2024 - Richard Biener + +- Update to GCC 13.3 release + +------------------------------------------------------------------- +Fri May 10 12:33:27 UTC 2024 - Richard Biener + +- Update to gcc-13 branch head, b7a2697733d19a093cbdd0e200, git8761 +- Removed gcc13-pr111731.patch now included upstream + +------------------------------------------------------------------- +Thu May 2 08:19:50 UTC 2024 - Richard Biener + +- Add gcc13-amdgcn-remove-fiji.patch removing Fiji support from + the GCN offload compiler as that is requiring Code Object version 3 + which is no longer supported by llvm18. + +------------------------------------------------------------------- +Thu Apr 4 07:43:17 UTC 2024 - Richard Biener + +- Add gcc13-pr101523.patch to avoid combine spending too much + compile-time and memory doing nothing on s390x. [boo#1188441] + +------------------------------------------------------------------- +Wed Mar 27 12:11:03 UTC 2024 - Richard Biener + +- Make requirement to lld version specific to avoid requiring the + meta-package. + +------------------------------------------------------------------- +Wed Mar 20 08:29:09 UTC 2024 - Richard Biener + +- Add gcc13-pr111731.patch to fix unwinding for JIT code. + [bsc#1221239] + +------------------------------------------------------------------- +Wed Mar 13 08:04:27 UTC 2024 - Richard Biener + +- Revert libgccjit dependency change. [boo#1220724] + +------------------------------------------------------------------- +Tue Mar 5 14:35:38 UTC 2024 - Richard Biener + +- Fix libgccjit-devel dependency, a newer shared library is OK. +- Fix libgccjit dependency, the corresponding compiler isn't required. + +------------------------------------------------------------------- +Thu Feb 22 14:50:13 UTC 2024 - Richard Biener + +- Use %patch -P N instead of %patchN. + +------------------------------------------------------------------- +Thu Feb 8 08:17:53 UTC 2024 - Richard Biener + +- Add gcc13-sanitizer-remove-crypt-interception.patch to remove + crypt and crypt_r interceptors. The crypt API change in SLE15 SP3 + breaks them. [bsc#1219520] + +------------------------------------------------------------------- +Tue Feb 6 08:04:04 UTC 2024 - Richard Biener + +- Update to gcc-13 branch head, 67ac78caf31f7cb3202177e642, git8285 +- Add gcc13-pr88345-min-func-alignment.diff to add support for + -fmin-function-alignment. [bsc#1214934] + +------------------------------------------------------------------- +Mon Feb 5 14:24:16 UTC 2024 - Richard Biener + +- Use %{_target_cpu} to determine host and build. + +------------------------------------------------------------------- +Thu Jan 25 07:59:39 UTC 2024 - Richard Biener + +- Update to gcc-13 branch head, fc7d87e0ffadca49bec29b2107, git8250 + * Includes fix for building TVM. [boo#1218492] + +------------------------------------------------------------------- +Mon Jan 22 10:05:20 UTC 2024 - Richard Biener + +- Add cross-X-newlib-devel requires to newlib cross compilers. + [boo#1219031] + +------------------------------------------------------------------- +Thu Jan 18 14:14:46 UTC 2024 - Richard Biener + +- Package m2rte.so plugin in the gcc13-m2 sub-package rather than + in gcc13-devel. [boo#1210959] +- Require libstdc++6-devel-gcc13 from gcc13-m2 as m2 programs + are linked against libstdc++6. + +------------------------------------------------------------------- +Tue Jan 9 14:20:57 UTC 2024 - Richard Biener + +- Update to gcc-13 branch head, 36ddb5230f56a30317630a928, git8205 + +------------------------------------------------------------------- +Thu Nov 30 11:43:17 UTC 2023 - Richard Biener + +- Update to gcc-13 branch head, 741743c028dc00f27b9c8b1d5, git8109 + * Includes fix for building mariadb on i686. [bsc#1217667] + * Remove pr111411.patch contained in the update. + +------------------------------------------------------------------- +Fri Nov 24 08:49:50 UTC 2023 - Richard Biener + +- Avoid update-alternatives dependency for accelerator crosses. +- Package tool links to llvm in cross-amdgcn-gcc13 rather than in + cross-amdgcn-newlib13-devel since that also has the dependence. +- Depend on llvmVER instead of llvm with VER equal to + %product_libs_llvm_ver where available and adjust tool discovery + accordingly. This should also properly trigger re-builds when + the patchlevel version of llvmVER changes, possibly changing + the binary names we link to. [bsc#1217450] + +------------------------------------------------------------------- +Tue Nov 7 12:57:49 UTC 2023 - Richard Biener + +- Add gcc13-bsc1216664.patch, works around SAP ASE DB crash during + C++ standard library initialization. [bsc#1216664] + +------------------------------------------------------------------- +Fri Sep 22 08:07:30 UTC 2023 - Dirk Müller + +- add pr111411.patch (bsc#1215427) + +------------------------------------------------------------------- +Tue Sep 12 17:52:25 UTC 2023 - Richard Biener + +- Bump to b96e66fd4ef3e36983969fb8cdd1956f551a074b, git7831 + * Includes many bugfixes + * Includes fix to -fstack-protector issues with variable + length stack allocations on aarch64. [bsc#1214052] (CVE-2023-4039) + +------------------------------------------------------------------- +Mon Aug 28 07:59:17 UTC 2023 - Richard Biener + +- Disable building glibc cross compilers on SLE based code streams, + the required cross-glibc packages are not available there. +- Disable building avr cross on non-openSUSE code streams since + avr-libc isn't available there. +- Disable building newlib cross compilers on non-openSUSE code streams + since newlib isn't available there. +- Fix typo preventing s390x compiler build. +- Raise s390x architecture baseline to z14 for ALP. [PED-253] +- Turn cross compiler to ppc64le to a glibc cross. + +------------------------------------------------------------------- +Wed Aug 23 06:50:07 UTC 2023 - Richard Biener + +- Turn cross compiler to s390x to a glibc cross. [bsc#1214460] + +------------------------------------------------------------------- +Fri Aug 18 13:03:36 UTC 2023 - Michal Suchanek + +- Raise Power architecture baseline to Power9 only for ALP (boo#1213915). + +------------------------------------------------------------------- +Thu Aug 3 13:34:26 UTC 2023 - Richard Biener + +- Bump to cc279d6c64562f05019e1d12d0d825f9391b5553, git7683 + * Includes GCC 13.2 release + * Includes patch to fix broken testcase in libbacktrace, fixing + build problems on SLES 12 + +------------------------------------------------------------------- +Wed Aug 2 08:01:18 UTC 2023 - Andreas Schwab + +- gdcflags.patch: Use substituted GDCFLAGS +- Filter out -Werror=return-type from D compile flags + +------------------------------------------------------------------- +Thu Jul 20 09:04:51 UTC 2023 - Richard Biener + +- Bump to 9aac37ab8a7b919a89c6d64bc7107a8436996e93, git7597 + * GCC 13.2 RC1 +- Add rpmlint filter for SLE12 complaining about invalid licenses. + +------------------------------------------------------------------- +Tue Jul 11 14:33:29 UTC 2023 - Andreas Schwab + +- Also handle -static-pie in the default-PIE specs + +------------------------------------------------------------------- +Mon Jul 10 08:12:40 UTC 2023 - Richard Biener + +- Bump to f9781fcf733ca3afe5b5811afd8ecbb18d9d3a11, git7552 +- Remove gcc13-pr110334.patch again as it breaks libreoffice build. + +------------------------------------------------------------------- +Wed Jun 28 06:56:52 UTC 2023 - Richard Biener + +- Bump to a533ded17fb13cbbb2fa5133ecd470360f66c5cf, git7489. +- Add gcc13-pr110334.patch to fix missed optimization in Skia + resulting in Firefox crashes when building with LTO. [boo#1212101] + +------------------------------------------------------------------- +Tue Jun 13 09:22:50 UTC 2023 - Richard Biener + +- Raise architecture levels for ALP. [PED-153] + * Raise POWER architecture baseline to power9. [PED-2005] + * Raise x86-64 architecture baseline to x86-64-v2 for ALP. [PED-252] + * Delay raising s390x architecture baseline to z14. [PED-253] + +------------------------------------------------------------------- +Mon May 22 09:05:30 UTC 2023 - Richard Biener + +- Bump to dd36656ada05731c069ecd5b1878380294fb1f3e, git7364. + * Includes the RISC-V atomic changes +- Remove riscv-atomic.patch and riscv-pthread.patch now included +- Make libstdc++6-devel packages own their directories since they + can be installed standalone. [bsc#1211427] + +------------------------------------------------------------------- +Thu Apr 27 07:29:05 UTC 2023 - Richard Biener + +- Bump to 910735c5d7ce7607384fc1eec4189e90c8ae5c84, git7256. + * Includes GCC 13.1 release and first bugfixes +- Update riscv-atomic.patch from the version committed upstream. + +------------------------------------------------------------------- +Fri Apr 21 06:46:36 UTC 2023 - Richard Biener + +- Bump to f980561c60b0446cc427595198d7f3f4f90e0924, git7231. + * fixes compile-time issue reported in [bsc#1210557] + * GCC 13.1 RC3 +- Disable building the rust frontend. + +------------------------------------------------------------------- +Wed Apr 12 21:15:13 UTC 2023 - Martin Liška + +- Bump to d339e9802f758e051b0a1ef6db732ff846cbf4e3, git7162. + +------------------------------------------------------------------- +Tue Apr 11 08:58:11 UTC 2023 - Martin Liška + +- Add new x86-related intrinsics (amxcomplexintrin.h). + +------------------------------------------------------------------- +Tue Apr 11 08:29:47 UTC 2023 - Andreas Schwab + +- riscv-atomic.patch: RISC-V: Add support for inlining subword atomic + operations +- riscv-pthread.patch: Don't add -latomic with -pthread + + +------------------------------------------------------------------- +Tue Apr 4 07:02:21 UTC 2023 - Martin Liška + +- Bump to d0b961b802dd7d9d555ff4515835a479329326e9, git6995. + +------------------------------------------------------------------- +Fri Mar 24 14:44:48 UTC 2023 - Guillaume GARDET + +- Add %limit_build for gcc13 to avoid OOM + +------------------------------------------------------------------- +Fri Mar 24 13:37:38 UTC 2023 - Martin Liška + +- Use --enable-link-serialization rather that --enable-link-mutex, + the benefit of the former one is that the linker jobs are not + holding tokens of the make's jobserver. + +------------------------------------------------------------------- +Thu Mar 23 22:14:59 UTC 2023 - Martin Liška + +- Bump to c4792bd1de0621932a47fb86aca09fafafdb2972, git6840. + +------------------------------------------------------------------- +Tue Mar 21 10:45:33 UTC 2023 - Richard Biener + +- Add cross-bpf packages. See https://gcc.gnu.org/wiki/BPFBackEnd + for the general state of BPF with GCC. + +------------------------------------------------------------------- +Tue Mar 21 08:39:35 UTC 2023 - Martin Liška + +- Bump to 5f413dc41ee4f8bc3a0fc295f98b75dceae52fa8, git6773. + +------------------------------------------------------------------- +Mon Feb 27 10:25:35 UTC 2023 - Richard Biener + +- Always enable the link mutex. + +------------------------------------------------------------------- +Mon Feb 27 08:34:33 UTC 2023 - Martin Liška + +- Bump to 529e03b9882fe48cfa3c182abb12a5858a5762a2, git6353. + +------------------------------------------------------------------- +Thu Feb 23 10:26:27 UTC 2023 - Martin Liška + +- Rebase gcc44-rename-info-files.patch patch. + +------------------------------------------------------------------- +Fri Jan 27 10:35:15 UTC 2023 - Martin Liška + +- Add support for new front-ends Rust and Modula-2. +- Align _multibuild order with gcc12 package. +- Bump to ca8fb0096713a8477614ef874f16ba5bf16c48bc, git5428. + +------------------------------------------------------------------- +Mon Jan 23 15:19:53 UTC 2023 - Richard Biener + +- Add bootstrap conditional to allow --without=bootstrap to be + specified to speed up local builds for testing. + +------------------------------------------------------------------- +Mon Jan 23 08:45:24 UTC 2023 - Richard Biener + +- Bump included newlib to version 4.3.0. + +------------------------------------------------------------------- +Thu Jan 19 11:34:00 UTC 2023 - Richard Biener + +- Update to GCC trunk head (r13-5254-g05b9868b182bb9) + * pulls Go frontend fix to fix build fail on s390x + * pulls upstream fix for PR107678, obsoleting gcc13-pr107678.patch +- Also package libhwasan_preinit.o on aarch64. + +------------------------------------------------------------------- +Tue Jan 17 09:30:14 UTC 2023 - Richard Biener + +- Configure external timezone database provided by the timezone + package. Make libstdc++6 recommend timezone to get a fully + working std::chrono. Install timezone when running the testsuite. +- Remove dependence on doxygen and graphviz when building the + testsuite. Those were used to build the libstdc++ API html + documentation but we stopped shipping that when Java support + was removed and nobody noticed. Purge traces of the built + libstdc++6-gccN-doc package. +- Package libhwasan_preinit.o on x86_64. + +------------------------------------------------------------------- +Mon Jan 16 11:59:43 UTC 2023 - Richard Biener + +- Update to GCC trunk head (r13-5199-g2f81164255bf0d) + * pulls changes up to the start of Stage 4 +- Change version numbering to match the commit count from + the git gcc-descr alias +- Add gcc13-pr107678.patch to fix unwinding on aarch64 with + pointer signing. [bsc#1206684] + +------------------------------------------------------------------- +Tue Dec 27 11:13:16 UTC 2022 - Ludwig Nussel + +- Don't rely on %usrmerged, set it based on standard %suse_version + +------------------------------------------------------------------- +Thu Dec 22 08:31:14 UTC 2022 - Matwey Kornilov + +- Enable PRU flavour for gcc13 + +------------------------------------------------------------------- +Mon Dec 19 14:59:32 UTC 2022 - Dirk Müller + +- update floatn fixinclude pickup to check each header separately (bsc#1206480) + +------------------------------------------------------------------- +Wed Dec 14 07:52:36 UTC 2022 - Richard Biener + +- Redo floatn fixinclude pick-up to simply keep what is there. + +------------------------------------------------------------------- +Tue Dec 13 10:34:35 UTC 2022 - Richard Biener + +- Bump to 0a43f7b1a73c8e3b9cefffe430274d0a3d6d3291, git197351. +- Bump libgo SONAME to libgo22. +- Do not package libhwasan for biarch (32-bit architecture) + as the extension depends on 64-bit pointers. +- Sync cross.spec.in changes from gcc12 package. + +------------------------------------------------------------------- +Mon Dec 5 08:01:00 UTC 2022 - Richard Biener + +- Bump to 380d62c14c99d8df13b7a86660e7ee67d01ad827, git197210. +- Adjust floatn fixincludes guard to work with SLE12 and earlier + SLE15. + +------------------------------------------------------------------- +Thu Dec 1 22:09:49 UTC 2022 - Martin Liška + +- Bump to de144fdab17dbbb64ccb540056ab78b4ffb3fbbc, git197173. + +------------------------------------------------------------------- +Thu Dec 1 13:59:05 UTC 2022 - Martin Liška + +- Depend on at least LLVM 13 for GCN cross compiler. + +------------------------------------------------------------------- +Thu Dec 1 05:34:47 UTC 2022 - Martin Liška + +- Bump to 4304e09a1617bcf1c87f5bc96017ae5017379d75, git197155. + +------------------------------------------------------------------- +Thu Dec 1 05:33:14 UTC 2022 - Martin Liška + +- Rebase gcc44-rename-info-files.patch. + +------------------------------------------------------------------- +Wed Nov 30 22:09:37 UTC 2022 - Martin Liška + +- Bump to d13c359a49291f0a1206adbad4065677010b7e4b, git197143. + +------------------------------------------------------------------- +Tue Nov 29 07:06:11 UTC 2022 - Richard Biener + +- 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 + +- Bump to 2b0ae7fb91f64fb005abf7d7903fd4c0764bb45c, git197102. + +------------------------------------------------------------------- +Tue Nov 22 07:14:27 UTC 2022 - Martin Liška + +- Handle new libstdc++exp.a lib. + +------------------------------------------------------------------- +Mon Nov 21 22:09:43 UTC 2022 - Martin Liška + +- Bump to 5c0d171f67d082c353ddc319859111d3b9126c17, git196938. + +------------------------------------------------------------------- +Tue Nov 8 11:32:46 UTC 2022 - Martin Liška + +- Add 2 new headers. + +------------------------------------------------------------------- +Mon Nov 7 23:58:33 UTC 2022 - Martin Liška + +- Bump to b457b779427b0f7b3fbac447811c9c52db5bc79e, git196485. + +------------------------------------------------------------------- +Tue Sep 27 15:32:26 UTC 2022 - Martin Liška + +- Revert --disable-fixincludes due to float128 needed fix. + +------------------------------------------------------------------- +Tue Sep 27 15:14:40 UTC 2022 - Martin Liška + +- Bump to 0b2706ac0e6d6b990d789325f9e081dfe4501f4f, git195623. + +------------------------------------------------------------------- +Wed Aug 31 20:04:10 UTC 2022 - Martin Liška + +- Bump to be9dd80f9334800300a80268dbb92cf3fafcfcf8, git195041. + +------------------------------------------------------------------- +Wed Aug 31 20:02:34 UTC 2022 - Martin Liška + +- Start using --disable-fixincludes. + +------------------------------------------------------------------- +Mon Aug 8 18:33:26 UTC 2022 - Martin Liška + +- 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 + +- Bump to cc01a27db5411a4fe354a97b7c86703c5bc81243, git194700. + +------------------------------------------------------------------- +Thu Apr 28 15:36:41 UTC 2022 - Martin Liška + +- 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 diff --git a/gcc13.spec b/gcc13.spec new file mode 100644 index 0000000..db11437 --- /dev/null +++ b/gcc13.spec @@ -0,0 +1,4166 @@ +# +# spec file for package gcc13 +# +# Copyright (c) 2024 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/ +# + + +%if 0%{?suse_version} < 1550 +%define _slibdir /%{_lib} +%define slibdir /lib +%define slibdir64 /lib64 +%else +%define _slibdir %{_libdir} +%define slibdir %{_prefix}/lib +%define slibdir64 %{_prefix}/lib64 +%define usrmerged 1 +%endif + +%bcond_without bootstrap + +# 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 x86_64 +%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 + +%define build_m2 1 + +%if %{build_objcp} +%define build_cp 1 +%define build_objc 1 +%endif + +%define build_rust 0 + +# 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 +%define build_rust 0 +%define build_m2 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 %{with bootstrap} +%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 + +# Limit the number of parallel jobs to avoid OOM +%bcond_without limitbuild + +# 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 22 +%define libgphobos_sover 4 +%define libgdruntime_sover 4 +%define libgccjit_sover 0 +%define libm2_sover 18 + +# 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}} +%define libm2_suffix %{plv libm2 %{libm2_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.3.1+git8964 +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 +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 +%if %{with limitbuild} +BuildRequires: memory-constraints +%endif +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 +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{?run_tests:1} +BuildRequires: dejagnu +BuildRequires: expect +BuildRequires: gdb +BuildRequires: timezone +%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.3.0.20230120.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 +Patch21: gdcflags.patch +Patch23: gcc13-bsc1216664.patch +Patch24: gcc13-sanitizer-remove-crypt-interception.patch +Patch26: gcc13-pr101523.patch +Patch27: gcc13-amdgcn-remove-fiji.patch +Patch28: gcc13-pr116657.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 +# Feature backports +Patch100: gcc13-pr88345-min-func-alignment.diff +Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.patch + +License: GPL-3.0-or-later +Summary: The GNU C Compiler and Support Files + +%description +Core package for the GNU Compiler Collection, including the C language +frontend. + +Language frontends other than C are split to different sub-packages, +namely gcc-ada, gcc-c++, gcc-fortran, gcc-obj, gcc-obj-c++, gcc-go, +gcc-rust and gcc-m2. + +%package -n gcc13-32bit +Summary: The GNU C Compiler 32bit support +Group: Development/Languages/C and C++ +Requires: gcc13 = %{version}-%{release} +Requires: libgcc_s%{libgcc_s}-32bit >= %{version}-%{release} +Requires: libgomp%{libgomp_sover}-32bit >= %{version}-%{release} +%ifarch %asan_arch +Requires: libasan%{libasan_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %atomic_arch +Requires: libatomic%{libatomic_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %ubsan_arch +Requires: libubsan%{libubsan_sover}-32bit >= %{version}-%{release} +%endif +%ifarch %vtv_arch +Requires: libvtv%{libvtv_sover}-32bit >= %{version}-%{release} +%endif +Requires: glibc-devel-32bit + +%description -n gcc13-32bit +This package contains 32bit support for the GNU Compiler Collection. + +%package -n gcc13-64bit +Summary: The GNU C Compiler 64bit support +Group: Development/Languages/C and C++ +Requires: gcc13 = %{version}-%{release} +Requires: libgcc_s%{libgcc_s}-64bit >= %{version}-%{release} +Requires: libgomp%{libgomp_sover}-64bit >= %{version}-%{release} +%ifarch %asan_arch +Requires: libasan%{libasan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %tsan_arch +Requires: libtsan%{libtsan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %hwasan_arch +Requires: libhwasan%{libhwasan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %atomic_arch +Requires: libatomic%{libatomic_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %lsan_arch +Requires: liblsan%{liblsan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %ubsan_arch +Requires: libubsan%{libubsan_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %vtv_arch +Requires: libvtv%{libvtv_sover}-64bit >= %{version}-%{release} +%endif +Requires: glibc-devel-64bit + +%description -n gcc13-64bit +This package contains 64bit support for the GNU Compiler Collection. + +%package devel +Summary: GCC plugins development enviroment +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc13 = %{version}-%{release} +Requires: gmp-devel +Requires: mpc-devel + +%description devel +Files required for developing and compiling GCC plugins. + +%package locale +Summary: Locale Data for the GNU Compiler Collection +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc13 = %{version}-%{release} + +%description locale +Locale data for the GNU Compiler Collection (GCC) to give error message +in the current locale. + +%package PIE +Summary: A default configuration to build all binaries in PIE mode +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13 = %{version}-%{release} + +%description PIE +This package contains a configuration file (spec) that changes the +compilers default setting to build all ELF binaries in the Position +Independend Executable (PIE) variant. This enables better address +space randomization (ASLR). + +%package c++ +Summary: The GNU C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-c++ = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix} = %{version}-%{release} + +%description c++ +This package contains the GNU compiler for C++. + +%package c++-32bit +Summary: The GNU C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-c++ = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-32bit = %{version}-%{release} + +%description c++-32bit +This package contains the GNU compiler for C++. + +%package c++-64bit +Summary: The GNU C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-c++ = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-64bit = %{version}-%{release} + +%description c++-64bit +This package contains the GNU compiler for C++. + +%package -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix} +Summary: Include Files and Libraries mandatory for Development +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Requires: glibc-devel +Requires: libstdc++%{libstdcxx_sover} >= %{version}-%{release} +%ifarch ia64 +Requires: libunwind-devel +%endif + +%description -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix} +This package contains all the headers and libraries of the standard C++ +library. It is needed for compiling C++ code. + +%package -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-32bit +Summary: Include Files and Libraries mandatory for Development +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Requires: glibc-devel-32bit +Requires: libstdc++%{libstdcxx_sover}-32bit >= %{version}-%{release} +%ifarch ia64 +Requires: libunwind-devel +%endif + +%description -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-32bit +This package contains all the headers and libraries of the standard C++ +library. It is needed for compiling C++ code. + +%package -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-64bit +Summary: Include Files and Libraries mandatory for Development +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Requires: glibc-devel-64bit +Requires: libstdc++%{libstdcxx_sover}-64bit >= %{version}-%{release} +%ifarch ia64 +Requires: libunwind-devel +%endif + +%description -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-64bit +This package contains all the headers and libraries of the standard C++ +library. It is needed for compiling C++ code. + +%package -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} +Summary: GDB pretty printers for the C++ standard library +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +# The -pp packages are tied to a specific shared library +Requires: libstdc++%{libstdcxx_sover} = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} = %{version}-%{release} +Provides: libstdc++%{libstdcxx_sover}-pp = %{version}-%{release} +# To allow updates from libstdc++6-pp-gccM to libstdc++6-pp we need +# enumerates Obsoletes, the separate -pp package was introduced with GCC9 +# and dropped somewhen during the GCC11 to GCC12 transition +Obsoletes: libstdc++6-pp-gcc9 libstdc++6-pp-gcc10 +Obsoletes: libstdc++6-pp-gcc11 +Provides: libstdc++6-pp-gcc10 +Provides: libstdc++6-pp-gcc11 +Provides: libstdc++6-pp-gcc9 +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-pp +# packageand() does not work with versioned specifications so the fallback +# is a Requires from libstdc++-devel to preserve previous behavior. +%if %{suse_version} >= 1500 +Supplements: (gdb and libstdc++%{libstdcxx_sover} = %{version}-%{release}) +%endif + +%description -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} +This package contains pretty printers for the C++ standard library usable +from GDB. + +%package -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}-32bit +Summary: GDB pretty printers for the C++ standard library +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +# The -pp packages are tied to a specific shared library +Requires: libstdc++%{libstdcxx_sover}-32bit = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} = %{version}-%{release} +Provides: libstdc++%{libstdcxx_sover}-pp-32bit = %{version}-%{release} +# To allow updates from libstdc++6-pp-gccM to libstdc++6-pp we need +# enumerates Obsoletes, the separate -pp package was introduced with GCC9 +# and dropped somewhen during the GCC11 to GCC12 transition +Obsoletes: libstdc++6-pp-gcc9-32bit libstdc++6-pp-gcc10-32bit +Obsoletes: libstdc++6-pp-gcc11-32bit +Provides: libstdc++6-pp-gcc10-32bit +Provides: libstdc++6-pp-gcc11-32bit +Provides: libstdc++6-pp-gcc9-32bit +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-pp-32bit +# packageand() does not work with versioned specifications so the fallback +# is a Requires from libstdc++-devel to preserve previous behavior. +%if %{suse_version} >= 1500 +Supplements: (gdb and libstdc++%{libstdcxx_sover}-32bit = %{version}-%{release}) +%endif + +%description -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}-32bit +This package contains pretty printers for the C++ standard library usable +from GDB. + +%package -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}-64bit +Summary: GDB pretty printers for the C++ standard library +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +# The -pp packages are tied to a specific shared library +Requires: libstdc++%{libstdcxx_sover}-64bit = %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} = %{version}-%{release} +Provides: libstdc++%{libstdcxx_sover}-pp-64bit = %{version}-%{release} +# To allow updates from libstdc++6-pp-gccM to libstdc++6-pp we need +# enumerates Obsoletes, the separate -pp package was introduced with GCC9 +# and dropped somewhen during the GCC11 to GCC12 transition +Obsoletes: libstdc++6-pp-gcc9-64bit libstdc++6-pp-gcc10-64bit +Obsoletes: libstdc++6-pp-gcc11-64bit +Provides: libstdc++6-pp-gcc10-64bit +Provides: libstdc++6-pp-gcc11-64bit +Provides: libstdc++6-pp-gcc9-64bit +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-pp-64bit +# packageand() does not work with versioned specifications so the fallback +# is a Requires from libstdc++-devel to preserve previous behavior. +%if %{suse_version} >= 1500 +Supplements: (gdb and libstdc++%{libstdcxx_sover}-64bit = %{version}-%{release}) +%endif + +%description -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}-64bit +This package contains pretty printers for the C++ standard library usable +from GDB. + +%package -n libgcc_s%{libgcc_s}%{libgcc_s_suffix} +Summary: C compiler runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgcc_s%{libgcc_s} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgcc_s%{libgcc_s} + +%description -n libgcc_s%{libgcc_s}%{libgcc_s_suffix} +Libgcc is needed for dynamically linked C programs. + +%post -n libgcc_s%{libgcc_s}%{libgcc_s_suffix} -p /sbin/ldconfig + +%postun -n libgcc_s%{libgcc_s}%{libgcc_s_suffix} -p /sbin/ldconfig + +%package -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit +Summary: C compiler runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgcc_s%{libgcc_s}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgcc_s%{libgcc_s}-32bit + +%description -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit +Libgcc is needed for dynamically linked C programs. + +%post -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit -p /sbin/ldconfig + +%postun -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit -p /sbin/ldconfig + +%package -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit +Summary: C compiler runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgcc_s%{libgcc_s}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgcc_s%{libgcc_s}-64bit + +%description -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit +Libgcc is needed for dynamically linked C programs. + +%post -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit -p /sbin/ldconfig + +%postun -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit -p /sbin/ldconfig + +%package -n libgomp%{libgomp_sover}%{libgomp_suffix} +Summary: The GNU compiler collection OpenMP runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgomp%{libgomp_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgomp%{libgomp_sover} + +%description -n libgomp%{libgomp_sover}%{libgomp_suffix} +This is the OpenMP runtime library needed by OpenMP enabled programs +that were built with the -fopenmp compiler option and by programs that +were auto-parallelized via the -ftree-parallelize-loops compiler +option. + + +%post -n libgomp%{libgomp_sover}%{libgomp_suffix} -p /sbin/ldconfig + +%postun -n libgomp%{libgomp_sover}%{libgomp_suffix} -p /sbin/ldconfig + +%package -n libgomp%{libgomp_sover}%{libgomp_suffix}-32bit +Summary: The GNU compiler collection OpenMP runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgomp%{libgomp_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgomp%{libgomp_sover}-32bit + +%description -n libgomp%{libgomp_sover}%{libgomp_suffix}-32bit +This is the OpenMP runtime library needed by OpenMP enabled programs +that were built with the -fopenmp compiler option and by programs that +were auto-parallelized via the -ftree-parallelize-loops compiler +option. + + +%post -n libgomp%{libgomp_sover}%{libgomp_suffix}-32bit -p /sbin/ldconfig + +%postun -n libgomp%{libgomp_sover}%{libgomp_suffix}-32bit -p /sbin/ldconfig + +%package -n libgomp%{libgomp_sover}%{libgomp_suffix}-64bit +Summary: The GNU compiler collection OpenMP runtime library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Base +Provides: libgomp%{libgomp_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgomp%{libgomp_sover}-64bit + +%description -n libgomp%{libgomp_sover}%{libgomp_suffix}-64bit +This is the OpenMP runtime library needed by OpenMP enabled programs +that were built with the -fopenmp compiler option and by programs that +were auto-parallelized via the -ftree-parallelize-loops compiler +option. + + +%post -n libgomp%{libgomp_sover}%{libgomp_suffix}-64bit -p /sbin/ldconfig + +%postun -n libgomp%{libgomp_sover}%{libgomp_suffix}-64bit -p /sbin/ldconfig + +%package -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix} +Summary: The standard C++ shared library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Suggests: libstdc++%{libstdcxx_sover}-locale +Provides: libstdc++%{libstdcxx_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover} +# Fallback for non-existing Supplements support +%if %{suse_version} < 1500 +Recommends: libstdc++%{libstdcxx_sover}-pp = %{version}-%{release} +%endif +# The std::chrono timezone database is provided by timezone +# (/usr/share/zoneinfo/tzdata.zi), without that the tzdb is empty and +# will only provide UTC +Recommends: timezone + +%description -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix} +The standard C++ library, needed for dynamically linked C++ programs. + + +%post -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix} -p /sbin/ldconfig + +%postun -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix} -p /sbin/ldconfig + +%package -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-32bit +Summary: The standard C++ shared library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Suggests: libstdc++%{libstdcxx_sover}-locale +Provides: libstdc++%{libstdcxx_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-32bit +# Fallback for non-existing Supplements support +%if %{suse_version} < 1500 +Recommends: libstdc++%{libstdcxx_sover}-pp-32bit = %{version}-%{release} +%endif +# The std::chrono timezone database is provided by timezone +# (/usr/share/zoneinfo/tzdata.zi), without that the tzdb is empty and +# will only provide UTC +Recommends: timezone + +%description -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-32bit +The standard C++ library, needed for dynamically linked C++ programs. + + +%post -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-32bit -p /sbin/ldconfig + +%postun -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-32bit -p /sbin/ldconfig + +%package -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-64bit +Summary: The standard C++ shared library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Suggests: libstdc++%{libstdcxx_sover}-locale +Provides: libstdc++%{libstdcxx_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-64bit +# Fallback for non-existing Supplements support +%if %{suse_version} < 1500 +Recommends: libstdc++%{libstdcxx_sover}-pp-64bit = %{version}-%{release} +%endif +# The std::chrono timezone database is provided by timezone +# (/usr/share/zoneinfo/tzdata.zi), without that the tzdb is empty and +# will only provide UTC +Recommends: timezone + +%description -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-64bit +The standard C++ library, needed for dynamically linked C++ programs. + + +%post -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-64bit -p /sbin/ldconfig + +%postun -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-64bit -p /sbin/ldconfig + +%package -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale +Summary: Standard C++ Library Locales +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libstdc++%{libstdcxx_sover}-locale = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libstdc++%{libstdcxx_sover}-locale + +%description -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale +The standard C++ library locale data. + +%package info +Summary: Documentation for the GNU compiler collection +License: GFDL-1.2-only +Group: Documentation/Other +PreReq: %{install_info_prereq} +%if 0%{?suse_version} >= 1120 +BuildArch: noarch +%endif + +%description info +GNU info-pages for the GNU compiler collection covering both user-level +and internals documentation. + +%package objc +Summary: GNU Objective C Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-objc = %{version}-%{release} +Requires: libobjc%{libobjc_sover} >= %{version}-%{release} + +%description objc +This package contains the GNU Objective C compiler. Objective C is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. + +%package objc-32bit +Summary: GNU Objective C Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-objc = %{version}-%{release} +Requires: libobjc%{libobjc_sover}-32bit >= %{version}-%{release} + +%description objc-32bit +This package contains the GNU Objective C compiler. Objective C is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. + +%package objc-64bit +Summary: GNU Objective C Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-objc = %{version}-%{release} +Requires: libobjc%{libobjc_sover}-64bit >= %{version}-%{release} + +%description objc-64bit +This package contains the GNU Objective C compiler. Objective C is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. + +%package -n libobjc%{libobjc_sover}%{libobjc_suffix} +Summary: Library for the GNU Objective C Compiler +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Libraries/Other +Provides: libobjc%{libobjc_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libobjc%{libobjc_sover} + +%description -n libobjc%{libobjc_sover}%{libobjc_suffix} +The library for the GNU Objective C compiler. + +%post -n libobjc%{libobjc_sover}%{libobjc_suffix} -p /sbin/ldconfig + +%postun -n libobjc%{libobjc_sover}%{libobjc_suffix} -p /sbin/ldconfig + +%package -n libobjc%{libobjc_sover}%{libobjc_suffix}-32bit +Summary: Library for the GNU Objective C Compiler +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Libraries/Other +Provides: libobjc%{libobjc_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libobjc%{libobjc_sover}-32bit + +%description -n libobjc%{libobjc_sover}%{libobjc_suffix}-32bit +The library for the GNU Objective C compiler. + +%post -n libobjc%{libobjc_sover}%{libobjc_suffix}-32bit -p /sbin/ldconfig + +%postun -n libobjc%{libobjc_sover}%{libobjc_suffix}-32bit -p /sbin/ldconfig + +%package -n libobjc%{libobjc_sover}%{libobjc_suffix}-64bit +Summary: Library for the GNU Objective C Compiler +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Libraries/Other +Provides: libobjc%{libobjc_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libobjc%{libobjc_sover}-64bit + +%description -n libobjc%{libobjc_sover}%{libobjc_suffix}-64bit +The library for the GNU Objective C compiler. + +%post -n libobjc%{libobjc_sover}%{libobjc_suffix}-64bit -p /sbin/ldconfig + +%postun -n libobjc%{libobjc_sover}%{libobjc_suffix}-64bit -p /sbin/ldconfig + +%package obj-c++ +Summary: GNU Objective C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-c++ = %{version}-%{release} +Requires: gcc13-obj-c++ = %{version}-%{release} +Requires: gcc13-objc = %{version}-%{release} + +%description obj-c++ +This package contains the GNU Objective C++ compiler. Objective C++ is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. + +%package obj-c++-32bit +Summary: GNU Objective C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-c++-32bit = %{version}-%{release} +Requires: gcc13-obj-c++ = %{version}-%{release} +Requires: gcc13-objc-32bit = %{version}-%{release} + +%description obj-c++-32bit +This package contains the GNU Objective C++ compiler. Objective C++ is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. + +%package obj-c++-64bit +Summary: GNU Objective C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-c++-64bit = %{version}-%{release} +Requires: gcc13-obj-c++ = %{version}-%{release} +Requires: gcc13-objc-64bit = %{version}-%{release} + +%description obj-c++-64bit +This package contains the GNU Objective C++ compiler. Objective C++ is an +object oriented language, created by Next Inc. and used in their +Nextstep OS. The source code is available in the gcc package. + +%package -n cpp13 +Summary: The GCC Preprocessor +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ + +%description -n cpp13 +This Package contains just the preprocessor that is used by the X11 +packages. + +%package ada +Summary: GNU Ada Compiler Based on GCC (GNAT) +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-ada = %{version}-%{release} +Requires: libada13 = %{version}-%{release} + +%description ada +This package contains an Ada compiler and associated development +tools based on the GNU GCC technology. + +%package ada-32bit +Summary: GNU Ada Compiler Based on GCC (GNAT) +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-ada = %{version}-%{release} +Requires: libada13-32bit = %{version}-%{release} + +%description ada-32bit +This package contains an Ada compiler and associated development +tools based on the GNU GCC technology. + +%package ada-64bit +Summary: GNU Ada Compiler Based on GCC (GNAT) +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-ada = %{version}-%{release} +Requires: libada13-64bit = %{version}-%{release} + +%description ada-64bit +This package contains an Ada compiler and associated development +tools based on the GNU GCC technology. + +%package -n libada13 +Summary: GNU Ada Runtime Libraries +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libgnarl-13 = %{version}-%{release} +Conflicts: %selfconflict libgnarl-13 +Provides: libgnat-13 = %{version}-%{release} +Conflicts: %selfconflict libgnat-13 + +%description -n libada13 +This package contains the shared libraries required to run programs +compiled with the GNU Ada compiler (GNAT) if they are compiled to use +shared libraries. It also contains the shared libraries for the +Implementation of the Ada Semantic Interface Specification (ASIS), the +implementation of Distributed Systems Programming (GLADE) and the Posix +1003.5 Binding (Florist). + +%post -n libada13 -p /sbin/ldconfig + +%postun -n libada13 -p /sbin/ldconfig + +%package -n libada13-32bit +Summary: GNU Ada Runtime Libraries +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libgnarl-13-32bit = %{version}-%{release} +Conflicts: %selfconflict libgnarl-13-32bit +Provides: libgnat-13-32bit = %{version}-%{release} +Conflicts: %selfconflict libgnat-13-32bit + +%description -n libada13-32bit +This package contains the shared libraries required to run programs +compiled with the GNU Ada compiler (GNAT) if they are compiled to use +shared libraries. It also contains the shared libraries for the +Implementation of the Ada Semantic Interface Specification (ASIS), the +implementation of Distributed Systems Programming (GLADE) and the Posix +1003.5 Binding (Florist). + +%post -n libada13-32bit -p /sbin/ldconfig + +%postun -n libada13-32bit -p /sbin/ldconfig + +%package -n libada13-64bit +Summary: GNU Ada Runtime Libraries +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libgnarl-13-64bit = %{version}-%{release} +Conflicts: %selfconflict libgnarl-13-64bit +Provides: libgnat-13-64bit = %{version}-%{release} +Conflicts: %selfconflict libgnat-13-64bit + +%description -n libada13-64bit +This package contains the shared libraries required to run programs +compiled with the GNU Ada compiler (GNAT) if they are compiled to use +shared libraries. It also contains the shared libraries for the +Implementation of the Ada Semantic Interface Specification (ASIS), the +implementation of Distributed Systems Programming (GLADE) and the Posix +1003.5 Binding (Florist). + +%post -n libada13-64bit -p /sbin/ldconfig + +%postun -n libada13-64bit -p /sbin/ldconfig + +%package fortran +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0-or-later +Group: Development/Languages/Fortran +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-fortran = %{version}-%{release} +Requires: libgfortran%{libgfortran_sover} >= %{version}-%{release} +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover} >= %{version}-%{release} +%endif + +%description fortran +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package fortran-32bit +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0-or-later +Group: Development/Languages/Fortran +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-fortran = %{version}-%{release} +Requires: libgfortran%{libgfortran_sover}-32bit >= %{version}-%{release} +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover}-32bit >= %{version}-%{release} +%endif + +%description fortran-32bit +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package fortran-64bit +Summary: The GNU Fortran Compiler and Support Files +License: GPL-3.0-or-later +Group: Development/Languages/Fortran +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-fortran = %{version}-%{release} +Requires: libgfortran%{libgfortran_sover}-64bit >= %{version}-%{release} +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover}-64bit >= %{version}-%{release} +%endif + +%description fortran-64bit +This is the Fortran compiler of the GNU Compiler Collection (GCC). + +%package -n libgfortran%{libgfortran_sover}%{libgfortran_suffix} +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/Fortran +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover} >= %{version}-%{release} +%endif +Provides: libgfortran%{libgfortran_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgfortran%{libgfortran_sover} + +%description -n libgfortran%{libgfortran_sover}%{libgfortran_suffix} +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). + +%post -n libgfortran%{libgfortran_sover}%{libgfortran_suffix} -p /sbin/ldconfig + +%postun -n libgfortran%{libgfortran_sover}%{libgfortran_suffix} -p /sbin/ldconfig + +%package -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-32bit +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/Fortran +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover}-32bit >= %{version}-%{release} +%endif +Provides: libgfortran%{libgfortran_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgfortran%{libgfortran_sover}-32bit + +%description -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-32bit +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). + +%post -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-32bit -p /sbin/ldconfig + +%postun -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-32bit -p /sbin/ldconfig + +%package -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-64bit +Summary: The GNU Fortran Compiler Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/Fortran +%ifarch %quadmath_arch +Requires: libquadmath%{libquadmath_sover}-64bit >= %{version}-%{release} +%endif +Provides: libgfortran%{libgfortran_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgfortran%{libgfortran_sover}-64bit + +%description -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-64bit +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC). + +%post -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-64bit -p /sbin/ldconfig + +%postun -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}-64bit -p /sbin/ldconfig + +%package -n libquadmath%{libquadmath_sover}%{libquadmath_suffix} +Summary: The GNU Fortran Compiler Quadmath Runtime Library +License: LGPL-2.1-only +Group: Development/Languages/Fortran +Provides: libquadmath%{libquadmath_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libquadmath%{libquadmath_sover} + +%description -n libquadmath%{libquadmath_sover}%{libquadmath_suffix} +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC) and quadruple precision floating point +operations. + +%post -n libquadmath%{libquadmath_sover}%{libquadmath_suffix} -p /sbin/ldconfig + +%postun -n libquadmath%{libquadmath_sover}%{libquadmath_suffix} -p /sbin/ldconfig + +%package -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-32bit +Summary: The GNU Fortran Compiler Quadmath Runtime Library +License: LGPL-2.1-only +Group: Development/Languages/Fortran +Provides: libquadmath%{libquadmath_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libquadmath%{libquadmath_sover}-32bit + +%description -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-32bit +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC) and quadruple precision floating point +operations. + +%post -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-32bit -p /sbin/ldconfig + +%postun -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-32bit -p /sbin/ldconfig + +%package -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-64bit +Summary: The GNU Fortran Compiler Quadmath Runtime Library +License: LGPL-2.1-only +Group: Development/Languages/Fortran +Provides: libquadmath%{libquadmath_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libquadmath%{libquadmath_sover}-64bit + +%description -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-64bit +The runtime library needed to run programs compiled with the Fortran compiler +of the GNU Compiler Collection (GCC) and quadruple precision floating point +operations. + +%post -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-64bit -p /sbin/ldconfig + +%postun -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}-64bit -p /sbin/ldconfig + +%package -n libitm%{libitm_sover}%{libitm_suffix} +Summary: The GNU Compiler Transactional Memory Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libitm%{libitm_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libitm%{libitm_sover} + +%description -n libitm%{libitm_sover}%{libitm_suffix} +The runtime library needed to run programs compiled with the +-fgnu-tm option of the GNU Compiler Collection (GCC). + +%post -n libitm%{libitm_sover}%{libitm_suffix} -p /sbin/ldconfig + +%postun -n libitm%{libitm_sover}%{libitm_suffix} -p /sbin/ldconfig + +%package -n libitm%{libitm_sover}%{libitm_suffix}-32bit +Summary: The GNU Compiler Transactional Memory Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libitm%{libitm_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libitm%{libitm_sover}-32bit + +%description -n libitm%{libitm_sover}%{libitm_suffix}-32bit +The runtime library needed to run programs compiled with the +-fgnu-tm option of the GNU Compiler Collection (GCC). + +%post -n libitm%{libitm_sover}%{libitm_suffix}-32bit -p /sbin/ldconfig + +%postun -n libitm%{libitm_sover}%{libitm_suffix}-32bit -p /sbin/ldconfig + +%package -n libitm%{libitm_sover}%{libitm_suffix}-64bit +Summary: The GNU Compiler Transactional Memory Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libitm%{libitm_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libitm%{libitm_sover}-64bit + +%description -n libitm%{libitm_sover}%{libitm_suffix}-64bit +The runtime library needed to run programs compiled with the +-fgnu-tm option of the GNU Compiler Collection (GCC). + +%post -n libitm%{libitm_sover}%{libitm_suffix}-64bit -p /sbin/ldconfig + +%postun -n libitm%{libitm_sover}%{libitm_suffix}-64bit -p /sbin/ldconfig + +%package -n libasan%{libasan_sover}%{libasan_suffix} +Summary: The GNU Compiler Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libasan%{libasan_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libasan%{libasan_sover} + +%description -n libasan%{libasan_sover}%{libasan_suffix} +The runtime library needed to run programs compiled with the +-fsanitize=address option of the GNU Compiler Collection (GCC). + +%post -n libasan%{libasan_sover}%{libasan_suffix} -p /sbin/ldconfig + +%postun -n libasan%{libasan_sover}%{libasan_suffix} -p /sbin/ldconfig + +%package -n libasan%{libasan_sover}%{libasan_suffix}-32bit +Summary: The GNU Compiler Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libasan%{libasan_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libasan%{libasan_sover}-32bit + +%description -n libasan%{libasan_sover}%{libasan_suffix}-32bit +The runtime library needed to run programs compiled with the +-fsanitize=address option of the GNU Compiler Collection (GCC). + +%post -n libasan%{libasan_sover}%{libasan_suffix}-32bit -p /sbin/ldconfig + +%postun -n libasan%{libasan_sover}%{libasan_suffix}-32bit -p /sbin/ldconfig + +%package -n libasan%{libasan_sover}%{libasan_suffix}-64bit +Summary: The GNU Compiler Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libasan%{libasan_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libasan%{libasan_sover}-64bit + +%description -n libasan%{libasan_sover}%{libasan_suffix}-64bit +The runtime library needed to run programs compiled with the +-fsanitize=address option of the GNU Compiler Collection (GCC). + +%post -n libasan%{libasan_sover}%{libasan_suffix}-64bit -p /sbin/ldconfig + +%postun -n libasan%{libasan_sover}%{libasan_suffix}-64bit -p /sbin/ldconfig + +%package -n libtsan%{libtsan_sover}%{libtsan_suffix} +Summary: The GNU Compiler Thread Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libtsan%{libtsan_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libtsan%{libtsan_sover} + +%description -n libtsan%{libtsan_sover}%{libtsan_suffix} +The runtime library needed to run programs compiled with the +-fsanitize=thread option of the GNU Compiler Collection (GCC). + +%post -n libtsan%{libtsan_sover}%{libtsan_suffix} -p /sbin/ldconfig + +%postun -n libtsan%{libtsan_sover}%{libtsan_suffix} -p /sbin/ldconfig + +%package -n libtsan%{libtsan_sover}%{libtsan_suffix}-32bit +Summary: The GNU Compiler Thread Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libtsan%{libtsan_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libtsan%{libtsan_sover}-32bit + +%description -n libtsan%{libtsan_sover}%{libtsan_suffix}-32bit +The runtime library needed to run programs compiled with the +-fsanitize=thread option of the GNU Compiler Collection (GCC). + +%post -n libtsan%{libtsan_sover}%{libtsan_suffix}-32bit -p /sbin/ldconfig + +%postun -n libtsan%{libtsan_sover}%{libtsan_suffix}-32bit -p /sbin/ldconfig + +%package -n libtsan%{libtsan_sover}%{libtsan_suffix}-64bit +Summary: The GNU Compiler Thread Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libtsan%{libtsan_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libtsan%{libtsan_sover}-64bit + +%description -n libtsan%{libtsan_sover}%{libtsan_suffix}-64bit +The runtime library needed to run programs compiled with the +-fsanitize=thread option of the GNU Compiler Collection (GCC). + +%post -n libtsan%{libtsan_sover}%{libtsan_suffix}-64bit -p /sbin/ldconfig + +%postun -n libtsan%{libtsan_sover}%{libtsan_suffix}-64bit -p /sbin/ldconfig + +%package -n libhwasan%{libhwasan_sover}%{libhwasan_suffix} +Summary: The GNU Compiler Hardware-assisted Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libhwasan%{libhwasan_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libhwasan%{libhwasan_sover} + +%description -n libhwasan%{libhwasan_sover}%{libhwasan_suffix} +The runtime library needed to run programs compiled with the +-fsanitize=hwaddress option of the GNU Compiler Collection (GCC). + +%post -n libhwasan%{libhwasan_sover}%{libhwasan_suffix} -p /sbin/ldconfig + +%postun -n libhwasan%{libhwasan_sover}%{libhwasan_suffix} -p /sbin/ldconfig + +%package -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-32bit +Summary: The GNU Compiler Hardware-assisted Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libhwasan%{libhwasan_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libhwasan%{libhwasan_sover}-32bit + +%description -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-32bit +The runtime library needed to run programs compiled with the +-fsanitize=hwaddress option of the GNU Compiler Collection (GCC). + +%post -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-32bit -p /sbin/ldconfig + +%postun -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-32bit -p /sbin/ldconfig + +%package -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-64bit +Summary: The GNU Compiler Hardware-assisted Address Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libhwasan%{libhwasan_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libhwasan%{libhwasan_sover}-64bit + +%description -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-64bit +The runtime library needed to run programs compiled with the +-fsanitize=hwaddress option of the GNU Compiler Collection (GCC). + +%post -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-64bit -p /sbin/ldconfig + +%postun -n libhwasan%{libhwasan_sover}%{libhwasan_suffix}-64bit -p /sbin/ldconfig + +%package -n libatomic%{libatomic_sover}%{libatomic_suffix} +Summary: The GNU Compiler Atomic Operations Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Provides: libatomic%{libatomic_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libatomic%{libatomic_sover} + +%description -n libatomic%{libatomic_sover}%{libatomic_suffix} +The runtime library for atomic operations of the GNU Compiler Collection (GCC). + +%post -n libatomic%{libatomic_sover}%{libatomic_suffix} -p /sbin/ldconfig + +%postun -n libatomic%{libatomic_sover}%{libatomic_suffix} -p /sbin/ldconfig + +%package -n libatomic%{libatomic_sover}%{libatomic_suffix}-32bit +Summary: The GNU Compiler Atomic Operations Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Provides: libatomic%{libatomic_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libatomic%{libatomic_sover}-32bit + +%description -n libatomic%{libatomic_sover}%{libatomic_suffix}-32bit +The runtime library for atomic operations of the GNU Compiler Collection (GCC). + +%post -n libatomic%{libatomic_sover}%{libatomic_suffix}-32bit -p /sbin/ldconfig + +%postun -n libatomic%{libatomic_sover}%{libatomic_suffix}-32bit -p /sbin/ldconfig + +%package -n libatomic%{libatomic_sover}%{libatomic_suffix}-64bit +Summary: The GNU Compiler Atomic Operations Runtime Library +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: Development/Languages/C and C++ +Provides: libatomic%{libatomic_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libatomic%{libatomic_sover}-64bit + +%description -n libatomic%{libatomic_sover}%{libatomic_suffix}-64bit +The runtime library for atomic operations of the GNU Compiler Collection (GCC). + +%post -n libatomic%{libatomic_sover}%{libatomic_suffix}-64bit -p /sbin/ldconfig + +%postun -n libatomic%{libatomic_sover}%{libatomic_suffix}-64bit -p /sbin/ldconfig + +%package -n liblsan%{liblsan_sover}%{liblsan_suffix} +Summary: The GNU Compiler Leak Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: liblsan%{liblsan_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict liblsan%{liblsan_sover} + +%description -n liblsan%{liblsan_sover}%{liblsan_suffix} +The runtime library needed to run programs compiled with the +-fsanitize=leak option of the GNU Compiler Collection (GCC). + +%post -n liblsan%{liblsan_sover}%{liblsan_suffix} -p /sbin/ldconfig + +%postun -n liblsan%{liblsan_sover}%{liblsan_suffix} -p /sbin/ldconfig + +%package -n liblsan%{liblsan_sover}%{liblsan_suffix}-32bit +Summary: The GNU Compiler Leak Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: liblsan%{liblsan_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict liblsan%{liblsan_sover}-32bit + +%description -n liblsan%{liblsan_sover}%{liblsan_suffix}-32bit +The runtime library needed to run programs compiled with the +-fsanitize=leak option of the GNU Compiler Collection (GCC). + +%post -n liblsan%{liblsan_sover}%{liblsan_suffix}-32bit -p /sbin/ldconfig + +%postun -n liblsan%{liblsan_sover}%{liblsan_suffix}-32bit -p /sbin/ldconfig + +%package -n liblsan%{liblsan_sover}%{liblsan_suffix}-64bit +Summary: The GNU Compiler Leak Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: liblsan%{liblsan_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict liblsan%{liblsan_sover}-64bit + +%description -n liblsan%{liblsan_sover}%{liblsan_suffix}-64bit +The runtime library needed to run programs compiled with the +-fsanitize=leak option of the GNU Compiler Collection (GCC). + +%post -n liblsan%{liblsan_sover}%{liblsan_suffix}-64bit -p /sbin/ldconfig + +%postun -n liblsan%{liblsan_sover}%{liblsan_suffix}-64bit -p /sbin/ldconfig + +%package -n libubsan%{libubsan_sover}%{libubsan_suffix} +Summary: The GNU Compiler Undefined Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libubsan%{libubsan_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libubsan%{libubsan_sover} + +%description -n libubsan%{libubsan_sover}%{libubsan_suffix} +The runtime library needed to run programs compiled with the +-fsanitize=undefined option of the GNU Compiler Collection (GCC). + +%post -n libubsan%{libubsan_sover}%{libubsan_suffix} -p /sbin/ldconfig + +%postun -n libubsan%{libubsan_sover}%{libubsan_suffix} -p /sbin/ldconfig + +%package -n libubsan%{libubsan_sover}%{libubsan_suffix}-32bit +Summary: The GNU Compiler Undefined Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libubsan%{libubsan_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libubsan%{libubsan_sover}-32bit + +%description -n libubsan%{libubsan_sover}%{libubsan_suffix}-32bit +The runtime library needed to run programs compiled with the +-fsanitize=undefined option of the GNU Compiler Collection (GCC). + +%post -n libubsan%{libubsan_sover}%{libubsan_suffix}-32bit -p /sbin/ldconfig + +%postun -n libubsan%{libubsan_sover}%{libubsan_suffix}-32bit -p /sbin/ldconfig + +%package -n libubsan%{libubsan_sover}%{libubsan_suffix}-64bit +Summary: The GNU Compiler Undefined Sanitizer Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libubsan%{libubsan_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libubsan%{libubsan_sover}-64bit + +%description -n libubsan%{libubsan_sover}%{libubsan_suffix}-64bit +The runtime library needed to run programs compiled with the +-fsanitize=undefined option of the GNU Compiler Collection (GCC). + +%post -n libubsan%{libubsan_sover}%{libubsan_suffix}-64bit -p /sbin/ldconfig + +%postun -n libubsan%{libubsan_sover}%{libubsan_suffix}-64bit -p /sbin/ldconfig + +%package -n libvtv%{libvtv_sover}%{libvtv_suffix} +Summary: The GNU Compiler Vtable Verifier Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libvtv%{libvtv_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libvtv%{libvtv_sover} + +%description -n libvtv%{libvtv_sover}%{libvtv_suffix} +The runtime library needed to run programs compiled with the +-fvtable-verify option of the GNU Compiler Collection (GCC). + +%post -n libvtv%{libvtv_sover}%{libvtv_suffix} -p /sbin/ldconfig + +%postun -n libvtv%{libvtv_sover}%{libvtv_suffix} -p /sbin/ldconfig + +%package -n libvtv%{libvtv_sover}%{libvtv_suffix}-32bit +Summary: The GNU Compiler Vtable Verifier Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libvtv%{libvtv_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libvtv%{libvtv_sover}-32bit + +%description -n libvtv%{libvtv_sover}%{libvtv_suffix}-32bit +The runtime library needed to run programs compiled with the +-fvtable-verify option of the GNU Compiler Collection (GCC). + +%post -n libvtv%{libvtv_sover}%{libvtv_suffix}-32bit -p /sbin/ldconfig + +%postun -n libvtv%{libvtv_sover}%{libvtv_suffix}-32bit -p /sbin/ldconfig + +%package -n libvtv%{libvtv_sover}%{libvtv_suffix}-64bit +Summary: The GNU Compiler Vtable Verifier Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libvtv%{libvtv_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libvtv%{libvtv_sover}-64bit + +%description -n libvtv%{libvtv_sover}%{libvtv_suffix}-64bit +The runtime library needed to run programs compiled with the +-fvtable-verify option of the GNU Compiler Collection (GCC). + +%post -n libvtv%{libvtv_sover}%{libvtv_suffix}-64bit -p /sbin/ldconfig + +%postun -n libvtv%{libvtv_sover}%{libvtv_suffix}-64bit -p /sbin/ldconfig + +%package go +Summary: GNU Go Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-go = %{version}-%{release} +Requires: libgo%{libgo_sover} >= %{version}-%{release} + +%description go +This package contains a Go compiler and associated development +files based on the GNU GCC technology. + +%package go-32bit +Summary: GNU Go Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-go = %{version}-%{release} +Requires: libgo%{libgo_sover}-32bit >= %{version}-%{release} + +%description go-32bit +This package contains a Go compiler and associated development +files based on the GNU GCC technology. + +%package go-64bit +Summary: GNU Go Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-go = %{version}-%{release} +Requires: libgo%{libgo_sover}-64bit >= %{version}-%{release} + +%description go-64bit +This package contains a Go compiler and associated development +files based on the GNU GCC technology. + +%package -n libgo%{libgo_sover}%{libgo_suffix} +Summary: GNU Go compiler runtime library +License: BSD-3-Clause +Group: Development/Languages/Other +Provides: libgo%{libgo_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgo%{libgo_sover} + +%description -n libgo%{libgo_sover}%{libgo_suffix} +Runtime library for the GNU Go language. + +%post -n libgo%{libgo_sover}%{libgo_suffix} -p /sbin/ldconfig + +%postun -n libgo%{libgo_sover}%{libgo_suffix} -p /sbin/ldconfig + +%package -n libgo%{libgo_sover}%{libgo_suffix}-32bit +Summary: GNU Go compiler runtime library +License: BSD-3-Clause +Group: Development/Languages/Other +Provides: libgo%{libgo_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgo%{libgo_sover}-32bit + +%description -n libgo%{libgo_sover}%{libgo_suffix}-32bit +Runtime library for the GNU Go language. + +%post -n libgo%{libgo_sover}%{libgo_suffix}-32bit -p /sbin/ldconfig + +%postun -n libgo%{libgo_sover}%{libgo_suffix}-32bit -p /sbin/ldconfig + +%package -n libgo%{libgo_sover}%{libgo_suffix}-64bit +Summary: GNU Go compiler runtime library +License: BSD-3-Clause +Group: Development/Languages/Other +Provides: libgo%{libgo_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgo%{libgo_sover}-64bit + +%description -n libgo%{libgo_sover}%{libgo_suffix}-64bit +Runtime library for the GNU Go language. + +%post -n libgo%{libgo_sover}%{libgo_suffix}-64bit -p /sbin/ldconfig + +%postun -n libgo%{libgo_sover}%{libgo_suffix}-64bit -p /sbin/ldconfig + +%package d +Summary: GNU D Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-d = %{version}-%{release} +Requires: libgdruntime%{libgdruntime_sover} >= %{version}-%{release} +Requires: libgphobos%{libgphobos_sover} >= %{version}-%{release} + +%description d +This package contains a D compiler and associated development +files based on the GNU GCC technology. + +%package d-32bit +Summary: GNU D Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-d = %{version}-%{release} +Requires: libgdruntime%{libgdruntime_sover}-32bit >= %{version}-%{release} +Requires: libgphobos%{libgphobos_sover}-32bit >= %{version}-%{release} + +%description d-32bit +This package contains a D compiler and associated development +files based on the GNU GCC technology. + +%package d-64bit +Summary: GNU D Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-d = %{version}-%{release} +Requires: libgdruntime%{libgdruntime_sover}-64bit >= %{version}-%{release} +Requires: libgphobos%{libgphobos_sover}-64bit >= %{version}-%{release} + +%description d-64bit +This package contains a D compiler and associated development +files based on the GNU GCC technology. + +%package -n libgphobos%{libgphobos_sover}%{libgphobos_suffix} +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgphobos%{libgphobos_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgphobos%{libgphobos_sover} + +%description -n libgphobos%{libgphobos_sover}%{libgphobos_suffix} +Runtime library for the GNU D language. + +%post -n libgphobos%{libgphobos_sover}%{libgphobos_suffix} -p /sbin/ldconfig + +%postun -n libgphobos%{libgphobos_sover}%{libgphobos_suffix} -p /sbin/ldconfig + +%package -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-32bit +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgphobos%{libgphobos_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgphobos%{libgphobos_sover}-32bit + +%description -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-32bit +Runtime library for the GNU D language. + +%post -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-32bit -p /sbin/ldconfig + +%postun -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-32bit -p /sbin/ldconfig + +%package -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-64bit +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgphobos%{libgphobos_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgphobos%{libgphobos_sover}-64bit + +%description -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-64bit +Runtime library for the GNU D language. + +%post -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-64bit -p /sbin/ldconfig + +%postun -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}-64bit -p /sbin/ldconfig + +%package -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix} +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgdruntime%{libgdruntime_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgdruntime%{libgdruntime_sover} + +%description -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix} +Runtime library for the GNU D language. + +%post -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix} -p /sbin/ldconfig + +%postun -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix} -p /sbin/ldconfig + +%package -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-32bit +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgdruntime%{libgdruntime_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgdruntime%{libgdruntime_sover}-32bit + +%description -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-32bit +Runtime library for the GNU D language. + +%post -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-32bit -p /sbin/ldconfig + +%postun -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-32bit -p /sbin/ldconfig + +%package -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-64bit +Summary: GNU D compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libgdruntime%{libgdruntime_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgdruntime%{libgdruntime_sover}-64bit + +%description -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-64bit +Runtime library for the GNU D language. + +%post -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-64bit -p /sbin/ldconfig + +%postun -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}-64bit -p /sbin/ldconfig + +%package -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} +Summary: The GNU Compiler Collection JIT library +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Provides: libgccjit%{libgccjit_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libgccjit%{libgccjit_sover} +# At runtime the JIT needs to be able to invoke the assembler and +# linker and find startfiles and libgcc. The built-in driver knows +# the compilers version install directory only so we require the +# respective compiler libgccjit was built from. +Requires: gcc13 + +%description -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} +Support for embedding GCC inside programs and libraries + +%post -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} -p /sbin/ldconfig + +%postun -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} -p /sbin/ldconfig + +%package -n libgccjit%{libgccjit_sover}-devel%{libdevel_suffix} +Summary: Support for embedding GCC inside programs and libraries +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Provides: libgccjit%{libgccjit_sover}-devel = %{version}-%{release} +# Only one gccjit package can be installed at the same time since +# header files conflict +Conflicts: %selfconflict libgccjit%{libgccjit_sover}-devel +Requires: libgccjit%{libgccjit_sover} >= %{version}-%{release} + +%description -n libgccjit%{libgccjit_sover}-devel%{libdevel_suffix} +Package contains header files and documentation for GCC JIT front-end. + +%package rust +Summary: GNU Rust Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-rust = %{version}-%{release} + +%description rust +This package contains a Rust compiler. + +%package rust-32bit +Summary: GNU Rust Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-rust = %{version}-%{release} + +%description rust-32bit +This package contains a Rust compiler. + +%package rust-64bit +Summary: GNU Rust Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-rust = %{version}-%{release} + +%description rust-64bit +This package contains a Rust compiler. + +%package m2 +Summary: GNU Modula-2 Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13 = %{version}-%{release} +Requires: gcc13-m2 = %{version}-%{release} +Requires: libm2cor%{libm2_sover} >= %{version}-%{release} +Requires: libm2iso%{libm2_sover} >= %{version}-%{release} +Requires: libm2log%{libm2_sover} >= %{version}-%{release} +Requires: libm2min%{libm2_sover} >= %{version}-%{release} +Requires: libm2pim%{libm2_sover} >= %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix} = %{version}-%{release} + +%description m2 +This package contains a Modula-2 compiler. + +%package m2-32bit +Summary: GNU Modula-2 Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-32bit = %{version}-%{release} +Requires: gcc13-m2 = %{version}-%{release} +Requires: libm2cor%{libm2_sover}-32bit >= %{version}-%{release} +Requires: libm2iso%{libm2_sover}-32bit >= %{version}-%{release} +Requires: libm2log%{libm2_sover}-32bit >= %{version}-%{release} +Requires: libm2min%{libm2_sover}-32bit >= %{version}-%{release} +Requires: libm2pim%{libm2_sover}-32bit >= %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-32bit = %{version}-%{release} + +%description m2-32bit +This package contains a Modula-2 compiler. + +%package m2-64bit +Summary: GNU Modula-2 Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc13-64bit = %{version}-%{release} +Requires: gcc13-m2 = %{version}-%{release} +Requires: libm2cor%{libm2_sover}-64bit >= %{version}-%{release} +Requires: libm2iso%{libm2_sover}-64bit >= %{version}-%{release} +Requires: libm2log%{libm2_sover}-64bit >= %{version}-%{release} +Requires: libm2min%{libm2_sover}-64bit >= %{version}-%{release} +Requires: libm2pim%{libm2_sover}-64bit >= %{version}-%{release} +Requires: libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}-64bit = %{version}-%{release} + +%description m2-64bit +This package contains a Modula-2 compiler. + +%package -n libm2log%{libm2_sover}%{libm2_suffix} +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2log%{libm2_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2log%{libm2_sover} + +%description -n libm2log%{libm2_sover}%{libm2_suffix} +Runtime library for the GNU Modula-2 language. + +%post -n libm2log%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%postun -n libm2log%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%package -n libm2log%{libm2_sover}%{libm2_suffix}-32bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2log%{libm2_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2log%{libm2_sover}-32bit + +%description -n libm2log%{libm2_sover}%{libm2_suffix}-32bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2log%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%postun -n libm2log%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%package -n libm2log%{libm2_sover}%{libm2_suffix}-64bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2log%{libm2_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2log%{libm2_sover}-64bit + +%description -n libm2log%{libm2_sover}%{libm2_suffix}-64bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2log%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%postun -n libm2log%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%package -n libm2cor%{libm2_sover}%{libm2_suffix} +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2cor%{libm2_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2cor%{libm2_sover} + +%description -n libm2cor%{libm2_sover}%{libm2_suffix} +Runtime library for the GNU Modula-2 language. + +%post -n libm2cor%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%postun -n libm2cor%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%package -n libm2cor%{libm2_sover}%{libm2_suffix}-32bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2cor%{libm2_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2cor%{libm2_sover}-32bit + +%description -n libm2cor%{libm2_sover}%{libm2_suffix}-32bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2cor%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%postun -n libm2cor%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%package -n libm2cor%{libm2_sover}%{libm2_suffix}-64bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2cor%{libm2_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2cor%{libm2_sover}-64bit + +%description -n libm2cor%{libm2_sover}%{libm2_suffix}-64bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2cor%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%postun -n libm2cor%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%package -n libm2iso%{libm2_sover}%{libm2_suffix} +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2iso%{libm2_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2iso%{libm2_sover} + +%description -n libm2iso%{libm2_sover}%{libm2_suffix} +Runtime library for the GNU Modula-2 language. + +%post -n libm2iso%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%postun -n libm2iso%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%package -n libm2iso%{libm2_sover}%{libm2_suffix}-32bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2iso%{libm2_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2iso%{libm2_sover}-32bit + +%description -n libm2iso%{libm2_sover}%{libm2_suffix}-32bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2iso%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%postun -n libm2iso%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%package -n libm2iso%{libm2_sover}%{libm2_suffix}-64bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2iso%{libm2_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2iso%{libm2_sover}-64bit + +%description -n libm2iso%{libm2_sover}%{libm2_suffix}-64bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2iso%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%postun -n libm2iso%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%package -n libm2pim%{libm2_sover}%{libm2_suffix} +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2pim%{libm2_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2pim%{libm2_sover} + +%description -n libm2pim%{libm2_sover}%{libm2_suffix} +Runtime library for the GNU Modula-2 language. + +%post -n libm2pim%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%postun -n libm2pim%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%package -n libm2pim%{libm2_sover}%{libm2_suffix}-32bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2pim%{libm2_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2pim%{libm2_sover}-32bit + +%description -n libm2pim%{libm2_sover}%{libm2_suffix}-32bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2pim%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%postun -n libm2pim%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%package -n libm2pim%{libm2_sover}%{libm2_suffix}-64bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2pim%{libm2_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2pim%{libm2_sover}-64bit + +%description -n libm2pim%{libm2_sover}%{libm2_suffix}-64bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2pim%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%postun -n libm2pim%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%package -n libm2min%{libm2_sover}%{libm2_suffix} +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2min%{libm2_sover} = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2min%{libm2_sover} + +%description -n libm2min%{libm2_sover}%{libm2_suffix} +Runtime library for the GNU Modula-2 language. + +%post -n libm2min%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%postun -n libm2min%{libm2_sover}%{libm2_suffix} -p /sbin/ldconfig + +%package -n libm2min%{libm2_sover}%{libm2_suffix}-32bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2min%{libm2_sover}-32bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2min%{libm2_sover}-32bit + +%description -n libm2min%{libm2_sover}%{libm2_suffix}-32bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2min%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%postun -n libm2min%{libm2_sover}%{libm2_suffix}-32bit -p /sbin/ldconfig + +%package -n libm2min%{libm2_sover}%{libm2_suffix}-64bit +Summary: GNU Modula-2 compiler runtime library +License: BSL-1.0 +Group: Development/Languages/Other +Provides: libm2min%{libm2_sover}-64bit = %{version}-%{release} +# Only one package may provide this - allows multiple gcc versions +# to co-exist without an overly large list of provides/obsoletes +Conflicts: %selfconflict libm2min%{libm2_sover}-64bit + +%description -n libm2min%{libm2_sover}%{libm2_suffix}-64bit +Runtime library for the GNU Modula-2 language. + +%post -n libm2min%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%postun -n libm2min%{libm2_sover}%{libm2_suffix}-64bit -p /sbin/ldconfig + +%package -n gcc13-testresults +Summary: Testsuite results +License: SUSE-Public-Domain +Group: Development/Languages/C and C++ + +%description -n gcc13-testresults +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 %{_target_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.3.0.20230120/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%patch -P 11 +%patch -P 15 +%patch -P 16 +%patch -P 17 -p1 +# These patches are needed only for llvm11 +%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 +%patch -P 18 -p1 +%patch -P 20 -p1 +%endif +# In SLE15 and earlier default to dwarf4, not dwarf5 +%if %{suse_version} < 1550 +%patch -P 19 -p1 +%endif +%patch -P 21 -p1 +%patch -P 23 -p1 +%patch -P 24 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 28 -p1 +%patch -P 51 +%patch -P 60 -p1 +%patch -P 61 -p1 +%patch -P 100 -p1 +%patch -P 101 -p1 + +#test patching end + +%build +%if %{with limitbuild} +%limit_build -m 900 +%endif +%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} +# Filter out unwanted flags from $RPM_OPT_FLAGS +optflags= +optflags_d= +for flag in $RPM_OPT_FLAGS; do + add_flag= + case $flag in + -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; + -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; + -ffortify=*|-Wall|-m32|-m64) ;; +%ifarch %ix86 + # -mcpu is superseded 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 superseded by proper + # default compiler settings now. + -mcpu=i?86|-march=i?86|-mtune=i?86) ;; +%endif +%ifarch s390 s390x + -fsigned-char) ;; + -O1) add_flag=-O2 ;; +%endif +%if 0%{?gcc_target_arch:1} + # Kill all -march/tune/cpu because that screws building the target libs + -march=*|-mtune=*|-mcpu=*) ;; +%endif + *) add_flag=$flag ;; + esac + if test -n "$add_flag"; then + optflags+=" $add_flag" + case $add_flag in + # Filter out -Werror=return-type for D (only valid for C and C++) + -Werror=return-type) ;; + *) optflags_d+=" $add_flag" ;; + esac + fi +done + +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 +%if %{build_rust} +languages=$languages,rust +%endif +%if %{build_m2} +languages=$languages,m2 +%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar +ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as +ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld +ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm +ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 + +../configure \ + CFLAGS="$optflags" \ + CXXFLAGS="$optflags" \ + XCFLAGS="$optflags" \ + TCFLAGS="$optflags" \ + GDCFLAGS="$optflags_d" \ + --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} \ + --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ + --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}" == "bpf" + --disable-gcov \ +%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 0%{?cross_arch:1} + --with-glibc-version=2.32 \ +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-cpu=power9 \ + --with-tune=power9 \ +%else +%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 +%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 %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" +%ifnarch %{disable_multilib_arch} + --enable-multilib \ +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch-32=x86-64-v2 \ +%else + --with-arch-32=x86-64 \ +%endif +%endif +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-arch=x86-64-v2 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1600 && !0%{?is_opensuse} + --with-tune=z14 --with-arch=z14 \ +%else +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%if 0%{?cross_arch:1} + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif +%if %{with bootstrap} +%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} + --with-build-config=bootstrap-lto-lean \ +%endif +%else + --disable-bootstrap \ +%endif + --enable-link-serialization \ + $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 +%if %{with bootstrap} +%define use_pgo_bootstrap 1 +%endif +%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} +# Work around tail/head -1 changes +export _POSIX2_VERSION=199209 +export LIBRARY_PATH=%{buildroot}/%{libsubdir}:%{buildroot}/%{mainlibdirbi} + +%make_install + +# verify libasan really ended up with libstdc++ as NEEDED. +%ifarch %asan_arch + readelf -d %{buildroot}/%{versmainlibdir}/libasan.so.%{libasan_sover}* | grep 'NEEDED.*libstdc++' || exit 1 +%if %{biarch} + readelf -d %{buildroot}/%{versmainlibdirbi}/libasan.so.%{libasan_sover}* | grep 'NEEDED.*libstdc++' || exit 1 +%endif +%endif + +# Remove some useless .la files +for lib in libobjc libgfortran libquadmath libcaf_single \ + libgomp libgomp-plugin-hsa libstdc++ libsupc++ libgo \ + libasan libhwasan libatomic libitm libtsan liblsan libubsan libvtv \ + libstdc++fs libgomp-plugin-nvptx libgomp-plugin-gcn \ + libgdruntime libgphobos libstdc++exp \ + libm2cor libm2iso libm2log libm2min libm2pim; do + rm -f %{buildroot}/%{versmainlibdir}/$lib.la +%if %{biarch} + rm -f %{buildroot}/%{versmainlibdirbi}/$lib.la +%endif +done + +mkdir -p %{buildroot}/%{_libdir} +%if %{biarch} +%if %{build_primary_64bit} +mkdir -p %{buildroot}/%{_prefix}/lib +%else +mkdir -p %{buildroot}/%{_prefix}/lib64 +%endif +%endif + +%if %{build_cp} +# Merge multilib c++config.h to allow omitting the duplicate and +# identical other arch specific headers +dir_ml= +cxxconfig="`find %{GCCDIST}/libstdc++-v3/include -name c++config.h`" +for i in `find %{GCCDIST}/[36]*/libstdc++-v3/include -name c++config.h 2>/dev/null`; do + if ! diff -up $cxxconfig $i; then + file_32=x + file_64=x + case $i in + %{GCCDIST}/32/*) + file_32=$i + file_64=$cxxconfig + dir_ml=32 + ;; + %{GCCDIST}/64/*) + file_32=$cxxconfig + file_64=$i + dir_ml=64 + ;; + esac + if ! ( test -f "$file_32" && test -f "$file_64" ); then + echo "Urgs?" + exit 1 + fi + + cat > %{buildroot}/%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/bits/c++config.h < +#if __WORDSIZE == 32 +`cat $file_32` +#else +`cat $file_64` +#endif +#endif +EOF + break + fi +done +rm -rf %{buildroot}/%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/[36]* +if ! test -z "$dir_ml"; then + ln -s . %{buildroot}/%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/$dir_ml +fi +%endif + +# move shared libs from versionspecific dir to main libdir +for libname in \ +%if %{build_fortran} + libgfortran \ +%endif +%ifarch %quadmath_arch + libquadmath \ +%endif +%if %{build_objc} + libobjc \ +%endif +%if %{build_cp} + libstdc++ \ +%endif +%if %{build_go} + libgo \ +%endif +%if %{build_d} + libgdruntime \ + libgphobos \ +%endif + libgomp \ +%if %{build_nvptx} + libgomp-plugin-nvptx \ +%endif +%if %{build_gcn} + libgomp-plugin-gcn \ +%endif +%if %{build_m2} + libm2log \ + libm2cor \ + libm2iso \ + libm2pim \ + libm2min \ +%endif +%ifarch %atomic_arch + libatomic \ +%endif +%ifarch %itm_arch + libitm \ +%endif +%ifarch %asan_arch + libasan \ +%endif +%ifarch %tsan_arch + libtsan \ +%endif +%ifarch %lsan_arch + liblsan \ +%endif +%ifarch %ubsan_arch + libubsan \ +%endif +%ifarch %hwasan_arch + libhwasan \ +%endif +%ifarch %vtv_arch + libvtv \ +%endif + ; do + for lib in `find %{buildroot}/%{versmainlibdir} -maxdepth 1 -name $libname.so.*`; do + mv $lib %{buildroot}/%{mainlibdir}/ + done + if test -L %{buildroot}/%{versmainlibdir}/$libname.so; then + ln -sf %{mainlibdir}/`readlink %{buildroot}/%{versmainlibdir}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + %{buildroot}/%{versmainlibdir}/$libname.so + fi +%if %{biarch} + if test -d %{buildroot}/%{versmainlibdirbi}; then + for lib in `find %{buildroot}/%{versmainlibdirbi} -maxdepth 1 -name "$libname.so.*"`; do + mv $lib %{buildroot}/%{mainlibdirbi}/ + done + if test -L %{buildroot}/%{versmainlibdirbi}/$libname.so; then + ln -sf %{mainlibdirbi}/`readlink %{buildroot}/%{versmainlibdirbi}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + %{buildroot}/%{versmainlibdirbi}/$libname.so + fi + fi +%endif +done +%if %{build_cp} +# And we want to move the shlib gdb pretty printers to a more sane +# place so ldconfig does not complain +mkdir -p %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdir} +mv %{buildroot}/%{mainlibdir}/libstdc++.so.*-gdb.py %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdir}/ +sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdir}/libstdc++.so.*-gdb.py +%if %{biarch} + if test -d %{buildroot}/%{versmainlibdirbi}; then + mkdir -p %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdirbi} + mv %{buildroot}/%{mainlibdirbi}/libstdc++.so.*-gdb.py %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdirbi}/ + sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' %{buildroot}/%{_datadir}/gdb/auto-load%{mainlibdirbi}/libstdc++.so.*-gdb.py + fi +%endif +%endif + +# Move libgcc_s around +if test -L %{buildroot}/%{_lib}/libgcc_s.so; then + rm -f %{buildroot}/%{_lib}/libgcc_s.so + ln -sf /%{_lib}/libgcc_s.so.%{libgcc_s} %{buildroot}/%{versmainlibdir}/libgcc_s.so +else + mv %{buildroot}/%{_lib}/libgcc_s.so %{buildroot}/%{versmainlibdir}/ +fi +chmod a+x %{buildroot}/%{_lib}/libgcc_s.so.%{libgcc_s} +%if 0%{?usrmerged} +mv %{buildroot}/%{_lib}/libgcc_s.so.%{libgcc_s} %{buildroot}/%{_slibdir}/libgcc_s.so.%{libgcc_s} +%endif +%if %{biarch} +%if %{build_primary_64bit} +if test -L %{buildroot}/lib/libgcc_s.so; then + rm -f %{buildroot}/lib/libgcc_s.so + ln -sf /lib/libgcc_s.so.%{libgcc_s} %{buildroot}/%{versmainlibdirbi32}/libgcc_s.so +else + mv %{buildroot}/lib/libgcc_s.so %{buildroot}/%{versmainlibdirbi32}/ +fi +ln -sf %{versmainlibdirbi32}/libgcc_s.so %{buildroot}/%{versmainlibdirbi32}/libgcc_s_32.so +chmod a+x %{buildroot}/lib/libgcc_s.so.%{libgcc_s} +%if 0%{?usrmerged} +mv %{buildroot}/lib/libgcc_s.so.%{libgcc_s} %{buildroot}/%{slibdir}/libgcc_s.so.%{libgcc_s} +%endif +%else +# 32-bit biarch systems +if test -L %{buildroot}/lib64/libgcc_s.so; then + rm -f %{buildroot}/lib64/libgcc_s.so + ln -sf /lib64/libgcc_s.so.%{libgcc_s} %{buildroot}/%{versmainlibdirbi64}/libgcc_s.so +else + mv %{buildroot}/lib64/libgcc_s.so %{buildroot}/%{versmainlibdirbi64}/ +fi +ln -sf %{versmainlibdirbi64}/libgcc_s.so %{buildroot}/%{versmainlibdirbi64}/libgcc_s_64.so +chmod a+x %{buildroot}/lib64/libgcc_s.so.%{libgcc_s} +%if 0%{?usrmerged} +mv %{buildroot}/lib64/libgcc_s.so.%{libgcc_s} %{buildroot}/%{slibdir64}/libgcc_s.so.%{libgcc_s} +%endif +%endif +%endif + +%if %{build_ada} +mv %{buildroot}/%{libsubdir}/adalib/lib*-*.so %{buildroot}/%{_libdir} +ln -sf %{_libdir}/libgnarl%{binsuffix}.so %{buildroot}/%{libsubdir}/adalib/libgnarl.so +ln -sf %{_libdir}/libgnat%{binsuffix}.so %{buildroot}/%{libsubdir}/adalib/libgnat.so +chmod a+x %{buildroot}/%{_libdir}/libgna*-*.so +%if %{biarch} +mv %{buildroot}/%{versmainlibdirbi}/adalib/lib*-*.so %{buildroot}/%{mainlibdirbi}/ +ln -sf %{mainlibdirbi}/libgnarl%{binsuffix}.so %{buildroot}/%{versmainlibdirbi}/adalib/libgnarl.so +ln -sf %{mainlibdirbi}/libgnat%{binsuffix}.so %{buildroot}/%{versmainlibdirbi}/adalib/libgnat.so +chmod a+x %{buildroot}/%{mainlibdirbi}/libgna*-*.so +%endif +%endif + +rm -f %{buildroot}/%{_prefix}/bin/c++%{binsuffix} + +# Remove some crap from the .la files: +for l in `find %{buildroot} -name '*.la'`; do + echo "changing $l" + sed -e '/^dependency_libs/s| -L%{_builddir}/[^ ]*||g' \ + -e '/^dependency_libs/s| -L/usr/%{GCCDIST}/bin||g' \ + -e '/^dependency_libs/s|-lm \(-lm \)*|-lm |' \ + -e '/^dependency_libs/s|-L[^ ]* ||g' \ +%if %{biarch} +%if %{build_primary_64bit} + -e '/^libdir/s|%{_libdir}/32|%{_prefix}/lib|' \ + -e '/^libdir/s|lib64/\.\./||' \ +%else + -e '/^libdir/s|%{_libdir}/64|%{_prefix}/lib64|' \ +%endif +%endif + < $l > $l.new + mv $l.new $l +done + +# The spec for the PIE subpackage +cat > %{buildroot}/%{libsubdir}/defaults.spec < ../floatn-fixes.list +# Whether floatn.h is fixed depends on the glibc version and architecture. +# For now keep it if it's there but in the end we want to fix glibc itself +# everywhere. +if test -f %{buildroot}/%{libsubdir}/include-fixed/bits/floatn.h; then + cat >> ../floatn-fixes.list <> ../floatn-fixes.list < gcc13-locale.lang + +%post info +%install_info --info-dir=%{_infodir} %{_infodir}/cpp%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/cppinternals%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gcc%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gccint%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gccinstall%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/libgomp%{binsuffix}.info.gz +%ifarch %itm_arch +%install_info --info-dir=%{_infodir} %{_infodir}/libitm%{binsuffix}.info.gz +%endif +%if %{build_fortran} +%install_info --info-dir=%{_infodir} %{_infodir}/gfortran%{binsuffix}.info.gz +%ifarch %quadmath_arch +%install_info --info-dir=%{_infodir} %{_infodir}/libquadmath%{binsuffix}.info.gz +%endif +%endif +%if %{build_ada} +%install_info --info-dir=%{_infodir} %{_infodir}/gnat-style%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gnat_rm%{binsuffix}.info.gz +%install_info --info-dir=%{_infodir} %{_infodir}/gnat_ugn%{binsuffix}.info.gz +%endif + +%preun info +%install_info_delete --info-dir=%{_infodir} %{_infodir}/cpp%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/cppinternals%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gcc%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gccint%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gccinstall%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/libgomp%{binsuffix}.info.gz +%ifarch %itm_arch +%install_info_delete --info-dir=%{_infodir} %{_infodir}/libitm%{binsuffix}.info.gz +%endif +%if %{build_fortran} +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gfortran%{binsuffix}.info.gz +%ifarch %quadmath_arch +%install_info_delete --info-dir=%{_infodir} %{_infodir}/libquadmath%{binsuffix}.info.gz +%endif +%endif +%if %{build_ada} +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gnat-style%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gnat_rm%{binsuffix}.info.gz +%install_info_delete --info-dir=%{_infodir} %{_infodir}/gnat_ugn%{binsuffix}.info.gz +%endif + +%files -f floatn-fixes.list +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%dir %{libsubdir}/include +%dir %{libsubdir}/include-fixed +%if %{biarch} +%if %{build_primary_64bit} +%dir %{libsubdir}/32 +%else +%dir %{libsubdir}/64 +%endif +%endif +%{_prefix}/bin/gcc%{binsuffix} +%{_prefix}/bin/%{GCCDIST}-gcc%{binsuffix} +%{_prefix}/bin/gcov%{binsuffix} +%{_prefix}/bin/gcov-dump%{binsuffix} +%{_prefix}/bin/gcov-tool%{binsuffix} +%{_prefix}/bin/gcc-ar%{binsuffix} +%{_prefix}/bin/gcc-nm%{binsuffix} +%{_prefix}/bin/gcc-ranlib%{binsuffix} +%{_prefix}/bin/lto-dump%{binsuffix} +%{libsubdir}/collect2 +%{libsubdir}/lto1 +%{libsubdir}/lto-wrapper +%{libsubdir}/liblto_plugin.so* +%{libsubdir}/include/limits.h +%{libsubdir}/include/syslimits.h +%{libsubdir}/include-fixed/README +%{libsubdir}/include/omp.h +%{libsubdir}/include/float.h +%{libsubdir}/include/iso646.h +%{libsubdir}/include/stdarg.h +%{libsubdir}/include/stdbool.h +%{libsubdir}/include/stdfix.h +%{libsubdir}/include/stddef.h +%{libsubdir}/include/unwind.h +%{libsubdir}/include/varargs.h +%{libsubdir}/include/stdint.h +%{libsubdir}/include/stdint-gcc.h +%{libsubdir}/include/stdnoreturn.h +%{libsubdir}/include/stdalign.h +%{libsubdir}/include/stdatomic.h +%{libsubdir}/include/openacc.h +%{libsubdir}/include/gcov.h +%{libsubdir}/include/acc_prof.h +%ifarch %sparc +%{libsubdir}/include/visintrin.h +%endif +%ifarch ppc ppc64 ppc64le +%{libsubdir}/include/altivec.h +%{libsubdir}/include/ppc-asm.h +%{libsubdir}/include/ppu_intrinsics.h +%{libsubdir}/include/si2vmx.h +%{libsubdir}/include/spu2vmx.h +%{libsubdir}/include/vec_types.h +%{libsubdir}/include/htmintrin.h +%{libsubdir}/include/htmxlintrin.h +%{libsubdir}/include/amo.h +%{libsubdir}/include/bmi2intrin.h +%{libsubdir}/include/bmiintrin.h +%{libsubdir}/include/emmintrin.h +%{libsubdir}/include/mm_malloc.h +%{libsubdir}/include/mmintrin.h +%{libsubdir}/include/x86intrin.h +%{libsubdir}/include/xmmintrin.h +%{libsubdir}/include/pmmintrin.h +%{libsubdir}/include/tmmintrin.h +%{libsubdir}/include/smmintrin.h +%{libsubdir}/include/rs6000-vecdefines.h +%{libsubdir}/include/immintrin.h +%{libsubdir}/include/nmmintrin.h +%{libsubdir}/include/x86gprintrin.h +%endif +%ifarch s390 s390x +%{libsubdir}/include/htmintrin.h +%{libsubdir}/include/htmxlintrin.h +%{libsubdir}/include/s390intrin.h +%{libsubdir}/include/vecintrin.h +%endif +%ifarch ia64 +%{libsubdir}/include/ia64intrin.h +%endif +%ifarch %arm +%{libsubdir}/include/mmintrin.h +%{libsubdir}/include/unwind-arm-common.h +%{libsubdir}/include/arm_cmse.h +%{libsubdir}/include/arm_mve.h +%{libsubdir}/include/arm_mve_types.h +%{libsubdir}/include/arm_cde.h +%endif +%ifarch %arm aarch64 +%{libsubdir}/include/arm_neon.h +%{libsubdir}/include/arm_acle.h +%{libsubdir}/include/arm_fp16.h +%{libsubdir}/include/arm_bf16.h +%endif +%ifarch aarch64 +%{libsubdir}/include/arm_sve.h +%endif +%ifarch riscv64 +%{libsubdir}/include/riscv_vector.h +%endif +%ifarch %ix86 x86_64 +%{libsubdir}/include/cross-stdarg.h +%{libsubdir}/include/cpuid.h +%{libsubdir}/include/mm3dnow.h +%{libsubdir}/include/mmintrin.h +%{libsubdir}/include/ammintrin.h +%{libsubdir}/include/bmmintrin.h +%{libsubdir}/include/emmintrin.h +%{libsubdir}/include/immintrin.h +%{libsubdir}/include/avxintrin.h +%{libsubdir}/include/pmmintrin.h +%{libsubdir}/include/xmmintrin.h +%{libsubdir}/include/tmmintrin.h +%{libsubdir}/include/nmmintrin.h +%{libsubdir}/include/smmintrin.h +%{libsubdir}/include/wmmintrin.h +%{libsubdir}/include/x86intrin.h +%{libsubdir}/include/ia32intrin.h +%{libsubdir}/include/mm_malloc.h +%{libsubdir}/include/fma4intrin.h +%{libsubdir}/include/xopintrin.h +%{libsubdir}/include/lwpintrin.h +%{libsubdir}/include/popcntintrin.h +%{libsubdir}/include/bmiintrin.h +%{libsubdir}/include/tbmintrin.h +%{libsubdir}/include/avx2intrin.h +%{libsubdir}/include/bmi2intrin.h +%{libsubdir}/include/fmaintrin.h +%{libsubdir}/include/lzcntintrin.h +%{libsubdir}/include/f16cintrin.h +%{libsubdir}/include/adxintrin.h +%{libsubdir}/include/fxsrintrin.h +%{libsubdir}/include/prfchwintrin.h +%{libsubdir}/include/rdseedintrin.h +%{libsubdir}/include/rtmintrin.h +%{libsubdir}/include/xsaveintrin.h +%{libsubdir}/include/xsaveoptintrin.h +%{libsubdir}/include/xtestintrin.h +%{libsubdir}/include/avx512cdintrin.h +%{libsubdir}/include/avx512erintrin.h +%{libsubdir}/include/avx512fintrin.h +%{libsubdir}/include/avx512pfintrin.h +%{libsubdir}/include/shaintrin.h +%{libsubdir}/include/avx512bwintrin.h +%{libsubdir}/include/avx512dqintrin.h +%{libsubdir}/include/avx512vlbwintrin.h +%{libsubdir}/include/avx512vldqintrin.h +%{libsubdir}/include/avx512vlintrin.h +%{libsubdir}/include/avx512ifmaintrin.h +%{libsubdir}/include/avx512ifmavlintrin.h +%{libsubdir}/include/avx512vbmiintrin.h +%{libsubdir}/include/avx512vbmivlintrin.h +%{libsubdir}/include/avx5124fmapsintrin.h +%{libsubdir}/include/avx5124vnniwintrin.h +%{libsubdir}/include/avx512vpopcntdqintrin.h +%{libsubdir}/include/avx512vbmi2intrin.h +%{libsubdir}/include/avx512vbmi2vlintrin.h +%{libsubdir}/include/avx512vnniintrin.h +%{libsubdir}/include/avx512vnnivlintrin.h +%{libsubdir}/include/avx512bitalgintrin.h +%{libsubdir}/include/avx512vpopcntdqvlintrin.h +%{libsubdir}/include/avx512bf16intrin.h +%{libsubdir}/include/avx512bf16vlintrin.h +%{libsubdir}/include/avx512vp2intersectintrin.h +%{libsubdir}/include/avx512vp2intersectvlintrin.h +%{libsubdir}/include/vpclmulqdqintrin.h +%{libsubdir}/include/enqcmdintrin.h +%{libsubdir}/include/cet.h +%{libsubdir}/include/vaesintrin.h +%{libsubdir}/include/clwbintrin.h +%{libsubdir}/include/clflushoptintrin.h +%{libsubdir}/include/xsavecintrin.h +%{libsubdir}/include/xsavesintrin.h +%{libsubdir}/include/mwaitxintrin.h +%{libsubdir}/include/clzerointrin.h +%{libsubdir}/include/pkuintrin.h +%{libsubdir}/include/sgxintrin.h +%{libsubdir}/include/cetintrin.h +%{libsubdir}/include/gfniintrin.h +%{libsubdir}/include/pconfigintrin.h +%{libsubdir}/include/wbnoinvdintrin.h +%{libsubdir}/include/movdirintrin.h +%{libsubdir}/include/cldemoteintrin.h +%{libsubdir}/include/waitpkgintrin.h +%{libsubdir}/include/serializeintrin.h +%{libsubdir}/include/tsxldtrkintrin.h +%{libsubdir}/include/amxbf16intrin.h +%{libsubdir}/include/amxint8intrin.h +%{libsubdir}/include/amxtileintrin.h +%{libsubdir}/include/x86gprintrin.h +%{libsubdir}/include/hresetintrin.h +%{libsubdir}/include/uintrintrin.h +%{libsubdir}/include/keylockerintrin.h +%{libsubdir}/include/avxvnniintrin.h +%{libsubdir}/include/mwaitintrin.h +%{libsubdir}/include/avx512fp16intrin.h +%{libsubdir}/include/avx512fp16vlintrin.h +%{libsubdir}/include/avxifmaintrin.h +%{libsubdir}/include/avxvnniint8intrin.h +%{libsubdir}/include/avxneconvertintrin.h +%{libsubdir}/include/amxfp16intrin.h +%{libsubdir}/include/cmpccxaddintrin.h +%{libsubdir}/include/prfchiintrin.h +%{libsubdir}/include/raointintrin.h +%{libsubdir}/include/amxcomplexintrin.h +%endif +%ifarch m68k +%{libsubdir}/include/math-68881.h +%endif +%ifarch %asan_arch +%{libsubdir}/include/sanitizer +%endif +%if %{build_fortran} +%{libsubdir}/include/ISO_Fortran_binding.h +%endif +%versmainlib *crt*.o +%versmainlib libgcc*.a +%versmainlib libgcov.a +%versmainlib libgcc_s*.so +%versmainlib libgomp.so +%versmainlib libgomp.a +%versmainlib libgomp.spec +%if %{build_nvptx} +%versmainlib libgomp-plugin-nvptx.so +%endif +%if %{build_gcn} +%versmainlib libgomp-plugin-gcn.so +%endif +%ifarch %itm_arch +%versmainlib libitm.so +%versmainlib libitm.a +%versmainlib libitm.spec +%endif +%ifarch %atomic_arch +%versmainlib libatomic.so +%versmainlib libatomic.a +%endif +%ifarch %asan_arch +%versmainlib libasan.so +%versmainlib libasan.a +%versmainlib libasan_preinit.o +%endif +%ifarch %tsan_arch +%if %build_primary_64bit +%versmainlib libtsan.so +%versmainlib libtsan.a +%versmainlib libtsan_preinit.o +%endif +%endif +%ifarch %lsan_arch +%if %build_primary_64bit +%versmainlib liblsan.so +%versmainlib liblsan.a +%versmainlib liblsan_preinit.o +%endif +%endif +%ifarch %ubsan_arch +%versmainlib libubsan.so +%versmainlib libubsan.a +%endif +%ifarch %hwasan_arch +%versmainlib libhwasan.so +%versmainlib libhwasan.a +%versmainlib libhwasan_preinit.o +%endif +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch %hwasan_arch +%versmainlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versmainlib libvtv.so +%versmainlib libvtv.a +%endif +%doc %{_mandir}/man1/gcc%{binsuffix}.1.gz +%doc %{_mandir}/man1/gcov%{binsuffix}.1.gz +%doc %{_mandir}/man1/gcov-dump%{binsuffix}.1.gz +%doc %{_mandir}/man1/gcov-tool%{binsuffix}.1.gz +%doc %{_mandir}/man1/lto-dump%{binsuffix}.1.gz + +%if %{separate_biarch} +%files -n gcc13%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib *crt*.o +%versbiarchlib libgcc*.a +%versbiarchlib libgcov.a +%versbiarchlib libgcc_s*.so +%versbiarchlib libgomp.so +%versbiarchlib libgomp.a +%versbiarchlib libgomp.spec +# No 32-bit plugins for nvptx and gcn +%ifarch %itm_arch +%versbiarchlib libitm.so +%versbiarchlib libitm.a +%versbiarchlib libitm.spec +%endif +%ifarch %atomic_arch +%versbiarchlib libatomic.a +%versbiarchlib libatomic.so +%endif +%ifarch %asan_arch +%versbiarchlib libasan.a +%versbiarchlib libasan.so +%versbiarchlib libasan_preinit.o +%endif +%ifarch %ubsan_arch +%versbiarchlib libubsan.a +%versbiarchlib libubsan.so +%endif +%ifarch %tsan_arch +%if %separate_bi64 +%versbiarchlib libtsan.a +%versbiarchlib libtsan.so +%versbiarchlib libtsan_preinit.o +%endif +%endif +%ifarch %lsan_arch +%if %separate_bi64 +%versbiarchlib liblsan.a +%versbiarchlib liblsan.so +%versbiarchlib liblsan_preinit.o +%endif +%endif +# libhwasan.{a,so} is not built in 32-bit mode +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch %hwasan_arch +%versbiarchlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versbiarchlib libvtv.a +%versbiarchlib libvtv.so +%endif +%endif + +%if %{enable_plugins} +%files devel +%defattr(-,root,root) +%dir %{libsubdir}/plugin +%{libsubdir}/plugin +%if %{build_m2} +%exclude %{libsubdir}/plugin/m2rte.so +%endif +%endif + +%files locale -f gcc13-locale.lang + +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale -f libstdc++.lang + +%files PIE +%defattr(-,root,root) +%dir %{libsubdir} +%{libsubdir}/defaults.spec + +%if %{build_cp} +%files c++ +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%{_prefix}/bin/g++%{binsuffix} +%doc %{_mandir}/man1/g++%{binsuffix}.1.gz +%{libsubdir}/cc1plus +%{libsubdir}/g++-mapper-server + +%if %{separate_biarch} +%files c++%{separate_biarch_suffix} +%defattr(-,root,root) +# empty - only for the dependency +%if %{suse_version} < 1310 +%doc README +%endif +%endif + +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix} +%defattr(-,root,root) +%mainlib libstdc++.so.%{libstdcxx_sover}* + +%if %{separate_biarch} +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libstdc++.so.%{libstdcxx_sover}* +%endif + +%files -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix} +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%versmainlib libstdc++.a +%versmainlib libstdc++fs.a +%versmainlib libstdc++exp.a +%versmainlib libstdc++.so +%versmainlib libsupc++.a +%{_prefix}/include/c++ + +%files -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix} +%defattr(-,root,root) +%dir %{_datadir}/gdb +%dir %{_datadir}/gdb/auto-load +%dir %{_datadir}/gdb/auto-load%{_prefix} +%dir %{_datadir}/gdb/auto-load/%{mainlibdir} +%{_datadir}/gdb/auto-load/%{mainlibdir}/libstdc++.so.*-gdb.py +%{_datadir}/gcc%{binsuffix} + +%if %{separate_biarch} +%files -n libstdc++%{libstdcxx_sover}-devel%{libdevel_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%versbiarchlib libstdc++.a +%versbiarchlib libstdc++fs.a +%versbiarchlib libstdc++exp.a +%versbiarchlib libstdc++.so +%versbiarchlib libsupc++.a + +%files -n libstdc++%{libstdcxx_sover}-pp%{libstdcxx_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{_datadir}/gdb/auto-load/%{mainlibdirbi} +%{_datadir}/gdb/auto-load/%{mainlibdirbi}/libstdc++.so.*-gdb.py +%endif +%endif + +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix} +%defattr(-,root,root) +%{_slibdir}/libgcc_s.so.%{libgcc_s} +%if %{biarch} +%if %{build_primary_64bit} +%if !%{separate_bi32} +%{slibdir}/libgcc_s.so.%{libgcc_s} +%endif +%else +%if !%{separate_bi64} +%{slibdir64}/libgcc_s.so.%{libgcc_s} +%endif +%endif +%endif + +%if %{separate_bi64} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit +%defattr(-,root,root) +%{slibdir64}/libgcc_s.so.%{libgcc_s} +%endif + +%if %{separate_bi32} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit +%defattr(-,root,root) +%{slibdir}/libgcc_s.so.%{libgcc_s} +%endif + +%files -n libgomp%{libgomp_sover}%{libgomp_suffix} +%defattr(-,root,root) +%mainlib libgomp.so.%{libgomp_sover}* +%if %{build_nvptx} +%mainlib libgomp-plugin-nvptx.so.%{libgomp_sover}* +%endif +%if %{build_gcn} +%mainlib libgomp-plugin-gcn.so.%{libgomp_sover}* +%endif + +%if %{separate_biarch} +%files -n libgomp%{libgomp_sover}%{libgomp_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgomp.so.%{libgomp_sover}* +%endif +# No 32-bit plugins for nvptx and gcn + +%ifarch %asan_arch +%files -n libasan%{libasan_sover}%{libasan_suffix} +%defattr(-,root,root) +%mainlib libasan.so.%{libasan_sover}* + +%if %{separate_biarch} +%files -n libasan%{libasan_sover}%{libasan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libasan.so.%{libasan_sover}* +%endif +%endif + +%ifarch %lsan_arch +%if %build_primary_64bit +%files -n liblsan%{liblsan_sover}%{liblsan_suffix} +%defattr(-,root,root) +%mainlib liblsan.so.%{liblsan_sover}* +%endif + +%if %{separate_biarch} && %{separate_bi64} +%files -n liblsan%{liblsan_sover}%{liblsan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib liblsan.so.%{liblsan_sover}* +%endif +%endif + +%ifarch %tsan_arch +%if %build_primary_64bit +%files -n libtsan%{libtsan_sover}%{libtsan_suffix} +%defattr(-,root,root) +%mainlib libtsan.so.%{libtsan_sover}* +%endif + +%if %{separate_biarch} && %{separate_bi64} +%files -n libtsan%{libtsan_sover}%{libtsan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libtsan.so.%{libtsan_sover}* +%endif +%endif + +%ifarch %hwasan_arch +%files -n libhwasan%{libhwasan_sover}%{libhwasan_suffix} +%defattr(-,root,root) +%mainlib libhwasan.so.%{libhwasan_sover}* +%endif + +%ifarch %atomic_arch +%files -n libatomic%{libatomic_sover}%{libatomic_suffix} +%defattr(-,root,root) +%mainlib libatomic.so.%{libatomic_sover}* + +%if %{separate_biarch} +%files -n libatomic%{libatomic_sover}%{libatomic_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libatomic.so.%{libatomic_sover}* +%endif +%endif + +%ifarch %itm_arch +%files -n libitm%{libitm_sover}%{libitm_suffix} +%defattr(-,root,root) +%mainlib libitm.so.%{libitm_sover}* + +%if %{separate_biarch} +%files -n libitm%{libitm_sover}%{libitm_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libitm.so.%{libitm_sover}* +%endif +%endif + +%ifarch %ubsan_arch +%files -n libubsan%{libubsan_sover}%{libubsan_suffix} +%defattr(-,root,root) +%mainlib libubsan.so.%{libubsan_sover}* + +%if %{separate_biarch} +%files -n libubsan%{libubsan_sover}%{libubsan_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libubsan.so.%{libubsan_sover}* +%endif +%endif + +%ifarch %vtv_arch +%files -n libvtv%{libvtv_sover}%{libvtv_suffix} +%defattr(-,root,root) +%mainlib libvtv.so.%{libvtv_sover}* + +%if %{separate_biarch} +%files -n libvtv%{libvtv_sover}%{libvtv_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libvtv.so.%{libvtv_sover}* +%endif + +%endif + +%if %{build_fortran} +%files fortran +%defattr(-,root,root) +%dir %{libsubdir}/finclude +%{_prefix}/bin/gfortran%{binsuffix} +%{libsubdir}/f951 +%{libsubdir}/finclude/* +%versmainlib libgfortran.a +%versmainlib libgfortran.so +%versmainlib libgfortran.spec +%versmainlib libcaf_single.a +%ifarch %quadmath_arch +%{libsubdir}/include/quadmath.h +%{libsubdir}/include/quadmath_weak.h +%versmainlib libquadmath.a +%versmainlib libquadmath.so +%endif +%doc %{_mandir}/man1/gfortran%{binsuffix}.1.gz + +%if %{separate_biarch} +%files fortran%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{versmainlibdirbi}/finclude +%{versmainlibdirbi}/finclude/* +%versbiarchlib libgfortran.a +%versbiarchlib libgfortran.so +%versbiarchlib libgfortran.spec +%versbiarchlib libcaf_single.a +%ifarch %quadmath_arch +%versbiarchlib libquadmath.a +%versbiarchlib libquadmath.so +%endif +%endif + +%files -n libgfortran%{libgfortran_sover}%{libgfortran_suffix} +%defattr(-,root,root) +%mainlib libgfortran.so.%{libgfortran_sover}* + +%if %{separate_biarch} +%files -n libgfortran%{libgfortran_sover}%{libgfortran_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgfortran.so.%{libgfortran_sover}* +%endif + +%ifarch %quadmath_arch +%files -n libquadmath%{libquadmath_sover}%{libquadmath_suffix} +%defattr(-,root,root) +%mainlib libquadmath.so.%{libquadmath_sover}* + +%if %{separate_biarch} +%files -n libquadmath%{libquadmath_sover}%{libquadmath_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libquadmath.so.%{libquadmath_sover}* +%endif +%endif +%endif + +%files info +%defattr(-,root,root) +%doc %{_infodir}/cpp%{binsuffix}.info*.gz +%doc %{_infodir}/cppinternals%{binsuffix}.info*.gz +%doc %{_infodir}/gcc%{binsuffix}.info*.gz +%doc %{_infodir}/gccint%{binsuffix}.info*.gz +%doc %{_infodir}/gccinstall%{binsuffix}.info*.gz +%doc %{_infodir}/libgomp%{binsuffix}.info*.gz +%ifarch %itm_arch +%doc %{_infodir}/libitm%{binsuffix}.info*.gz +%endif +%if %{build_fortran} +%doc %{_infodir}/gfortran%{binsuffix}.info*.gz +%ifarch %quadmath_arch +%doc %{_infodir}/libquadmath%{binsuffix}.info*.gz +%endif +%endif +%if %{build_ada} +%doc %{_infodir}/gnat-style%{binsuffix}.info*gz +%doc %{_infodir}/gnat_rm%{binsuffix}.info*gz +%doc %{_infodir}/gnat_ugn%{binsuffix}.info*gz +%endif +%if %{build_d} +%doc %{_infodir}/gdc%{binsuffix}.info*gz +%endif + +%files -n cpp13 +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%{_prefix}/bin/cpp%{binsuffix} +%{libsubdir}/cc1 +%doc %{_mandir}/man1/cpp%{binsuffix}.1.gz + +%if %{build_objc} +%files objc +%defattr(-,root,root) +%{libsubdir}/cc1obj +%{libsubdir}/include/objc +%versmainlib libobjc.a +%versmainlib libobjc.so + +%if %{separate_biarch} +%files objc%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib libobjc.a +%versbiarchlib libobjc.so +%endif + +%files -n libobjc%{libobjc_sover}%{libobjc_suffix} +%defattr(-,root,root) +%mainlib libobjc.so.%{libobjc_sover}* + +%if %{separate_biarch} +%files -n libobjc%{libobjc_sover}%{libobjc_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libobjc.so.%{libobjc_sover}* +%endif +%endif + +%if %{build_objcp} +%files obj-c++ +%defattr(-,root,root) +%{libsubdir}/cc1objplus + +%if %{separate_biarch} +%files obj-c++%{separate_biarch_suffix} +%defattr(-,root,root) +# empty - only for the dependency +%if %{suse_version} < 1310 +%doc README +%endif +%endif +%endif + +%if %{build_ada} +%files ada +%defattr(-,root,root) +%dir %{_libdir}/gcc +%dir %{_libdir}/gcc/%{GCCDIST} +%dir %{libsubdir} +%{_prefix}/bin/gnat* +%dir %{versmainlibdir}/adalib +%{versmainlibdir}/adainclude +%{versmainlibdir}/adalib/*.ali +%{versmainlibdir}/adalib/*.a +%{versmainlibdir}/adalib/libgnarl.so +%{versmainlibdir}/adalib/libgnat.so +%{versmainlibdir}/gnat1 +%{versmainlibdir}/ada_target_properties + +%if %{separate_biarch} +%files ada%{separate_biarch_suffix} +%defattr(-,root,root) +%dir %{versmainlibdirbi}/adalib +%{versmainlibdirbi}/adainclude +%{versmainlibdirbi}/adalib/*.ali +%{versmainlibdirbi}/adalib/*.a +%{versmainlibdirbi}/adalib/libgnarl.so +%{versmainlibdirbi}/adalib/libgnat.so +%{versmainlibdirbi}/ada_target_properties +%endif + +%files -n libada13 +%defattr(-,root,root) +%mainlib libgnarl%{binsuffix}.so +%mainlib libgnat%{binsuffix}.so + +%if %{separate_biarch} +%files -n libada13%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgnarl%{binsuffix}.so +%biarchlib libgnat%{binsuffix}.so +%endif +%endif + +%if %{build_go} +%files go +%defattr(-,root,root) +%{_prefix}/bin/gccgo%{binsuffix} +%{_prefix}/bin/go%{binsuffix} +%{_prefix}/bin/gofmt%{binsuffix} +%{libsubdir}/go1 +%versmainlib libgo.a +%versmainlib libgo.so +%versmainlib libgobegin.a +%versmainlib libgolibbegin.a +%versmainlibdir/buildid +%versmainlibdir/cgo +%dir %mainlibdir/go +%dir %mainlibdir/go/%{gcc_dir_version} +%mainlibdir/go/%{gcc_dir_version}/%{GCCDIST} +%doc %{_mandir}/man1/gccgo%{binsuffix}.1.gz +%doc %{_mandir}/man1/go%{binsuffix}.1.gz +%doc %{_mandir}/man1/gofmt%{binsuffix}.1.gz + +%if %{separate_biarch} +%files go%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib libgo.a +%versbiarchlib libgo.so +%versbiarchlib libgobegin.a +%versbiarchlib libgolibbegin.a +%dir %mainlibdirbi/go +%dir %mainlibdirbi/go/%{gcc_dir_version} +%mainlibdirbi/go/%{gcc_dir_version}/%{GCCDIST} +%endif + +%files -n libgo%{libgo_sover}%{libgo_suffix} +%defattr(-,root,root) +%mainlib libgo.so.%{libgo_sover}* + +%if %{separate_biarch} +%files -n libgo%{libgo_sover}%{libgo_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgo.so.%{libgo_sover}* +%endif +%endif + +%if %{build_d} +%files d +%defattr(-,root,root) +%{_prefix}/bin/gdc%{binsuffix} +%{libsubdir}/d21 +%versmainlib libgphobos.a +%versmainlib libgphobos.so +%versmainlib libgdruntime.a +%versmainlib libgdruntime.so +%versmainlib libgphobos.spec +%{versmainlibdir}/include/d +%doc %{_mandir}/man1/gdc%{binsuffix}.1.gz + +%if %{separate_biarch} +%files d%{separate_biarch_suffix} +%defattr(-,root,root) +%versbiarchlib libgphobos.a +%versbiarchlib libgphobos.so +%versbiarchlib libgdruntime.a +%versbiarchlib libgdruntime.so +%versbiarchlib libgphobos.spec +%endif + +%files -n libgphobos%{libgphobos_sover}%{libgphobos_suffix} +%defattr(-,root,root) +%mainlib libgphobos.so.%{libgphobos_sover}* + +%if %{separate_biarch} +%files -n libgphobos%{libgphobos_sover}%{libgphobos_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgphobos.so.%{libgphobos_sover}* +%endif + +%files -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix} +%defattr(-,root,root) +%mainlib libgdruntime.so.%{libgdruntime_sover}* + +%if %{separate_biarch} +%files -n libgdruntime%{libgdruntime_sover}%{libgdruntime_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libgdruntime.so.%{libgdruntime_sover}* +%endif +%endif + +%if %{build_jit} +%files -n libgccjit%{libgccjit_sover}%{libgccjit_suffix} +%defattr(-,root,root) +%{_prefix}/%{_lib}/libgccjit.so.%{libgccjit_sover}* + +%files -n libgccjit%{libgccjit_sover}-devel%{libdevel_suffix} +%defattr(-,root,root) +%doc gcc/jit/docs/examples +%{_prefix}/%{_lib}/libgccjit.so +%{_prefix}/include/libgccjit.h +%{_prefix}/include/libgccjit++.h +%{_infodir}/libgccjit.info.gz +%endif + +%if %{build_rust} +%files rust +%defattr(-,root,root) +%{_prefix}/bin/gccrs%{binsuffix} +%{libsubdir}/rust1 +%endif + +%if %{build_m2} +%files m2 +%defattr(-,root,root) +%{_prefix}/bin/gm2%{binsuffix} +%{libsubdir}/cc1gm2 +%if %{enable_plugins} +%{libsubdir}/plugin/m2rte.so +%endif +%{versmainlibdir}/m2 +%versmainlib libm2log.a +%versmainlib libm2log.so +%versmainlib libm2cor.a +%versmainlib libm2cor.so +%versmainlib libm2iso.a +%versmainlib libm2iso.so +%versmainlib libm2pim.a +%versmainlib libm2pim.so +%versmainlib libm2min.a +%versmainlib libm2min.so +%doc %{_mandir}/man1/gm2%{binsuffix}.1.gz + +%if %{separate_biarch} +%files m2%{separate_biarch_suffix} +%defattr(-,root,root) +%{versmainlibdirbi}/m2 +%versbiarchlib libm2log.a +%versbiarchlib libm2log.so +%versbiarchlib libm2cor.a +%versbiarchlib libm2cor.so +%versbiarchlib libm2iso.a +%versbiarchlib libm2iso.so +%versbiarchlib libm2pim.a +%versbiarchlib libm2pim.so +%versbiarchlib libm2min.a +%versbiarchlib libm2min.so +%endif + +%files -n libm2log%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2log.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2log%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2log.so.%{libm2_sover}* +%endif + +%files -n libm2cor%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2cor.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2cor%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2cor.so.%{libm2_sover}* +%endif + +%files -n libm2iso%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2iso.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2iso%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2iso.so.%{libm2_sover}* +%endif + +%files -n libm2pim%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2pim.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2pim%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2pim.so.%{libm2_sover}* +%endif + +%files -n libm2min%{libm2_sover}%{libm2_suffix} +%defattr(-,root,root) +%mainlib libm2min.so.%{libm2_sover}* + +%if %{separate_biarch} +%files -n libm2min%{libm2_sover}%{libm2_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libm2min.so.%{libm2_sover}* +%endif +%endif + +%if 0%{?run_tests:1} +%files -n gcc13-testresults +%defattr(-,root,root) +%doc testresults/test_summary.txt +%doc testresults/*.sum +%doc testresults/*.log +%endif + +%changelog diff --git a/gcc41-ppc32-retaddr.patch b/gcc41-ppc32-retaddr.patch new file mode 100644 index 0000000..c8a3818 --- /dev/null +++ b/gcc41-ppc32-retaddr.patch @@ -0,0 +1,91 @@ +2005-11-28 Jakub Jelinek + + * 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; ++} diff --git a/gcc43-no-unwind-tables.diff b/gcc43-no-unwind-tables.diff new file mode 100644 index 0000000..818e96e --- /dev/null +++ b/gcc43-no-unwind-tables.diff @@ -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 = diff --git a/gcc44-rename-info-files.patch b/gcc44-rename-info-files.patch new file mode 100644 index 0000000..443d380 --- /dev/null +++ b/gcc44-rename-info-files.patch @@ -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 + + * 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(-) + +diff --git a/gcc/Makefile.in b/gcc/Makefile.in +index d8b76d83d68..4f9c274ee38 100644 +--- a/gcc/Makefile.in ++++ b/gcc/Makefile.in +@@ -3333,8 +3333,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 + +@@ -3390,21 +3411,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 + +@@ -3815,11 +3856,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 +@@ -4058,8 +4099,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) ; \ +diff --git a/gcc/ada/gnat-style.texi b/gcc/ada/gnat-style.texi +index f3b1c29a24f..46bd21535cf 100644 +--- a/gcc/ada/gnat-style.texi ++++ b/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 +diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi +index 212ed3df9d8..bed8ce40548 100644 +--- a/gcc/ada/gnat_rm.texi ++++ b/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 +diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi +index a1daff92fbe..514931ec139 100644 +--- a/gcc/ada/gnat_ugn.texi ++++ b/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 +diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in +index 1679fb81097..6845aa67d43 100644 +--- a/gcc/d/Make-lang.in ++++ b/gcc/d/Make-lang.in +@@ -247,10 +247,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 + +@@ -275,11 +276,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: + +@@ -320,7 +321,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) +@@ -370,7 +371,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. + +diff --git a/gcc/d/gdc.texi b/gcc/d/gdc.texi +index 24b6ee00478..1a35bb099e6 100644 +--- a/gcc/d/gdc.texi ++++ b/gcc/d/gdc.texi +@@ -38,7 +38,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 + +diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi +index b0a2ce3ac6b..922a1c95181 100644 +--- a/gcc/doc/cpp.texi ++++ b/gcc/doc/cpp.texi +@@ -50,7 +50,7 @@ This manual contains no Invariant Sections. The Front-Cover Texts are + @ifinfo + @dircategory Software development + @direntry +-* Cpp: (cpp). The GNU C preprocessor. ++* @value{fncpp}: (@value{fncpp}). The GNU C preprocessor. + @end direntry + @end ifinfo + +diff --git a/gcc/doc/cppinternals.texi b/gcc/doc/cppinternals.texi +index a8ddb5c190e..e8fe1fcf2d8 100644 +--- a/gcc/doc/cppinternals.texi ++++ b/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 + +diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi +index 3adb67aa47a..0fae318cade 100644 +--- a/gcc/doc/extend.texi ++++ b/gcc/doc/extend.texi +@@ -24488,7 +24488,7 @@ want to write code that checks whether these features are available, you can + 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. +diff --git a/gcc/doc/gcc.texi b/gcc/doc/gcc.texi +index b3d500d4f47..d58e57dd480 100644 +--- a/gcc/doc/gcc.texi ++++ b/gcc/doc/gcc.texi +@@ -70,12 +70,12 @@ Texts being (a) (see below), and with the Back-Cover Texts being (b) + @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 + @sp 1 +@@ -135,7 +135,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. +diff --git a/gcc/doc/gccint.texi b/gcc/doc/gccint.texi +index 33cf7fdafce..8c76bf8a0c6 100644 +--- a/gcc/doc/gccint.texi ++++ b/gcc/doc/gccint.texi +@@ -49,7 +49,7 @@ Texts being (a) (see below), and with the Back-Cover Texts being (b) + @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 corresponds to the compilers + @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 +diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi +index 63fc949b447..a5a1b01fc55 100644 +--- a/gcc/doc/install.texi ++++ b/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 +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index def2df4584b..e5385a6140f 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -17722,7 +17722,7 @@ One of the standard libraries bypassed by @option{-nostdlib} and + @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 +@@ -17731,7 +17731,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}.) + + @opindex nostdlib++ +@@ -35109,7 +35109,7 @@ Note that you can also specify places to search using options such as + @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 +@@ -35289,7 +35289,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 +diff --git a/gcc/doc/libgcc.texi b/gcc/doc/libgcc.texi +index 73aa803f97b..e005588b88e 100644 +--- a/gcc/doc/libgcc.texi ++++ b/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 +diff --git a/gcc/fortran/Make-lang.in b/gcc/fortran/Make-lang.in +index 1666fd8f0ff..96ec8861a3d 100644 +--- a/gcc/fortran/Make-lang.in ++++ b/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-dir installdirs + + 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: +diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi +index b96712987e1..55ed2a540c2 100644 +--- a/gcc/fortran/gfortran.texi ++++ b/gcc/fortran/gfortran.texi +@@ -101,7 +101,7 @@ Texts being (a) (see below), and with the Back-Cover Texts being (b) + @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}). +diff --git a/libffi/Makefile.am b/libffi/Makefile.am +index c6d6f849c53..6fbf374a2e7 100644 +--- a/libffi/Makefile.am ++++ b/libffi/Makefile.am +@@ -28,6 +28,8 @@ TEXINFO_TEX = ../gcc/doc/include/texinfo.tex + # 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) +diff --git a/libffi/Makefile.in b/libffi/Makefile.in +index 5524a6a571e..1898ffee446 100644 +--- a/libffi/Makefile.in ++++ b/libffi/Makefile.in +@@ -249,7 +249,8 @@ AM_V_texidevnull = $(am__v_texidevnull_@AM_V@) + 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.tex + # 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-html-am uninstall-info-am \ + + 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) +diff --git a/libffi/doc/libffi.texi b/libffi/doc/libffi.texi +index 7fd3625d992..62dc76d6d64 100644 +--- a/libffi/doc/libffi.texi ++++ b/libffi/doc/libffi.texi +@@ -43,7 +43,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + @dircategory Development + @direntry +-* libffi: (libffi). Portable foreign function interface library. ++* libffi: (@value{fnlibffi}). Portable foreign-function interface library. + @end direntry + + @titlepage +diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am +index 428f7a9dab5..cce97d85bc8 100644 +--- a/libgomp/Makefile.am ++++ b/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 $@ + + +diff --git a/libgomp/Makefile.in b/libgomp/Makefile.in +index 2c81ccacc1d..0fb67876733 100644 +--- a/libgomp/Makefile.in ++++ b/libgomp/Makefile.in +@@ -612,6 +612,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 = +@@ -1392,15 +1393,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 +diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi +index 5bcb84a1d6f..60715911924 100644 +--- a/libgomp/libgomp.texi ++++ b/libgomp/libgomp.texi +@@ -31,7 +31,7 @@ texts being (a) (see below), and with the Back-Cover Texts being (b) + @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 +diff --git a/libitm/libitm.texi b/libitm/libitm.texi +index 9bb818fa53f..e62a90231f5 100644 +--- a/libitm/libitm.texi ++++ b/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. +diff --git a/libquadmath/libquadmath.texi b/libquadmath/libquadmath.texi +index 2e3a62511b1..ac658f5f2a7 100644 +--- a/libquadmath/libquadmath.texi ++++ b/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. diff --git a/gcc44-textdomain.patch b/gcc44-textdomain.patch new file mode 100644 index 0000000..297f20f --- /dev/null +++ b/gcc44-textdomain.patch @@ -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_ diff --git a/gcc48-libstdc++-api-reference.patch b/gcc48-libstdc++-api-reference.patch new file mode 100644 index 0000000..4becfa0 --- /dev/null +++ b/gcc48-libstdc++-api-reference.patch @@ -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 @@ +

  • + Frequently Asked Questions +

  • +- API and Source Documentation ++ API and Source Documentation +

  • +


    Table of Contents

    The GNU C++ Library Manual
    I. + Introduction + diff --git a/gcc7-avoid-fixinc-error.diff b/gcc7-avoid-fixinc-error.diff new file mode 100644 index 0000000..d0c639a --- /dev/null +++ b/gcc7-avoid-fixinc-error.diff @@ -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}`; \ diff --git a/gcc7-remove-Wexpansion-to-defined-from-Wextra.patch b/gcc7-remove-Wexpansion-to-defined-from-Wextra.patch new file mode 100644 index 0000000..50b9ee7 --- /dev/null +++ b/gcc7-remove-Wexpansion-to-defined-from-Wextra.patch @@ -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 diff --git a/gcc9-reproducible-builds-buildid-for-checksum.patch b/gcc9-reproducible-builds-buildid-for-checksum.patch new file mode 100644 index 0000000..5dbb3da --- /dev/null +++ b/gcc9-reproducible-builds-buildid-for-checksum.patch @@ -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 ++ ++#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; + } diff --git a/gcc9-reproducible-builds.patch b/gcc9-reproducible-builds.patch new file mode 100644 index 0000000..8567e30 --- /dev/null +++ b/gcc9-reproducible-builds.patch @@ -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 + diff --git a/gdcflags.patch b/gdcflags.patch new file mode 100644 index 0000000..8083125 --- /dev/null +++ b/gdcflags.patch @@ -0,0 +1,57 @@ +From 1ed21e23d6d4da8201a09558b71d9a34281e54dd Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Sun, 16 Jul 2023 19:43:56 +0200 +Subject: [PATCH] Use substituted GDCFLAGS + +Use the substituted value for GCDFLAGS instead of hardcoding $(CFLAGS) so +that the subdir configure scripts use the configured value. + + * configure.ac (GDCFLAGS): Set default from ${CFLAGS}. + * configure: Regenerate. + * Makefile.in (GDCFLAGS): Substitute @GDCFLAGS@. +--- + Makefile.in | 2 +- + configure | 1 + + configure.ac | 1 + + 3 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Makefile.in b/Makefile.in +index 04307ca561b..144bccd2603 100644 +--- a/Makefile.in ++++ b/Makefile.in +@@ -444,7 +444,7 @@ LIBCFLAGS = $(CFLAGS) + CXXFLAGS = @CXXFLAGS@ + LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates + GOCFLAGS = $(CFLAGS) +-GDCFLAGS = $(CFLAGS) ++GDCFLAGS = @GDCFLAGS@ + GM2FLAGS = $(CFLAGS) + + # Pass additional PGO and LTO compiler options to the PGO build. +diff --git a/configure b/configure +index 0d3f5c6455d..3269da9829f 100755 +--- a/configure ++++ b/configure +@@ -12947,6 +12947,7 @@ fi + + + ++GDCFLAGS=${GDCFLAGS-${CFLAGS}} + + # Target tools. + +diff --git a/configure.ac b/configure.ac +index dddab2a56d8..d07a0fa7698 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -3662,6 +3662,7 @@ AC_SUBST(CFLAGS) + AC_SUBST(CXXFLAGS) + AC_SUBST(GDC) + AC_SUBST(GDCFLAGS) ++GDCFLAGS=${GDCFLAGS-${CFLAGS}} + + # Target tools. + AC_ARG_WITH([build-time-tools], +-- +2.41.0 + diff --git a/newlib-4.3.0.20230120.tar.xz b/newlib-4.3.0.20230120.tar.xz new file mode 100644 index 0000000..12dde4b --- /dev/null +++ b/newlib-4.3.0.20230120.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c53284298c95bc3bf2c7c252e9dac52977295b021194e75766b1e68f6191f10 +size 4871768 diff --git a/pre_checkin.sh b/pre_checkin.sh new file mode 100644 index 0000000..c77308b --- /dev/null +++ b/pre_checkin.sh @@ -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 diff --git a/tls-no-direct.diff b/tls-no-direct.diff new file mode 100644 index 0000000..626d85f --- /dev/null +++ b/tls-no-direct.diff @@ -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 From fa6b0aea9c2403622e6737736ef600bab5b654a81af69b67f5fb9f7e3ff34027 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 22 Oct 2024 08:07:37 +0000 Subject: [PATCH 2/2] - Remove epiphany build, newlib no longer builds for it. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gcc13?expand=0&rev=115 --- _multibuild | 2 - change_spec | 2 +- cross-epiphany-gcc13-bootstrap.spec | 1087 --------------------------- cross-epiphany-gcc13.spec | 1086 -------------------------- gcc13.changes | 5 + 5 files changed, 6 insertions(+), 2176 deletions(-) delete mode 100644 cross-epiphany-gcc13-bootstrap.spec delete mode 100644 cross-epiphany-gcc13.spec diff --git a/_multibuild b/_multibuild index 16ce003..99df490 100644 --- a/_multibuild +++ b/_multibuild @@ -23,8 +23,6 @@ cross-hppa-gcc13 cross-arm-none-gcc13-bootstrap cross-arm-none-gcc13 -cross-epiphany-gcc13-bootstrap -cross-epiphany-gcc13 cross-riscv64-elf-gcc13-bootstrap cross-riscv64-elf-gcc13 cross-rx-gcc13-bootstrap diff --git a/change_spec b/change_spec index 066845e..2bda278 100644 --- a/change_spec +++ b/change_spec @@ -115,7 +115,7 @@ 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-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 diff --git a/cross-epiphany-gcc13-bootstrap.spec b/cross-epiphany-gcc13-bootstrap.spec deleted file mode 100644 index d2e7f56..0000000 --- a/cross-epiphany-gcc13-bootstrap.spec +++ /dev/null @@ -1,1087 +0,0 @@ -# -# spec file -# -# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" -%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 build_rust 0 -%define build_m2 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 "%{binutils_target}" == "bpf" -%define binutils_os %{canonical_target}-none -%else -%if 0%{?gcc_accel:1} -%define binutils_os %{gcc_target_arch} -%else -%define binutils_os %{canonical_target}-suse-linux -%endif -%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.3.1+git8964 -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.3.0.20230120.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 -Patch21: gdcflags.patch -Patch23: gcc13-bsc1216664.patch -Patch24: gcc13-sanitizer-remove-crypt-interception.patch -Patch26: gcc13-pr101523.patch -Patch27: gcc13-amdgcn-remove-fiji.patch -Patch28: gcc13-pr116657.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 -# Feature backports -Patch100: gcc13-pr88345-min-func-alignment.diff -Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 -%if %{with limitbuild} -BuildRequires: memory-constraints -%endif -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} -%if !0%{?is_opensuse} -ExclusiveArch: do-not-build -%endif -BuildRequires: cross-%cross_arch-newlib-devel -Requires: cross-%cross_arch-newlib-devel -%endif -%if "%{cross_arch}" == "avr" -%if !0%{?is_opensuse} -ExclusiveArch: do-not-build -%endif -BuildRequires: avr-libc -%endif -%if 0%{?gcc_target_glibc:1} -%if %{suse_version} < 1600 -ExclusiveArch: do-not-build -%endif -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 -%define product_libs_llvm_ver 13 -%else -BuildRequires: llvm%{product_libs_llvm_ver} -%endif -BuildRequires: lld%{product_libs_llvm_ver} -%if %{suse_version} < 1550 -Requires: llvm13 -%else -Requires: llvm%{product_libs_llvm_ver} -%endif -Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} -Requires: lld%{product_libs_llvm_ver} -# 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 "%{cross_arch}" == "pru" -ExclusiveArch: %arm -%endif -%if 0%{?gcc_target_glibc:1} -%ifarch %{cross_arch} -ExcludeArch: %{cross_arch} -%endif -%endif -%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} -ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 -%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 -%if 0%{!?gcc_accel:1} -BuildRequires: update-alternatives -Requires(post): update-alternatives -Requires(preun):update-alternatives -%endif -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.3.0.20230120/newlib . -%else -%setup -q -n gcc-%{version} -%endif - -#test patching start - -%patch -P 2 -%patch -P 5 -%patch -P 6 -%patch -P 7 -%patch -P 11 -%patch -P 15 -%patch -P 16 -%patch -P 17 -p1 -# These patches are needed only for llvm11 -%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 -%patch -P 18 -p1 -%patch -P 20 -p1 -%endif -# In SLE15 and earlier default to dwarf4, not dwarf5 -%if %{suse_version} < 1550 -%patch -P 19 -p1 -%endif -%patch -P 21 -p1 -%patch -P 23 -p1 -%patch -P 24 -p1 -%patch -P 26 -p1 -%patch -P 27 -p1 -%patch -P 28 -p1 -%patch -P 51 -%patch -P 60 -p1 -%patch -P 61 -p1 -%patch -P 100 -p1 -%patch -P 101 -p1 - -#test patching end - -%build -%if %{with limitbuild} -%limit_build -m 900 -%endif -%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} -# Filter out unwanted flags from $RPM_OPT_FLAGS -optflags= -optflags_d= -for flag in $RPM_OPT_FLAGS; do - add_flag= - case $flag in - -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; - -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; - -ffortify=*|-Wall|-m32|-m64) ;; -%ifarch %ix86 - # -mcpu is superseded 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 superseded by proper - # default compiler settings now. - -mcpu=i?86|-march=i?86|-mtune=i?86) ;; -%endif -%ifarch s390 s390x - -fsigned-char) ;; - -O1) add_flag=-O2 ;; -%endif -%if 0%{?gcc_target_arch:1} - # Kill all -march/tune/cpu because that screws building the target libs - -march=*|-mtune=*|-mcpu=*) ;; -%endif - *) add_flag=$flag ;; - esac - if test -n "$add_flag"; then - optflags+=" $add_flag" - case $add_flag in - # Filter out -Werror=return-type for D (only valid for C and C++) - -Werror=return-type) ;; - *) optflags_d+=" $add_flag" ;; - esac - fi -done - -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 -%if %{build_rust} -languages=$languages,rust -%endif -%if %{build_m2} -languages=$languages,m2 -%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar -ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as -ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld -ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm -ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 - -../configure \ - CFLAGS="$optflags" \ - CXXFLAGS="$optflags" \ - XCFLAGS="$optflags" \ - TCFLAGS="$optflags" \ - GDCFLAGS="$optflags_d" \ - --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} \ - --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ - --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}" == "bpf" - --disable-gcov \ -%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 0%{?cross_arch:1} - --with-glibc-version=2.32 \ -%endif -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-cpu=power9 \ - --with-tune=power9 \ -%else -%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 -%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 %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-arch-32=x86-64-v2 \ -%else -%if 0%{?sle_version:%sle_version} >= 150000 - --with-arch-32=x86-64 \ -%else - --with-arch-32=i586 \ -%endif -%endif - --with-tune=generic \ -%endif -%if "%{TARGET_ARCH}" == "x86_64" -%ifnarch %{disable_multilib_arch} - --enable-multilib \ -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-arch-32=x86-64-v2 \ -%else - --with-arch-32=x86-64 \ -%endif -%endif -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-arch=x86-64-v2 \ -%endif - --with-tune=generic \ -%endif -%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-tune=z14 --with-arch=z14 \ -%else -%if %{suse_version} >= 1310 - --with-tune=zEC12 --with-arch=z196 \ -%else - --with-tune=z9-109 --with-arch=z900 \ -%endif -%endif - --with-long-double-128 \ - --enable-decimal-float \ -%if 0%{?cross_arch:1} - --disable-multilib \ -%endif -%endif -%if "%{TARGET_ARCH}" == "m68k" - --disable-multilib \ -%endif -%if "%{TARGET_ARCH}" == "riscv64" - --disable-multilib \ -%endif -%if %{with bootstrap} -%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} - --with-build-config=bootstrap-lto-lean \ -%endif -%else - --disable-bootstrap \ -%endif - --enable-link-serialization \ - $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar -ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as -ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld -ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm -ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" - 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 -%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" - --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 - --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} - -%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} -%if "%{cross_arch}" == "amdgcn" -%{_prefix}/%{gcc_target_arch}/bin -%{_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 -%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} && "%{cross_arch}" != "bpf" -%{_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} && "%{cross_arch}" != "bpf" -%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} -%exclude %{_prefix}/%{gcc_target_arch}/bin -%endif - -%changelog diff --git a/cross-epiphany-gcc13.spec b/cross-epiphany-gcc13.spec deleted file mode 100644 index 662a757..0000000 --- a/cross-epiphany-gcc13.spec +++ /dev/null @@ -1,1086 +0,0 @@ -# -# spec file -# -# Copyright (c) 2024 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} || "%{cross_arch}" == "bpf" -%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 build_rust 0 -%define build_m2 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 "%{binutils_target}" == "bpf" -%define binutils_os %{canonical_target}-none -%else -%if 0%{?gcc_accel:1} -%define binutils_os %{gcc_target_arch} -%else -%define binutils_os %{canonical_target}-suse-linux -%endif -%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.3.1+git8964 -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.3.0.20230120.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 -Patch21: gdcflags.patch -Patch23: gcc13-bsc1216664.patch -Patch24: gcc13-sanitizer-remove-crypt-interception.patch -Patch26: gcc13-pr101523.patch -Patch27: gcc13-amdgcn-remove-fiji.patch -Patch28: gcc13-pr116657.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 -# Feature backports -Patch100: gcc13-pr88345-min-func-alignment.diff -Patch101: gcc13-rs6000-Adjust-fpatchable-function-entry.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 %{_target_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 -%if %{with limitbuild} -BuildRequires: memory-constraints -%endif -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} -%if !0%{?is_opensuse} -ExclusiveArch: do-not-build -%endif -BuildRequires: cross-%cross_arch-newlib-devel -Requires: cross-%cross_arch-newlib-devel -%endif -%if "%{cross_arch}" == "avr" -%if !0%{?is_opensuse} -ExclusiveArch: do-not-build -%endif -BuildRequires: avr-libc -%endif -%if 0%{?gcc_target_glibc:1} -%if %{suse_version} < 1600 -ExclusiveArch: do-not-build -%endif -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 -%define product_libs_llvm_ver 13 -%else -BuildRequires: llvm%{product_libs_llvm_ver} -%endif -BuildRequires: lld%{product_libs_llvm_ver} -%if %{suse_version} < 1550 -Requires: llvm13 -%else -Requires: llvm%{product_libs_llvm_ver} -%endif -Requires: cross-amdgcn-newlib-devel >= %{version}-%{release} -Requires: lld%{product_libs_llvm_ver} -# 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 "%{cross_arch}" == "pru" -ExclusiveArch: %arm -%endif -%if 0%{?gcc_target_glibc:1} -%ifarch %{cross_arch} -ExcludeArch: %{cross_arch} -%endif -%endif -%if 0%{?gcc_icecream:1}%{?gcc_libc_bootstrap:1} -ExclusiveArch: i586 ppc64le ppc64 x86_64 s390x aarch64 riscv64 -%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 -%if 0%{!?gcc_accel:1} -BuildRequires: update-alternatives -Requires(post): update-alternatives -Requires(preun):update-alternatives -%endif -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.3.0.20230120/newlib . -%else -%setup -q -n gcc-%{version} -%endif - -#test patching start - -%patch -P 2 -%patch -P 5 -%patch -P 6 -%patch -P 7 -%patch -P 11 -%patch -P 15 -%patch -P 16 -%patch -P 17 -p1 -# These patches are needed only for llvm11 -%if "%{TARGET_ARCH}" == "amdgcn" && %{suse_version} < 1550 -%patch -P 18 -p1 -%patch -P 20 -p1 -%endif -# In SLE15 and earlier default to dwarf4, not dwarf5 -%if %{suse_version} < 1550 -%patch -P 19 -p1 -%endif -%patch -P 21 -p1 -%patch -P 23 -p1 -%patch -P 24 -p1 -%patch -P 26 -p1 -%patch -P 27 -p1 -%patch -P 28 -p1 -%patch -P 51 -%patch -P 60 -p1 -%patch -P 61 -p1 -%patch -P 100 -p1 -%patch -P 101 -p1 - -#test patching end - -%build -%if %{with limitbuild} -%limit_build -m 900 -%endif -%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} -# Filter out unwanted flags from $RPM_OPT_FLAGS -optflags= -optflags_d= -for flag in $RPM_OPT_FLAGS; do - add_flag= - case $flag in - -U_FORTIFY_SOURCE|-D_FORTIFY_SOURCE=*) ;; - -fno-rtti|-fno-exceptions|-Wmissing-format-attribute|-fstack-protector*) ;; - -ffortify=*|-Wall|-m32|-m64) ;; -%ifarch %ix86 - # -mcpu is superseded 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 superseded by proper - # default compiler settings now. - -mcpu=i?86|-march=i?86|-mtune=i?86) ;; -%endif -%ifarch s390 s390x - -fsigned-char) ;; - -O1) add_flag=-O2 ;; -%endif -%if 0%{?gcc_target_arch:1} - # Kill all -march/tune/cpu because that screws building the target libs - -march=*|-mtune=*|-mcpu=*) ;; -%endif - *) add_flag=$flag ;; - esac - if test -n "$add_flag"; then - optflags+=" $add_flag" - case $add_flag in - # Filter out -Werror=return-type for D (only valid for C and C++) - -Werror=return-type) ;; - *) optflags_d+=" $add_flag" ;; - esac - fi -done - -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 -%if %{build_rust} -languages=$languages,rust -%endif -%if %{build_m2} -languages=$languages,m2 -%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-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ar -ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-as -ln -s /usr/bin/lld-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-ld -ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* target-tools/bin/amdgcn-amdhsa-nm -ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* 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 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 - -../configure \ - CFLAGS="$optflags" \ - CXXFLAGS="$optflags" \ - XCFLAGS="$optflags" \ - TCFLAGS="$optflags" \ - GDCFLAGS="$optflags_d" \ - --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} \ - --with-libstdcxx-zoneinfo=%{_datadir}/zoneinfo \ - --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}" == "bpf" - --disable-gcov \ -%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 0%{?cross_arch:1} - --with-glibc-version=2.32 \ -%endif -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-cpu=power9 \ - --with-tune=power9 \ -%else -%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 -%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 %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-arch-32=x86-64-v2 \ -%else -%if 0%{?sle_version:%sle_version} >= 150000 - --with-arch-32=x86-64 \ -%else - --with-arch-32=i586 \ -%endif -%endif - --with-tune=generic \ -%endif -%if "%{TARGET_ARCH}" == "x86_64" -%ifnarch %{disable_multilib_arch} - --enable-multilib \ -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-arch-32=x86-64-v2 \ -%else - --with-arch-32=x86-64 \ -%endif -%endif -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-arch=x86-64-v2 \ -%endif - --with-tune=generic \ -%endif -%if "%{TARGET_ARCH}" == "s390" || "%{TARGET_ARCH}" == "s390x" -%if %{suse_version} >= 1600 && !0%{?is_opensuse} - --with-tune=z14 --with-arch=z14 \ -%else -%if %{suse_version} >= 1310 - --with-tune=zEC12 --with-arch=z196 \ -%else - --with-tune=z9-109 --with-arch=z900 \ -%endif -%endif - --with-long-double-128 \ - --enable-decimal-float \ -%if 0%{?cross_arch:1} - --disable-multilib \ -%endif -%endif -%if "%{TARGET_ARCH}" == "m68k" - --disable-multilib \ -%endif -%if "%{TARGET_ARCH}" == "riscv64" - --disable-multilib \ -%endif -%if %{with bootstrap} -%if %{use_lto_bootstrap} && !0%{?building_testsuite:1} - --with-build-config=bootstrap-lto-lean \ -%endif -%else - --disable-bootstrap \ -%endif - --enable-link-serialization \ - $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 /usr/bin/llvm-ar-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ar -ln -s /usr/bin/llvm-mc-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/as -ln -s /usr/bin/lld-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/ld -ln -s /usr/bin/llvm-nm-%{product_libs_llvm_ver}* $RPM_BUILD_ROOT%{_prefix}/amdgcn-amdhsa/bin/nm -ln -s /usr/bin/llvm-ranlib-%{product_libs_llvm_ver}* $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} && "%{cross_arch}" != "bpf" - 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 -%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" != "bpf" - --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 - --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} - -%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} -%if "%{cross_arch}" == "amdgcn" -%{_prefix}/%{gcc_target_arch}/bin -%{_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 -%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} && "%{cross_arch}" != "bpf" -%{_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} && "%{cross_arch}" != "bpf" -%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} -%exclude %{_prefix}/%{gcc_target_arch}/bin -%endif - -%changelog diff --git a/gcc13.changes b/gcc13.changes index 59cd35c..73e2cf6 100644 --- a/gcc13.changes +++ b/gcc13.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Tue Oct 22 08:06:21 UTC 2024 - Richard Biener + +- Remove epiphany build, newlib no longer builds for it. + ------------------------------------------------------------------- Wed Oct 16 13:32:36 UTC 2024 - Richard Biener