commit f4e84891802028b52040d019d6d3bd9ab991c07392b882041ab43557d5e6ec1b Author: Richard Biener Date: Tue Oct 22 08:05:40 2024 +0000 - Remove epiphany build, newlib no longer builds for it. OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gcc7?expand=0&rev=250 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..6702c30 --- /dev/null +++ b/README.First-for.SuSE.packagers @@ -0,0 +1,37 @@ +IMPORTANT: Please change gcc.spec.in or cross.spec.in and then +run ./pre_checkin.sh! Do not change any .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 two parts, gcc$VER and gcc$VER-testresults +(plus various spec files for cross and offload). The testsuite is run from +gcc$VER-testresults.spec, a dummy source package with the actual testresults, +gcc$VER-testresults, generated from it which contains testing logfiles and +a 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: + +- In your branch project make sure at least gcc$VER and gcc$VER-testresults + are built for all relevant architectures of the product + +- When the build finished, call + /suse/rguenther/bin/compare-testresults-bs.sh \ + gcc$VER-testresults gcc$VER-testresults \ + SUSE:SLE-15:Update standard .1234 \ + home:user:branches:gcc standard + It will compare testresults of the base (shipped in the product already, + look for the magic .1234 suffix as to the latest released update) to + your proposed update. The differences will be recorded in a temporary + directory which is printed as output, they should not contain any new + failures. If they do, 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..4a09b4d --- /dev/null +++ b/_constraints @@ -0,0 +1,11 @@ + + + + 16 + + + 4 + + 4 + + diff --git a/_multibuild b/_multibuild new file mode 100644 index 0000000..ac505db --- /dev/null +++ b/_multibuild @@ -0,0 +1,22 @@ + +gcc7-testresults +cross-aarch64-gcc7 +cross-arm-gcc7 +cross-avr-gcc7-bootstrap +cross-avr-gcc7 +cross-i386-gcc7 +cross-x86_64-gcc7 +cross-s390x-gcc7 +cross-sparc-gcc7 +cross-sparc64-gcc7 +cross-ppc64-gcc7 +cross-ppc64le-gcc7 +cross-m68k-gcc7 +cross-mips-gcc7 +cross-hppa-gcc7 +cross-arm-none-gcc7-bootstrap +cross-arm-none-gcc7 +cross-rx-gcc7-bootstrap +cross-rx-gcc7 +cross-nvptx-gcc7 + diff --git a/change_spec b/change_spec new file mode 100644 index 0000000..c226f53 --- /dev/null +++ b/change_spec @@ -0,0 +1,125 @@ +#!/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" +} + +# 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_cross cross-aarch64-gcc$base_ver aarch64 aarch64-suse-linux %define gcc_icecream 1 +add_cross cross-arm-gcc$base_ver arm arm-suse-linux-gnueabi %define gcc_icecream 0 +add_cross cross-avr-gcc$base_ver-bootstrap avr avr "%define gcc_libc_bootstrap 1" +add_cross cross-avr-gcc$base_ver avr avr +add_cross cross-i386-gcc$base_ver i386 i586-suse-linux %define gcc_icecream 1 +add_cross cross-x86_64-gcc$base_ver x86_64 x86_64-suse-linux %define gcc_icecream 1 +add_cross cross-s390x-gcc$base_ver s390x s390x-suse-linux %define gcc_icecream 1 +add_cross cross-sparc-gcc$base_ver sparcv9 sparc-suse-linux %define gcc_icecream 1 +add_cross cross-sparc64-gcc$base_ver sparc64 sparc64-suse-linux %define gcc_icecream 1 +add_cross cross-ppc64-gcc$base_ver ppc64 powerpc64-suse-linux %define gcc_icecream 1 +add_cross cross-ppc64le-gcc$base_ver ppc64le powerpc64le-suse-linux %define gcc_icecream 1 +add_cross cross-m68k-gcc$base_ver m68k m68k-suse-linux %define gcc_icecream 1 +add_cross cross-mips-gcc$base_ver mips mips-suse-linux %define gcc_icecream 1 +add_cross cross-hppa-gcc$base_ver 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-rx-gcc$base_ver rx rx-elf +#add_newlib_cross cross-rl78-gcc$base_ver rl78 rl78-elf +#add_newlib_cross cross-nds32le-gcc$base_ver nds32le nds32le-elf +fi +# the nvptx cross is used for offloading +add_cross cross-nvptx-gcc$base_ver nvptx nvptx-none %define gcc_accel 1 + +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-gcc7.spec b/cross-aarch64-gcc7.spec new file mode 100644 index 0000000..71da18f --- /dev/null +++ b/cross-aarch64-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch aarch64 +%define gcc_target_arch aarch64-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: ppc64le ppc64 x86_64 s390x +%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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-arm-gcc7.spec b/cross-arm-gcc7.spec new file mode 100644 index 0000000..2f124d2 --- /dev/null +++ b/cross-arm-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch arm +%define gcc_target_arch arm-suse-linux-gnueabi +%define gcc_icecream 0 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-arm-none-gcc7-bootstrap.spec b/cross-arm-none-gcc7-bootstrap.spec new file mode 100644 index 0000000..83ec0ff --- /dev/null +++ b/cross-arm-none-gcc7-bootstrap.spec @@ -0,0 +1,929 @@ +# +# 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-gcc7-bootstrap +%define cross_arch arm-none +%define gcc_target_arch arm-none-eabi +%define gcc_target_newlib 1 +%define gcc_libc_bootstrap 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-arm-none-gcc7.spec b/cross-arm-none-gcc7.spec new file mode 100644 index 0000000..e34b1b6 --- /dev/null +++ b/cross-arm-none-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch arm-none +%define gcc_target_arch arm-none-eabi +%define gcc_target_newlib 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-avr-gcc7-bootstrap.spec b/cross-avr-gcc7-bootstrap.spec new file mode 100644 index 0000000..97cfbdc --- /dev/null +++ b/cross-avr-gcc7-bootstrap.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7-bootstrap +%define cross_arch avr +%define gcc_target_arch avr +%define gcc_libc_bootstrap 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-avr-gcc7.spec b/cross-avr-gcc7.spec new file mode 100644 index 0000000..f63754e --- /dev/null +++ b/cross-avr-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch avr +%define gcc_target_arch avr + +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-epiphany-gcc7-bootstrap.spec b/cross-epiphany-gcc7-bootstrap.spec new file mode 100644 index 0000000..69bcae0 --- /dev/null +++ b/cross-epiphany-gcc7-bootstrap.spec @@ -0,0 +1,929 @@ +# +# 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-gcc7-bootstrap +%define cross_arch epiphany +%define gcc_target_arch epiphany-elf +%define gcc_target_newlib 1 +%define gcc_libc_bootstrap 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-epiphany-gcc7.spec b/cross-epiphany-gcc7.spec new file mode 100644 index 0000000..c7d2310 --- /dev/null +++ b/cross-epiphany-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch epiphany +%define gcc_target_arch epiphany-elf +%define gcc_target_newlib 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-hppa-gcc7.spec b/cross-hppa-gcc7.spec new file mode 100644 index 0000000..cdb7f98 --- /dev/null +++ b/cross-hppa-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch hppa +%define gcc_target_arch hppa-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-i386-gcc7.spec b/cross-i386-gcc7.spec new file mode 100644 index 0000000..ab5e10d --- /dev/null +++ b/cross-i386-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-i386-gcc7 +%define cross_arch i386 +%define gcc_target_arch i586-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-m68k-gcc7.spec b/cross-m68k-gcc7.spec new file mode 100644 index 0000000..b09b167 --- /dev/null +++ b/cross-m68k-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch m68k +%define gcc_target_arch m68k-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-mips-gcc7.spec b/cross-mips-gcc7.spec new file mode 100644 index 0000000..eb48b54 --- /dev/null +++ b/cross-mips-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch mips +%define gcc_target_arch mips-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-nvptx-gcc7.spec b/cross-nvptx-gcc7.spec new file mode 100644 index 0000000..dd6d154 --- /dev/null +++ b/cross-nvptx-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch nvptx +%define gcc_target_arch nvptx-none +%define gcc_accel 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-ppc64-gcc7.spec b/cross-ppc64-gcc7.spec new file mode 100644 index 0000000..2406697 --- /dev/null +++ b/cross-ppc64-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch ppc64 +%define gcc_target_arch powerpc64-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: ppc64le 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-ppc64le-gcc7.spec b/cross-ppc64le-gcc7.spec new file mode 100644 index 0000000..e55fd46 --- /dev/null +++ b/cross-ppc64le-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch ppc64le +%define gcc_target_arch powerpc64le-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-rx-gcc7-bootstrap.spec b/cross-rx-gcc7-bootstrap.spec new file mode 100644 index 0000000..4f04e27 --- /dev/null +++ b/cross-rx-gcc7-bootstrap.spec @@ -0,0 +1,929 @@ +# +# 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-gcc7-bootstrap +%define cross_arch rx +%define gcc_target_arch rx-elf +%define gcc_target_newlib 1 +%define gcc_libc_bootstrap 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-rx-gcc7.spec b/cross-rx-gcc7.spec new file mode 100644 index 0000000..d3da371 --- /dev/null +++ b/cross-rx-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch rx +%define gcc_target_arch rx-elf +%define gcc_target_newlib 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-s390x-gcc7.spec b/cross-s390x-gcc7.spec new file mode 100644 index 0000000..18f7d37 --- /dev/null +++ b/cross-s390x-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch s390x +%define gcc_target_arch s390x-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: ppc64le ppc64 x86_64 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-sparc-gcc7.spec b/cross-sparc-gcc7.spec new file mode 100644 index 0000000..557aa37 --- /dev/null +++ b/cross-sparc-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch sparcv9 +%define gcc_target_arch sparc-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-sparc64-gcc7.spec b/cross-sparc64-gcc7.spec new file mode 100644 index 0000000..bbb78bd --- /dev/null +++ b/cross-sparc64-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch sparc64 +%define gcc_target_arch sparc64-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross-x86_64-gcc7.spec b/cross-x86_64-gcc7.spec new file mode 100644 index 0000000..8aaecfd --- /dev/null +++ b/cross-x86_64-gcc7.spec @@ -0,0 +1,928 @@ +# +# 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-gcc7 +%define cross_arch x86_64 +%define gcc_target_arch x86_64-suse-linux +%define gcc_icecream 1 +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: bison +BuildRequires: flex +BuildRequires: gcc-c++ +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%endif +%if "%{cross_arch}" == "nvptx" +BuildRequires: nvptx-tools +Requires: cross-nvptx-newlib-devel >= %{version}-%{release} +Requires: nvptx-tools +ExclusiveArch: +%define nvptx_newlib 1 +%endif +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: ppc64le ppc64 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} +# 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}-gcc7 +%endif +#!BuildIgnore: gcc-PIE +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun):update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_smp_mflags} all-host +%endif + +%if 0%{?gcc_icecream:%gcc_icecream} +%package -n cross-%cross_arch-gcc7-icecream-backend +Summary: Icecream backend for the GNU C Compiler +Group: Development/Languages/C and C++ + +%description -n cross-%cross_arch-gcc7-icecream-backend +This package contains the icecream environment for the GNU C Compiler +%endif + +%if 0%{?nvptx_newlib:1} +%package -n cross-nvptx-newlib7-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-newlib7-devel +Newlib development files for the nvptx offload target compiler. +%endif + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; 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} 7 \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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-gcc7-icecream-backend +%defattr(-,root,root) +/usr/share/icecream-envs +%endif + +%if 0%{?nvptx_newlib:1} +%files -n cross-nvptx-newlib7-devel +%defattr(-,root,root) +%{_prefix}/%{gcc_target_arch} +%endif + +%changelog diff --git a/cross.spec.in b/cross.spec.in new file mode 100644 index 0000000..8a4d6b3 --- /dev/null +++ b/cross.spec.in @@ -0,0 +1,405 @@ +# +# spec file for package gcc (Version 4.0.1) +# +# Copyright (c) 2005 SUSE Linux AG, Nuernberg, Germany. +# This file and all modifications and additions to the pristine +# package are under the same license as the package itself. +# +# Please submit bugfixes or comments via http://www.suse.de/feedback/ +# + +# nospeccleaner + +%define build_cp 0%{!?gcc_accel:1} +%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_hsa 0 +%define build_nvptx 0 + +%define enable_plugins 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 +%define build_cp 0 +%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" +%define binutils_os %{canonical_target} +%else +%if "%{binutils_target}" == "epiphany" || "%{binutils_target}" == "nds32le" || "%{binutils_target}" == "rl78" || "%{binutils_target}" == "rx" +%define binutils_os %{canonical_target}-elf +%else +%if "%{binutils_target}" == "arm" +%define binutils_os %{canonical_target}-suse-linux-gnueabi +%else +%if 0%{?gcc_accel:1} +%define binutils_os %{gcc_target_arch} +%else +%define binutils_os %{canonical_target}-suse-linux +%endif +%endif +%endif +%endif + +%if 0%{?gcc_icecream:1} +%define sysroot %{_prefix}/%{gcc_target_arch} +%else +# offloading builds newlib in-tree and can install in +# the GCC private path without extra sysroot +%if 0%{!?gcc_accel:1} +# use same sysroot as in binutils.spec +%define sysroot %{_prefix}/%{binutils_os}/sys-root +%endif +%endif + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: %{pkgname} +# SRC-COMMON-BEGIN +# SRC-COMMON-END +%if "%{cross_arch}" != "nvptx" +BuildRequires: cross-%{binutils_target}-binutils +Requires: cross-%{binutils_target}-binutils +%endif +BuildRequires: gcc-c++ +BuildRequires: bison +BuildRequires: flex +BuildRequires: gettext-devel +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +BuildRequires: zlib-devel +%ifarch %ix86 x86_64 ppc ppc64 s390 s390x ia64 %sparc hppa %arm +BuildRequires: isl-devel +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{!?gcc_icecream:1} +%if 0%{?gcc_target_newlib:1} && 0%{!?gcc_libc_bootstrap:1} +BuildRequires: cross-%cross_arch-newlib-devel +%endif +%if 0%{!?gcc_libc_bootstrap:1} && "%{cross_arch}" == "avr" +BuildRequires: avr-libc +%endif +%if 0%{?gcc_target_glibc:1} +BuildRequires: cross-%cross_arch-glibc-devel +%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 +%endif +%if 0%{?gcc_icecream:1} +ExclusiveArch: 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} +# 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 +BuildRequires: update-alternatives +Requires(post): update-alternatives +Requires(preun): update-alternatives +Summary: The GNU Compiler Collection targeting %{cross_arch} +License: GPL-3.0-or-later + +%description +The GNU Compiler Collection as a cross-compiler targeting %{cross_arch}. +%if 0%{?gcc_icecream:1} +Note this is only useful for building freestanding things like the +kernel since it fails to include target libraries and headers. +%endif +%if 0%{?gcc_libc_bootstrap:1} +This is a package that is necessary for bootstrapping another package +only, it is not intended for any other use. +%endif + +# BUILD-COMMON-BEGIN +# BUILD-COMMON-END +%if 0%{!?gcc_icecream:1} && 0%{!?gcc_libc_bootstrap:1} +make %{?_smp_mflags} +%else +make %{?_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 + + +%define targetlibsubdir %{_libdir}/gcc/%{gcc_target_arch}/%{gcc_dir_version} + +%install +cd obj-%{GCCDIST} + +# 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 +# debugedit is not prepared for this and crashes +%if 0%{?gcc_icecream:1} +# so expect the sysroot to be populated from natively built binaries +%else +%if 0%{!?gcc_libc_bootstrap:1} +export NO_BRP_STRIP_DEBUG=true +export NO_DEBUGINFO_STRIP_DEBUG=true +%define __debug_install_post %{nil} +: >../debugfiles.list +: >../debugsourcefiles.list +: >../debugsources.list +# 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 +%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 + +%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 gcov gcov-dump gcov-tool; do + ln -s %{_sysconfdir}/alternatives/%{gcc_target_arch}-$ex \ + %{buildroot}%{_bindir}/%{gcc_target_arch}-$ex +done + +%post +%{_sbindir}/update-alternatives \ + --install %{_bindir}/%{gcc_target_arch}-gcc %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} @base_ver@ \ + --slave %{_bindir}/%{gcc_target_arch}-cpp %{gcc_target_arch}-cpp %{_bindir}/%{gcc_target_arch}-cpp%{binsuffix} \ +%if %{build_cp} + --slave %{_bindir}/%{gcc_target_arch}-c++ %{gcc_target_arch}-c++ %{_bindir}/%{gcc_target_arch}-c++%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-g++ %{gcc_target_arch}-g++ %{_bindir}/%{gcc_target_arch}-g++%{binsuffix} \ +%endif + --slave %{_bindir}/%{gcc_target_arch}-gcc-ar %{gcc_target_arch}-gcc-ar %{_bindir}/%{gcc_target_arch}-gcc-ar%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-nm %{gcc_target_arch}-gcc-nm %{_bindir}/%{gcc_target_arch}-gcc-nm%{binsuffix} \ + --slave %{_bindir}/%{gcc_target_arch}-gcc-ranlib %{gcc_target_arch}-gcc-ranlib %{_bindir}/%{gcc_target_arch}-gcc-ranlib%{binsuffix} \ + --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} + +%postun +if [ ! -f %{_bindir}/%{gcc_target_arch}-gcc ] ; then + %{_sbindir}/update-alternatives --remove %{gcc_target_arch}-gcc %{_bindir}/%{gcc_target_arch}-gcc%{binsuffix} +fi +%endif + +%files +%defattr(-,root,root) +%if 0%{?gcc_accel:1} +%{_prefix}/bin/%{GCCDIST}-accel-%{gcc_target_arch}-* +%dir %{libsubdir} +%dir %{libsubdir}/accel +%{libsubdir}/accel/%{gcc_target_arch} +%else +%{_prefix}/bin/%{gcc_target_arch}-gcc%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-cpp%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ar%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-nm%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcc-ranlib%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump%{binsuffix} +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool%{binsuffix} +%{_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}-gcov +%{_prefix}/bin/%{gcc_target_arch}-gcov-dump +%{_prefix}/bin/%{gcc_target_arch}-gcov-tool +%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}-gcov +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-dump +%ghost %{_sysconfdir}/alternatives/%{gcc_target_arch}-gcov-tool +%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 + +%changelog -n cross-%{pkgname}-gcc@base_ver@ diff --git a/gcc-7.5.0+r278197.tar.xz b/gcc-7.5.0+r278197.tar.xz new file mode 100644 index 0000000..1eb52fa --- /dev/null +++ b/gcc-7.5.0+r278197.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8f2be0008f0069d4d285ff82e5a73982ecdb1121e25be1bf9ff53207b4b498bd +size 61466948 diff --git a/gcc-add-defaultsspec.diff b/gcc-add-defaultsspec.diff new file mode 100644 index 0000000..8719c39 --- /dev/null +++ b/gcc-add-defaultsspec.diff @@ -0,0 +1,51 @@ +Index: gcc/gcc.c +=================================================================== +--- gcc/gcc.c.orig 2013-11-26 15:41:59.000000000 +0100 ++++ gcc/gcc.c 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..a66f9c3 --- /dev/null +++ b/gcc.spec.in @@ -0,0 +1,2619 @@ +# +# spec file for package gcc7 +# +# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# 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 + + +# 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 +%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 +%define tsan_arch x86_64 aarch64 ppc ppc64 ppc64le +%define asan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %sparc %arm aarch64 +%define itm_arch x86_64 %ix86 %arm aarch64 ppc ppc64 ppc64le 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 +%define ubsan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %arm aarch64 +%if 0%{?build_libvtv:1} +%define vtv_arch x86_64 %ix86 +%endif +%define cilkrts_arch x86_64 %ix86 +%if %{suse_version} >= 1310 +%define mpx_arch x86_64 %ix86 +%endif + +%define build_cp 1 +%define build_fortran 1 +%define build_objc 1 +%define build_objcp 1 +%ifarch riscv64 +%define build_go 0 +%else +%define build_go 1 +%endif + +%if %{build_objcp} +%define build_cp 1 +%define build_objc 1 +%endif + +# For optional compilers only build C, C++, Fortran, Ada and Go +%if 0%{?build_optional_compiler_languages:1} +%define build_objc 0 +%define build_objcp 0 +%endif + +%ifarch x86_64 +%define build_hsa 1 +%define build_nvptx 1 +%else +%define build_hsa 0 +%define build_nvptx 0 +%endif + +# Enable plugins just for Tumbleweed, not for SLES +%if 0%{!?sle_version:1} +%define enable_plugins 1 +%else +%define enable_plugins 0 +%endif + +# 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 4 +%define libquadmath_sover 0 +%define libasan_sover 4 +%define libtsan_sover 0 +%define libatomic_sover 1 +%define libitm_sover 1 +%define libubsan_sover 0 +%define liblsan_sover 0 +%define libvtv_sover 0 +%define libcilkrts_sover 5 +%define libgo_sover 11 +%define libmpx_sover 2 +%define libmpxwrappers_sover 2 + +# 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 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 libcilkrts_suffix %{plv libcilkrts %{libcilkrts_sover}} +%define libgo_suffix %{plv libgo %{libgo_sover}} +%define libmpx_suffix %{plv libmpx %{libmpx_sover}} +%define libmpxwrappers_suffix %{plv libmpxwrappers %{libmpx_sover}} + + +# libFOO-devel package suffix +%define libdevel_suffix -gcc@base_ver@ + + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + + +Name: gcc@base_ver@ +BuildRequires: xz +# With generated files in src we could drop the following +BuildRequires: bison +BuildRequires: flex +BuildRequires: gettext-devel +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +# until here, but at least renaming and patching info files breaks this +BuildRequires: gcc-c++ +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +BuildRequires: zlib-devel +%if %{suse_version} >= 1230 +BuildRequires: isl-devel +%endif +%if %{build_ada} +%if 0%{?gcc_version:%{gcc_version}} > 7 +%define hostsuffix %{binsuffix} +BuildRequires: gcc@base_ver@-ada +BuildRequires: gcc@base_ver@-c++ +%else +%if %{suse_version} < 1310 +%define hostsuffix -4.8 +BuildRequires: gcc48-ada +BuildRequires: gcc48-c++ +%else +%define hostsuffix %{nil} +BuildRequires: gcc-ada +%endif +%endif +%endif +%if 0%{?building_testsuite:1} +# For building the libstdc++ API reference +BuildRequires: doxygen +BuildRequires: graphviz +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{?run_tests:1} +BuildRequires: dejagnu +BuildRequires: expect +BuildRequires: gdb +%if %{build_nvptx} +BuildRequires: cross-nvptx-gcc@base_ver@ +BuildRequires: cross-nvptx-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 +%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 + +# SRC-COMMON-BEGIN +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 + +%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 %atomic_arch +Requires: libatomic%{libatomic_sover} >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover} >= %{version}-%{release} +%endif +%ifarch %cilkrts_arch +Requires: libcilkrts%{libcilkrts_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 +%ifarch %mpx_arch +Requires: libmpx%{libmpx_sover} >= %{version}-%{release} +Requires: libmpxwrappers%{libmpxwrappers_sover} >= %{version}-%{release} +%endif +Suggests: gcc@base_ver@-info gcc@base_ver@-locale +%endif + +# SRC-COMMON-BEGIN +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +# 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++ and gcc-go. + + + +%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 %cilkrts_arch +Requires: libcilkrts%{libcilkrts_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 +%ifarch %mpx_arch +Requires: libmpx%{libmpx_sover}-32bit >= %{version}-%{release} +Requires: libmpxwrappers%{libmpxwrappers_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 %atomic_arch +Requires: libatomic%{libatomic_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %cilkrts_arch +Requires: libcilkrts%{libcilkrts_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 +%ifarch %mpx_arch +Requires: libmpx%{libmpx_sover}-64bit >= %{version}-%{release} +Requires: libmpxwrappers%{libmpxwrappers_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-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 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@ + +%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 +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 +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 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 libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}@variant@ +Summary: The GNU Compiler Cilk+ Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libcilkrts%{libcilkrts_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 libcilkrts%{libcilkrts_sover}@variant@ + +%description -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fcilkplus option of the GNU Compiler Collection (GCC). + +%post -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libcilkrts%{libcilkrts_sover}%{libcilkrts_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 -n libmpx%{libmpx_sover}%{libmpx_suffix}@variant@ +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpx%{libmpx_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 libmpx%{libmpx_sover}@variant@ + +%description -n libmpx%{libmpx_sover}%{libmpx_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpx%{libmpx_sover}%{libmpx_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libmpx%{libmpx_sover}%{libmpx_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + +# PACKAGE-BEGIN +%package -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}@variant@ +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpxwrappers%{libmpxwrappers_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 libmpxwrappers%{libmpxwrappers_sover}@variant@ + +%description -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}@variant@ +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}@variant@ -p /sbin/ldconfig + +%postun -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}@variant@ -p /sbin/ldconfig +# PACKAGE-END + + +%package -n libstdc++%{libstdcxx_sover}%{libdevel_suffix}-doc +Summary: Documentation for the GNU C++ standard library +License: GPL-3.0-or-later +Group: Documentation/HTML +%if 0%{?suse_version} >= 1120 +BuildArch: noarch +%endif + +%description -n libstdc++%{libstdcxx_sover}%{libdevel_suffix}-doc +Extensive HTML documentation for the GNU C++ standard library. + +# 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 -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 + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +# BUILD-COMMON-END + +STAGE1_FLAGS="-g -O2" +%if 0%{?do_profiling} +%define profiledbootstraprule profiledbootstrap +%endif +# Only run profiled bootstrap on archs where it works and matters +%ifarch x86_64 %ix86 ppc64le s390x aarch64 +setarch `arch` -R make %{?profiledbootstraprule} STAGE1_CFLAGS="$STAGE1_FLAGS" BOOT_CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} +%else +make STAGE1_CFLAGS="$STAGE1_FLAGS" BOOT_CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} +%endif +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=$RPM_BUILD_ROOT%{libsubdir}:$RPM_BUILD_ROOT%{mainlibdirbi} +make install DESTDIR=$RPM_BUILD_ROOT + +# verify libasan really ended up with libstdc++ as NEEDED. +%ifarch %asan_arch + readelf -d $RPM_BUILD_ROOT%{versmainlibdir}/libasan.so.%{libasan_sover}* | grep 'NEEDED.*libstdc++' || exit 1 +%if %{biarch} + readelf -d $RPM_BUILD_ROOT%{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 libatomic libitm libtsan libcilkrts liblsan libubsan libvtv \ + libmpx libmpxwrappers libstdc++fs libgomp-plugin-nvptx; do + rm -f $RPM_BUILD_ROOT%{versmainlibdir}/$lib.la +%if %{biarch} + rm -f $RPM_BUILD_ROOT%{versmainlibdirbi}/$lib.la +%endif +done + +mkdir -p $RPM_BUILD_ROOT%{_libdir} +%if %{biarch} +%if %{build_primary_64bit} +mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib +%else +mkdir -p $RPM_BUILD_ROOT%{_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 > $RPM_BUILD_ROOT%{_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 $RPM_BUILD_ROOT%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/[36]* +if ! test -z "$dir_ml"; then + ln -s . $RPM_BUILD_ROOT%{_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 + libgomp \ +%if %{build_hsa} + libgomp-plugin-hsa \ +%endif +%if %{build_nvptx} + libgomp-plugin-nvptx \ +%endif +%ifarch %atomic_arch + libatomic \ +%endif +%ifarch %itm_arch + libitm \ +%endif +%ifarch %asan_arch + libasan \ +%endif +%ifarch %tsan_arch + libtsan \ +%endif +%ifarch %cilkrts_arch + libcilkrts \ +%endif +%ifarch %lsan_arch + liblsan \ +%endif +%ifarch %ubsan_arch + libubsan \ +%endif +%ifarch %vtv_arch + libvtv \ +%endif +%ifarch %mpx_arch + libmpx libmpxwrappers \ +%endif + ; do + for lib in `find $RPM_BUILD_ROOT%{versmainlibdir} -maxdepth 1 -name $libname.so.*`; do + mv $lib $RPM_BUILD_ROOT%{mainlibdir}/ + done + if test -L $RPM_BUILD_ROOT%{versmainlibdir}/$libname.so; then + ln -sf %{mainlibdir}/`readlink $RPM_BUILD_ROOT%{versmainlibdir}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + $RPM_BUILD_ROOT%{versmainlibdir}/$libname.so + fi +%if %{biarch} + if test -d $RPM_BUILD_ROOT%{versmainlibdirbi}; then + for lib in `find $RPM_BUILD_ROOT%{versmainlibdirbi} -maxdepth 1 -name "$libname.so.*"`; do + mv $lib $RPM_BUILD_ROOT%{mainlibdirbi}/ + done + if test -L $RPM_BUILD_ROOT%{versmainlibdirbi}/$libname.so; then + ln -sf %{mainlibdirbi}/`readlink $RPM_BUILD_ROOT%{versmainlibdirbi}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + $RPM_BUILD_ROOT%{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 $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdir} +mv $RPM_BUILD_ROOT%{mainlibdir}/libstdc++.so.*-gdb.py $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdir}/ +sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdir}/libstdc++.so.*-gdb.py +%if %{biarch} + if test -d $RPM_BUILD_ROOT%{versmainlibdirbi}; then + mkdir -p $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdirbi} + mv $RPM_BUILD_ROOT%{mainlibdirbi}/libstdc++.so.*-gdb.py $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdirbi}/ + sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdirbi}/libstdc++.so.*-gdb.py + fi +%endif +%endif + +# Move libgcc_s around +if test -L $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so; then + rm -f $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so + ln -sf /%{_lib}/libgcc_s.so.%{libgcc_s} $RPM_BUILD_ROOT%{versmainlibdir}/libgcc_s.so +else + mv $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdir}/ +fi +chmod a+x $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so.%{libgcc_s} +%if %{biarch} +%if %{build_primary_64bit} +if test -L $RPM_BUILD_ROOT/lib/libgcc_s.so; then + rm -f $RPM_BUILD_ROOT/lib/libgcc_s.so + ln -sf /lib/libgcc_s.so.%{libgcc_s} $RPM_BUILD_ROOT%{versmainlibdirbi32}/libgcc_s.so +else + mv $RPM_BUILD_ROOT/lib/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi32}/ +fi +ln -sf %{versmainlibdirbi32}/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi32}/libgcc_s_32.so +chmod a+x $RPM_BUILD_ROOT/lib/libgcc_s.so.%{libgcc_s} +%else +# 32-bit biarch systems +if test -L $RPM_BUILD_ROOT/lib64/libgcc_s.so; then + rm -f $RPM_BUILD_ROOT/lib64/libgcc_s.so + ln -sf /lib64/libgcc_s.so.%{libgcc_s} $RPM_BUILD_ROOT%{versmainlibdirbi64}/libgcc_s.so +else + mv $RPM_BUILD_ROOT/lib64/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi64}/ +fi +ln -sf %{versmainlibdirbi64}/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi64}/libgcc_s_64.so +chmod a+x $RPM_BUILD_ROOT/lib64/libgcc_s.so.%{libgcc_s} +%endif +%endif + +%if %{build_ada} +mv $RPM_BUILD_ROOT%{libsubdir}/adalib/lib*-*.so $RPM_BUILD_ROOT%{_libdir} +ln -sf %{_libdir}/libgnarl%{binsuffix}.so $RPM_BUILD_ROOT%{libsubdir}/adalib/libgnarl.so +ln -sf %{_libdir}/libgnat%{binsuffix}.so $RPM_BUILD_ROOT%{libsubdir}/adalib/libgnat.so +chmod a+x $RPM_BUILD_ROOT%{_libdir}/libgna*-*.so +%if %{biarch} +mv $RPM_BUILD_ROOT%{versmainlibdirbi}/adalib/lib*-*.so $RPM_BUILD_ROOT%{mainlibdirbi}/ +ln -sf %{mainlibdirbi}/libgnarl%{binsuffix}.so $RPM_BUILD_ROOT%{versmainlibdirbi}/adalib/libgnarl.so +ln -sf %{mainlibdirbi}/libgnat%{binsuffix}.so $RPM_BUILD_ROOT%{versmainlibdirbi}/adalib/libgnat.so +chmod a+x $RPM_BUILD_ROOT%{mainlibdirbi}/libgna*-*.so +%endif +%endif + +rm -f $RPM_BUILD_ROOT%{_prefix}/bin/c++%{binsuffix} + +# Remove some crap from the .la files: +for l in `find $RPM_BUILD_ROOT -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 + +# GCC-TESTSUITE-DELETE-END +%if 0%{?run_tests:1} +cp `find . -name "*.sum"` ../testresults/ +cp `find . -name "*.log" \! -name "config.log" | grep -v 'acats.\?/tests' ` ../testresults/ +chmod 644 ../testresults/* +%endif +# GCC-TESTSUITE-DELETE-BEGIN +# Remove files that we do not need to clean up filelist +rm -f $RPM_BUILD_ROOT%{_prefix}/bin/%{GCCDIST}-* +rm -rf $RPM_BUILD_ROOT%{libsubdir}/install-tools +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/zutil.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/linux/a.out.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/linux/vt.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/asm-generic/socket.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/bits/mathdef.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/sys/ucontext.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/bits/statx.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/pthread.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/bits/unistd_ext.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/sys/rseq.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/sys/mount.h +%if !%{enable_plugins} +# no plugins +rm -rf $RPM_BUILD_ROOT%{libsubdir}/plugin +%endif +rm -f $RPM_BUILD_ROOT%{_infodir}/dir + + +rm -f $RPM_BUILD_ROOT%{_mandir}/man7/fsf-funding.7 +rm -f $RPM_BUILD_ROOT%{_mandir}/man7/gfdl.7 +rm -f $RPM_BUILD_ROOT%{_mandir}/man7/gpl.7 +rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a +%if %{biarch} +%if %{build_primary_64bit} +rm -f $RPM_BUILD_ROOT%{_prefix}/lib/libiberty.a +%else +rm -f $RPM_BUILD_ROOT%{_prefix}/lib64/libiberty.a +%endif +%endif +rm -f $RPM_BUILD_ROOT%{libsubdir}/liblto_plugin.a +rm -f $RPM_BUILD_ROOT%{libsubdir}/liblto_plugin.la +%if %{build_go} +# gccgo.info isn't properly versioned +rm $RPM_BUILD_ROOT%{_infodir}/gccgo.info* +%endif + +# For regular build, some info files do not get renamed properly. +# Do so here. +mv $RPM_BUILD_ROOT%{_infodir}/libgomp.info $RPM_BUILD_ROOT%{_infodir}/libgomp%{binsuffix}.info +%ifarch %itm_arch +mv $RPM_BUILD_ROOT%{_infodir}/libitm.info $RPM_BUILD_ROOT%{_infodir}/libitm%{binsuffix}.info +%endif +%if %{build_fortran} +%ifarch %quadmath_arch +mv $RPM_BUILD_ROOT%{_infodir}/libquadmath.info $RPM_BUILD_ROOT%{_infodir}/libquadmath%{binsuffix}.info +%endif +%endif +%if %{build_ada} +mv $RPM_BUILD_ROOT%{_infodir}/gnat-style.info $RPM_BUILD_ROOT%{_infodir}/gnat-style%{binsuffix}.info +mv $RPM_BUILD_ROOT%{_infodir}/gnat_rm.info $RPM_BUILD_ROOT%{_infodir}/gnat_rm%{binsuffix}.info +mv $RPM_BUILD_ROOT%{_infodir}/gnat_ugn.info $RPM_BUILD_ROOT%{_infodir}/gnat_ugn%{binsuffix}.info +%endif + + +cd .. +%find_lang cpplib%{binsuffix} +%find_lang gcc%{binsuffix} +%find_lang libstdc++ +cat cpplib%{binsuffix}.lang gcc%{binsuffix}.lang > 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 +%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/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} +%{libsubdir}/collect2 +%{libsubdir}/lto1 +%{libsubdir}/lto-wrapper +%{libsubdir}/liblto_plugin.so* +%{libsubdir}/include-fixed/README +%{libsubdir}/include-fixed/limits.h +%{libsubdir}/include-fixed/syslimits.h +%{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 +%ifarch %sparc +%{libsubdir}/include/visintrin.h +%endif +%ifarch ppc ppc64 ppc64le +%{libsubdir}/include/altivec.h +%{libsubdir}/include/ppc-asm.h +%{libsubdir}/include/paired.h +%{libsubdir}/include/ppu_intrinsics.h +%{libsubdir}/include/si2vmx.h +%{libsubdir}/include/spe.h +%{libsubdir}/include/spu2vmx.h +%{libsubdir}/include/vec_types.h +%{libsubdir}/include/htmintrin.h +%{libsubdir}/include/htmxlintrin.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 +%endif +%ifarch %arm aarch64 +%{libsubdir}/include/arm_neon.h +%{libsubdir}/include/arm_acle.h +%{libsubdir}/include/arm_fp16.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/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 +%endif +%ifarch m68k +%{libsubdir}/include/math-68881.h +%endif +%ifarch %cilkrts_arch +%{libsubdir}/include/cilk +%endif +%ifarch %asan_arch +%{libsubdir}/include/sanitizer +%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_hsa} +%versmainlib libgomp-plugin-hsa.so +%endif +%if %{build_nvptx} +%versmainlib libgomp-plugin-nvptx.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 %cilkrts_arch +%versmainlib libcilkrts.so +%versmainlib libcilkrts.a +%versmainlib libcilkrts.spec +%endif +%ifarch %lsan_arch +%if %build_primary_64bit +%versmainlib liblsan.so +%versmainlib liblsan.a +%endif +%endif +%ifarch %ubsan_arch +%versmainlib libubsan.so +%versmainlib libubsan.a +%endif +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch +%versmainlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versmainlib libvtv.so +%versmainlib libvtv.a +%endif +%ifarch %mpx_arch +%versmainlib libmpx.so +%versmainlib libmpx.a +%versmainlib libmpxwrappers.so +%versmainlib libmpxwrappers.a +%versmainlib libmpx.spec +%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 + +%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 +%if %{build_nvptx} +%versbiarchlib libgomp-plugin-nvptx.so +%endif +%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 %cilkrts_arch +%versbiarchlib libcilkrts.a +%versbiarchlib libcilkrts.so +%versbiarchlib libcilkrts.spec +%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 +%endif +%endif +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch +%versbiarchlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versbiarchlib libvtv.a +%versbiarchlib libvtv.so +%endif +%ifarch %mpx_arch +%versbiarchlib libmpx.so +%versbiarchlib libmpx.a +%versbiarchlib libmpxwrappers.so +%versbiarchlib libmpxwrappers.a +%versbiarchlib libmpx.spec +%endif +%endif + +%if %{enable_plugins} +%files devel +%defattr(-,root,root) +%dir %{libsubdir}/plugin +%{libsubdir}/plugin +%endif + +%files locale -f gcc@base_ver@-locale.lang + +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale -f libstdc++.lang + +%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 + +%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) +%versmainlib libstdc++.a +%versmainlib libstdc++fs.a +%versmainlib libstdc++.so +%versmainlib libsupc++.a +%{_prefix}/include/c++ +%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) +%versbiarchlib libstdc++.a +%versbiarchlib libstdc++fs.a +%versbiarchlib libstdc++.so +%versbiarchlib libsupc++.a +%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) +/%{_lib}/libgcc_s.so.%{libgcc_s} +%if %{biarch} +%if %{build_primary_64bit} +%if !%{separate_bi32} +/lib/libgcc_s.so.%{libgcc_s} +%endif +%else +%if !%{separate_bi64} +/lib64/libgcc_s.so.%{libgcc_s} +%endif +%endif +%endif + +%if %{separate_bi64} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit +%defattr(-,root,root) +/lib64/libgcc_s.so.%{libgcc_s} +%endif + +%if %{separate_bi32} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit +%defattr(-,root,root) +/lib/libgcc_s.so.%{libgcc_s} +%endif + + +%files -n libgomp%{libgomp_sover}%{libgomp_suffix} +%defattr(-,root,root) +%mainlib libgomp.so.%{libgomp_sover}* +%if %{build_hsa} +%mainlib libgomp-plugin-hsa.so.%{libgomp_sover}* +%endif +%if %{build_nvptx} +%mainlib libgomp-plugin-nvptx.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 +%if %{build_nvptx} +%biarchlib libgomp-plugin-nvptx.so.%{libgomp_sover}* +%endif + + + +%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 %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 %cilkrts_arch +%files -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix} +%defattr(-,root,root) +%mainlib libcilkrts.so.%{libcilkrts_sover}* + +%if %{separate_biarch} +%files -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libcilkrts.so.%{libcilkrts_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 + + +%ifarch %mpx_arch +%files -n libmpx%{libmpx_sover}%{libmpx_suffix} +%defattr(-,root,root) +%mainlib libmpx.so.%{libmpx_sover}* + +%if %{separate_biarch} +%files -n libmpx%{libmpx_sover}%{libmpx_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libmpx.so.%{libmpx_sover}* +%endif + +%files -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix} +%defattr(-,root,root) +%mainlib libmpxwrappers.so.%{libmpxwrappers_sover}* + +%if %{separate_biarch} +%files -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libmpxwrappers.so.%{libmpxwrappers_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 + +%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 + +%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 +%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/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 +# 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/gcc41-ppc32-retaddr.patch b/gcc41-ppc32-retaddr.patch new file mode 100644 index 0000000..72f7ca7 --- /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.c +#=================================================================== +#--- gcc/config/rs6000/rs6000.c.orig 2013-11-26 15:42:33.000000000 +0100 +#+++ gcc/config/rs6000/rs6000.c 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..e19163f --- /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 +@@ -288,7 +288,7 @@ CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(IN + $(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) ++ $(INHIBIT_LIBC_CFLAGS) -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..660332e --- /dev/null +++ b/gcc44-rename-info-files.patch @@ -0,0 +1,665 @@ +#! /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(-) + +Index: gcc/Makefile.in +=================================================================== +--- gcc/Makefile.in.orig 2017-03-22 09:07:47.180401238 +0100 ++++ gcc/Makefile.in 2017-03-22 09:07:50.212445405 +0100 +@@ -3066,8 +3066,27 @@ 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)') ++ ++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)' + + info: $(INFOFILES) lang.info @GENINSRC@ srcinfo lang.srcinfo + +@@ -3122,21 +3141,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 + +@@ -3555,11 +3594,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 +@@ -3780,8 +3819,11 @@ uninstall: lang.uninstall + -rm -rf $(DESTDIR)$(bindir)/$(GCOV_INSTALL_NAME)$(exeext) + -rm -rf $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext) + -rm -rf $(DESTDIR)$(man1dir)/cpp$(man1ext) +- -rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info* +- -rm -f $(DESTDIR)$(infodir)/cppinternals.info* $(DESTDIR)$(infodir)/gccint.info* ++ -rm -f $(DESTDIR)$(infodir)/$(INFO_CPP_NAME).info* ++ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCC_NAME).info* ++ -rm -f $(DESTDIR)$(infodir)/$(INFO_CPPINT_NAME).info* ++ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINT_NAME).info* ++ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINSTALL_NAME).info* + for i in ar nm ranlib ; do \ + install_name=`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ;\ + target_install_name=$(target_noncanonical)-`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ; \ +Index: gcc/ada/gnat-style.texi +=================================================================== +--- gcc/ada/gnat-style.texi.orig 2017-03-22 09:07:47.184401296 +0100 ++++ gcc/ada/gnat-style.texi 2017-03-22 09:07:50.212445405 +0100 +@@ -31,7 +31,7 @@ Texts. A copy of the license is include + + @dircategory Software development + @direntry +-* gnat-style: (gnat-style). GNAT Coding Style ++* gnat-style: (gnat-style-7). GNAT Coding Style + @end direntry + + @macro syntax{element} +Index: gcc/ada/gnat_rm.texi +=================================================================== +--- gcc/ada/gnat_rm.texi.orig 2017-03-22 09:07:47.192401412 +0100 ++++ gcc/ada/gnat_rm.texi 2017-03-22 09:07:50.220445522 +0100 +@@ -12,7 +12,7 @@ + @finalout + @dircategory GNU Ada Tools + @direntry +-* gnat_rm: (gnat_rm.info). gnat_rm ++* GNAT Reference Manual: (gnat_rm-7). Reference Manual for GNU Ada tools. + @end direntry + + @definfoenclose strong,`,' +Index: gcc/ada/gnat_ugn.texi +=================================================================== +--- gcc/ada/gnat_ugn.texi.orig 2017-03-22 09:07:47.200401529 +0100 ++++ gcc/ada/gnat_ugn.texi 2017-03-22 09:07:50.224445580 +0100 +@@ -12,7 +12,7 @@ + @finalout + @dircategory GNU Ada Tools + @direntry +-* gnat_ugn: (gnat_ugn.info). gnat_ugn ++* User's Guide: (gnat_ugn-7). + @end direntry + + @definfoenclose strong,`,' +Index: gcc/doc/cpp.texi +=================================================================== +--- gcc/doc/cpp.texi.orig 2017-03-22 09:07:47.200401529 +0100 ++++ gcc/doc/cpp.texi 2017-03-22 09:07:50.228445638 +0100 +@@ -50,7 +50,7 @@ This manual contains no Invariant Sectio + @ifinfo + @dircategory Software development + @direntry +-* Cpp: (cpp). The GNU C preprocessor. ++* @value{fncpp}: (@value{fncpp}). The GNU C preprocessor. + @end direntry + @end ifinfo + +Index: gcc/doc/cppinternals.texi +=================================================================== +--- gcc/doc/cppinternals.texi.orig 2017-03-22 09:07:47.200401529 +0100 ++++ gcc/doc/cppinternals.texi 2017-03-22 09:07:50.228445638 +0100 +@@ -7,7 +7,7 @@ + @ifinfo + @dircategory Software development + @direntry +-* Cpplib: (cppinternals). Cpplib internals. ++* @value{fncppint}: (@value{fncppint}). Cpplib internals. + @end direntry + @end ifinfo + +Index: gcc/doc/extend.texi +=================================================================== +--- gcc/doc/extend.texi.orig 2017-03-22 09:07:47.204401587 +0100 ++++ gcc/doc/extend.texi 2017-03-22 09:07:50.232445697 +0100 +@@ -21790,7 +21790,7 @@ want to write code that checks whether t + test for the GNU compiler the same way as for C programs: check for a + predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to + test specifically for GNU C++ (@pxref{Common Predefined Macros,, +-Predefined Macros,cpp,The GNU C Preprocessor}). ++Predefined Macros,@value{fncpp},The GNU C Preprocessor}). + + @menu + * C++ Volatiles:: What constitutes an access to a volatile object. +Index: gcc/doc/gcc.texi +=================================================================== +--- gcc/doc/gcc.texi.orig 2017-03-22 09:07:47.208401645 +0100 ++++ gcc/doc/gcc.texi 2017-03-22 09:10:01.702361422 +0100 +@@ -63,11 +63,11 @@ Texts being (a) (see below), and with th + @ifnottex + @dircategory Software development + @direntry +-* gcc: (gcc). The GNU Compiler Collection. +-* g++: (gcc). The GNU C++ compiler. +-* gcov: (gcc) Gcov. @command{gcov}---a test coverage program. +-* gcov-tool: (gcc) Gcov-tool. @command{gcov-tool}---an offline gcda profile processing program. +-* gcov-dump: (gcc) Gcov-dump. @command{gcov-dump}---an offline gcda and gcno profile dump tool. ++* @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. + @end direntry + This file documents the use of the GNU compilers. + @sp 1 +@@ -127,7 +127,7 @@ version @value{version-GCC}. + The internals of the GNU compilers, including how to port them to new + targets and some information about how to write front ends for new + languages, are documented in a separate manual. @xref{Top,, +-Introduction, gccint, GNU Compiler Collection (GCC) Internals}. ++Introduction, @value{fngccint}, GNU Compiler Collection (GCC) Internals}. + + @menu + * G++ and GCC:: You can compile C or C++ programs. +Index: gcc/doc/gccint.texi +=================================================================== +--- gcc/doc/gccint.texi.orig 2017-03-22 09:07:47.208401645 +0100 ++++ gcc/doc/gccint.texi 2017-03-22 09:07:50.232445697 +0100 +@@ -49,7 +49,7 @@ Texts being (a) (see below), and with th + @ifnottex + @dircategory Software development + @direntry +-* gccint: (gccint). Internals of the GNU Compiler Collection. ++* @value{fngccint}: (@value{fngccint}). Internals of the GNU Compiler Collection. + @end direntry + This file documents the internals of the GNU compilers. + @sp 1 +@@ -81,7 +81,7 @@ write front ends for new languages. It + @value{VERSION_PACKAGE} + @end ifset + version @value{version-GCC}. The use of the GNU compilers is documented in a +-separate manual. @xref{Top,, Introduction, gcc, Using the GNU ++separate manual. @xref{Top,, Introduction, @value{fngcc}, Using the GNU + Compiler Collection (GCC)}. + + This manual is mainly a reference manual rather than a tutorial. It +Index: gcc/doc/install.texi +=================================================================== +--- gcc/doc/install.texi.orig 2017-03-22 09:07:47.208401645 +0100 ++++ gcc/doc/install.texi 2017-03-22 09:07:50.232445697 +0100 +@@ -94,7 +94,7 @@ Free Documentation License}''. + @end ifinfo + @dircategory Software development + @direntry +-* gccinstall: (gccinstall). Installing the GNU Compiler Collection. ++* @value{fngccinstall}: (@value{fngccinstall}). Installing the GNU Compiler Collection. + @end direntry + + @c Part 3 Titlepage and Copyright +Index: gcc/doc/invoke.texi +=================================================================== +--- gcc/doc/invoke.texi.orig 2017-03-22 09:07:47.216401762 +0100 ++++ gcc/doc/invoke.texi 2017-03-22 09:07:50.240445813 +0100 +@@ -7215,7 +7215,7 @@ the standard calling sequence automatica + and nothing is saved by pretending it doesn't exist. The + machine-description macro @code{FRAME_POINTER_REQUIRED} controls + whether a target machine supports this flag. @xref{Registers,,Register +-Usage, gccint, GNU Compiler Collection (GCC) Internals}. ++Usage, @value{fngccint}, GNU Compiler Collection (GCC) Internals}. + + The default setting (when not optimizing for + size) for 32-bit GNU/Linux x86 and 32-bit Darwin x86 targets is +@@ -11601,7 +11601,7 @@ One of the standard libraries bypassed b + @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines + which GCC uses to overcome shortcomings of particular machines, or special + needs for some languages. +-(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler ++(@xref{Interface,,Interfacing to GCC Output,@value{fngccint},GNU Compiler + Collection (GCC) Internals}, + for more discussion of @file{libgcc.a}.) + In most cases, you need @file{libgcc.a} even when you want to avoid +@@ -11610,7 +11610,7 @@ or @option{-nodefaultlibs} you should us + This ensures that you have no unresolved references to internal GCC + library subroutines. + (An example of such an internal subroutine is @code{__main}, used to ensure C++ +-constructors are called; @pxref{Collect2,,@code{collect2}, gccint, ++constructors are called; @pxref{Collect2,,@code{collect2}, @value{fngccint}, + GNU Compiler Collection (GCC) Internals}.) + + @item -pie +@@ -26503,7 +26503,7 @@ Note that you can also specify places to + @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These + take precedence over places specified using environment variables, which + in turn take precedence over those specified by the configuration of GCC@. +-@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint, ++@xref{Driver,, Controlling the Compilation Driver @file{gcc}, @value{fngccint}, + GNU Compiler Collection (GCC) Internals}. + + @table @env +@@ -26663,7 +26663,7 @@ the headers it contains change. + + A precompiled header file is searched for when @code{#include} is + seen in the compilation. As it searches for the included file +-(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the ++(@pxref{Search Path,,Search Path,@value{fncpp},The C Preprocessor}) the + compiler looks for a precompiled header in each directory just before it + looks for the include file in that directory. The name searched for is + the name specified in the @code{#include} with @samp{.gch} appended. If +Index: gcc/doc/libgcc.texi +=================================================================== +--- gcc/doc/libgcc.texi.orig 2017-03-22 09:07:47.220401820 +0100 ++++ gcc/doc/libgcc.texi 2017-03-22 09:07:50.240445813 +0100 +@@ -24,7 +24,7 @@ that needs them. + GCC will also generate calls to C library routines, such as + @code{memcpy} and @code{memset}, in some cases. The set of routines + that GCC may possibly use is documented in @ref{Other +-Builtins,,,gcc, Using the GNU Compiler Collection (GCC)}. ++Builtins,,,@value{fngcc}, Using the GNU Compiler Collection (GCC)}. + + These routines take arguments and return values of a specific machine + mode, not a specific C type. @xref{Machine Modes}, for an explanation +Index: gcc/fortran/Make-lang.in +=================================================================== +--- gcc/fortran/Make-lang.in.orig 2017-03-22 09:07:47.220401820 +0100 ++++ gcc/fortran/Make-lang.in 2017-03-22 09:07:50.240445813 +0100 +@@ -114,7 +114,8 @@ fortran.tags: force + cd $(srcdir)/fortran; etags -o TAGS.sub *.c *.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 + fortran.dvi: doc/gfortran.dvi doc/gfc-internals.dvi + + F95_HTMLFILES = $(build_htmldir)/gfortran +@@ -181,10 +182,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 + +@@ -249,7 +250,7 @@ fortran.install-common: install-finclude + + fortran.install-plugin: + +-fortran.install-info: $(DESTDIR)$(infodir)/gfortran.info ++fortran.install-info: $(DESTDIR)$(infodir)/$(INFO_FORTRAN_NAME).info + + fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext) + +@@ -267,7 +268,7 @@ fortran.uninstall: + rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \ + rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \ + rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \ +- rm -rf $(DESTDIR)$(infodir)/gfortran.info* ++ rm -rf $(DESTDIR)$(infodir)/$(INFO_FORTRAN_NAME).info* + + # + # Clean hooks: +Index: gcc/fortran/gfortran.texi +=================================================================== +--- gcc/fortran/gfortran.texi.orig 2017-03-22 09:07:47.220401820 +0100 ++++ gcc/fortran/gfortran.texi 2017-03-22 09:07:50.244445871 +0100 +@@ -101,7 +101,7 @@ Texts being (a) (see below), and with th + @ifinfo + @dircategory Software development + @direntry +-* gfortran: (gfortran). The GNU Fortran Compiler. ++* @value{fngfortran}: (@value{fngfortran}). The GNU Fortran Compiler. + @end direntry + This file documents the use and the internals of + the GNU Fortran compiler, (@command{gfortran}). +Index: libffi/Makefile.am +=================================================================== +--- libffi/Makefile.am.orig 2017-03-22 09:07:47.220401820 +0100 ++++ libffi/Makefile.am 2017-03-22 09:07:50.244445871 +0100 +@@ -25,6 +25,8 @@ TEXINFO_TEX = ../gcc/doc/include/texin + # Defines info, dvi, pdf and html targets + MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include + info_TEXINFOS = doc/libffi.texi ++INFO_LIBFFI_NAME = $(shell echo libffi | sed '${program_transform_name}') ++INFO_DEPS = doc/$(INFO_LIBFFI_NAME).info + + # AM_CONDITIONAL on configure option --generated-files-in-srcdir + if GENINSRC +@@ -42,17 +44,17 @@ 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) doc/libffi.info ++CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) doc/$(INFO_LIBFFI_NAME).info + MAINTAINERCLEANFILES = $(srcdir)/doc/libffi.info + + ## ################################################################ +Index: libffi/Makefile.in +=================================================================== +--- libffi/Makefile.in.orig 2017-03-22 09:07:47.224401878 +0100 ++++ libffi/Makefile.in 2017-03-22 09:07:50.244445871 +0100 +@@ -158,7 +158,6 @@ MULTIDIRS = + MULTISUBDIR = + MULTIDO = true + MULTICLEAN = true +-INFO_DEPS = doc/libffi.info + am__TEXINFO_TEX_DIR = $(srcdir)/../gcc/doc/include + DVIS = doc/libffi.dvi + PDFS = doc/libffi.pdf +@@ -352,6 +351,8 @@ TEXINFO_TEX = ../gcc/doc/include/texinfo + # Defines info, dvi, pdf and html targets + MAKEINFOFLAGS = -I $(srcdir)/../gcc/doc/include + info_TEXINFOS = doc/libffi.texi ++INFO_LIBFFI_NAME = $(shell echo libffi | sed '${program_transform_name}') ++INFO_DEPS = doc/$(INFO_LIBFFI_NAME).info + @GENINSRC_FALSE@STAMP_GENINSRC = + + # AM_CONDITIONAL on configure option --generated-files-in-srcdir +@@ -360,7 +361,7 @@ info_TEXINFOS = doc/libffi.texi + + # AM_CONDITIONAL on configure check ACX_CHECK_PROG_VER([MAKEINFO]) + @BUILD_INFO_TRUE@STAMP_BUILD_INFO = stamp-build-info +-CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) doc/libffi.info ++CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) doc/$(INFO_LIBFFI_NAME).info + MAINTAINERCLEANFILES = $(srcdir)/doc/libffi.info + + # Work around what appears to be a GNU make bug handling MAKEFLAGS +@@ -1893,14 +1894,15 @@ uninstall-am: uninstall-dvi-am uninstall + + all-local: $(STAMP_GENINSRC) + +-stamp-geninsrc: doc/libffi.info +- cp -p $(top_builddir)/doc/libffi.info $(srcdir)/doc/libffi.info ++$(srcdir)/doc/libffi.info: stamp-geninsrc ++stamp-geninsrc: doc/$(INFO_LIBFFI_NAME).info ++ cp -p $(top_builddir)/doc/$(INFO_LIBFFI_NAME).info $(srcdir)/doc/libffi.info + @touch $@ + +-doc/libffi.info: $(STAMP_BUILD_INFO) ++doc/$(INFO_LIBFFI_NAME).info: $(STAMP_BUILD_INFO) + + stamp-build-info: doc/libffi.texi $(srcdir)/doc/version.texi doc/$(am__dirstamp) +- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir)/doc -o doc/libffi.info $(srcdir)/doc/libffi.texi ++ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -D 'fnlibffi $(INFO_LIBFFI_NAME)' -I $(srcdir)/doc -o doc/$(INFO_LIBFFI_NAME).info $(srcdir)/doc/libffi.texi + @touch $@ + @LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@libffi.map-sun : libffi.map $(top_srcdir)/../contrib/make_sunver.pl \ + @LIBAT_BUILD_VERSIONED_SHLIB_SUN_TRUE@@LIBAT_BUILD_VERSIONED_SHLIB_TRUE@ $(libffi_la_OBJECTS) $(libffi_la_LIBADD) +Index: libffi/doc/libffi.texi +=================================================================== +--- libffi/doc/libffi.texi.orig 2017-03-22 09:07:47.224401878 +0100 ++++ libffi/doc/libffi.texi 2017-03-22 09:07:50.244445871 +0100 +@@ -33,7 +33,7 @@ section entitled ``GNU General Public Li + + @dircategory Development + @direntry +-* libffi: (libffi). Portable foreign-function interface library. ++* libffi: (@value{fnlibffi}). Portable foreign-function interface library. + @end direntry + + @titlepage +Index: libgomp/Makefile.am +=================================================================== +--- libgomp/Makefile.am.orig 2017-03-22 09:07:47.224401878 +0100 ++++ libgomp/Makefile.am 2017-03-22 09:07:50.244445871 +0100 +@@ -125,16 +125,19 @@ 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 ++$(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 $@ + + +-CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) libgomp.info ++CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) $(INFO_LIBGOMP_NAME).info + MAINTAINERCLEANFILES = $(srcdir)/libgomp.info +Index: libgomp/Makefile.in +=================================================================== +--- libgomp/Makefile.in.orig 2017-03-22 09:07:47.224401878 +0100 ++++ libgomp/Makefile.in 2017-03-22 09:07:50.244445871 +0100 +@@ -487,7 +487,8 @@ info_TEXINFOS = libgomp.texi + + # AM_CONDITIONAL on configure check ACX_CHECK_PROG_VER([MAKEINFO]) + @BUILD_INFO_TRUE@STAMP_BUILD_INFO = stamp-build-info +-CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) libgomp.info ++INFO_LIBGOMP_NAME = $(shell echo libgomp|sed '$(program_transform_name)') ++CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) $(INFO_LIBGOMP_NAME).info + MAINTAINERCLEANFILES = $(srcdir)/libgomp.info + all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive +@@ -1302,15 +1303,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 $@ + + # Tell versions [3.59,3.63) of GNU make to not export all variables. +Index: libgomp/libgomp.texi +=================================================================== +--- libgomp/libgomp.texi.orig 2017-03-22 09:07:47.224401878 +0100 ++++ libgomp/libgomp.texi 2017-03-22 09:07:50.244445871 +0100 +@@ -31,7 +31,7 @@ texts being (a) (see below), and with th + @ifinfo + @dircategory GNU Libraries + @direntry +-* libgomp: (libgomp). GNU Offloading and Multi Processing Runtime Library. ++* @value{fnlibgomp}: (@value{fnlibgomp}). GNU Offloading and Multi Processing Runtime Library. + @end direntry + + This manual documents libgomp, the GNU Offloading and Multi Processing +Index: libitm/libitm.texi +=================================================================== +--- libitm/libitm.texi.orig 2017-03-22 09:07:47.224401878 +0100 ++++ libitm/libitm.texi 2017-03-22 09:07:50.244445871 +0100 +@@ -20,7 +20,7 @@ Free Documentation License''. + @ifinfo + @dircategory GNU Libraries + @direntry +-* libitm: (libitm). GNU Transactional Memory Library ++* libitm: (libitm-6). GNU Transactional Memory Library + @end direntry + + This manual documents the GNU Transactional Memory Library. +Index: libquadmath/libquadmath.texi +=================================================================== +--- libquadmath/libquadmath.texi.orig 2017-03-22 09:07:47.224401878 +0100 ++++ libquadmath/libquadmath.texi 2017-03-22 09:07:50.244445871 +0100 +@@ -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..05577d0 --- /dev/null +++ b/gcc44-textdomain.patch @@ -0,0 +1,116 @@ +#! /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 + + +Index: gcc/Makefile.in +=================================================================== +--- gcc/Makefile.in.orig 2013-11-26 16:46:03.000000000 +0100 ++++ gcc/Makefile.in 2013-11-26 16:46:43.271816000 +0100 +@@ -3795,8 +3795,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-7.mo; \ ++ $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc-7.mo; \ + done + + # Rule for regenerating the message template (gcc.pot). +Index: gcc/intl.c +=================================================================== +--- gcc/intl.c.orig 2013-11-26 15:42:31.000000000 +0100 ++++ gcc/intl.c 2013-11-26 16:46:43.271816000 +0100 +@@ -55,8 +55,8 @@ gcc_init_libintl (void) + setlocale (LC_ALL, ""); + #endif + +- (void) bindtextdomain ("gcc", LOCALEDIR); +- (void) textdomain ("gcc"); ++ (void) bindtextdomain ("gcc-7", LOCALEDIR); ++ (void) textdomain ("gcc-7"); + + /* Opening quotation mark. */ + open_quote = _("`"); +Index: libcpp/Makefile.in +=================================================================== +--- libcpp/Makefile.in.orig 2013-11-26 16:26:56.000000000 +0100 ++++ libcpp/Makefile.in 2013-11-26 16:47:15.764193260 +0100 +@@ -49,6 +49,7 @@ LDFLAGS = @LDFLAGS@ + LIBICONV = @LIBICONV@ + LIBINTL = @LIBINTL@ + PACKAGE = @PACKAGE@ ++PACKAGE_SUFFIX = -7 + RANLIB = @RANLIB@ + SHELL = @SHELL@ + USED_CATALOGS = @USED_CATALOGS@ +@@ -74,8 +75,10 @@ INCLUDES = -I$(srcdir) -I. -I$(srcdir)/. + -I$(srcdir)/include + + ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(PICFLAG) ++ALL_CFLAGS += -DPACKAGE_SUFFIX=\"$(strip $(PACKAGE_SUFFIX))\" + ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(NOEXCEPTION_FLAGS) $(INCLUDES) \ + $(CPPFLAGS) $(PICFLAG) ++ALL_CXXFLAGS += -DPACKAGE_SUFFIX=\"$(strip $(PACKAGE_SUFFIX))\" + + # The name of the compiler to use. + COMPILER = $(CXX) +@@ -164,8 +167,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: +Index: libcpp/system.h +=================================================================== +--- libcpp/system.h.orig 2013-01-15 10:49:52.000000000 +0100 ++++ libcpp/system.h 2013-11-26 16:46:43.271816000 +0100 +@@ -280,7 +280,7 @@ extern int errno; + #endif + + #ifndef _ +-# define _(msgid) dgettext (PACKAGE, msgid) ++# define _(msgid) dgettext (PACKAGE PACKAGE_SUFFIX, msgid) + #endif + + #ifndef N_ +Index: libcpp/init.c +=================================================================== +--- libcpp/init.c.orig 2013-11-26 15:42:40.000000000 +0100 ++++ libcpp/init.c 2013-11-26 16:46:43.271816000 +0100 +@@ -152,7 +152,7 @@ init_library (void) + init_trigraph_map (); + + #ifdef ENABLE_NLS +- (void) bindtextdomain (PACKAGE, LOCALEDIR); ++ (void) bindtextdomain (PACKAGE PACKAGE_SUFFIX, LOCALEDIR); + #endif + } + } diff --git a/gcc48-bsc1161913.patch b/gcc48-bsc1161913.patch new file mode 100644 index 0000000..8b4fa2b --- /dev/null +++ b/gcc48-bsc1161913.patch @@ -0,0 +1,78 @@ +commit 5c8a1211b9873a1b69ef7b2fddae181535bc3b0a +Author: Vladimir N. Makarov +Date: Tue Jan 28 15:43:44 2020 -0500 + + Fix for PR93272 - LRA: EH reg allocated to hold local variable + + 2020-01-28 Vladimir Makarov + + PR rtl-optimization/93272 + * ira-lives.c (process_out_of_region_eh_regs): New function. + (process_bb_node_lives): Call it. + +diff --git a/gcc/ira-lives.c b/gcc/ira-lives.c +index 31635dd3438..71c545ef105 100644 +--- a/gcc/ira-lives.c ++++ b/gcc/ira-lives.c +@@ -1116,6 +1116,50 @@ find_call_crossed_cheap_reg (rtx insn) + return cheap_reg; + } + ++#ifdef EH_RETURN_DATA_REGNO ++ ++/* Add EH return hard registers as conflict hard registers to allocnos ++ living at end of BB. For most allocnos it is already done in ++ process_bb_node_lives when we processing input edges but it does ++ not work when and EH edge is edge out of the current region. This ++ function covers such out of region edges. */ ++static void ++process_out_of_region_eh_regs (basic_block bb) ++{ ++ edge e; ++ edge_iterator ei; ++ unsigned int i; ++ bitmap_iterator bi; ++ bool eh_p = false; ++ ++ FOR_EACH_EDGE (e, ei, bb->succs) ++ if ((e->flags & EDGE_EH) ++ && IRA_BB_NODE (e->dest)->parent != IRA_BB_NODE (bb)->parent) ++ eh_p = true; ++ ++ if (! eh_p) ++ return; ++ ++ EXECUTE_IF_SET_IN_BITMAP (df_get_live_out (bb), FIRST_PSEUDO_REGISTER, i, bi) ++ { ++ ira_allocno_t a = ira_curr_regno_allocno_map[i]; ++ for (int n = ALLOCNO_NUM_OBJECTS (a) - 1; n >= 0; n--) ++ { ++ ira_object_t obj = ALLOCNO_OBJECT (a, n); ++ for (int k = 0; ; k++) ++ { ++ unsigned int regno = EH_RETURN_DATA_REGNO (k); ++ if (regno == INVALID_REGNUM) ++ break; ++ SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno); ++ SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), regno); ++ } ++ } ++ } ++} ++ ++#endif ++ + /* Process insns of the basic block given by its LOOP_TREE_NODE to + update allocno live ranges, allocno hard register conflicts, + intersected calls, and register pressure info for allocnos for the +@@ -1170,6 +1214,10 @@ process_bb_node_lives (ira_loop_tree_node_t loop_tree_node) + EXECUTE_IF_SET_IN_BITMAP (reg_live_out, FIRST_PSEUDO_REGISTER, j, bi) + mark_pseudo_regno_live (j); + ++#ifdef EH_RETURN_DATA_REGNO ++ process_out_of_region_eh_regs (bb); ++#endif ++ + freq = REG_FREQ_FROM_BB (bb); + if (freq == 0) + freq = 1; 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/gcc48-remove-mpfr-2.4.0-requirement.patch b/gcc48-remove-mpfr-2.4.0-requirement.patch new file mode 100644 index 0000000..b5eb04f --- /dev/null +++ b/gcc48-remove-mpfr-2.4.0-requirement.patch @@ -0,0 +1,247 @@ +Index: configure.ac +=================================================================== +--- configure.ac (revision 216911) ++++ configure.ac (working copy) +@@ -1454,7 +1454,7 @@ if test -d ${srcdir}/gcc && test "x$have + AC_MSG_CHECKING([for the correct version of mpfr.h]) + AC_TRY_COMPILE([#include + #include ],[ +- #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,0) ++ #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,1) + choke me + #endif + ], [AC_TRY_COMPILE([#include +Index: configure +=================================================================== +--- configure (revision 216911) ++++ configure (working copy) +@@ -5524,7 +5524,7 @@ int + main () + { + +- #if MPFR_VERSION < MPFR_VERSION_NUM(2,4,0) ++ #if MPFR_VERSION < MPFR_VERSION_NUM(2,3,1) + choke me + #endif + +Index: gcc/fortran/simplify.c +=================================================================== +--- gcc/fortran/simplify.c (revision 216911) ++++ gcc/fortran/simplify.c (working copy) +@@ -4278,10 +4278,7 @@ gfc_simplify_mod (gfc_expr *a, gfc_expr + return &gfc_bad_expr; + } + +- gfc_set_model_kind (kind); +- mpfr_fmod (result->value.real, a->value.real, p->value.real, +- GFC_RND_MODE); +- break; ++ return NULL; + + default: + gfc_internal_error ("gfc_simplify_mod(): Bad arguments"); +@@ -4327,19 +4324,7 @@ gfc_simplify_modulo (gfc_expr *a, gfc_ex + return &gfc_bad_expr; + } + +- gfc_set_model_kind (kind); +- mpfr_fmod (result->value.real, a->value.real, p->value.real, +- GFC_RND_MODE); +- if (mpfr_cmp_ui (result->value.real, 0) != 0) +- { +- if (mpfr_signbit (a->value.real) != mpfr_signbit (p->value.real)) +- mpfr_add (result->value.real, result->value.real, p->value.real, +- GFC_RND_MODE); +- } +- else +- mpfr_copysign (result->value.real, result->value.real, +- p->value.real, GFC_RND_MODE); +- break; ++ return NULL; + + default: + gfc_internal_error ("gfc_simplify_modulo(): Bad arguments"); +Index: gcc/ubsan.c +=================================================================== +--- gcc/ubsan.c.orig 2015-06-01 14:52:11.717105684 +0200 ++++ gcc/ubsan.c 2015-06-01 14:52:26.945253071 +0200 +@@ -1564,40 +1564,6 @@ + min = build_real (expr_type, minval2); + } + } +- else if (REAL_MODE_FORMAT (mode)->b == 10) +- { +- /* For _Decimal128 up to 34 decimal digits, - sign, +- dot, e, exponent. */ +- char buf[64]; +- mpfr_t m; +- int p = REAL_MODE_FORMAT (mode)->p; +- REAL_VALUE_TYPE maxval, minval; +- +- /* Use mpfr_snprintf rounding to compute the smallest +- representable decimal number greater or equal than +- 1 << (prec - !uns_p). */ +- mpfr_init2 (m, prec + 2); +- mpfr_set_ui_2exp (m, 1, prec - !uns_p, GMP_RNDN); +- mpfr_snprintf (buf, sizeof buf, "%.*RUe", p - 1, m); +- decimal_real_from_string (&maxval, buf); +- max = build_real (expr_type, maxval); +- +- /* For unsigned, assume -1.0 is always representable. */ +- if (uns_p) +- min = build_minus_one_cst (expr_type); +- else +- { +- /* Use mpfr_snprintf rounding to compute the largest +- representable decimal number less or equal than +- (-1 << (prec - 1)) - 1. */ +- mpfr_set_si_2exp (m, -1, prec - 1, GMP_RNDN); +- mpfr_sub_ui (m, m, 1, GMP_RNDN); +- mpfr_snprintf (buf, sizeof buf, "%.*RDe", p - 1, m); +- decimal_real_from_string (&minval, buf); +- min = build_real (expr_type, minval); +- } +- mpfr_clear (m); +- } + else + return NULL_TREE; + +Index: gcc/gimple-ssa-sprintf.c +=================================================================== +--- gcc/gimple-ssa-sprintf.c (revision 257728) ++++ gcc/gimple-ssa-sprintf.c (working copy) +@@ -1637,18 +1637,7 @@ get_mpfr_format_length (mpfr_ptr x, cons + p = 1024; + } + +- len = mpfr_snprintf (NULL, 0, fmtstr, (int)p, x); +- +- /* Handle the unlikely (impossible?) error by returning more than +- the maximum dictated by the function's return type. */ +- if (len < 0) +- return target_dir_max () + 1; +- +- /* Adjust the return value by the difference. */ +- if (p < prec) +- len += prec - p; +- +- return len; ++ return target_dir_max () + 1; + } + + /* Return the number of bytes to format using the format specifier + +Index: gcc/fortran/simplify.c +=================================================================== +--- gcc/fortran/simplify.c (revision 257983) ++++ gcc/fortran/simplify.c (working copy) +@@ -1745,51 +1745,6 @@ simplify_trig_call (gfc_expr *icall) + } + } + +-/* Convert a floating-point number from radians to degrees. */ +- +-static void +-degrees_f (mpfr_t x, mp_rnd_t rnd_mode) +-{ +- mpfr_t tmp; +- mpfr_init (tmp); +- +- /* Set x = x % 2pi to avoid offsets with large angles. */ +- mpfr_const_pi (tmp, rnd_mode); +- mpfr_mul_ui (tmp, tmp, 2, rnd_mode); +- mpfr_fmod (tmp, x, tmp, rnd_mode); +- +- /* Set x = x * 180. */ +- mpfr_mul_ui (x, x, 180, rnd_mode); +- +- /* Set x = x / pi. */ +- mpfr_const_pi (tmp, rnd_mode); +- mpfr_div (x, x, tmp, rnd_mode); +- +- mpfr_clear (tmp); +-} +- +-/* Convert a floating-point number from degrees to radians. */ +- +-static void +-radians_f (mpfr_t x, mp_rnd_t rnd_mode) +-{ +- mpfr_t tmp; +- mpfr_init (tmp); +- +- /* Set x = x % 360 to avoid offsets with large angles. */ +- mpfr_set_ui (tmp, 360, rnd_mode); +- mpfr_fmod (tmp, x, tmp, rnd_mode); +- +- /* Set x = x * pi. */ +- mpfr_const_pi (tmp, rnd_mode); +- mpfr_mul (x, x, tmp, rnd_mode); +- +- /* Set x = x / 180. */ +- mpfr_div_ui (x, x, 180, rnd_mode); +- +- mpfr_clear (tmp); +-} +- + + /* Convert argument to radians before calling a trig function. */ + +@@ -1803,12 +1758,7 @@ gfc_simplify_trigd (gfc_expr *icall) + if (arg->ts.type != BT_REAL) + gfc_internal_error ("in gfc_simplify_trigd(): Bad type"); + +- if (arg->expr_type == EXPR_CONSTANT) +- /* Convert constant to radians before passing off to simplifier. */ +- radians_f (arg->value.real, GFC_RND_MODE); +- +- /* Let the usual simplifier take over - we just simplified the arg. */ +- return simplify_trig_call (icall); ++ return NULL; + } + + /* Convert result of an inverse trig function to degrees. */ +@@ -1816,21 +1766,9 @@ gfc_simplify_trigd (gfc_expr *icall) + gfc_expr * + gfc_simplify_atrigd (gfc_expr *icall) + { +- gfc_expr *result; +- + if (icall->value.function.actual->expr->ts.type != BT_REAL) + gfc_internal_error ("in gfc_simplify_atrigd(): Bad type"); + +- /* See if another simplifier has work to do first. */ +- result = simplify_trig_call (icall); +- +- if (result && result->expr_type == EXPR_CONSTANT) +- { +- /* Convert constant to degrees after passing off to actual simplifier. */ +- degrees_f (result->value.real, GFC_RND_MODE); +- return result; +- } +- + /* Let gfc_resolve_atrigd take care of the non-constant case. */ + return NULL; + } +@@ -1840,21 +1778,9 @@ gfc_simplify_atrigd (gfc_expr *icall) + gfc_expr * + gfc_simplify_atan2d (gfc_expr *y, gfc_expr *x) + { +- gfc_expr *result; +- + if (x->ts.type != BT_REAL || y->ts.type != BT_REAL) + gfc_internal_error ("in gfc_simplify_atan2d(): Bad type"); + +- if (x->expr_type == EXPR_CONSTANT && y->expr_type == EXPR_CONSTANT) +- { +- result = gfc_simplify_atan2 (y, x); +- if (result != NULL) +- { +- degrees_f (result->value.real, GFC_RND_MODE); +- return result; +- } +- } +- + /* Let gfc_resolve_atan2d take care of the non-constant case. */ + return NULL; + } diff --git a/gcc5-no-return-gcc43-workaround.patch b/gcc5-no-return-gcc43-workaround.patch new file mode 100644 index 0000000..8a01dc5 --- /dev/null +++ b/gcc5-no-return-gcc43-workaround.patch @@ -0,0 +1,23 @@ +Workaround + +[ 3445s] I: Program returns random data in a function +[ 3445s] E: gcc5 no-return-in-nonvoid-function ../../gcc/cp/constexpr.c:3676 + +during stage1 when compiling with a GCC 4.3 host compiler + +--- gcc/cp/constexpr.c.orig 2015-06-02 09:33:15.085636193 +0200 ++++ gcc/cp/constexpr.c 2015-06-02 09:34:04.637080196 +0200 +@@ -3668,11 +3668,10 @@ + { + r = get_target_expr (r); + TREE_CONSTANT (r) = true; +- return r; + } + } +- else +- return r; ++ ++ return r; + } + + /* Returns true if T is a valid subexpression of a constant expression, diff --git a/gcc7-aarch64-bsc1214052.patch b/gcc7-aarch64-bsc1214052.patch new file mode 100644 index 0000000..6dab583 --- /dev/null +++ b/gcc7-aarch64-bsc1214052.patch @@ -0,0 +1,993 @@ +From 04553281f42e5c4340d554a93d1a73006365d8fb Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Fri, 16 Jun 2023 17:00:51 +0100 +Subject: [PATCH 1/7] aarch64: Explicitly handle frames with no saved registers +To: gcc-patches@gcc.gnu.org + +If a frame has no saved registers, it can be allocated in one go. +There is no need to treat the areas below and above the saved +registers as separate. + +This is a no-op as thing stand, since a leaf function will have +no outgoing arguments, and so all the frame will be above where +the saved registers normally go. + +gcc/ + * config/aarch64/aarch64.c (aarch64_layout_frame): Explicitly + allocate the frame in one go if there are no saved registers. +--- + gcc/config/aarch64/aarch64.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 4e94be3b0b4..bb4f6020e5d 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -2901,8 +2901,10 @@ aarch64_layout_frame (void) + else if (cfun->machine->frame.wb_candidate1 != INVALID_REGNUM) + max_push_offset = 256; + +- if (cfun->machine->frame.frame_size < max_push_offset +- && crtl->outgoing_args_size == 0) ++ if (cfun->machine->frame.saved_regs_size == 0) ++ cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size; ++ else if (cfun->machine->frame.frame_size < max_push_offset ++ && crtl->outgoing_args_size == 0) + { + /* Simple, small frame with no outgoing arguments: + stp reg1, reg2, [sp, -frame_size]! +-- +2.25.1 + + +From e97c93de7ceadad75774f897424a50ece3215129 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Fri, 16 Jun 2023 16:55:12 +0100 +Subject: [PATCH 2/7] aarch64: Add bytes_below_hard_fp to frame info +To: gcc-patches@gcc.gnu.org + +The frame layout code currently hard-codes the assumption that +the number of bytes below the saved registers is equal to the +size of the outgoing arguments. This patch abstracts that +value into a new field of aarch64_frame. + +gcc/ + * config/aarch64/aarch64.h (aarch64_frame::bytes_below_hard_fp): New + field. + * config/aarch64/aarch64.c (aarch64_layout_frame): Initialize it, + and use it instead of crtl->outgoing_args_size. + (aarch64_get_separate_components): Use bytes_below_hard_fp instead + of outgoing_args_size. + (aarch64_process_components): Likewise. +--- + gcc/config/aarch64/aarch64.c | 40 +++++++++++++++++++++--------------- + gcc/config/aarch64/aarch64.h | 6 +++++- + 2 files changed, 28 insertions(+), 18 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index bb4f6020e5d..12df8bb783c 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -2826,6 +2826,8 @@ aarch64_layout_frame (void) + last_fp_reg = regno; + } + ++ cfun->machine->frame.bytes_below_hard_fp = crtl->outgoing_args_size; ++ + if (frame_pointer_needed) + { + /* FP and LR are placed in the linkage record. */ +@@ -2885,7 +2887,7 @@ aarch64_layout_frame (void) + + cfun->machine->frame.frame_size + = ROUND_UP (cfun->machine->frame.hard_fp_offset +- + crtl->outgoing_args_size, ++ + cfun->machine->frame.bytes_below_hard_fp, + STACK_BOUNDARY / BITS_PER_UNIT); + + cfun->machine->frame.locals_offset = cfun->machine->frame.saved_varargs_size; +@@ -2904,32 +2906,33 @@ aarch64_layout_frame (void) + if (cfun->machine->frame.saved_regs_size == 0) + cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size; + else if (cfun->machine->frame.frame_size < max_push_offset +- && crtl->outgoing_args_size == 0) ++ && cfun->machine->frame.bytes_below_hard_fp == 0) + { +- /* Simple, small frame with no outgoing arguments: ++ /* Simple, small frame with no data below the saved registers. + stp reg1, reg2, [sp, -frame_size]! + stp reg3, reg4, [sp, 16] */ + cfun->machine->frame.callee_adjust = cfun->machine->frame.frame_size; + } +- else if ((crtl->outgoing_args_size ++ else if ((cfun->machine->frame.bytes_below_hard_fp + + cfun->machine->frame.saved_regs_size < 512) + && !(cfun->calls_alloca + && cfun->machine->frame.hard_fp_offset < max_push_offset)) + { +- /* Frame with small outgoing arguments: ++ /* Frame with small area below the saved registers: + sub sp, sp, frame_size +- stp reg1, reg2, [sp, outgoing_args_size] +- stp reg3, reg4, [sp, outgoing_args_size + 16] */ ++ stp reg1, reg2, [sp, bytes_below_hard_fp] ++ stp reg3, reg4, [sp, bytes_below_hard_fp + 16] */ + cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size; + cfun->machine->frame.callee_offset + = cfun->machine->frame.frame_size - cfun->machine->frame.hard_fp_offset; + } + else if (cfun->machine->frame.hard_fp_offset < max_push_offset) + { +- /* Frame with large outgoing arguments but a small local area: ++ /* Frame with large area below the saved registers, but with a ++ small area above: + stp reg1, reg2, [sp, -hard_fp_offset]! + stp reg3, reg4, [sp, 16] +- sub sp, sp, outgoing_args_size */ ++ sub sp, sp, bytes_below_hard_fp */ + cfun->machine->frame.callee_adjust = cfun->machine->frame.hard_fp_offset; + cfun->machine->frame.final_adjust + = cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust; +@@ -2945,17 +2948,19 @@ aarch64_layout_frame (void) + cfun->machine->frame.callee_adjust = varargs_and_saved_regs_size; + cfun->machine->frame.final_adjust + = cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust; ++ cfun->machine->frame.bytes_below_hard_fp ++ = cfun->machine->frame.final_adjust; + cfun->machine->frame.hard_fp_offset = cfun->machine->frame.callee_adjust; + cfun->machine->frame.locals_offset = cfun->machine->frame.hard_fp_offset; + } + else + { +- /* Frame with large local area and outgoing arguments using frame pointer: ++ /* General case: + sub sp, sp, hard_fp_offset + stp x29, x30, [sp, 0] + add x29, sp, 0 + stp reg3, reg4, [sp, 16] +- sub sp, sp, outgoing_args_size */ ++ sub sp, sp, bytes_below_hard_fp */ + cfun->machine->frame.initial_adjust = cfun->machine->frame.hard_fp_offset; + cfun->machine->frame.final_adjust + = cfun->machine->frame.frame_size - cfun->machine->frame.initial_adjust; +@@ -3313,9 +3318,11 @@ aarch64_get_separate_components (void) + if (aarch64_register_saved_on_entry (regno)) + { + HOST_WIDE_INT offset = cfun->machine->frame.reg_offset[regno]; ++ ++ /* Get the offset relative to the register we'll use. */ + if (!frame_pointer_needed) +- offset += cfun->machine->frame.frame_size +- - cfun->machine->frame.hard_fp_offset; ++ offset += cfun->machine->frame.bytes_below_hard_fp; ++ + /* Check that we can access the stack slot of the register with one + direct load with no adjustments needed. */ + if (offset_12bit_unsigned_scaled_p (DImode, offset)) +@@ -3418,8 +3425,8 @@ aarch64_process_components (sbitmap components, bool prologue_p) + rtx reg = gen_rtx_REG (mode, regno); + HOST_WIDE_INT offset = cfun->machine->frame.reg_offset[regno]; + if (!frame_pointer_needed) +- offset += cfun->machine->frame.frame_size +- - cfun->machine->frame.hard_fp_offset; ++ offset += cfun->machine->frame.bytes_below_hard_fp; ++ + rtx addr = plus_constant (Pmode, ptr_reg, offset); + rtx mem = gen_frame_mem (mode, addr); + +@@ -3460,8 +3467,7 @@ aarch64_process_components (sbitmap components, bool prologue_p) + /* REGNO2 can be saved/restored in a pair with REGNO. */ + rtx reg2 = gen_rtx_REG (mode, regno2); + if (!frame_pointer_needed) +- offset2 += cfun->machine->frame.frame_size +- - cfun->machine->frame.hard_fp_offset; ++ offset2 += cfun->machine->frame.bytes_below_hard_fp; + rtx addr2 = plus_constant (Pmode, ptr_reg, offset2); + rtx mem2 = gen_frame_mem (mode, addr2); + rtx set2 = prologue_p ? gen_rtx_SET (mem2, reg2) +diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h +index ddf833ebfe8..6dc6ef2b989 100644 +--- a/gcc/config/aarch64/aarch64.h ++++ b/gcc/config/aarch64/aarch64.h +@@ -558,9 +558,13 @@ struct GTY (()) aarch64_frame + HOST_WIDE_INT saved_varargs_size; + + /* The size of the saved callee-save int/FP registers. */ +- + HOST_WIDE_INT saved_regs_size; + ++ /* The number of bytes between the bottom of the static frame (the bottom ++ of the outgoing arguments) and the hard frame pointer. This value is ++ always a multiple of STACK_BOUNDARY. */ ++ HOST_WIDE_INT bytes_below_hard_fp; ++ + /* Offset from the base of the frame (incomming SP) to the + top of the locals area. This value is always a multiple of + STACK_BOUNDARY. */ +-- +2.25.1 + + +From e628f34ef3a7db3a75aa146b3e75099a9c431d20 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Tue, 27 Jun 2023 11:25:40 +0100 +Subject: [PATCH 3/7] aarch64: Rename locals_offset to bytes_above_locals +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +To: gcc-patches@gcc.gnu.org + +locals_offset was described as: + + /* Offset from the base of the frame (incomming SP) to the + top of the locals area. This value is always a multiple of + STACK_BOUNDARY. */ + +This is implicitly an “upside down” view of the frame: the incoming +SP is at offset 0, and anything N bytes below the incoming SP is at +offset N (rather than -N). + +However, reg_offset instead uses a “right way up” view; that is, +it views offsets in address terms. Something above X is at a +positive offset from X and something below X is at a negative +offset from X. + +Also, even on FRAME_GROWS_DOWNWARD targets like AArch64, +target-independent code views offsets in address terms too: +locals are allocated at negative offsets to virtual_stack_vars. + +It seems confusing to have *_offset fields of the same structure +using different polarities like this. This patch tries to avoid +that by renaming locals_offset to bytes_above_locals. + +gcc/ + * config/aarch64/aarch64.h (aarch64_frame::locals_offset): Rename to... + (aarch64_frame::bytes_above_locals): ...this. + * config/aarch64/aarch64.c (aarch64_layout_frame) + (aarch64_initial_elimination_offset): Update accordingly. +--- + gcc/config/aarch64/aarch64.c | 12 +++++++----- + gcc/config/aarch64/aarch64.h | 6 +++--- + 2 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 12df8bb783c..27dd3b7a62b 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -2890,7 +2890,8 @@ aarch64_layout_frame (void) + + cfun->machine->frame.bytes_below_hard_fp, + STACK_BOUNDARY / BITS_PER_UNIT); + +- cfun->machine->frame.locals_offset = cfun->machine->frame.saved_varargs_size; ++ cfun->machine->frame.bytes_above_locals ++ = cfun->machine->frame.saved_varargs_size; + + cfun->machine->frame.initial_adjust = 0; + cfun->machine->frame.final_adjust = 0; +@@ -2951,7 +2952,8 @@ aarch64_layout_frame (void) + cfun->machine->frame.bytes_below_hard_fp + = cfun->machine->frame.final_adjust; + cfun->machine->frame.hard_fp_offset = cfun->machine->frame.callee_adjust; +- cfun->machine->frame.locals_offset = cfun->machine->frame.hard_fp_offset; ++ cfun->machine->frame.bytes_above_locals ++ = cfun->machine->frame.hard_fp_offset; + } + else + { +@@ -5653,14 +5655,14 @@ aarch64_initial_elimination_offset (unsigned from, unsigned to) + + if (from == FRAME_POINTER_REGNUM) + return cfun->machine->frame.hard_fp_offset +- - cfun->machine->frame.locals_offset; ++ - cfun->machine->frame.bytes_above_locals; + } + + if (to == STACK_POINTER_REGNUM) + { + if (from == FRAME_POINTER_REGNUM) +- return cfun->machine->frame.frame_size +- - cfun->machine->frame.locals_offset; ++ return cfun->machine->frame.frame_size ++ - cfun->machine->frame.bytes_above_locals; + } + + return cfun->machine->frame.frame_size; +diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h +index 6dc6ef2b989..79af237ada6 100644 +--- a/gcc/config/aarch64/aarch64.h ++++ b/gcc/config/aarch64/aarch64.h +@@ -565,10 +565,10 @@ struct GTY (()) aarch64_frame + always a multiple of STACK_BOUNDARY. */ + HOST_WIDE_INT bytes_below_hard_fp; + +- /* Offset from the base of the frame (incomming SP) to the +- top of the locals area. This value is always a multiple of ++ /* The number of bytes between the top of the locals area and the top ++ of the frame (the incomming SP). This value is always a multiple of + STACK_BOUNDARY. */ +- HOST_WIDE_INT locals_offset; ++ HOST_WIDE_INT bytes_above_locals; + + /* Offset from the base of the frame (incomming SP) to the + hard_frame_pointer. This value is always a multiple of +-- +2.25.1 + + +From da0132a4cd2eb26ecaff20578bf2753b20014223 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Tue, 27 Jun 2023 11:28:11 +0100 +Subject: [PATCH 4/7] aarch64: Rename hard_fp_offset to bytes_above_hard_fp +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +To: gcc-patches@gcc.gnu.org + +Similarly to the previous locals_offset patch, hard_fp_offset +was described as: + + /* Offset from the base of the frame (incomming SP) to the + hard_frame_pointer. This value is always a multiple of + STACK_BOUNDARY. */ + poly_int64 hard_fp_offset; + +which again took an “upside-down” view: higher offsets meant lower +addresses. This patch renames the field to bytes_above_hard_fp instead. + +gcc/ + * config/aarch64/aarch64.h (aarch64_frame::hard_fp_offset): Rename + to... + (aarch64_frame::bytes_above_hard_fp): ...this. + * config/aarch64/aarch64.c (aarch64_layout_frame) + (aarch64_expand_prologue): Update accordingly. + (aarch64_initial_elimination_offset): Likewise. +--- + gcc/config/aarch64/aarch64.c | 29 ++++++++++++++++------------- + gcc/config/aarch64/aarch64.h | 6 +++--- + 2 files changed, 19 insertions(+), 16 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 27dd3b7a62b..e3c36abb1e3 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -2881,12 +2881,12 @@ aarch64_layout_frame (void) + HOST_WIDE_INT varargs_and_saved_regs_size + = offset + cfun->machine->frame.saved_varargs_size; + +- cfun->machine->frame.hard_fp_offset ++ cfun->machine->frame.bytes_above_hard_fp + = ROUND_UP (varargs_and_saved_regs_size + get_frame_size (), + STACK_BOUNDARY / BITS_PER_UNIT); + + cfun->machine->frame.frame_size +- = ROUND_UP (cfun->machine->frame.hard_fp_offset ++ = ROUND_UP (cfun->machine->frame.bytes_above_hard_fp + + cfun->machine->frame.bytes_below_hard_fp, + STACK_BOUNDARY / BITS_PER_UNIT); + +@@ -2917,7 +2917,7 @@ aarch64_layout_frame (void) + else if ((cfun->machine->frame.bytes_below_hard_fp + + cfun->machine->frame.saved_regs_size < 512) + && !(cfun->calls_alloca +- && cfun->machine->frame.hard_fp_offset < max_push_offset)) ++ && cfun->machine->frame.bytes_above_hard_fp < max_push_offset)) + { + /* Frame with small area below the saved registers: + sub sp, sp, frame_size +@@ -2925,16 +2925,17 @@ aarch64_layout_frame (void) + stp reg3, reg4, [sp, bytes_below_hard_fp + 16] */ + cfun->machine->frame.initial_adjust = cfun->machine->frame.frame_size; + cfun->machine->frame.callee_offset +- = cfun->machine->frame.frame_size - cfun->machine->frame.hard_fp_offset; ++ = cfun->machine->frame.frame_size - cfun->machine->frame.bytes_above_hard_fp; + } +- else if (cfun->machine->frame.hard_fp_offset < max_push_offset) ++ else if (cfun->machine->frame.bytes_above_hard_fp < max_push_offset) + { + /* Frame with large area below the saved registers, but with a + small area above: +- stp reg1, reg2, [sp, -hard_fp_offset]! ++ stp reg1, reg2, [sp, -bytes_above_hard_fp]! + stp reg3, reg4, [sp, 16] + sub sp, sp, bytes_below_hard_fp */ +- cfun->machine->frame.callee_adjust = cfun->machine->frame.hard_fp_offset; ++ cfun->machine->frame.callee_adjust ++ = cfun->machine->frame.bytes_above_hard_fp; + cfun->machine->frame.final_adjust + = cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust; + } +@@ -2951,19 +2952,21 @@ aarch64_layout_frame (void) + = cfun->machine->frame.frame_size - cfun->machine->frame.callee_adjust; + cfun->machine->frame.bytes_below_hard_fp + = cfun->machine->frame.final_adjust; +- cfun->machine->frame.hard_fp_offset = cfun->machine->frame.callee_adjust; ++ cfun->machine->frame.bytes_above_hard_fp ++ = cfun->machine->frame.callee_adjust; + cfun->machine->frame.bytes_above_locals +- = cfun->machine->frame.hard_fp_offset; ++ = cfun->machine->frame.bytes_above_hard_fp; + } + else + { + /* General case: +- sub sp, sp, hard_fp_offset ++ sub sp, sp, bytes_above_hard_fp + stp x29, x30, [sp, 0] + add x29, sp, 0 + stp reg3, reg4, [sp, 16] + sub sp, sp, bytes_below_hard_fp */ +- cfun->machine->frame.initial_adjust = cfun->machine->frame.hard_fp_offset; ++ cfun->machine->frame.initial_adjust ++ = cfun->machine->frame.bytes_above_hard_fp; + cfun->machine->frame.final_adjust + = cfun->machine->frame.frame_size - cfun->machine->frame.initial_adjust; + } +@@ -5651,10 +5654,10 @@ aarch64_initial_elimination_offset (unsigned from, unsigned to) + if (to == HARD_FRAME_POINTER_REGNUM) + { + if (from == ARG_POINTER_REGNUM) +- return cfun->machine->frame.hard_fp_offset; ++ return cfun->machine->frame.bytes_above_hard_fp; + + if (from == FRAME_POINTER_REGNUM) +- return cfun->machine->frame.hard_fp_offset ++ return cfun->machine->frame.bytes_above_hard_fp + - cfun->machine->frame.bytes_above_locals; + } + +diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h +index 79af237ada6..35ba9681e03 100644 +--- a/gcc/config/aarch64/aarch64.h ++++ b/gcc/config/aarch64/aarch64.h +@@ -570,10 +570,10 @@ struct GTY (()) aarch64_frame + STACK_BOUNDARY. */ + HOST_WIDE_INT bytes_above_locals; + +- /* Offset from the base of the frame (incomming SP) to the +- hard_frame_pointer. This value is always a multiple of ++ /* The number of bytes between the hard_frame_pointer and the top of ++ the frame (the incomming SP). This value is always a multiple of + STACK_BOUNDARY. */ +- HOST_WIDE_INT hard_fp_offset; ++ HOST_WIDE_INT bytes_above_hard_fp; + + /* The size of the frame. This value is the offset from base of the + * frame (incomming SP) to the stack_pointer. This value is always +-- +2.25.1 + + +From 19776fcf06856ceff521f99a1ceddaf113cf0d09 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Thu, 22 Jun 2023 22:26:30 +0100 +Subject: [PATCH 5/7] aarch64: Tweak frame_size comment +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit +To: gcc-patches@gcc.gnu.org + +This patch fixes another case in which a value was described with +an “upside-down” view. + +gcc/ + * config/aarch64/aarch64.h (aarch64_frame::frame_size): Tweak comment. +--- + gcc/config/aarch64/aarch64.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h +index 35ba9681e03..19b7082187a 100644 +--- a/gcc/config/aarch64/aarch64.h ++++ b/gcc/config/aarch64/aarch64.h +@@ -575,9 +575,9 @@ struct GTY (()) aarch64_frame + STACK_BOUNDARY. */ + HOST_WIDE_INT bytes_above_hard_fp; + +- /* The size of the frame. This value is the offset from base of the +- * frame (incomming SP) to the stack_pointer. This value is always +- * a multiple of STACK_BOUNDARY. */ ++ /* The size of the frame, i.e. the number of bytes between the bottom ++ of the outgoing arguments and the incoming SP. This value is always ++ a multiple of STACK_BOUNDARY. */ + HOST_WIDE_INT frame_size; + + /* The size of the initial stack adjustment before saving callee-saves. */ +-- +2.25.1 + + +From 69c18301a2dea6dd686d4351ba3c095490707d16 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Tue, 15 Aug 2023 19:05:30 +0100 +Subject: [PATCH 6/7] Backport check-function-bodies support +To: gcc-patches@gcc.gnu.org + +--- + gcc/testsuite/lib/scanasm.exp | 191 ++++++++++++++++++++++++++++++++++ + 1 file changed, 191 insertions(+) + +diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp +index bab23e8e165..1103f86c602 100644 +--- a/gcc/testsuite/lib/scanasm.exp ++++ b/gcc/testsuite/lib/scanasm.exp +@@ -514,3 +514,194 @@ proc scan-lto-assembler { args } { + verbose "output_file: $output_file" + dg-scan "scan-assembler" 1 $testcase $output_file $args + } ++ ++# Read assembly file FILENAME and store a mapping from function names ++# to function bodies in array RESULT. FILENAME has already been uploaded ++# locally where necessary and is known to exist. ++ ++proc parse_function_bodies { filename result } { ++ upvar $result up_result ++ ++ # Regexp for the start of a function definition (name in \1). ++ set label {^([a-zA-Z_]\S+):$} ++ ++ # Regexp for the end of a function definition. ++ set terminator {^\s*\.size} ++ ++ # Regexp for lines that aren't interesting. ++ set fluff {^\s*(?:\.|//|@|$)} ++ ++ set fd [open $filename r] ++ set in_function 0 ++ while { [gets $fd line] >= 0 } { ++ if { [regexp $label $line dummy function_name] } { ++ set in_function 1 ++ set function_body "" ++ } elseif { $in_function } { ++ if { [regexp $terminator $line] } { ++ set up_result($function_name) $function_body ++ set in_function 0 ++ } elseif { ![regexp $fluff $line] } { ++ append function_body $line "\n" ++ } ++ } ++ } ++ close $fd ++} ++ ++# FUNCTIONS is an array that maps function names to function bodies. ++# Return true if it contains a definition of function NAME and if ++# that definition matches BODY_REGEXP. ++ ++proc check_function_body { functions name body_regexp } { ++ upvar $functions up_functions ++ ++ if { ![info exists up_functions($name)] } { ++ return 0 ++ } ++ set fn_res [regexp "^$body_regexp\$" $up_functions($name)] ++ if { !$fn_res } { ++ verbose -log "body: $body_regexp" ++ verbose -log "against: $up_functions($name)" ++ } ++ return $fn_res ++} ++ ++# Check the implementations of functions against expected output. Used as: ++# ++# { dg-do { check-function-bodies PREFIX TERMINATOR[ OPTION[ SELECTOR]] } } ++# ++# See sourcebuild.texi for details. ++ ++proc check-function-bodies { args } { ++ if { [llength $args] < 2 } { ++ error "too few arguments to check-function-bodies" ++ } ++ if { [llength $args] > 4 } { ++ error "too many arguments to check-function-bodies" ++ } ++ ++ if { [llength $args] >= 3 } { ++ set required_flags [lindex $args 2] ++ ++ upvar 2 dg-extra-tool-flags extra_tool_flags ++ set flags $extra_tool_flags ++ ++ global torture_current_flags ++ if { [info exists torture_current_flags] } { ++ append flags " " $torture_current_flags ++ } ++ foreach required_flag $required_flags { ++ switch -- $required_flag { ++ target - ++ xfail { ++ error "misplaced $required_flag in check-function-bodies" ++ } ++ } ++ } ++ foreach required_flag $required_flags { ++ if { ![regexp " $required_flag " $flags] } { ++ return ++ } ++ } ++ } ++ ++ set xfail_all 0 ++ if { [llength $args] >= 4 } { ++ switch [dg-process-target [lindex $args 3]] { ++ "S" { } ++ "N" { return } ++ "F" { set xfail_all 1 } ++ "P" { } ++ } ++ } ++ ++ set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ ++ global srcdir ++ set input_filename "$srcdir/$filename" ++ set output_filename "[file rootname [file tail $filename]].s" ++ ++ set prefix [lindex $args 0] ++ set prefix_len [string length $prefix] ++ set terminator [lindex $args 1] ++ if { [string equal $terminator ""] } { ++ set terminator "*/" ++ } ++ set terminator_len [string length $terminator] ++ ++ set have_bodies 0 ++ if { [is_remote host] } { ++ remote_upload host "$filename" ++ } ++ if { [file exists $output_filename] } { ++ parse_function_bodies $output_filename functions ++ set have_bodies 1 ++ } else { ++ verbose -log "$testcase: output file does not exist" ++ } ++ ++ set count 0 ++ set function_regexp "" ++ set label {^(\S+):$} ++ ++ set lineno 1 ++ set fd [open $input_filename r] ++ set in_function 0 ++ while { [gets $fd line] >= 0 } { ++ if { [string equal -length $prefix_len $line $prefix] } { ++ set line [string trim [string range $line $prefix_len end]] ++ if { !$in_function } { ++ if { [regexp "^(.*?\\S)\\s+{(.*)}\$" $line dummy \ ++ line selector] } { ++ set selector [dg-process-target $selector] ++ } else { ++ set selector "P" ++ } ++ if { ![regexp $label $line dummy function_name] } { ++ close $fd ++ error "check-function-bodies: line $lineno does not have a function label" ++ } ++ set in_function 1 ++ set function_regexp "" ++ } elseif { [string equal $line "("] } { ++ append function_regexp "(?:" ++ } elseif { [string equal $line "|"] } { ++ append function_regexp "|" ++ } elseif { [string equal $line ")"] } { ++ append function_regexp ")" ++ } elseif { [string equal $line "..."] } { ++ append function_regexp ".*" ++ } else { ++ append function_regexp "\t" $line "\n" ++ } ++ } elseif { [string equal -length $terminator_len $line $terminator] } { ++ if { ![string equal $selector "N"] } { ++ if { $xfail_all || [string equal $selector "F"] } { ++ setup_xfail "*-*-*" ++ } ++ set testname "$testcase check-function-bodies $function_name" ++ if { !$have_bodies } { ++ unresolved $testname ++ } elseif { [check_function_body functions $function_name \ ++ $function_regexp] } { ++ pass $testname ++ } else { ++ fail $testname ++ } ++ } ++ set in_function 0 ++ incr count ++ } ++ incr lineno ++ } ++ close $fd ++ if { $in_function } { ++ error "check-function-bodies: missing \"$terminator\"" ++ } ++ if { $count == 0 } { ++ error "check-function-bodies: no matches found" ++ } ++} +-- +2.25.1 + + +From c2c772172f0478315ab94386ebf9963efd36eb75 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Thu, 15 Jun 2023 19:16:52 +0100 +Subject: [PATCH 7/7] aarch64: Make stack smash canary protect saved registers +To: gcc-patches@gcc.gnu.org + +AArch64 normally puts the saved registers near the bottom of the frame, +immediately above any dynamic allocations. But this means that a +stack-smash attack on those dynamic allocations could overwrite the +saved registers without needing to reach as far as the stack smash +canary. + +The same thing could also happen for variable-sized arguments that are +passed by value, since those are allocated before a call and popped on +return. + +This patch avoids that by putting the locals (and thus the canary) below +the saved registers when stack smash protection is active. + +The patch fixes CVE-2023-4039. + +gcc/ + * config/aarch64/aarch64.c (aarch64_save_regs_above_locals_p): + New function. + (aarch64_layout_frame): Use it to decide whether locals should + go above or below the saved registers. + (aarch64_expand_prologue): Update stack layout comment. + Emit a stack tie after the final adjustment. + +gcc/testsuite/ + * gcc.target/aarch64/stack-protector-8.c: New test. + * gcc.target/aarch64/stack-protector-9.c: Likewise. +--- + gcc/config/aarch64/aarch64.c | 45 +++++++++- + .../gcc.target/aarch64/stack-protector-8.c | 86 +++++++++++++++++++ + .../gcc.target/aarch64/stack-protector-9.c | 33 +++++++ + 3 files changed, 161 insertions(+), 3 deletions(-) + create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-protector-8.c + create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-protector-9.c + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index e3c36abb1e3..8708b4fe4ea 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -2780,6 +2780,20 @@ aarch64_frame_pointer_required (void) + return false; + } + ++/* Return true if the current function should save registers above ++ the locals area, rather than below it. */ ++ ++static bool ++aarch64_save_regs_above_locals_p () ++{ ++ /* When using stack smash protection, make sure that the canary slot ++ comes between the locals and the saved registers. Otherwise, ++ it would be possible for a carefully sized smash attack to change ++ the saved registers (particularly LR and FP) without reaching the ++ canary. */ ++ return crtl->stack_protect_guard; ++} ++ + /* Mark the registers that need to be saved by the callee and calculate + the size of the callee-saved registers area and frame record (both FP + and LR may be omitted). */ +@@ -2828,6 +2842,16 @@ aarch64_layout_frame (void) + + cfun->machine->frame.bytes_below_hard_fp = crtl->outgoing_args_size; + ++ bool regs_at_top_p = aarch64_save_regs_above_locals_p (); ++ ++ if (regs_at_top_p) ++ { ++ cfun->machine->frame.bytes_below_hard_fp += get_frame_size (); ++ cfun->machine->frame.bytes_below_hard_fp ++ = ROUND_UP (cfun->machine->frame.bytes_below_hard_fp, ++ STACK_BOUNDARY / BITS_PER_UNIT); ++ } ++ + if (frame_pointer_needed) + { + /* FP and LR are placed in the linkage record. */ +@@ -2881,8 +2905,11 @@ aarch64_layout_frame (void) + HOST_WIDE_INT varargs_and_saved_regs_size + = offset + cfun->machine->frame.saved_varargs_size; + ++ cfun->machine->frame.bytes_above_hard_fp = varargs_and_saved_regs_size; ++ if (!regs_at_top_p) ++ cfun->machine->frame.bytes_above_hard_fp += get_frame_size (); + cfun->machine->frame.bytes_above_hard_fp +- = ROUND_UP (varargs_and_saved_regs_size + get_frame_size (), ++ = ROUND_UP (cfun->machine->frame.bytes_above_hard_fp, + STACK_BOUNDARY / BITS_PER_UNIT); + + cfun->machine->frame.frame_size +@@ -2892,6 +2919,9 @@ aarch64_layout_frame (void) + + cfun->machine->frame.bytes_above_locals + = cfun->machine->frame.saved_varargs_size; ++ if (regs_at_top_p) ++ cfun->machine->frame.bytes_above_locals ++ += cfun->machine->frame.saved_regs_size; + + cfun->machine->frame.initial_adjust = 0; + cfun->machine->frame.final_adjust = 0; +@@ -3537,10 +3567,10 @@ aarch64_set_handled_components (sbitmap components) + | for register varargs | + | | + +-------------------------------+ +- | local variables | <-- frame_pointer_rtx ++ | local variables (1) | <-- frame_pointer_rtx + | | + +-------------------------------+ +- | padding0 | \ ++ | padding (1) | \ + +-------------------------------+ | + | callee-saved registers | | frame.saved_regs_size + +-------------------------------+ | +@@ -3548,6 +3578,10 @@ aarch64_set_handled_components (sbitmap components) + +-------------------------------+ | + | FP' | / <- hard_frame_pointer_rtx (aligned) + +-------------------------------+ ++ | local variables (2) | ++ +-------------------------------+ ++ | padding (2) | ++ +-------------------------------+ + | dynamic allocation | + +-------------------------------+ + | padding | +@@ -3557,6 +3591,9 @@ aarch64_set_handled_components (sbitmap components) + +-------------------------------+ + | | <-- stack_pointer_rtx (aligned) + ++ The regions marked (1) and (2) are mutually exclusive. (2) is used ++ when aarch64_save_regs_above_locals_p is true. ++ + Dynamic stack allocations via alloca() decrease stack_pointer_rtx + but leave frame_pointer_rtx and hard_frame_pointer_rtx + unchanged. */ +@@ -3626,6 +3663,8 @@ aarch64_expand_prologue (void) + aarch64_save_callee_saves (DFmode, callee_offset, V0_REGNUM, V31_REGNUM, + callee_adjust != 0 || frame_pointer_needed); + aarch64_sub_sp (IP1_REGNUM, final_adjust, !frame_pointer_needed); ++ if (frame_pointer_needed && final_adjust != 0) ++ emit_insn (gen_stack_tie (stack_pointer_rtx, hard_frame_pointer_rtx)); + } + + /* Return TRUE if we can use a simple_return insn. +diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c +new file mode 100644 +index 00000000000..2575abbec73 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c +@@ -0,0 +1,86 @@ ++/* { dg-options " -O -fstack-protector-strong" } */ ++/* { dg-final { check-function-bodies "**" "" } } */ ++ ++void g(void *); ++ ++/* ++** test1: ++** sub sp, sp, #304 ++** stp x29, x30, \[sp, #?272\] ++** add x29, sp, #?272 ++** str (x[0-9]+), \[sp, #?288\] ++** ... ++** ldr (x[0-9]+), \[\1\] ++** str \2, \[(?:sp, #?264|x29, #?-8)\] ++** mov \2, *0 ++** ( ++** add x0, sp, #?8 ++** | ++** sub x0, x29, #?264 ++** ) ++** bl g ++** ... ++** ldr x[0-9]+, \[\1\] ++** ... ++** ( ++** bne .* ++** | ++** cbnz .* ++** ) ++** ... ++** ldr \1, \[sp, #?288\] ++** ldp x29, x30, \[sp, #?272\] ++** add sp, sp, #?304 ++** ret ++** bl __stack_chk_fail ++*/ ++int test1() { ++ int y[0x40]; ++ g(y); ++ return 1; ++} ++ ++/* ++** test2: ++** stp x29, x30, \[sp, #?-32\]! ++** ( ++** mov x29, sp ++** | ++** add x29, sp, #?0 ++** ) ++** str (x[0-9]+), \[sp, #?16\] ++** sub sp, sp, #1040 ++** ... ++** ldr (x[0-9]+), \[\1\] ++** str \2, \[(?:sp, #?1032|x29, #?-8)\] ++** mov \2, *0 ++** ( ++** add x0, sp, #?8 ++** | ++** sub x0, x29, #?1032 ++** ) ++** bl g ++** ... ++** ldr x[0-9]+, \[\1\] ++** ... ++** ( ++** bne .* ++** | ++** cbnz .* ++** ) ++** ... ++** ( ++** add sp, sp, #?1040 ++** | ++** add sp, x29, #?0 ++** ) ++** ldr \1, \[sp, #?16\] ++** ldp x29, x30, \[sp\], #?32 ++** ret ++** bl __stack_chk_fail ++*/ ++int test2() { ++ int y[0x100]; ++ g(y); ++ return 1; ++} +diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c +new file mode 100644 +index 00000000000..1d267343806 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c +@@ -0,0 +1,33 @@ ++/* { dg-options "-O2 -mcpu=cortex-a73 -fstack-protector-all" } */ ++/* { dg-final { check-function-bodies "**" "" } } */ ++ ++/* ++** main: ++** ... ++** stp x29, x30, \[sp, #?-[0-9]+\]! ++** ... ++** sub sp, sp, #[0-9]+ ++** ... ++** str x[0-9]+, \[x29, #?-8\] ++** ... ++*/ ++int f(const char *); ++void g(void *); ++int main(int argc, char* argv[]) ++{ ++ int a; ++ int b; ++ char c[2+f(argv[1])]; ++ int d[0x100]; ++ char y; ++ ++ y=42; a=4; b=10; ++ c[0] = 'h'; c[1] = '\0'; ++ ++ c[f(argv[2])] = '\0'; ++ ++ __builtin_printf("%d %d\n%s\n", a, b, c); ++ g(d); ++ ++ return 0; ++} +-- +2.25.1 + diff --git a/gcc7-aarch64-moutline-atomics.patch b/gcc7-aarch64-moutline-atomics.patch new file mode 100644 index 0000000..33cf2d6 --- /dev/null +++ b/gcc7-aarch64-moutline-atomics.patch @@ -0,0 +1,4298 @@ +From 56c60ff0b1ee5d15e9e1673eddda6cb450e4253c Mon Sep 17 00:00:00 2001 +From: Kyrylo Tkachov +Date: Tue, 6 Jun 2017 13:26:46 +0000 +Subject: [PATCH 01/24] Allow const0_rtx operand for atomic compare-exchange + patterns +To: gcc-patches@gcc.gnu.org + +2017-06-06 Kyrylo Tkachov + +gcc/ + * config/aarch64/atomics.md (atomic_compare_and_swap expander): + Use aarch64_reg_or_zero predicate for operand 4. + (aarch64_compare_and_swap define_insn_and_split): + Use aarch64_reg_or_zero predicate for operand 3. Add 'Z' constraint. + (aarch64_store_exclusive): Likewise for operand 2. + +gcc/testsuite/ + * gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c: New test. + +(cherry picked from commit 4ebcc903bf03705099cd4b50231dc8fe444d70b9) +--- + gcc/config/aarch64/atomics.md | 8 ++++---- + .../aarch64/atomic_cmp_exchange_zero_reg_1.c | 12 ++++++++++++ + 2 files changed, 16 insertions(+), 4 deletions(-) + create mode 100644 gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c + +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 09d441075f0..27fc1933ce3 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -25,7 +25,7 @@ + (match_operand:ALLI 1 "register_operand" "") ;; val out + (match_operand:ALLI 2 "aarch64_sync_memory_operand" "") ;; memory + (match_operand:ALLI 3 "general_operand" "") ;; expected +- (match_operand:ALLI 4 "register_operand" "") ;; desired ++ (match_operand:ALLI 4 "aarch64_reg_or_zero" "") ;; desired + (match_operand:SI 5 "const_int_operand") ;; is_weak + (match_operand:SI 6 "const_int_operand") ;; mod_s + (match_operand:SI 7 "const_int_operand")] ;; mod_f +@@ -45,7 +45,7 @@ + (set (match_dup 1) + (unspec_volatile:SHORT + [(match_operand:SI 2 "aarch64_plus_operand" "rI") ;; expected +- (match_operand:SHORT 3 "register_operand" "r") ;; desired ++ (match_operand:SHORT 3 "aarch64_reg_or_zero" "rZ") ;; desired + (match_operand:SI 4 "const_int_operand") ;; is_weak + (match_operand:SI 5 "const_int_operand") ;; mod_s + (match_operand:SI 6 "const_int_operand")] ;; mod_f +@@ -69,7 +69,7 @@ + (set (match_dup 1) + (unspec_volatile:GPI + [(match_operand:GPI 2 "aarch64_plus_operand" "rI") ;; expect +- (match_operand:GPI 3 "register_operand" "r") ;; desired ++ (match_operand:GPI 3 "aarch64_reg_or_zero" "rZ") ;; desired + (match_operand:SI 4 "const_int_operand") ;; is_weak + (match_operand:SI 5 "const_int_operand") ;; mod_s + (match_operand:SI 6 "const_int_operand")] ;; mod_f +@@ -534,7 +534,7 @@ + (unspec_volatile:SI [(const_int 0)] UNSPECV_SX)) + (set (match_operand:ALLI 1 "aarch64_sync_memory_operand" "=Q") + (unspec_volatile:ALLI +- [(match_operand:ALLI 2 "register_operand" "r") ++ [(match_operand:ALLI 2 "aarch64_reg_or_zero" "rZ") + (match_operand:SI 3 "const_int_operand")] + UNSPECV_SX))] + "" +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c +new file mode 100644 +index 00000000000..15606b68990 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c +@@ -0,0 +1,12 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2" } */ ++ ++int ++foo (int *a) ++{ ++ int x = 3; ++ return __atomic_compare_exchange_n (a, &x, 0, 1, __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE); ++} ++ ++/* { dg-final { scan-assembler "stxr\\tw\[0-9\]+, wzr,.*" } } */ ++/* { dg-final { scan-assembler-not "mov\\tw\[0-9\]+, 0" } } */ +-- +2.26.2 + + +From b8e2b779d1815147073e9dcb04a1f8f9d96b1a62 Mon Sep 17 00:00:00 2001 +From: Ramana Radhakrishnan +Date: Mon, 16 Jul 2018 09:03:48 +0000 +Subject: [PATCH 02/24] Add early clobber for aarch64_store_exclusive. +To: gcc-patches@gcc.gnu.org + +2018-07-16 Ramana Radhakrishnan + +gcc/ + * config/aarch64/atomics.md (aarch64_store_execlusive): Add + early clobber. + +(cherry picked from commit 1d896f48fa2f796ba13773ab735ef40fa3afb257) +--- + gcc/config/aarch64/atomics.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 27fc1933ce3..eb4b95c2453 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -530,7 +530,7 @@ + ) + + (define_insn "aarch64_store_exclusive" +- [(set (match_operand:SI 0 "register_operand" "=r") ++ [(set (match_operand:SI 0 "register_operand" "=&r") + (unspec_volatile:SI [(const_int 0)] UNSPECV_SX)) + (set (match_operand:ALLI 1 "aarch64_sync_memory_operand" "=Q") + (unspec_volatile:ALLI +-- +2.26.2 + + +From 03ffcedc78870eaf89e0f45b3d7a2e3af003e45a Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 31 Oct 2018 09:29:29 +0000 +Subject: [PATCH 03/24] aarch64: Simplify LSE cas generation +To: gcc-patches@gcc.gnu.org + +The cas insn is a single insn, and if expanded properly need not +be split after reload. Use the proper inputs for the insn. + +2018-10-31 Richard Henderson + +gcc/ + * config/aarch64/aarch64.c (aarch64_expand_compare_and_swap): + Force oldval into the rval register for TARGET_LSE; emit the compare + during initial expansion so that it may be deleted if unused. + (aarch64_gen_atomic_cas): Remove. + * config/aarch64/atomics.md (@aarch64_compare_and_swap_lse): + Change =&r to +r for operand 0; use match_dup for operand 2; + remove is_weak and mod_f operands as unused. Drop the split + and merge with... + (@aarch64_atomic_cas): ... this pattern's output; remove. + (@aarch64_compare_and_swap_lse): Similarly. + (@aarch64_atomic_cas): Similarly. + +(cherry picked from commit 77f33f44baf24c22848197aa80962c003dd7b3e2) +--- + gcc/config/aarch64/aarch64-protos.h | 1 - + gcc/config/aarch64/aarch64.c | 62 ++++-------- + gcc/config/aarch64/atomics.md | 143 +++++++++------------------- + 3 files changed, 63 insertions(+), 143 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h +index 9543f8c9f29..e25f9833af4 100644 +--- a/gcc/config/aarch64/aarch64-protos.h ++++ b/gcc/config/aarch64/aarch64-protos.h +@@ -425,7 +425,6 @@ rtx aarch64_load_tp (rtx); + + void aarch64_expand_compare_and_swap (rtx op[]); + void aarch64_split_compare_and_swap (rtx op[]); +-void aarch64_gen_atomic_cas (rtx, rtx, rtx, rtx, rtx); + + bool aarch64_atomic_ldop_supported_p (enum rtx_code); + void aarch64_gen_atomic_ldop (enum rtx_code, rtx, rtx, rtx, rtx, rtx); +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 05eaef3d2e6..c03d0ff9b40 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -11865,7 +11865,6 @@ aarch64_expand_compare_and_swap (rtx operands[]) + machine_mode mode, cmp_mode; + typedef rtx (*gen_cas_fn) (rtx, rtx, rtx, rtx, rtx, rtx, rtx); + int idx; +- gen_cas_fn gen; + const gen_cas_fn split_cas[] = + { + gen_aarch64_compare_and_swapqi, +@@ -11873,7 +11872,8 @@ aarch64_expand_compare_and_swap (rtx operands[]) + gen_aarch64_compare_and_swapsi, + gen_aarch64_compare_and_swapdi + }; +- const gen_cas_fn atomic_cas[] = ++ typedef rtx (*gen_lse_fn) (rtx, rtx, rtx, rtx); ++ const gen_lse_fn atomic_cas[] = + { + gen_aarch64_compare_and_swapqi_lse, + gen_aarch64_compare_and_swaphi_lse, +@@ -11932,14 +11932,26 @@ aarch64_expand_compare_and_swap (rtx operands[]) + gcc_unreachable (); + } + if (TARGET_LSE) +- gen = atomic_cas[idx]; ++ { ++ /* The CAS insn requires oldval and rval overlap, but we need to ++ have a copy of oldval saved across the operation to tell if ++ the operation is successful. */ ++ if (mode == QImode || mode == HImode) ++ rval = copy_to_mode_reg (SImode, gen_lowpart (SImode, oldval)); ++ else if (reg_overlap_mentioned_p (rval, oldval)) ++ rval = copy_to_mode_reg (mode, oldval); ++ else ++ emit_move_insn (rval, oldval); ++ emit_insn (atomic_cas[idx] (rval, mem, newval, mod_s)); ++ aarch64_gen_compare_reg (EQ, rval, oldval); ++ } + else +- gen = split_cas[idx]; +- +- emit_insn (gen (rval, mem, oldval, newval, is_weak, mod_s, mod_f)); ++ emit_insn (split_cas[idx] (rval, mem, oldval, newval, is_weak, mod_s, ++ mod_f)); + + if (mode == QImode || mode == HImode) +- emit_move_insn (operands[1], gen_lowpart (mode, rval)); ++ rval = gen_lowpart (mode, rval); ++ emit_move_insn (operands[1], rval); + + x = gen_rtx_REG (CCmode, CC_REGNUM); + x = gen_rtx_EQ (SImode, x, const0_rtx); +@@ -11989,42 +12001,6 @@ aarch64_emit_post_barrier (enum memmodel model) + } + } + +-/* Emit an atomic compare-and-swap operation. RVAL is the destination register +- for the data in memory. EXPECTED is the value expected to be in memory. +- DESIRED is the value to store to memory. MEM is the memory location. MODEL +- is the memory ordering to use. */ +- +-void +-aarch64_gen_atomic_cas (rtx rval, rtx mem, +- rtx expected, rtx desired, +- rtx model) +-{ +- rtx (*gen) (rtx, rtx, rtx, rtx); +- machine_mode mode; +- +- mode = GET_MODE (mem); +- +- switch (mode) +- { +- case QImode: gen = gen_aarch64_atomic_casqi; break; +- case HImode: gen = gen_aarch64_atomic_cashi; break; +- case SImode: gen = gen_aarch64_atomic_cassi; break; +- case DImode: gen = gen_aarch64_atomic_casdi; break; +- default: +- gcc_unreachable (); +- } +- +- /* Move the expected value into the CAS destination register. */ +- emit_insn (gen_rtx_SET (rval, expected)); +- +- /* Emit the CAS. */ +- emit_insn (gen (rval, mem, desired, model)); +- +- /* Compare the expected value with the value loaded by the CAS, to establish +- whether the swap was made. */ +- aarch64_gen_compare_reg (EQ, rval, expected); +-} +- + /* Split a compare and swap pattern. */ + + void +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index eb4b95c2453..713aec618a2 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -85,56 +85,50 @@ + } + ) + +-(define_insn_and_split "aarch64_compare_and_swap_lse" +- [(set (reg:CC CC_REGNUM) ;; bool out +- (unspec_volatile:CC [(const_int 0)] UNSPECV_ATOMIC_CMPSW)) +- (set (match_operand:SI 0 "register_operand" "=&r") ;; val out +- (zero_extend:SI +- (match_operand:SHORT 1 "aarch64_sync_memory_operand" "+Q"))) ;; memory +- (set (match_dup 1) +- (unspec_volatile:SHORT +- [(match_operand:SI 2 "aarch64_plus_operand" "rI") ;; expected +- (match_operand:SHORT 3 "register_operand" "r") ;; desired +- (match_operand:SI 4 "const_int_operand") ;; is_weak +- (match_operand:SI 5 "const_int_operand") ;; mod_s +- (match_operand:SI 6 "const_int_operand")] ;; mod_f +- UNSPECV_ATOMIC_CMPSW))] +- "TARGET_LSE" +- "#" +- "&& reload_completed" +- [(const_int 0)] +- { +- aarch64_gen_atomic_cas (operands[0], operands[1], +- operands[2], operands[3], +- operands[5]); +- DONE; +- } +-) +- +-(define_insn_and_split "aarch64_compare_and_swap_lse" +- [(set (reg:CC CC_REGNUM) ;; bool out +- (unspec_volatile:CC [(const_int 0)] UNSPECV_ATOMIC_CMPSW)) +- (set (match_operand:GPI 0 "register_operand" "=&r") ;; val out +- (match_operand:GPI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory +- (set (match_dup 1) +- (unspec_volatile:GPI +- [(match_operand:GPI 2 "aarch64_plus_operand" "rI") ;; expect +- (match_operand:GPI 3 "register_operand" "r") ;; desired +- (match_operand:SI 4 "const_int_operand") ;; is_weak +- (match_operand:SI 5 "const_int_operand") ;; mod_s +- (match_operand:SI 6 "const_int_operand")] ;; mod_f +- UNSPECV_ATOMIC_CMPSW))] +- "TARGET_LSE" +- "#" +- "&& reload_completed" +- [(const_int 0)] +- { +- aarch64_gen_atomic_cas (operands[0], operands[1], +- operands[2], operands[3], +- operands[5]); +- DONE; +- } +-) ++(define_insn "aarch64_compare_and_swap_lse" ++ [(set (match_operand:SI 0 "register_operand" "+r") ;; val out ++ (zero_extend:SI ++ (match_operand:SHORT 1 "aarch64_sync_memory_operand" "+Q"))) ;; memory ++ (set (match_dup 1) ++ (unspec_volatile:SHORT ++ [(match_dup 0) ;; expected ++ (match_operand:SHORT 2 "aarch64_reg_or_zero" "rZ") ;; desired ++ (match_operand:SI 3 "const_int_operand")] ;; mod_s ++ UNSPECV_ATOMIC_CMPSW))] ++ "TARGET_LSE" ++{ ++ enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ if (is_mm_relaxed (model)) ++ return "cas\t%0, %2, %1"; ++ else if (is_mm_acquire (model) || is_mm_consume (model)) ++ return "casa\t%0, %2, %1"; ++ else if (is_mm_release (model)) ++ return "casl\t%0, %2, %1"; ++ else ++ return "casal\t%0, %2, %1"; ++}) ++ ++(define_insn "aarch64_compare_and_swap_lse" ++ [(set (match_operand:GPI 0 "register_operand" "+r") ;; val out ++ (match_operand:GPI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory ++ (set (match_dup 1) ++ (unspec_volatile:GPI ++ [(match_dup 0) ;; expected ++ (match_operand:GPI 2 "aarch64_reg_or_zero" "rZ") ;; desired ++ (match_operand:SI 3 "const_int_operand")] ;; mod_s ++ UNSPECV_ATOMIC_CMPSW))] ++ "TARGET_LSE" ++{ ++ enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ if (is_mm_relaxed (model)) ++ return "cas\t%0, %2, %1"; ++ else if (is_mm_acquire (model) || is_mm_consume (model)) ++ return "casa\t%0, %2, %1"; ++ else if (is_mm_release (model)) ++ return "casl\t%0, %2, %1"; ++ else ++ return "casal\t%0, %2, %1"; ++}) + + (define_expand "atomic_exchange" + [(match_operand:ALLI 0 "register_operand" "") +@@ -607,55 +601,6 @@ + return "swpal\t%2, %0, %1"; + }) + +-;; Atomic compare-and-swap: HI and smaller modes. +- +-(define_insn "aarch64_atomic_cas" +- [(set (match_operand:SI 0 "register_operand" "+&r") ;; out +- (zero_extend:SI +- (match_operand:SHORT 1 "aarch64_sync_memory_operand" "+Q"))) ;; memory. +- (set (match_dup 1) +- (unspec_volatile:SHORT +- [(match_dup 0) +- (match_operand:SHORT 2 "register_operand" "r") ;; value. +- (match_operand:SI 3 "const_int_operand" "")] ;; model. +- UNSPECV_ATOMIC_CAS))] +- "TARGET_LSE && reload_completed" +-{ +- enum memmodel model = memmodel_from_int (INTVAL (operands[3])); +- if (is_mm_relaxed (model)) +- return "cas\t%0, %2, %1"; +- else if (is_mm_acquire (model) || is_mm_consume (model)) +- return "casa\t%0, %2, %1"; +- else if (is_mm_release (model)) +- return "casl\t%0, %2, %1"; +- else +- return "casal\t%0, %2, %1"; +-}) +- +-;; Atomic compare-and-swap: SI and larger modes. +- +-(define_insn "aarch64_atomic_cas" +- [(set (match_operand:GPI 0 "register_operand" "+&r") ;; out +- (match_operand:GPI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory. +- (set (match_dup 1) +- (unspec_volatile:GPI +- [(match_dup 0) +- (match_operand:GPI 2 "register_operand" "r") ;; value. +- (match_operand:SI 3 "const_int_operand" "")] ;; model. +- UNSPECV_ATOMIC_CAS))] +- "TARGET_LSE && reload_completed" +-{ +- enum memmodel model = memmodel_from_int (INTVAL (operands[3])); +- if (is_mm_relaxed (model)) +- return "cas\t%0, %2, %1"; +- else if (is_mm_acquire (model) || is_mm_consume (model)) +- return "casa\t%0, %2, %1"; +- else if (is_mm_release (model)) +- return "casl\t%0, %2, %1"; +- else +- return "casal\t%0, %2, %1"; +-}) +- + ;; Atomic load-op: Load data, operate, store result, keep data. + + (define_insn "aarch64_atomic_load" +-- +2.26.2 + + +From 19c478bafa944772683d4fdf6a4be962b9fb5d7e Mon Sep 17 00:00:00 2001 +From: Kyrylo Tkachov +Date: Fri, 2 Jun 2017 14:41:52 +0000 +Subject: [PATCH 04/24] Emit tighter strong atomic compare-exchange loop when + comparing against zero +To: gcc-patches@gcc.gnu.org + +2017-06-02 Kyrylo Tkachov + +gcc/ + * config/aarch64/aarch64.c (aarch64_split_compare_and_swap): + Emit CBNZ inside loop when doing a strong exchange and comparing + against zero. Generate the CC flags after the loop. + +gcc/testsuite/ + * gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c: New test. + +(cherry picked from commit 17f47f8621099fdc4b0fc6681924f97230c8a114) +--- + gcc/config/aarch64/aarch64.c | 41 ++++++++++++++++--- + .../atomic_cmp_exchange_zero_strong_1.c | 12 ++++++ + 2 files changed, 47 insertions(+), 6 deletions(-) + create mode 100644 gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index c03d0ff9b40..c2789665728 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -12024,6 +12024,17 @@ aarch64_split_compare_and_swap (rtx operands[]) + mode = GET_MODE (mem); + model = memmodel_from_int (INTVAL (model_rtx)); + ++ /* When OLDVAL is zero and we want the strong version we can emit a tighter ++ loop: ++ .label1: ++ LD[A]XR rval, [mem] ++ CBNZ rval, .label2 ++ ST[L]XR scratch, newval, [mem] ++ CBNZ scratch, .label1 ++ .label2: ++ CMP rval, 0. */ ++ bool strong_zero_p = !is_weak && oldval == const0_rtx; ++ + label1 = NULL; + if (!is_weak) + { +@@ -12040,11 +12051,21 @@ aarch64_split_compare_and_swap (rtx operands[]) + else + aarch64_emit_load_exclusive (mode, rval, mem, model_rtx); + +- cond = aarch64_gen_compare_reg (NE, rval, oldval); +- x = gen_rtx_NE (VOIDmode, cond, const0_rtx); +- x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, +- gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); +- aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); ++ if (strong_zero_p) ++ { ++ x = gen_rtx_NE (VOIDmode, rval, const0_rtx); ++ x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, ++ gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); ++ aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); ++ } ++ else ++ { ++ cond = aarch64_gen_compare_reg (NE, rval, oldval); ++ x = gen_rtx_NE (VOIDmode, cond, const0_rtx); ++ x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, ++ gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); ++ aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); ++ } + + aarch64_emit_store_exclusive (mode, scratch, mem, newval, model_rtx); + +@@ -12063,7 +12084,15 @@ aarch64_split_compare_and_swap (rtx operands[]) + } + + emit_label (label2); +- ++ /* If we used a CBNZ in the exchange loop emit an explicit compare with RVAL ++ to set the condition flags. If this is not used it will be removed by ++ later passes. */ ++ if (strong_zero_p) ++ { ++ cond = gen_rtx_REG (CCmode, CC_REGNUM); ++ x = gen_rtx_COMPARE (CCmode, rval, const0_rtx); ++ emit_insn (gen_rtx_SET (cond, x)); ++ } + /* Emit any final barrier needed for a __sync operation. */ + if (is_mm_sync (model)) + aarch64_emit_post_barrier (model); +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c +new file mode 100644 +index 00000000000..b14a7c29437 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c +@@ -0,0 +1,12 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2" } */ ++ ++int ++foo (int *a) ++{ ++ int x = 0; ++ return __atomic_compare_exchange_n (a, &x, 4, 0, ++ __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE); ++} ++ ++/* { dg-final { scan-assembler-times "cbnz\\tw\[0-9\]+" 2 } } */ +-- +2.26.2 + + +From 1b90e5f91c930b124f1d4940b515a7ea64809904 Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 31 Oct 2018 09:42:39 +0000 +Subject: [PATCH 05/24] aarch64: Improve cas generation +To: gcc-patches@gcc.gnu.org + +Do not zero-extend the input to the cas for subword operations; +instead, use the appropriate zero-extending compare insns. +Correct the predicates and constraints for immediate expected operand. + +2018-10-31 Richard Henderson + +gcc/ + * config/aarch64/aarch64.c (aarch64_gen_compare_reg_maybe_ze): New. + (aarch64_split_compare_and_swap): Use it. + (aarch64_expand_compare_and_swap): Likewise. Remove convert_modes; + test oldval against the proper predicate. + * config/aarch64/atomics.md (@atomic_compare_and_swap): + Use nonmemory_operand for expected. + (cas_short_expected_pred): New. + (@aarch64_compare_and_swap): Use it; use "rn" not "rI" to match. + (@aarch64_compare_and_swap): Use "rn" not "rI" for expected. + * config/aarch64/predicates.md (aarch64_plushi_immediate): New. + (aarch64_plushi_operand): New. + +(cherry picked from commit d400fda3a8c3330f77eb9d51874f5482d3819a9f) +--- + gcc/config/aarch64/aarch64.c | 97 ++++++++++++++++++++------------ + gcc/config/aarch64/atomics.md | 19 ++++--- + gcc/config/aarch64/predicates.md | 12 ++++ + 3 files changed, 84 insertions(+), 44 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index c2789665728..afde9e291f9 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -1198,6 +1198,33 @@ aarch64_gen_compare_reg (RTX_CODE code, rtx x, rtx y) + return cc_reg; + } + ++/* Similarly, but maybe zero-extend Y if Y_MODE < SImode. */ ++ ++static rtx ++aarch64_gen_compare_reg_maybe_ze (RTX_CODE code, rtx x, rtx y, ++ machine_mode y_mode) ++{ ++ if (y_mode == QImode || y_mode == HImode) ++ { ++ if (CONST_INT_P (y)) ++ y = GEN_INT (INTVAL (y) & GET_MODE_MASK (y_mode)); ++ else ++ { ++ rtx t, cc_reg; ++ machine_mode cc_mode; ++ ++ t = gen_rtx_ZERO_EXTEND (SImode, y); ++ t = gen_rtx_COMPARE (CC_SWPmode, t, x); ++ cc_mode = CC_SWPmode; ++ cc_reg = gen_rtx_REG (cc_mode, CC_REGNUM); ++ emit_set_insn (cc_reg, t); ++ return cc_reg; ++ } ++ } ++ ++ return aarch64_gen_compare_reg (code, x, y); ++} ++ + /* Build the SYMBOL_REF for __tls_get_addr. */ + + static GTY(()) rtx tls_get_addr_libfunc; +@@ -11861,8 +11888,8 @@ aarch64_emit_unlikely_jump (rtx insn) + void + aarch64_expand_compare_and_swap (rtx operands[]) + { +- rtx bval, rval, mem, oldval, newval, is_weak, mod_s, mod_f, x; +- machine_mode mode, cmp_mode; ++ rtx bval, rval, mem, oldval, newval, is_weak, mod_s, mod_f, x, cc_reg; ++ machine_mode mode, r_mode; + typedef rtx (*gen_cas_fn) (rtx, rtx, rtx, rtx, rtx, rtx, rtx); + int idx; + const gen_cas_fn split_cas[] = +@@ -11890,36 +11917,19 @@ aarch64_expand_compare_and_swap (rtx operands[]) + mod_s = operands[6]; + mod_f = operands[7]; + mode = GET_MODE (mem); +- cmp_mode = mode; + + /* Normally the succ memory model must be stronger than fail, but in the + unlikely event of fail being ACQUIRE and succ being RELEASE we need to + promote succ to ACQ_REL so that we don't lose the acquire semantics. */ +- + if (is_mm_acquire (memmodel_from_int (INTVAL (mod_f))) + && is_mm_release (memmodel_from_int (INTVAL (mod_s)))) + mod_s = GEN_INT (MEMMODEL_ACQ_REL); + +- switch (mode) ++ r_mode = mode; ++ if (mode == QImode || mode == HImode) + { +- case QImode: +- case HImode: +- /* For short modes, we're going to perform the comparison in SImode, +- so do the zero-extension now. */ +- cmp_mode = SImode; +- rval = gen_reg_rtx (SImode); +- oldval = convert_modes (SImode, mode, oldval, true); +- /* Fall through. */ +- +- case SImode: +- case DImode: +- /* Force the value into a register if needed. */ +- if (!aarch64_plus_operand (oldval, mode)) +- oldval = force_reg (cmp_mode, oldval); +- break; +- +- default: +- gcc_unreachable (); ++ r_mode = SImode; ++ rval = gen_reg_rtx (r_mode); + } + + switch (mode) +@@ -11936,25 +11946,40 @@ aarch64_expand_compare_and_swap (rtx operands[]) + /* The CAS insn requires oldval and rval overlap, but we need to + have a copy of oldval saved across the operation to tell if + the operation is successful. */ +- if (mode == QImode || mode == HImode) +- rval = copy_to_mode_reg (SImode, gen_lowpart (SImode, oldval)); +- else if (reg_overlap_mentioned_p (rval, oldval)) +- rval = copy_to_mode_reg (mode, oldval); ++ if (reg_overlap_mentioned_p (rval, oldval)) ++ rval = copy_to_mode_reg (r_mode, oldval); + else +- emit_move_insn (rval, oldval); ++ emit_move_insn (rval, gen_lowpart (r_mode, oldval)); ++ + emit_insn (atomic_cas[idx] (rval, mem, newval, mod_s)); +- aarch64_gen_compare_reg (EQ, rval, oldval); ++ cc_reg = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode); + } + else +- emit_insn (split_cas[idx] (rval, mem, oldval, newval, is_weak, mod_s, +- mod_f)); ++ { ++ /* The oldval predicate varies by mode. Test it and force to reg. */ ++ insn_code code; ++ switch (mode) ++ { ++ case QImode: code = CODE_FOR_aarch64_compare_and_swapqi; break; ++ case HImode: code = CODE_FOR_aarch64_compare_and_swaphi; break; ++ case SImode: code = CODE_FOR_aarch64_compare_and_swapsi; break; ++ case DImode: code = CODE_FOR_aarch64_compare_and_swapdi; break; ++ default: ++ gcc_unreachable (); ++ } ++ if (!insn_data[code].operand[2].predicate (oldval, mode)) ++ oldval = force_reg (mode, oldval); + +- if (mode == QImode || mode == HImode) ++ emit_insn (split_cas[idx] (rval, mem, oldval, newval, is_weak, mod_s, ++ mod_f)); ++ cc_reg = gen_rtx_REG (CCmode, CC_REGNUM); ++ } ++ ++ if (r_mode != mode) + rval = gen_lowpart (mode, rval); + emit_move_insn (operands[1], rval); + +- x = gen_rtx_REG (CCmode, CC_REGNUM); +- x = gen_rtx_EQ (SImode, x, const0_rtx); ++ x = gen_rtx_EQ (SImode, cc_reg, const0_rtx); + emit_insn (gen_rtx_SET (bval, x)); + } + +@@ -12060,10 +12085,10 @@ aarch64_split_compare_and_swap (rtx operands[]) + } + else + { +- cond = aarch64_gen_compare_reg (NE, rval, oldval); ++ cond = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode); + x = gen_rtx_NE (VOIDmode, cond, const0_rtx); + x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, +- gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); ++ gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); + aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); + } + +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 713aec618a2..577000fa6a4 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -24,8 +24,8 @@ + [(match_operand:SI 0 "register_operand" "") ;; bool out + (match_operand:ALLI 1 "register_operand" "") ;; val out + (match_operand:ALLI 2 "aarch64_sync_memory_operand" "") ;; memory +- (match_operand:ALLI 3 "general_operand" "") ;; expected +- (match_operand:ALLI 4 "aarch64_reg_or_zero" "") ;; desired ++ (match_operand:ALLI 3 "nonmemory_operand" "") ;; expected ++ (match_operand:ALLI 4 "aarch64_reg_or_zero" "") ;; desired + (match_operand:SI 5 "const_int_operand") ;; is_weak + (match_operand:SI 6 "const_int_operand") ;; mod_s + (match_operand:SI 7 "const_int_operand")] ;; mod_f +@@ -36,19 +36,22 @@ + } + ) + ++(define_mode_attr cas_short_expected_pred ++ [(QI "aarch64_reg_or_imm") (HI "aarch64_plushi_operand")]) ++ + (define_insn_and_split "aarch64_compare_and_swap" + [(set (reg:CC CC_REGNUM) ;; bool out + (unspec_volatile:CC [(const_int 0)] UNSPECV_ATOMIC_CMPSW)) +- (set (match_operand:SI 0 "register_operand" "=&r") ;; val out ++ (set (match_operand:SI 0 "register_operand" "=&r") ;; val out + (zero_extend:SI + (match_operand:SHORT 1 "aarch64_sync_memory_operand" "+Q"))) ;; memory + (set (match_dup 1) + (unspec_volatile:SHORT +- [(match_operand:SI 2 "aarch64_plus_operand" "rI") ;; expected ++ [(match_operand:SHORT 2 "" "rn") ;; expected + (match_operand:SHORT 3 "aarch64_reg_or_zero" "rZ") ;; desired +- (match_operand:SI 4 "const_int_operand") ;; is_weak +- (match_operand:SI 5 "const_int_operand") ;; mod_s +- (match_operand:SI 6 "const_int_operand")] ;; mod_f ++ (match_operand:SI 4 "const_int_operand") ;; is_weak ++ (match_operand:SI 5 "const_int_operand") ;; mod_s ++ (match_operand:SI 6 "const_int_operand")] ;; mod_f + UNSPECV_ATOMIC_CMPSW)) + (clobber (match_scratch:SI 7 "=&r"))] + "" +@@ -68,7 +71,7 @@ + (match_operand:GPI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory + (set (match_dup 1) + (unspec_volatile:GPI +- [(match_operand:GPI 2 "aarch64_plus_operand" "rI") ;; expect ++ [(match_operand:GPI 2 "aarch64_plus_operand" "rn") ;; expect + (match_operand:GPI 3 "aarch64_reg_or_zero" "rZ") ;; desired + (match_operand:SI 4 "const_int_operand") ;; is_weak + (match_operand:SI 5 "const_int_operand") ;; mod_s +diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md +index e83d45b3945..20429e5d04c 100644 +--- a/gcc/config/aarch64/predicates.md ++++ b/gcc/config/aarch64/predicates.md +@@ -86,6 +86,18 @@ + (ior (match_operand 0 "register_operand") + (match_operand 0 "aarch64_plus_immediate"))) + ++(define_predicate "aarch64_plushi_immediate" ++ (match_code "const_int") ++{ ++ HOST_WIDE_INT val = INTVAL (op); ++ /* The HImode value must be zero-extendable to an SImode plus_operand. */ ++ return ((val & 0xfff) == val || sext_hwi (val & 0xf000, 16) == val); ++}) ++ ++(define_predicate "aarch64_plushi_operand" ++ (ior (match_operand 0 "register_operand") ++ (match_operand 0 "aarch64_plushi_immediate"))) ++ + (define_predicate "aarch64_pluslong_immediate" + (and (match_code "const_int") + (match_test "(INTVAL (op) < 0xffffff && INTVAL (op) > -0xffffff)"))) +-- +2.26.2 + + +From 585818b9697910d3c136db9805f129f4d735e28d Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 31 Oct 2018 09:47:21 +0000 +Subject: [PATCH 06/24] aarch64: Improve swp generation +To: gcc-patches@gcc.gnu.org + +Allow zero as an input; fix constraints; avoid unnecessary split. + +2018-10-31 Richard Henderson + +gcc/ + * config/aarch64/aarch64.c (aarch64_emit_atomic_swap): Remove. + (aarch64_gen_atomic_ldop): Don't call it. + * config/aarch64/atomics.md (atomic_exchange): + Use aarch64_reg_or_zero. + (aarch64_atomic_exchange): Likewise. + (aarch64_atomic_exchange_lse): Remove split; remove & from + operand 0; use aarch64_reg_or_zero for input; merge ... + (@aarch64_atomic_swp): ... this and remove. + +(cherry picked from commit 8f5603d363a4e0453d2c38c7103aeb0bdca85c4e) +--- + gcc/config/aarch64/aarch64.c | 25 ------------------ + gcc/config/aarch64/atomics.md | 49 +++++++++++------------------------ + 2 files changed, 15 insertions(+), 59 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index afde9e291f9..d08af9d63ca 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -12142,27 +12142,6 @@ aarch64_emit_bic (machine_mode mode, rtx dst, rtx s1, rtx s2, int shift) + emit_insn (gen (dst, s2, shift_rtx, s1)); + } + +-/* Emit an atomic swap. */ +- +-static void +-aarch64_emit_atomic_swap (machine_mode mode, rtx dst, rtx value, +- rtx mem, rtx model) +-{ +- rtx (*gen) (rtx, rtx, rtx, rtx); +- +- switch (mode) +- { +- case QImode: gen = gen_aarch64_atomic_swpqi; break; +- case HImode: gen = gen_aarch64_atomic_swphi; break; +- case SImode: gen = gen_aarch64_atomic_swpsi; break; +- case DImode: gen = gen_aarch64_atomic_swpdi; break; +- default: +- gcc_unreachable (); +- } +- +- emit_insn (gen (dst, mem, value, model)); +-} +- + /* Operations supported by aarch64_emit_atomic_load_op. */ + + enum aarch64_atomic_load_op_code +@@ -12275,10 +12254,6 @@ aarch64_gen_atomic_ldop (enum rtx_code code, rtx out_data, rtx out_result, + a SET then emit a swap instruction and finish. */ + switch (code) + { +- case SET: +- aarch64_emit_atomic_swap (mode, out_data, src, mem, model_rtx); +- return; +- + case MINUS: + /* Negate the value and treat it as a PLUS. */ + { +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 577000fa6a4..f1cc972bae4 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -136,7 +136,7 @@ + (define_expand "atomic_exchange" + [(match_operand:ALLI 0 "register_operand" "") + (match_operand:ALLI 1 "aarch64_sync_memory_operand" "") +- (match_operand:ALLI 2 "register_operand" "") ++ (match_operand:ALLI 2 "aarch64_reg_or_zero" "") + (match_operand:SI 3 "const_int_operand" "")] + "" + { +@@ -156,10 +156,10 @@ + + (define_insn_and_split "aarch64_atomic_exchange" + [(set (match_operand:ALLI 0 "register_operand" "=&r") ;; output +- (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory ++ (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory + (set (match_dup 1) + (unspec_volatile:ALLI +- [(match_operand:ALLI 2 "register_operand" "r") ;; input ++ [(match_operand:ALLI 2 "aarch64_reg_or_zero" "rZ") ;; input + (match_operand:SI 3 "const_int_operand" "")] ;; model + UNSPECV_ATOMIC_EXCHG)) + (clobber (reg:CC CC_REGNUM)) +@@ -175,22 +175,25 @@ + } + ) + +-(define_insn_and_split "aarch64_atomic_exchange_lse" +- [(set (match_operand:ALLI 0 "register_operand" "=&r") ++(define_insn "aarch64_atomic_exchange_lse" ++ [(set (match_operand:ALLI 0 "register_operand" "=r") + (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) + (set (match_dup 1) + (unspec_volatile:ALLI +- [(match_operand:ALLI 2 "register_operand" "r") ++ [(match_operand:ALLI 2 "aarch64_reg_or_zero" "rZ") + (match_operand:SI 3 "const_int_operand" "")] + UNSPECV_ATOMIC_EXCHG))] + "TARGET_LSE" +- "#" +- "&& reload_completed" +- [(const_int 0)] + { +- aarch64_gen_atomic_ldop (SET, operands[0], NULL, operands[1], +- operands[2], operands[3]); +- DONE; ++ enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ if (is_mm_relaxed (model)) ++ return "swp\t%2, %0, %1"; ++ else if (is_mm_acquire (model) || is_mm_consume (model)) ++ return "swpa\t%2, %0, %1"; ++ else if (is_mm_release (model)) ++ return "swpl\t%2, %0, %1"; ++ else ++ return "swpal\t%2, %0, %1"; + } + ) + +@@ -582,28 +585,6 @@ + + ;; ARMv8.1-A LSE instructions. + +-;; Atomic swap with memory. +-(define_insn "aarch64_atomic_swp" +- [(set (match_operand:ALLI 0 "register_operand" "+&r") +- (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) +- (set (match_dup 1) +- (unspec_volatile:ALLI +- [(match_operand:ALLI 2 "register_operand" "r") +- (match_operand:SI 3 "const_int_operand" "")] +- UNSPECV_ATOMIC_SWP))] +- "TARGET_LSE && reload_completed" +- { +- enum memmodel model = memmodel_from_int (INTVAL (operands[3])); +- if (is_mm_relaxed (model)) +- return "swp\t%2, %0, %1"; +- else if (is_mm_acquire (model) || is_mm_consume (model)) +- return "swpa\t%2, %0, %1"; +- else if (is_mm_release (model)) +- return "swpl\t%2, %0, %1"; +- else +- return "swpal\t%2, %0, %1"; +- }) +- + ;; Atomic load-op: Load data, operate, store result, keep data. + + (define_insn "aarch64_atomic_load" +-- +2.26.2 + + +From 2d9e1f5e434f9511ca82149bbf9b0d64acacac64 Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 31 Oct 2018 09:58:48 +0000 +Subject: [PATCH 07/24] aarch64: Improve atomic-op lse generation +To: gcc-patches@gcc.gnu.org + +Fix constraints; avoid unnecessary split. Drop the use of the atomic_op +iterator in favor of the ATOMIC_LDOP iterator; this is simplier and more +logical for ldclr aka bic. + +2018-10-31 Richard Henderson + +gcc/ + * config/aarch64/aarch64.c (aarch64_emit_bic): Remove. + (aarch64_atomic_ldop_supported_p): Remove. + (aarch64_gen_atomic_ldop): Remove. + * config/aarch64/atomic.md (atomic_): + Fully expand LSE operations here. + (atomic_fetch_): Likewise. + (atomic__fetch): Likewise. + (aarch64_atomic__lse): Drop atomic_op iterator + and use ATOMIC_LDOP instead; use register_operand for the input; + drop the split and emit insns directly. + (aarch64_atomic_fetch__lse): Likewise. + (aarch64_atomic__fetch_lse): Remove. + (@aarch64_atomic_load): Remove. + +(cherry picked from commit 7803ec5ee2a547043fb6708a08ddb1361ba91202) +--- + gcc/config/aarch64/aarch64-protos.h | 2 - + gcc/config/aarch64/aarch64.c | 247 ---------------------------- + gcc/config/aarch64/atomics.md | 197 +++++++++++----------- + gcc/config/aarch64/iterators.md | 5 +- + 4 files changed, 108 insertions(+), 343 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h +index e25f9833af4..e47f2174479 100644 +--- a/gcc/config/aarch64/aarch64-protos.h ++++ b/gcc/config/aarch64/aarch64-protos.h +@@ -426,8 +426,6 @@ rtx aarch64_load_tp (rtx); + void aarch64_expand_compare_and_swap (rtx op[]); + void aarch64_split_compare_and_swap (rtx op[]); + +-bool aarch64_atomic_ldop_supported_p (enum rtx_code); +-void aarch64_gen_atomic_ldop (enum rtx_code, rtx, rtx, rtx, rtx, rtx); + void aarch64_split_atomic_op (enum rtx_code, rtx, rtx, rtx, rtx, rtx, rtx); + + bool aarch64_gen_adjusted_ldpstp (rtx *, bool, enum machine_mode, RTX_CODE); +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index d08af9d63ca..ed3cec30859 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -11983,32 +11983,6 @@ aarch64_expand_compare_and_swap (rtx operands[]) + emit_insn (gen_rtx_SET (bval, x)); + } + +-/* Test whether the target supports using a atomic load-operate instruction. +- CODE is the operation and AFTER is TRUE if the data in memory after the +- operation should be returned and FALSE if the data before the operation +- should be returned. Returns FALSE if the operation isn't supported by the +- architecture. */ +- +-bool +-aarch64_atomic_ldop_supported_p (enum rtx_code code) +-{ +- if (!TARGET_LSE) +- return false; +- +- switch (code) +- { +- case SET: +- case AND: +- case IOR: +- case XOR: +- case MINUS: +- case PLUS: +- return true; +- default: +- return false; +- } +-} +- + /* Emit a barrier, that is appropriate for memory model MODEL, at the end of a + sequence implementing an atomic operation. */ + +@@ -12123,227 +12097,6 @@ aarch64_split_compare_and_swap (rtx operands[]) + aarch64_emit_post_barrier (model); + } + +-/* Emit a BIC instruction. */ +- +-static void +-aarch64_emit_bic (machine_mode mode, rtx dst, rtx s1, rtx s2, int shift) +-{ +- rtx shift_rtx = GEN_INT (shift); +- rtx (*gen) (rtx, rtx, rtx, rtx); +- +- switch (mode) +- { +- case SImode: gen = gen_and_one_cmpl_lshrsi3; break; +- case DImode: gen = gen_and_one_cmpl_lshrdi3; break; +- default: +- gcc_unreachable (); +- } +- +- emit_insn (gen (dst, s2, shift_rtx, s1)); +-} +- +-/* Operations supported by aarch64_emit_atomic_load_op. */ +- +-enum aarch64_atomic_load_op_code +-{ +- AARCH64_LDOP_PLUS, /* A + B */ +- AARCH64_LDOP_XOR, /* A ^ B */ +- AARCH64_LDOP_OR, /* A | B */ +- AARCH64_LDOP_BIC /* A & ~B */ +-}; +- +-/* Emit an atomic load-operate. */ +- +-static void +-aarch64_emit_atomic_load_op (enum aarch64_atomic_load_op_code code, +- machine_mode mode, rtx dst, rtx src, +- rtx mem, rtx model) +-{ +- typedef rtx (*aarch64_atomic_load_op_fn) (rtx, rtx, rtx, rtx); +- const aarch64_atomic_load_op_fn plus[] = +- { +- gen_aarch64_atomic_loadaddqi, +- gen_aarch64_atomic_loadaddhi, +- gen_aarch64_atomic_loadaddsi, +- gen_aarch64_atomic_loadadddi +- }; +- const aarch64_atomic_load_op_fn eor[] = +- { +- gen_aarch64_atomic_loadeorqi, +- gen_aarch64_atomic_loadeorhi, +- gen_aarch64_atomic_loadeorsi, +- gen_aarch64_atomic_loadeordi +- }; +- const aarch64_atomic_load_op_fn ior[] = +- { +- gen_aarch64_atomic_loadsetqi, +- gen_aarch64_atomic_loadsethi, +- gen_aarch64_atomic_loadsetsi, +- gen_aarch64_atomic_loadsetdi +- }; +- const aarch64_atomic_load_op_fn bic[] = +- { +- gen_aarch64_atomic_loadclrqi, +- gen_aarch64_atomic_loadclrhi, +- gen_aarch64_atomic_loadclrsi, +- gen_aarch64_atomic_loadclrdi +- }; +- aarch64_atomic_load_op_fn gen; +- int idx = 0; +- +- switch (mode) +- { +- case QImode: idx = 0; break; +- case HImode: idx = 1; break; +- case SImode: idx = 2; break; +- case DImode: idx = 3; break; +- default: +- gcc_unreachable (); +- } +- +- switch (code) +- { +- case AARCH64_LDOP_PLUS: gen = plus[idx]; break; +- case AARCH64_LDOP_XOR: gen = eor[idx]; break; +- case AARCH64_LDOP_OR: gen = ior[idx]; break; +- case AARCH64_LDOP_BIC: gen = bic[idx]; break; +- default: +- gcc_unreachable (); +- } +- +- emit_insn (gen (dst, mem, src, model)); +-} +- +-/* Emit an atomic load+operate. CODE is the operation. OUT_DATA is the +- location to store the data read from memory. OUT_RESULT is the location to +- store the result of the operation. MEM is the memory location to read and +- modify. MODEL_RTX is the memory ordering to use. VALUE is the second +- operand for the operation. Either OUT_DATA or OUT_RESULT, but not both, can +- be NULL. */ +- +-void +-aarch64_gen_atomic_ldop (enum rtx_code code, rtx out_data, rtx out_result, +- rtx mem, rtx value, rtx model_rtx) +-{ +- machine_mode mode = GET_MODE (mem); +- machine_mode wmode = (mode == DImode ? DImode : SImode); +- const bool short_mode = (mode < SImode); +- aarch64_atomic_load_op_code ldop_code; +- rtx src; +- rtx x; +- +- if (out_data) +- out_data = gen_lowpart (mode, out_data); +- +- if (out_result) +- out_result = gen_lowpart (mode, out_result); +- +- /* Make sure the value is in a register, putting it into a destination +- register if it needs to be manipulated. */ +- if (!register_operand (value, mode) +- || code == AND || code == MINUS) +- { +- src = out_result ? out_result : out_data; +- emit_move_insn (src, gen_lowpart (mode, value)); +- } +- else +- src = value; +- gcc_assert (register_operand (src, mode)); +- +- /* Preprocess the data for the operation as necessary. If the operation is +- a SET then emit a swap instruction and finish. */ +- switch (code) +- { +- case MINUS: +- /* Negate the value and treat it as a PLUS. */ +- { +- rtx neg_src; +- +- /* Resize the value if necessary. */ +- if (short_mode) +- src = gen_lowpart (wmode, src); +- +- neg_src = gen_rtx_NEG (wmode, src); +- emit_insn (gen_rtx_SET (src, neg_src)); +- +- if (short_mode) +- src = gen_lowpart (mode, src); +- } +- /* Fall-through. */ +- case PLUS: +- ldop_code = AARCH64_LDOP_PLUS; +- break; +- +- case IOR: +- ldop_code = AARCH64_LDOP_OR; +- break; +- +- case XOR: +- ldop_code = AARCH64_LDOP_XOR; +- break; +- +- case AND: +- { +- rtx not_src; +- +- /* Resize the value if necessary. */ +- if (short_mode) +- src = gen_lowpart (wmode, src); +- +- not_src = gen_rtx_NOT (wmode, src); +- emit_insn (gen_rtx_SET (src, not_src)); +- +- if (short_mode) +- src = gen_lowpart (mode, src); +- } +- ldop_code = AARCH64_LDOP_BIC; +- break; +- +- default: +- /* The operation can't be done with atomic instructions. */ +- gcc_unreachable (); +- } +- +- aarch64_emit_atomic_load_op (ldop_code, mode, out_data, src, mem, model_rtx); +- +- /* If necessary, calculate the data in memory after the update by redoing the +- operation from values in registers. */ +- if (!out_result) +- return; +- +- if (short_mode) +- { +- src = gen_lowpart (wmode, src); +- out_data = gen_lowpart (wmode, out_data); +- out_result = gen_lowpart (wmode, out_result); +- } +- +- x = NULL_RTX; +- +- switch (code) +- { +- case MINUS: +- case PLUS: +- x = gen_rtx_PLUS (wmode, out_data, src); +- break; +- case IOR: +- x = gen_rtx_IOR (wmode, out_data, src); +- break; +- case XOR: +- x = gen_rtx_XOR (wmode, out_data, src); +- break; +- case AND: +- aarch64_emit_bic (wmode, out_result, out_data, src, 0); +- return; +- default: +- gcc_unreachable (); +- } +- +- emit_set_insn (out_result, x); +- +- return; +-} +- + /* Split an atomic operation. */ + + void +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index f1cc972bae4..735407c9fd7 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -207,13 +207,37 @@ + rtx (*gen) (rtx, rtx, rtx); + + /* Use an atomic load-operate instruction when possible. */ +- if (aarch64_atomic_ldop_supported_p ()) +- gen = gen_aarch64_atomic__lse; ++ if (TARGET_LSE) ++ { ++ switch () ++ { ++ case MINUS: ++ operands[1] = expand_simple_unop (mode, NEG, operands[1], ++ NULL, 1); ++ /* fallthru */ ++ case PLUS: ++ gen = gen_aarch64_atomic_add_lse; ++ break; ++ case IOR: ++ gen = gen_aarch64_atomic_ior_lse; ++ break; ++ case XOR: ++ gen = gen_aarch64_atomic_xor_lse; ++ break; ++ case AND: ++ operands[1] = expand_simple_unop (mode, NOT, operands[1], ++ NULL, 1); ++ gen = gen_aarch64_atomic_bic_lse; ++ break; ++ default: ++ gcc_unreachable (); ++ } ++ operands[1] = force_reg (mode, operands[1]); ++ } + else + gen = gen_aarch64_atomic_; + + emit_insn (gen (operands[0], operands[1], operands[2])); +- + DONE; + } + ) +@@ -239,22 +263,25 @@ + } + ) + +-(define_insn_and_split "aarch64_atomic__lse" ++(define_insn "aarch64_atomic__lse" + [(set (match_operand:ALLI 0 "aarch64_sync_memory_operand" "+Q") +- (unspec_volatile:ALLI +- [(atomic_op:ALLI (match_dup 0) +- (match_operand:ALLI 1 "" "r")) +- (match_operand:SI 2 "const_int_operand")] +- UNSPECV_ATOMIC_OP)) ++ (unspec_volatile:ALLI ++ [(match_dup 0) ++ (match_operand:ALLI 1 "register_operand" "r") ++ (match_operand:SI 2 "const_int_operand")] ++ ATOMIC_LDOP)) + (clobber (match_scratch:ALLI 3 "=&r"))] + "TARGET_LSE" +- "#" +- "&& reload_completed" +- [(const_int 0)] + { +- aarch64_gen_atomic_ldop (, operands[3], NULL, operands[0], +- operands[1], operands[2]); +- DONE; ++ enum memmodel model = memmodel_from_int (INTVAL (operands[2])); ++ if (is_mm_relaxed (model)) ++ return "ld\t%1, %3, %0"; ++ else if (is_mm_release (model)) ++ return "ldl\t%1, %3, %0"; ++ else if (is_mm_acquire (model) || is_mm_consume (model)) ++ return "lda\t%1, %3, %0"; ++ else ++ return "ldal\t%1, %3, %0"; + } + ) + +@@ -280,7 +307,7 @@ + } + ) + +-;; Load-operate-store, returning the updated memory data. ++;; Load-operate-store, returning the original memory data. + + (define_expand "atomic_fetch_" + [(match_operand:ALLI 0 "register_operand" "") +@@ -293,13 +320,37 @@ + rtx (*gen) (rtx, rtx, rtx, rtx); + + /* Use an atomic load-operate instruction when possible. */ +- if (aarch64_atomic_ldop_supported_p ()) +- gen = gen_aarch64_atomic_fetch__lse; ++ if (TARGET_LSE) ++ { ++ switch () ++ { ++ case MINUS: ++ operands[2] = expand_simple_unop (mode, NEG, operands[2], ++ NULL, 1); ++ /* fallthru */ ++ case PLUS: ++ gen = gen_aarch64_atomic_fetch_add_lse; ++ break; ++ case IOR: ++ gen = gen_aarch64_atomic_fetch_ior_lse; ++ break; ++ case XOR: ++ gen = gen_aarch64_atomic_fetch_xor_lse; ++ break; ++ case AND: ++ operands[2] = expand_simple_unop (mode, NOT, operands[2], ++ NULL, 1); ++ gen = gen_aarch64_atomic_fetch_bic_lse; ++ break; ++ default: ++ gcc_unreachable (); ++ } ++ operands[2] = force_reg (mode, operands[2]); ++ } + else + gen = gen_aarch64_atomic_fetch_; + + emit_insn (gen (operands[0], operands[1], operands[2], operands[3])); +- + DONE; + }) + +@@ -326,23 +377,26 @@ + } + ) + +-(define_insn_and_split "aarch64_atomic_fetch__lse" +- [(set (match_operand:ALLI 0 "register_operand" "=&r") +- (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) ++(define_insn "aarch64_atomic_fetch__lse" ++ [(set (match_operand:ALLI 0 "register_operand" "=r") ++ (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) + (set (match_dup 1) +- (unspec_volatile:ALLI +- [(atomic_op:ALLI (match_dup 1) +- (match_operand:ALLI 2 "" "r")) +- (match_operand:SI 3 "const_int_operand")] +- UNSPECV_ATOMIC_LDOP))] ++ (unspec_volatile:ALLI ++ [(match_dup 1) ++ (match_operand:ALLI 2 "register_operand" "r") ++ (match_operand:SI 3 "const_int_operand")] ++ ATOMIC_LDOP))] + "TARGET_LSE" +- "#" +- "&& reload_completed" +- [(const_int 0)] + { +- aarch64_gen_atomic_ldop (, operands[0], NULL, operands[1], +- operands[2], operands[3]); +- DONE; ++ enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ if (is_mm_relaxed (model)) ++ return "ld\t%2, %0, %1"; ++ else if (is_mm_acquire (model) || is_mm_consume (model)) ++ return "lda\t%2, %0, %1"; ++ else if (is_mm_release (model)) ++ return "ldl\t%2, %0, %1"; ++ else ++ return "ldal\t%2, %0, %1"; + } + ) + +@@ -370,7 +424,7 @@ + } + ) + +-;; Load-operate-store, returning the original memory data. ++;; Load-operate-store, returning the updated memory data. + + (define_expand "atomic__fetch" + [(match_operand:ALLI 0 "register_operand" "") +@@ -380,17 +434,23 @@ + (match_operand:SI 3 "const_int_operand")] + "" + { +- rtx (*gen) (rtx, rtx, rtx, rtx); +- rtx value = operands[2]; +- +- /* Use an atomic load-operate instruction when possible. */ +- if (aarch64_atomic_ldop_supported_p ()) +- gen = gen_aarch64_atomic__fetch_lse; ++ /* Use an atomic load-operate instruction when possible. In this case ++ we will re-compute the result from the original mem value. */ ++ if (TARGET_LSE) ++ { ++ rtx tmp = gen_reg_rtx (mode); ++ operands[2] = force_reg (mode, operands[2]); ++ emit_insn (gen_atomic_fetch_ ++ (tmp, operands[1], operands[2], operands[3])); ++ tmp = expand_simple_binop (mode, , tmp, operands[2], ++ operands[0], 1, OPTAB_WIDEN); ++ emit_move_insn (operands[0], tmp); ++ } + else +- gen = gen_aarch64_atomic__fetch; +- +- emit_insn (gen (operands[0], operands[1], value, operands[3])); +- ++ { ++ emit_insn (gen_aarch64_atomic__fetch ++ (operands[0], operands[1], operands[2], operands[3])); ++ } + DONE; + }) + +@@ -417,29 +477,6 @@ + } + ) + +-(define_insn_and_split "aarch64_atomic__fetch_lse" +- [(set (match_operand:ALLI 0 "register_operand" "=&r") +- (atomic_op:ALLI +- (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q") +- (match_operand:ALLI 2 "" "r"))) +- (set (match_dup 1) +- (unspec_volatile:ALLI +- [(match_dup 1) +- (match_dup 2) +- (match_operand:SI 3 "const_int_operand")] +- UNSPECV_ATOMIC_LDOP)) +- (clobber (match_scratch:ALLI 4 "=&r"))] +- "TARGET_LSE" +- "#" +- "&& reload_completed" +- [(const_int 0)] +- { +- aarch64_gen_atomic_ldop (, operands[4], operands[0], operands[1], +- operands[2], operands[3]); +- DONE; +- } +-) +- + (define_insn_and_split "atomic_nand_fetch" + [(set (match_operand:ALLI 0 "register_operand" "=&r") + (not:ALLI +@@ -582,29 +619,3 @@ + return "dmb\\tish"; + } + ) +- +-;; ARMv8.1-A LSE instructions. +- +-;; Atomic load-op: Load data, operate, store result, keep data. +- +-(define_insn "aarch64_atomic_load" +- [(set (match_operand:ALLI 0 "register_operand" "=r") +- (match_operand:ALLI 1 "aarch64_sync_memory_operand" "+Q")) +- (set (match_dup 1) +- (unspec_volatile:ALLI +- [(match_dup 1) +- (match_operand:ALLI 2 "register_operand") +- (match_operand:SI 3 "const_int_operand")] +- ATOMIC_LDOP))] +- "TARGET_LSE && reload_completed" +- { +- enum memmodel model = memmodel_from_int (INTVAL (operands[3])); +- if (is_mm_relaxed (model)) +- return "ld\t%2, %0, %1"; +- else if (is_mm_acquire (model) || is_mm_consume (model)) +- return "lda\t%2, %0, %1"; +- else if (is_mm_release (model)) +- return "ldl\t%2, %0, %1"; +- else +- return "ldal\t%2, %0, %1"; +- }) +diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md +index 4a39e30da13..fc87fc902a6 100644 +--- a/gcc/config/aarch64/iterators.md ++++ b/gcc/config/aarch64/iterators.md +@@ -369,7 +369,6 @@ + UNSPECV_ATOMIC_CAS ; Represent an atomic CAS. + UNSPECV_ATOMIC_SWP ; Represent an atomic SWP. + UNSPECV_ATOMIC_OP ; Represent an atomic operation. +- UNSPECV_ATOMIC_LDOP ; Represent an atomic load-operation + UNSPECV_ATOMIC_LDOP_OR ; Represent an atomic load-or + UNSPECV_ATOMIC_LDOP_BIC ; Represent an atomic load-bic + UNSPECV_ATOMIC_LDOP_XOR ; Represent an atomic load-xor +@@ -1113,6 +1112,10 @@ + [(UNSPECV_ATOMIC_LDOP_OR "set") (UNSPECV_ATOMIC_LDOP_BIC "clr") + (UNSPECV_ATOMIC_LDOP_XOR "eor") (UNSPECV_ATOMIC_LDOP_PLUS "add")]) + ++(define_int_attr atomic_ldoptab ++ [(UNSPECV_ATOMIC_LDOP_OR "ior") (UNSPECV_ATOMIC_LDOP_BIC "bic") ++ (UNSPECV_ATOMIC_LDOP_XOR "xor") (UNSPECV_ATOMIC_LDOP_PLUS "add")]) ++ + ;; ------------------------------------------------------------------- + ;; Int Iterators Attributes. + ;; ------------------------------------------------------------------- +-- +2.26.2 + + +From 7ab1ff93727b1c32ea3a8dcfc5f068e0c4e1acf8 Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 31 Oct 2018 23:11:22 +0000 +Subject: [PATCH 08/24] aarch64: Remove early clobber from ATOMIC_LDOP scratch +To: gcc-patches@gcc.gnu.org + +2018-10-31 Richard Henderson + +gcc/ + * config/aarch64/atomics.md (aarch64_atomic__lse): + scratch register need not be early-clobber. Document the reason + why we cannot use ST. + +(cherry picked from commit 53de1ea800db54b47290d578c43892799b66c8dc) +--- + gcc/config/aarch64/atomics.md | 14 +++++++++++++- + 1 file changed, 13 insertions(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 735407c9fd7..1ef7c20db21 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -263,6 +263,18 @@ + } + ) + ++;; It is tempting to want to use ST for relaxed and release ++;; memory models here. However, that is incompatible with the ++;; C++ memory model for the following case: ++;; ++;; atomic_fetch_add(ptr, 1, memory_order_relaxed); ++;; atomic_thread_fence(memory_order_acquire); ++;; ++;; The problem is that the architecture says that ST (and LD ++;; insns where the destination is XZR) are not regarded as a read. ++;; However we also implement the acquire memory barrier with DMB LD, ++;; and so the ST is not blocked by the barrier. ++ + (define_insn "aarch64_atomic__lse" + [(set (match_operand:ALLI 0 "aarch64_sync_memory_operand" "+Q") + (unspec_volatile:ALLI +@@ -270,7 +282,7 @@ + (match_operand:ALLI 1 "register_operand" "r") + (match_operand:SI 2 "const_int_operand")] + ATOMIC_LDOP)) +- (clobber (match_scratch:ALLI 3 "=&r"))] ++ (clobber (match_scratch:ALLI 3 "=r"))] + "TARGET_LSE" + { + enum memmodel model = memmodel_from_int (INTVAL (operands[2])); +-- +2.26.2 + + +From 3d05e960c18653ce1e4f19fba701645b1a030da7 Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Thu, 19 Sep 2019 14:36:24 +0000 +Subject: [PATCH 09/24] aarch64: Extend %R for integer registers +To: gcc-patches@gcc.gnu.org + +2019-09-19 Richard Henderson + +gcc/ + * config/aarch64/aarch64.c (aarch64_print_operand): Allow integer + registers with %R. + +(cherry picked from commit e3f15286d1129de2cceee6acd5d5584cb5422db6) +--- + gcc/config/aarch64/aarch64.c | 13 +++++++------ + 1 file changed, 7 insertions(+), 6 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index ed3cec30859..ec325813f5a 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -5082,12 +5082,13 @@ aarch64_print_operand (FILE *f, rtx x, int code) + case 'd': + case 'q': + /* Print a scalar FP/SIMD register name. */ +- if (!REG_P (x) || !FP_REGNUM_P (REGNO (x))) +- { +- output_operand_lossage ("incompatible floating point / vector register operand for '%%%c'", code); +- return; +- } +- asm_fprintf (f, "%c%d", code, REGNO (x) - V0_REGNUM); ++ if (REG_P (x) && FP_REGNUM_P (REGNO (x))) ++ asm_fprintf (f, "%c%d", code, REGNO (x) - V0_REGNUM); ++ else if (REG_P (x) && GP_REGNUM_P (REGNO (x))) ++ asm_fprintf (f, "%c%d", code, REGNO (x) - R0_REGNUM); ++ else ++ output_operand_lossage ("incompatible register operand for '%%%c'", ++ code); + break; + + case 'S': +-- +2.26.2 + + +From ed63b93e1aefcea56305ef13e4b4726af0d4f27f Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Thu, 19 Sep 2019 14:36:29 +0000 +Subject: [PATCH 10/24] aarch64: Implement TImode compare-and-swap +To: gcc-patches@gcc.gnu.org + +This pattern will only be used with the __sync functions, because +we do not yet have a bare TImode atomic load. + +2019-09-19 Richard Henderson + +gcc/ + * config/aarch64/aarch64.c (aarch64_gen_compare_reg): Add support + for NE comparison of TImode values. + (aarch64_emit_load_exclusive): Add support for TImode. + (aarch64_emit_store_exclusive): Likewise. + (aarch64_split_compare_and_swap): Disable strong_zero_p for TImode. + * config/aarch64/atomics.md (@atomic_compare_and_swap): + Change iterator from ALLI to ALLI_TI. + (@atomic_compare_and_swap): New. + (@atomic_compare_and_swap_lse): New. + (aarch64_load_exclusive_pair): New. + (aarch64_store_exclusive_pair): New. + * config/aarch64/iterators.md (JUST_TI): New. + +(cherry picked from commit 4a2095ebace8534038ce2adf4ae94bfc854066c4) +--- + gcc/config/aarch64/aarch64.c | 59 ++++++++++++++++++--- + gcc/config/aarch64/atomics.md | 93 +++++++++++++++++++++++++++++++-- + gcc/config/aarch64/iterators.md | 6 +++ + 3 files changed, 145 insertions(+), 13 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index ec325813f5a..e86f34edcc6 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -1191,10 +1191,33 @@ emit_set_insn (rtx x, rtx y) + rtx + aarch64_gen_compare_reg (RTX_CODE code, rtx x, rtx y) + { +- machine_mode mode = SELECT_CC_MODE (code, x, y); +- rtx cc_reg = gen_rtx_REG (mode, CC_REGNUM); ++ machine_mode cmp_mode = GET_MODE (x); ++ machine_mode cc_mode; ++ rtx cc_reg; + +- emit_set_insn (cc_reg, gen_rtx_COMPARE (mode, x, y)); ++ if (cmp_mode == TImode) ++ { ++ gcc_assert (code == NE); ++ ++ cc_mode = CCmode; ++ cc_reg = gen_rtx_REG (cc_mode, CC_REGNUM); ++ ++ rtx x_lo = operand_subword (x, 0, 0, TImode); ++ rtx y_lo = operand_subword (y, 0, 0, TImode); ++ emit_set_insn (cc_reg, gen_rtx_COMPARE (cc_mode, x_lo, y_lo)); ++ ++ rtx x_hi = operand_subword (x, 1, 0, TImode); ++ rtx y_hi = operand_subword (y, 1, 0, TImode); ++ emit_insn (gen_ccmpdi (cc_reg, cc_reg, x_hi, y_hi, ++ gen_rtx_EQ (cc_mode, cc_reg, const0_rtx), ++ GEN_INT (AARCH64_EQ))); ++ } ++ else ++ { ++ cc_mode = SELECT_CC_MODE (code, x, y); ++ cc_reg = gen_rtx_REG (cc_mode, CC_REGNUM); ++ emit_set_insn (cc_reg, gen_rtx_COMPARE (cc_mode, x, y)); ++ } + return cc_reg; + } + +@@ -11839,6 +11862,14 @@ aarch64_emit_load_exclusive (machine_mode mode, rtx rval, + { + rtx (*gen) (rtx, rtx, rtx); + ++ if (mode == TImode) ++ { ++ emit_insn (gen_aarch64_load_exclusive_pair ++ (gen_lowpart (DImode, rval), gen_highpart (DImode, rval), ++ mem, model_rtx)); ++ return; ++ } ++ + switch (mode) + { + case QImode: gen = gen_aarch64_load_exclusiveqi; break; +@@ -11856,10 +11887,18 @@ aarch64_emit_load_exclusive (machine_mode mode, rtx rval, + + static void + aarch64_emit_store_exclusive (machine_mode mode, rtx bval, +- rtx rval, rtx mem, rtx model_rtx) ++ rtx mem, rtx rval, rtx model_rtx) + { + rtx (*gen) (rtx, rtx, rtx, rtx); + ++ if (mode == TImode) ++ { ++ emit_insn (gen_aarch64_store_exclusive_pair ++ (bval, mem, operand_subword (rval, 0, 0, TImode), ++ operand_subword (rval, 1, 0, TImode), model_rtx)); ++ return; ++ } ++ + switch (mode) + { + case QImode: gen = gen_aarch64_store_exclusiveqi; break; +@@ -11870,7 +11909,7 @@ aarch64_emit_store_exclusive (machine_mode mode, rtx bval, + gcc_unreachable (); + } + +- emit_insn (gen (bval, rval, mem, model_rtx)); ++ emit_insn (gen (bval, mem, rval, model_rtx)); + } + + /* Mark the previous jump instruction as unlikely. */ +@@ -11898,7 +11937,8 @@ aarch64_expand_compare_and_swap (rtx operands[]) + gen_aarch64_compare_and_swapqi, + gen_aarch64_compare_and_swaphi, + gen_aarch64_compare_and_swapsi, +- gen_aarch64_compare_and_swapdi ++ gen_aarch64_compare_and_swapdi, ++ gen_aarch64_compare_and_swapti + }; + typedef rtx (*gen_lse_fn) (rtx, rtx, rtx, rtx); + const gen_lse_fn atomic_cas[] = +@@ -11906,7 +11946,8 @@ aarch64_expand_compare_and_swap (rtx operands[]) + gen_aarch64_compare_and_swapqi_lse, + gen_aarch64_compare_and_swaphi_lse, + gen_aarch64_compare_and_swapsi_lse, +- gen_aarch64_compare_and_swapdi_lse ++ gen_aarch64_compare_and_swapdi_lse, ++ gen_aarch64_compare_and_swapti_lse + }; + + bval = operands[0]; +@@ -11939,6 +11980,7 @@ aarch64_expand_compare_and_swap (rtx operands[]) + case HImode: idx = 1; break; + case SImode: idx = 2; break; + case DImode: idx = 3; break; ++ case TImode: idx = 4; break; + default: + gcc_unreachable (); + } +@@ -11965,6 +12007,7 @@ aarch64_expand_compare_and_swap (rtx operands[]) + case HImode: code = CODE_FOR_aarch64_compare_and_swaphi; break; + case SImode: code = CODE_FOR_aarch64_compare_and_swapsi; break; + case DImode: code = CODE_FOR_aarch64_compare_and_swapdi; break; ++ case TImode: code = CODE_FOR_aarch64_compare_and_swapti; break; + default: + gcc_unreachable (); + } +@@ -12033,7 +12076,7 @@ aarch64_split_compare_and_swap (rtx operands[]) + CBNZ scratch, .label1 + .label2: + CMP rval, 0. */ +- bool strong_zero_p = !is_weak && oldval == const0_rtx; ++ bool strong_zero_p = !is_weak && oldval == const0_rtx && mode != TImode; + + label1 = NULL; + if (!is_weak) +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 1ef7c20db21..316c84699d0 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -22,10 +22,10 @@ + + (define_expand "atomic_compare_and_swap" + [(match_operand:SI 0 "register_operand" "") ;; bool out +- (match_operand:ALLI 1 "register_operand" "") ;; val out +- (match_operand:ALLI 2 "aarch64_sync_memory_operand" "") ;; memory +- (match_operand:ALLI 3 "nonmemory_operand" "") ;; expected +- (match_operand:ALLI 4 "aarch64_reg_or_zero" "") ;; desired ++ (match_operand:ALLI_TI 1 "register_operand" "") ;; val out ++ (match_operand:ALLI_TI 2 "aarch64_sync_memory_operand" "") ;; memory ++ (match_operand:ALLI_TI 3 "nonmemory_operand" "") ;; expected ++ (match_operand:ALLI_TI 4 "aarch64_reg_or_zero" "") ;; desired + (match_operand:SI 5 "const_int_operand") ;; is_weak + (match_operand:SI 6 "const_int_operand") ;; mod_s + (match_operand:SI 7 "const_int_operand")] ;; mod_f +@@ -88,9 +88,33 @@ + } + ) + ++(define_insn_and_split "aarch64_compare_and_swap" ++ [(set (reg:CC CC_REGNUM) ;; bool out ++ (unspec_volatile:CC [(const_int 0)] UNSPECV_ATOMIC_CMPSW)) ++ (set (match_operand:JUST_TI 0 "register_operand" "=&r") ;; val out ++ (match_operand:JUST_TI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory ++ (set (match_dup 1) ++ (unspec_volatile:JUST_TI ++ [(match_operand:JUST_TI 2 "aarch64_reg_or_zero" "rZ") ;; expect ++ (match_operand:JUST_TI 3 "aarch64_reg_or_zero" "rZ") ;; desired ++ (match_operand:SI 4 "const_int_operand") ;; is_weak ++ (match_operand:SI 5 "const_int_operand") ;; mod_s ++ (match_operand:SI 6 "const_int_operand")] ;; mod_f ++ UNSPECV_ATOMIC_CMPSW)) ++ (clobber (match_scratch:SI 7 "=&r"))] ++ "" ++ "#" ++ "&& reload_completed" ++ [(const_int 0)] ++ { ++ aarch64_split_compare_and_swap (operands); ++ DONE; ++ } ++) ++ + (define_insn "aarch64_compare_and_swap_lse" + [(set (match_operand:SI 0 "register_operand" "+r") ;; val out +- (zero_extend:SI ++ (zero_extend:SI + (match_operand:SHORT 1 "aarch64_sync_memory_operand" "+Q"))) ;; memory + (set (match_dup 1) + (unspec_volatile:SHORT +@@ -133,6 +157,28 @@ + return "casal\t%0, %2, %1"; + }) + ++(define_insn "aarch64_compare_and_swap_lse" ++ [(set (match_operand:JUST_TI 0 "register_operand" "+r") ;; val out ++ (match_operand:JUST_TI 1 "aarch64_sync_memory_operand" "+Q")) ;; memory ++ (set (match_dup 1) ++ (unspec_volatile:JUST_TI ++ [(match_dup 0) ;; expect ++ (match_operand:JUST_TI 2 "register_operand" "r") ;; desired ++ (match_operand:SI 3 "const_int_operand")] ;; mod_s ++ UNSPECV_ATOMIC_CMPSW))] ++ "TARGET_LSE" ++{ ++ enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ if (is_mm_relaxed (model)) ++ return "casp\t%0, %R0, %2, %R2, %1"; ++ else if (is_mm_acquire (model) || is_mm_consume (model)) ++ return "caspa\t%0, %R0, %2, %R2, %1"; ++ else if (is_mm_release (model)) ++ return "caspl\t%0, %R0, %2, %R2, %1"; ++ else ++ return "caspal\t%0, %R0, %2, %R2, %1"; ++}) ++ + (define_expand "atomic_exchange" + [(match_operand:ALLI 0 "register_operand" "") + (match_operand:ALLI 1 "aarch64_sync_memory_operand" "") +@@ -578,6 +624,24 @@ + } + ) + ++(define_insn "aarch64_load_exclusive_pair" ++ [(set (match_operand:DI 0 "register_operand" "=r") ++ (unspec_volatile:DI ++ [(match_operand:TI 2 "aarch64_sync_memory_operand" "Q") ++ (match_operand:SI 3 "const_int_operand")] ++ UNSPECV_LX)) ++ (set (match_operand:DI 1 "register_operand" "=r") ++ (unspec_volatile:DI [(match_dup 2) (match_dup 3)] UNSPECV_LX))] ++ "" ++ { ++ enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ if (is_mm_relaxed (model) || is_mm_consume (model) || is_mm_release (model)) ++ return "ldxp\t%0, %1, %2"; ++ else ++ return "ldaxp\t%0, %1, %2"; ++ } ++) ++ + (define_insn "aarch64_store_exclusive" + [(set (match_operand:SI 0 "register_operand" "=&r") + (unspec_volatile:SI [(const_int 0)] UNSPECV_SX)) +@@ -596,6 +660,25 @@ + } + ) + ++(define_insn "aarch64_store_exclusive_pair" ++ [(set (match_operand:SI 0 "register_operand" "=&r") ++ (unspec_volatile:SI [(const_int 0)] UNSPECV_SX)) ++ (set (match_operand:TI 1 "aarch64_sync_memory_operand" "=Q") ++ (unspec_volatile:TI ++ [(match_operand:DI 2 "aarch64_reg_or_zero" "rZ") ++ (match_operand:DI 3 "aarch64_reg_or_zero" "rZ") ++ (match_operand:SI 4 "const_int_operand")] ++ UNSPECV_SX))] ++ "" ++ { ++ enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ if (is_mm_relaxed (model) || is_mm_consume (model) || is_mm_acquire (model)) ++ return "stxp\t%w0, %x2, %x3, %1"; ++ else ++ return "stlxp\t%w0, %x2, %x3, %1"; ++ } ++) ++ + (define_expand "mem_thread_fence" + [(match_operand:SI 0 "const_int_operand" "")] + "" +diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md +index fc87fc902a6..813f53690b7 100644 +--- a/gcc/config/aarch64/iterators.md ++++ b/gcc/config/aarch64/iterators.md +@@ -29,12 +29,18 @@ + ;; Iterator for HI, SI, DI, some instructions can only work on these modes. + (define_mode_iterator GPI_I16 [(HI "AARCH64_ISA_F16") SI DI]) + ++;; "Iterator" for just TI -- features like @pattern only work with iterators. ++(define_mode_iterator JUST_TI [TI]) ++ + ;; Iterator for QI and HI modes + (define_mode_iterator SHORT [QI HI]) + + ;; Iterator for all integer modes (up to 64-bit) + (define_mode_iterator ALLI [QI HI SI DI]) + ++;; Iterator for all integer modes (up to 128-bit) ++(define_mode_iterator ALLI_TI [QI HI SI DI TI]) ++ + ;; Iterator for all integer modes that can be extended (up to 64-bit) + (define_mode_iterator ALLX [QI HI SI]) + +-- +2.26.2 + + +From a10b63386c2e87e7712ee2d1705a6af74ced8fec Mon Sep 17 00:00:00 2001 +From: Wilco Dijkstra +Date: Fri, 17 Jan 2020 13:17:21 +0000 +Subject: [PATCH 11/24] Fix shrinkwrapping interactions with atomics (PR92692) +To: gcc-patches@gcc.gnu.org + +The separate shrinkwrapping pass may insert stores in the middle +of atomics loops which can cause issues on some implementations. +Avoid this by delaying splitting atomics patterns until after +prolog/epilog generation. + +2020-01-17 Wilco Dijkstra + +gcc/ + PR target/92692 + * config/aarch64/aarch64.c (aarch64_split_compare_and_swap) + Add assert to ensure prolog has been emitted. + (aarch64_split_atomic_op): Likewise. + * config/aarch64/atomics.md (aarch64_compare_and_swap) + Use epilogue_completed rather than reload_completed. + (aarch64_atomic_exchange): Likewise. + (aarch64_atomic_): Likewise. + (atomic_nand): Likewise. + (aarch64_atomic_fetch_): Likewise. + (atomic_fetch_nand): Likewise. + (aarch64_atomic__fetch): Likewise. + (atomic_nand_fetch): Likewise. + +(cherry picked from commit e5e07b68187b9aa334519746c45b8cffc5eb7e5c) +--- + gcc/config/aarch64/atomics.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 316c84699d0..f32f5528f1a 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -104,7 +104,7 @@ + (clobber (match_scratch:SI 7 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_compare_and_swap (operands); +-- +2.26.2 + + +From fd8684c86bebd765649e7e4b70f151c87a1f13da Mon Sep 17 00:00:00 2001 +From: Kyrylo Tkachov +Date: Wed, 1 Apr 2020 11:54:14 +0100 +Subject: [PATCH 12/24] aarch64: Tidy aarch64_split_compare_and_swap +To: gcc-patches@gcc.gnu.org + +2019-09-19 Richard Henderson + + * config/aarch64/aarch64 (aarch64_split_compare_and_swap): Disable + strong_zero_p for aarch64_track_speculation; unify some code paths; + use aarch64_gen_compare_reg instead of open-coding. + +(cherry picked from commit b7e560deb37e38fb224a0cf108e15df4a717167a) +--- + gcc/config/aarch64/aarch64.c | 40 ++++++++++++------------------------ + 1 file changed, 13 insertions(+), 27 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index e86f34edcc6..53de92e65fc 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -12049,13 +12049,11 @@ aarch64_emit_post_barrier (enum memmodel model) + void + aarch64_split_compare_and_swap (rtx operands[]) + { +- rtx rval, mem, oldval, newval, scratch; ++ rtx rval, mem, oldval, newval, scratch, x, model_rtx; + machine_mode mode; + bool is_weak; + rtx_code_label *label1, *label2; +- rtx x, cond; + enum memmodel model; +- rtx model_rtx; + + rval = operands[0]; + mem = operands[1]; +@@ -12076,7 +12074,7 @@ aarch64_split_compare_and_swap (rtx operands[]) + CBNZ scratch, .label1 + .label2: + CMP rval, 0. */ +- bool strong_zero_p = !is_weak && oldval == const0_rtx && mode != TImode; ++ bool strong_zero_p = (!is_weak && oldval == const0_rtx && mode != TImode); + + label1 = NULL; + if (!is_weak) +@@ -12089,26 +12087,20 @@ aarch64_split_compare_and_swap (rtx operands[]) + /* The initial load can be relaxed for a __sync operation since a final + barrier will be emitted to stop code hoisting. */ + if (is_mm_sync (model)) +- aarch64_emit_load_exclusive (mode, rval, mem, +- GEN_INT (MEMMODEL_RELAXED)); ++ aarch64_emit_load_exclusive (mode, rval, mem, GEN_INT (MEMMODEL_RELAXED)); + else + aarch64_emit_load_exclusive (mode, rval, mem, model_rtx); + + if (strong_zero_p) +- { +- x = gen_rtx_NE (VOIDmode, rval, const0_rtx); +- x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, +- gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); +- aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); +- } ++ x = gen_rtx_NE (VOIDmode, rval, const0_rtx); + else + { +- cond = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode); +- x = gen_rtx_NE (VOIDmode, cond, const0_rtx); +- x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, +- gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); +- aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); ++ rtx cc_reg = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode); ++ x = gen_rtx_NE (VOIDmode, cc_reg, const0_rtx); + } ++ x = gen_rtx_IF_THEN_ELSE (VOIDmode, x, ++ gen_rtx_LABEL_REF (Pmode, label2), pc_rtx); ++ aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); + + aarch64_emit_store_exclusive (mode, scratch, mem, newval, model_rtx); + +@@ -12120,22 +12112,16 @@ aarch64_split_compare_and_swap (rtx operands[]) + aarch64_emit_unlikely_jump (gen_rtx_SET (pc_rtx, x)); + } + else +- { +- cond = gen_rtx_REG (CCmode, CC_REGNUM); +- x = gen_rtx_COMPARE (CCmode, scratch, const0_rtx); +- emit_insn (gen_rtx_SET (cond, x)); +- } ++ aarch64_gen_compare_reg (NE, scratch, const0_rtx); + + emit_label (label2); ++ + /* If we used a CBNZ in the exchange loop emit an explicit compare with RVAL + to set the condition flags. If this is not used it will be removed by + later passes. */ + if (strong_zero_p) +- { +- cond = gen_rtx_REG (CCmode, CC_REGNUM); +- x = gen_rtx_COMPARE (CCmode, rval, const0_rtx); +- emit_insn (gen_rtx_SET (cond, x)); +- } ++ aarch64_gen_compare_reg (NE, rval, const0_rtx); ++ + /* Emit any final barrier needed for a __sync operation. */ + if (is_mm_sync (model)) + aarch64_emit_post_barrier (model); +-- +2.26.2 + + +From a77275f87d9e4c33a00610c5ccfba48c6eeffe55 Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Thu, 19 Sep 2019 14:36:38 +0000 +Subject: [PATCH 13/24] aarch64: Add out-of-line functions for LSE atomics +To: gcc-patches@gcc.gnu.org + +This is the libgcc part of the interface -- providing the functions. +Rationale is provided at the top of libgcc/config/aarch64/lse.S. + +2019-09-19 Richard Henderson + +gcc/ + * config/aarch64/lse-init.c: New file. + * config/aarch64/lse.S: New file. + * config/aarch64/t-lse: New file. + * config.host: Add t-lse to all aarch64 tuples. + +(cherry picked from commit 33befddcb849235353dc263db1c7d07dc15c9faa) +--- + libgcc/config.host | 3 + + libgcc/config/aarch64/lse-init.c | 45 ++++++ + libgcc/config/aarch64/lse.S | 235 +++++++++++++++++++++++++++++++ + libgcc/config/aarch64/t-lse | 44 ++++++ + 4 files changed, 327 insertions(+) + create mode 100644 libgcc/config/aarch64/lse-init.c + create mode 100644 libgcc/config/aarch64/lse.S + create mode 100644 libgcc/config/aarch64/t-lse + +diff --git a/libgcc/config.host b/libgcc/config.host +index b8e23766695..b937cfb1763 100644 +--- a/libgcc/config.host ++++ b/libgcc/config.host +@@ -334,12 +334,14 @@ aarch64*-*-elf | aarch64*-*-rtems*) + extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o" + extra_parts="$extra_parts crtfastmath.o" + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" ++ tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" + tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + md_unwind_header=aarch64/aarch64-unwind.h + ;; + aarch64*-*-freebsd*) + extra_parts="$extra_parts crtfastmath.o" + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" ++ tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" + tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + md_unwind_header=aarch64/freebsd-unwind.h + ;; +@@ -347,6 +349,7 @@ aarch64*-*-linux*) + extra_parts="$extra_parts crtfastmath.o" + md_unwind_header=aarch64/linux-unwind.h + tmake_file="${tmake_file} ${cpu_type}/t-aarch64" ++ tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc" + tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm" + ;; + alpha*-*-linux*) +diff --git a/libgcc/config/aarch64/lse-init.c b/libgcc/config/aarch64/lse-init.c +new file mode 100644 +index 00000000000..33d29147479 +--- /dev/null ++++ b/libgcc/config/aarch64/lse-init.c +@@ -0,0 +1,45 @@ ++/* Out-of-line LSE atomics for AArch64 architecture, Init. ++ Copyright (C) 2019 Free Software Foundation, Inc. ++ Contributed by Linaro Ltd. ++ ++This file is part of GCC. ++ ++GCC is free software; you can redistribute it and/or modify it under ++the terms of the GNU General Public License as published by the Free ++Software Foundation; either version 3, or (at your option) any later ++version. ++ ++GCC is distributed in the hope that it will be useful, but WITHOUT ANY ++WARRANTY; without even the implied warranty of MERCHANTABILITY or ++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++for more details. ++ ++Under Section 7 of GPL version 3, you are granted additional ++permissions described in the GCC Runtime Library Exception, version ++3.1, as published by the Free Software Foundation. ++ ++You should have received a copy of the GNU General Public License and ++a copy of the GCC Runtime Library Exception along with this program; ++see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ++. */ ++ ++/* Define the symbol gating the LSE implementations. */ ++_Bool __aarch64_have_lse_atomics ++ __attribute__((visibility("hidden"), nocommon)); ++ ++/* Disable initialization of __aarch64_have_lse_atomics during bootstrap. */ ++#ifndef inhibit_libc ++# include ++ ++/* Disable initialization if the system headers are too old. */ ++# if defined(AT_HWCAP) && defined(HWCAP_ATOMICS) ++ ++static void __attribute__((constructor)) ++init_have_lse_atomics (void) ++{ ++ unsigned long hwcap = getauxval (AT_HWCAP); ++ __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0; ++} ++ ++# endif /* HWCAP */ ++#endif /* inhibit_libc */ +diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S +new file mode 100644 +index 00000000000..a5f6673596c +--- /dev/null ++++ b/libgcc/config/aarch64/lse.S +@@ -0,0 +1,235 @@ ++/* Out-of-line LSE atomics for AArch64 architecture. ++ Copyright (C) 2019 Free Software Foundation, Inc. ++ Contributed by Linaro Ltd. ++ ++This file is part of GCC. ++ ++GCC is free software; you can redistribute it and/or modify it under ++the terms of the GNU General Public License as published by the Free ++Software Foundation; either version 3, or (at your option) any later ++version. ++ ++GCC is distributed in the hope that it will be useful, but WITHOUT ANY ++WARRANTY; without even the implied warranty of MERCHANTABILITY or ++FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++for more details. ++ ++Under Section 7 of GPL version 3, you are granted additional ++permissions described in the GCC Runtime Library Exception, version ++3.1, as published by the Free Software Foundation. ++ ++You should have received a copy of the GNU General Public License and ++a copy of the GCC Runtime Library Exception along with this program; ++see the files COPYING3 and COPYING.RUNTIME respectively. If not, see ++. */ ++ ++/* ++ * The problem that we are trying to solve is operating system deployment ++ * of ARMv8.1-Atomics, also known as Large System Exensions (LSE). ++ * ++ * There are a number of potential solutions for this problem which have ++ * been proposed and rejected for various reasons. To recap: ++ * ++ * (1) Multiple builds. The dynamic linker will examine /lib64/atomics/ ++ * if HWCAP_ATOMICS is set, allowing entire libraries to be overwritten. ++ * However, not all Linux distributions are happy with multiple builds, ++ * and anyway it has no effect on main applications. ++ * ++ * (2) IFUNC. We could put these functions into libgcc_s.so, and have ++ * a single copy of each function for all DSOs. However, ARM is concerned ++ * that the branch-to-indirect-branch that is implied by using a PLT, ++ * as required by IFUNC, is too much overhead for smaller cpus. ++ * ++ * (3) Statically predicted direct branches. This is the approach that ++ * is taken here. These functions are linked into every DSO that uses them. ++ * All of the symbols are hidden, so that the functions are called via a ++ * direct branch. The choice of LSE vs non-LSE is done via one byte load ++ * followed by a well-predicted direct branch. The functions are compiled ++ * separately to minimize code size. ++ */ ++ ++/* Tell the assembler to accept LSE instructions. */ ++ .arch armv8-a+lse ++ ++/* Declare the symbol gating the LSE implementations. */ ++ .hidden __aarch64_have_lse_atomics ++ ++/* Turn size and memory model defines into mnemonic fragments. */ ++#if SIZE == 1 ++# define S b ++# define UXT uxtb ++#elif SIZE == 2 ++# define S h ++# define UXT uxth ++#elif SIZE == 4 || SIZE == 8 || SIZE == 16 ++# define S ++# define UXT mov ++#else ++# error ++#endif ++ ++#if MODEL == 1 ++# define SUFF _relax ++# define A ++# define L ++#elif MODEL == 2 ++# define SUFF _acq ++# define A a ++# define L ++#elif MODEL == 3 ++# define SUFF _rel ++# define A ++# define L l ++#elif MODEL == 4 ++# define SUFF _acq_rel ++# define A a ++# define L l ++#else ++# error ++#endif ++ ++/* Concatenate symbols. */ ++#define glue2_(A, B) A ## B ++#define glue2(A, B) glue2_(A, B) ++#define glue3_(A, B, C) A ## B ## C ++#define glue3(A, B, C) glue3_(A, B, C) ++#define glue4_(A, B, C, D) A ## B ## C ## D ++#define glue4(A, B, C, D) glue4_(A, B, C, D) ++ ++/* Select the size of a register, given a regno. */ ++#define x(N) glue2(x, N) ++#define w(N) glue2(w, N) ++#if SIZE < 8 ++# define s(N) w(N) ++#else ++# define s(N) x(N) ++#endif ++ ++#define NAME(BASE) glue4(__aarch64_, BASE, SIZE, SUFF) ++#define LDXR glue4(ld, A, xr, S) ++#define STXR glue4(st, L, xr, S) ++ ++/* Temporary registers used. Other than these, only the return value ++ register (x0) and the flags are modified. */ ++#define tmp0 16 ++#define tmp1 17 ++#define tmp2 15 ++ ++/* Start and end a function. */ ++.macro STARTFN name ++ .text ++ .balign 16 ++ .globl \name ++ .hidden \name ++ .type \name, %function ++ .cfi_startproc ++\name: ++.endm ++ ++.macro ENDFN name ++ .cfi_endproc ++ .size \name, . - \name ++.endm ++ ++/* Branch to LABEL if LSE is disabled. */ ++.macro JUMP_IF_NOT_LSE label ++ adrp x(tmp0), __aarch64_have_lse_atomics ++ ldrb w(tmp0), [x(tmp0), :lo12:__aarch64_have_lse_atomics] ++ cbz w(tmp0), \label ++.endm ++ ++#ifdef L_cas ++ ++STARTFN NAME(cas) ++ JUMP_IF_NOT_LSE 8f ++ ++#if SIZE < 16 ++#define CAS glue4(cas, A, L, S) ++ ++ CAS s(0), s(1), [x2] ++ ret ++ ++8: UXT s(tmp0), s(0) ++0: LDXR s(0), [x2] ++ cmp s(0), s(tmp0) ++ bne 1f ++ STXR w(tmp1), s(1), [x2] ++ cbnz w(tmp1), 0b ++1: ret ++ ++#else ++#define LDXP glue3(ld, A, xp) ++#define STXP glue3(st, L, xp) ++#define CASP glue3(casp, A, L) ++ ++ CASP x0, x1, x2, x3, [x4] ++ ret ++ ++8: mov x(tmp0), x0 ++ mov x(tmp1), x1 ++0: LDXP x0, x1, [x4] ++ cmp x0, x(tmp0) ++ ccmp x1, x(tmp1), #0, eq ++ bne 1f ++ STXP w(tmp2), x(tmp0), x(tmp1), [x4] ++ cbnz w(tmp2), 0b ++1: ret ++ ++#endif ++ ++ENDFN NAME(cas) ++#endif ++ ++#ifdef L_swp ++#define SWP glue4(swp, A, L, S) ++ ++STARTFN NAME(swp) ++ JUMP_IF_NOT_LSE 8f ++ ++ SWP s(0), s(0), [x1] ++ ret ++ ++8: mov s(tmp0), s(0) ++0: LDXR s(0), [x1] ++ STXR w(tmp1), s(tmp0), [x1] ++ cbnz w(tmp1), 0b ++ ret ++ ++ENDFN NAME(swp) ++#endif ++ ++#if defined(L_ldadd) || defined(L_ldclr) \ ++ || defined(L_ldeor) || defined(L_ldset) ++ ++#ifdef L_ldadd ++#define LDNM ldadd ++#define OP add ++#elif defined(L_ldclr) ++#define LDNM ldclr ++#define OP bic ++#elif defined(L_ldeor) ++#define LDNM ldeor ++#define OP eor ++#elif defined(L_ldset) ++#define LDNM ldset ++#define OP orr ++#else ++#error ++#endif ++#define LDOP glue4(LDNM, A, L, S) ++ ++STARTFN NAME(LDNM) ++ JUMP_IF_NOT_LSE 8f ++ ++ LDOP s(0), s(0), [x1] ++ ret ++ ++8: mov s(tmp0), s(0) ++0: LDXR s(0), [x1] ++ OP s(tmp1), s(0), s(tmp0) ++ STXR w(tmp1), s(tmp1), [x1] ++ cbnz w(tmp1), 0b ++ ret ++ ++ENDFN NAME(LDNM) ++#endif +diff --git a/libgcc/config/aarch64/t-lse b/libgcc/config/aarch64/t-lse +new file mode 100644 +index 00000000000..fe3868dacbf +--- /dev/null ++++ b/libgcc/config/aarch64/t-lse +@@ -0,0 +1,44 @@ ++# Out-of-line LSE atomics for AArch64 architecture. ++# Copyright (C) 2019 Free Software Foundation, Inc. ++# Contributed by Linaro Ltd. ++# ++# This file is part of GCC. ++# ++# GCC is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3, or (at your option) ++# any later version. ++# ++# GCC is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GCC; see the file COPYING3. If not see ++# . ++ ++# Compare-and-swap has 5 sizes and 4 memory models. ++S0 := $(foreach s, 1 2 4 8 16, $(addsuffix _$(s), cas)) ++O0 := $(foreach m, 1 2 3 4, $(addsuffix _$(m)$(objext), $(S0))) ++ ++# Swap, Load-and-operate have 4 sizes and 4 memory models ++S1 := $(foreach s, 1 2 4 8, $(addsuffix _$(s), swp ldadd ldclr ldeor ldset)) ++O1 := $(foreach m, 1 2 3 4, $(addsuffix _$(m)$(objext), $(S1))) ++ ++LSE_OBJS := $(O0) $(O1) ++ ++libgcc-objects += $(LSE_OBJS) lse-init$(objext) ++ ++empty = ++space = $(empty) $(empty) ++PAT_SPLIT = $(subst _,$(space),$(*F)) ++PAT_BASE = $(word 1,$(PAT_SPLIT)) ++PAT_N = $(word 2,$(PAT_SPLIT)) ++PAT_M = $(word 3,$(PAT_SPLIT)) ++ ++lse-init$(objext): $(srcdir)/config/aarch64/lse-init.c ++ $(gcc_compile) -c $< ++ ++$(LSE_OBJS): $(srcdir)/config/aarch64/lse.S ++ $(gcc_compile) -DL_$(PAT_BASE) -DSIZE=$(PAT_N) -DMODEL=$(PAT_M) -c $< +-- +2.26.2 + + +From 96202f3214509cdc52a10d032d392d797ab93330 Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 31 Oct 2018 23:12:14 +0000 +Subject: [PATCH 14/24] Add visibility to libfunc constructors +To: gcc-patches@gcc.gnu.org + +2018-10-31 Richard Henderson + +gcc/ + * optabs-libfuncs.c (build_libfunc_function_visibility): + New, split out from... + (build_libfunc_function): ... here. + (init_one_libfunc_visibility): New, split out from ... + (init_one_libfunc): ... here. + +(cherry picked from commit a3ace685830da611697d0b9721ca675f3ae13766) +--- + gcc/optabs-libfuncs.c | 26 ++++++++++++++++++++------ + gcc/optabs-libfuncs.h | 2 ++ + 2 files changed, 22 insertions(+), 6 deletions(-) + +diff --git a/gcc/optabs-libfuncs.c b/gcc/optabs-libfuncs.c +index a3a32b7652c..1cbda947fb7 100644 +--- a/gcc/optabs-libfuncs.c ++++ b/gcc/optabs-libfuncs.c +@@ -726,10 +726,10 @@ struct libfunc_decl_hasher : ggc_ptr_hash + /* A table of previously-created libfuncs, hashed by name. */ + static GTY (()) hash_table *libfunc_decls; + +-/* Build a decl for a libfunc named NAME. */ ++/* Build a decl for a libfunc named NAME with visibility VIS. */ + + tree +-build_libfunc_function (const char *name) ++build_libfunc_function_visibility (const char *name, symbol_visibility vis) + { + /* ??? We don't have any type information; pretend this is "int foo ()". */ + tree decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL, +@@ -738,7 +738,7 @@ build_libfunc_function (const char *name) + DECL_EXTERNAL (decl) = 1; + TREE_PUBLIC (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; +- DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; ++ DECL_VISIBILITY (decl) = vis; + DECL_VISIBILITY_SPECIFIED (decl) = 1; + gcc_assert (DECL_ASSEMBLER_NAME (decl)); + +@@ -749,11 +749,19 @@ build_libfunc_function (const char *name) + return decl; + } + ++/* Build a decl for a libfunc named NAME. */ ++ ++tree ++build_libfunc_function (const char *name) ++{ ++ return build_libfunc_function_visibility (name, VISIBILITY_DEFAULT); ++} ++ + /* Return a libfunc for NAME, creating one if we don't already have one. +- The returned rtx is a SYMBOL_REF. */ ++ The decl is given visibility VIS. The returned rtx is a SYMBOL_REF. */ + + rtx +-init_one_libfunc (const char *name) ++init_one_libfunc_visibility (const char *name, symbol_visibility vis) + { + tree id, decl; + hashval_t hash; +@@ -770,12 +778,18 @@ init_one_libfunc (const char *name) + { + /* Create a new decl, so that it can be passed to + targetm.encode_section_info. */ +- decl = build_libfunc_function (name); ++ decl = build_libfunc_function_visibility (name, vis); + *slot = decl; + } + return XEXP (DECL_RTL (decl), 0); + } + ++rtx ++init_one_libfunc (const char *name) ++{ ++ return init_one_libfunc_visibility (name, VISIBILITY_DEFAULT); ++} ++ + /* Adjust the assembler name of libfunc NAME to ASMSPEC. */ + + rtx +diff --git a/gcc/optabs-libfuncs.h b/gcc/optabs-libfuncs.h +index a271d2dee5b..af06d6100a8 100644 +--- a/gcc/optabs-libfuncs.h ++++ b/gcc/optabs-libfuncs.h +@@ -63,7 +63,9 @@ void gen_satfract_conv_libfunc (convert_optab, const char *, + void gen_satfractuns_conv_libfunc (convert_optab, const char *, + machine_mode, machine_mode); + ++tree build_libfunc_function_visibility (const char *, symbol_visibility); + tree build_libfunc_function (const char *); ++rtx init_one_libfunc_visibility (const char *, symbol_visibility); + rtx init_one_libfunc (const char *); + rtx set_user_assembler_libfunc (const char *, const char *); + +-- +2.26.2 + + +From ab5bf64b93983d41d5619e0f2024b76913b812db Mon Sep 17 00:00:00 2001 +From: Andrew Pinski +Date: Sun, 6 Aug 2017 18:10:58 +0000 +Subject: [PATCH 15/24] atomic_cmp_exchange_zero_reg_1.c: Pass + -march=armv8-a+nolse, skip if -mcpu= is passed. +To: gcc-patches@gcc.gnu.org + +2017-08-06 Andrew Pinski + +gcc/testsuite/ + * gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c: Pass + -march=armv8-a+nolse, skip if -mcpu= is passed. + * gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c: Likewise. + +(cherry picked from commit 905964740f674a784224620d1339676448aaada6) +--- + .../gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c | 3 ++- + .../gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c | 3 ++- + 2 files changed, 4 insertions(+), 2 deletions(-) + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c +index 15606b68990..f2a21ddf2e1 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c +@@ -1,5 +1,6 @@ + /* { dg-do compile } */ +-/* { dg-options "-O2" } */ ++/* { dg-options "-O2 -march=armv8-a+nolse" } */ ++/* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */ + + int + foo (int *a) +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c +index b14a7c29437..8d2ae67dfbe 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c +@@ -1,5 +1,6 @@ + /* { dg-do compile } */ +-/* { dg-options "-O2" } */ ++/* { dg-options "-O2 -march=armv8-a+nolse" } */ ++/* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */ + + int + foo (int *a) +-- +2.26.2 + + +From 4547522bebc79ece2ebc505116a81f47c423743a Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Thu, 19 Sep 2019 14:36:43 +0000 +Subject: [PATCH 16/24] aarch64: Implement -moutline-atomics +To: gcc-patches@gcc.gnu.org + +2019-09-19 Richard Henderson + +gcc/ + * config/aarch64/aarch64.opt (-moutline-atomics): New. + * config/aarch64/aarch64.c (aarch64_atomic_ool_func): New. + (aarch64_ool_cas_names, aarch64_ool_swp_names): New. + (aarch64_ool_ldadd_names, aarch64_ool_ldset_names): New. + (aarch64_ool_ldclr_names, aarch64_ool_ldeor_names): New. + (aarch64_expand_compare_and_swap): Honor TARGET_OUTLINE_ATOMICS. + * config/aarch64/atomics.md (atomic_exchange): Likewise. + (atomic_): Likewise. + (atomic_fetch_): Likewise. + (atomic__fetch): Likewise. + * doc/invoke.texi: Document -moutline-atomics. + +gcc/testsuite/ + * gcc.target/aarch64/atomic-op-acq_rel.c: Use -mno-outline-atomics. + * gcc.target/aarch64/atomic-comp-swap-release-acquire.c: Likewise. + * gcc.target/aarch64/atomic-op-acquire.c: Likewise. + * gcc.target/aarch64/atomic-op-char.c: Likewise. + * gcc.target/aarch64/atomic-op-consume.c: Likewise. + * gcc.target/aarch64/atomic-op-imm.c: Likewise. + * gcc.target/aarch64/atomic-op-int.c: Likewise. + * gcc.target/aarch64/atomic-op-long.c: Likewise. + * gcc.target/aarch64/atomic-op-relaxed.c: Likewise. + * gcc.target/aarch64/atomic-op-release.c: Likewise. + * gcc.target/aarch64/atomic-op-seq_cst.c: Likewise. + * gcc.target/aarch64/atomic-op-short.c: Likewise. + * gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c: Likewise. + * gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c: Likewise. + * gcc.target/aarch64/sync-comp-swap.c: Likewise. + * gcc.target/aarch64/sync-op-acquire.c: Likewise. + * gcc.target/aarch64/sync-op-full.c: Likewise. + +(cherry picked from commit 3950b229a5ed6710f30241c2ddc3c74909bf4740) +--- + gcc/config/aarch64/aarch64-protos.h | 13 +++ + gcc/config/aarch64/aarch64.c | 87 +++++++++++++++++ + gcc/config/aarch64/aarch64.opt | 4 + + gcc/config/aarch64/atomics.md | 94 +++++++++++++++++-- + gcc/doc/invoke.texi | 15 ++- + .../atomic-comp-swap-release-acquire.c | 2 +- + .../gcc.target/aarch64/atomic-op-acq_rel.c | 2 +- + .../gcc.target/aarch64/atomic-op-acquire.c | 2 +- + .../gcc.target/aarch64/atomic-op-char.c | 2 +- + .../gcc.target/aarch64/atomic-op-consume.c | 2 +- + .../gcc.target/aarch64/atomic-op-imm.c | 2 +- + .../gcc.target/aarch64/atomic-op-int.c | 2 +- + .../gcc.target/aarch64/atomic-op-long.c | 2 +- + .../gcc.target/aarch64/atomic-op-relaxed.c | 2 +- + .../gcc.target/aarch64/atomic-op-release.c | 2 +- + .../gcc.target/aarch64/atomic-op-seq_cst.c | 2 +- + .../gcc.target/aarch64/atomic-op-short.c | 2 +- + .../aarch64/atomic_cmp_exchange_zero_reg_1.c | 2 +- + .../atomic_cmp_exchange_zero_strong_1.c | 2 +- + .../gcc.target/aarch64/sync-comp-swap.c | 2 +- + .../gcc.target/aarch64/sync-op-acquire.c | 2 +- + .../gcc.target/aarch64/sync-op-full.c | 2 +- + 22 files changed, 221 insertions(+), 26 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h +index e47f2174479..e5ab894ddc7 100644 +--- a/gcc/config/aarch64/aarch64-protos.h ++++ b/gcc/config/aarch64/aarch64-protos.h +@@ -472,4 +472,17 @@ std::string aarch64_get_extension_string_for_isa_flags (unsigned long, + + rtl_opt_pass *make_pass_fma_steering (gcc::context *ctxt); + ++struct atomic_ool_names ++{ ++ const char *str[5][4]; ++}; ++ ++rtx aarch64_atomic_ool_func(machine_mode mode, rtx model_rtx, ++ const atomic_ool_names *names); ++extern const atomic_ool_names aarch64_ool_swp_names; ++extern const atomic_ool_names aarch64_ool_ldadd_names; ++extern const atomic_ool_names aarch64_ool_ldset_names; ++extern const atomic_ool_names aarch64_ool_ldclr_names; ++extern const atomic_ool_names aarch64_ool_ldeor_names; ++ + #endif /* GCC_AARCH64_PROTOS_H */ +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 53de92e65fc..5ccb13b46fe 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -11923,6 +11923,82 @@ aarch64_emit_unlikely_jump (rtx insn) + add_int_reg_note (jump, REG_BR_PROB, very_unlikely); + } + ++/* We store the names of the various atomic helpers in a 5x4 array. ++ Return the libcall function given MODE, MODEL and NAMES. */ ++ ++rtx ++aarch64_atomic_ool_func(machine_mode mode, rtx model_rtx, ++ const atomic_ool_names *names) ++{ ++ memmodel model = memmodel_base (INTVAL (model_rtx)); ++ int mode_idx, model_idx; ++ ++ switch (mode) ++ { ++ case QImode: ++ mode_idx = 0; ++ break; ++ case HImode: ++ mode_idx = 1; ++ break; ++ case SImode: ++ mode_idx = 2; ++ break; ++ case DImode: ++ mode_idx = 3; ++ break; ++ case TImode: ++ mode_idx = 4; ++ break; ++ default: ++ gcc_unreachable (); ++ } ++ ++ switch (model) ++ { ++ case MEMMODEL_RELAXED: ++ model_idx = 0; ++ break; ++ case MEMMODEL_CONSUME: ++ case MEMMODEL_ACQUIRE: ++ model_idx = 1; ++ break; ++ case MEMMODEL_RELEASE: ++ model_idx = 2; ++ break; ++ case MEMMODEL_ACQ_REL: ++ case MEMMODEL_SEQ_CST: ++ model_idx = 3; ++ break; ++ default: ++ gcc_unreachable (); ++ } ++ ++ return init_one_libfunc_visibility (names->str[mode_idx][model_idx], ++ VISIBILITY_HIDDEN); ++} ++ ++#define DEF0(B, N) \ ++ { "__aarch64_" #B #N "_relax", \ ++ "__aarch64_" #B #N "_acq", \ ++ "__aarch64_" #B #N "_rel", \ ++ "__aarch64_" #B #N "_acq_rel" } ++ ++#define DEF4(B) DEF0(B, 1), DEF0(B, 2), DEF0(B, 4), DEF0(B, 8), \ ++ { NULL, NULL, NULL, NULL } ++#define DEF5(B) DEF0(B, 1), DEF0(B, 2), DEF0(B, 4), DEF0(B, 8), DEF0(B, 16) ++ ++static const atomic_ool_names aarch64_ool_cas_names = { { DEF5(cas) } }; ++const atomic_ool_names aarch64_ool_swp_names = { { DEF4(swp) } }; ++const atomic_ool_names aarch64_ool_ldadd_names = { { DEF4(ldadd) } }; ++const atomic_ool_names aarch64_ool_ldset_names = { { DEF4(ldset) } }; ++const atomic_ool_names aarch64_ool_ldclr_names = { { DEF4(ldclr) } }; ++const atomic_ool_names aarch64_ool_ldeor_names = { { DEF4(ldeor) } }; ++ ++#undef DEF0 ++#undef DEF4 ++#undef DEF5 ++ + /* Expand a compare and swap pattern. */ + + void +@@ -11997,6 +12073,17 @@ aarch64_expand_compare_and_swap (rtx operands[]) + emit_insn (atomic_cas[idx] (rval, mem, newval, mod_s)); + cc_reg = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode); + } ++ else if (TARGET_OUTLINE_ATOMICS) ++ { ++ /* Oldval must satisfy compare afterward. */ ++ if (!aarch64_plus_operand (oldval, mode)) ++ oldval = force_reg (mode, oldval); ++ rtx func = aarch64_atomic_ool_func (mode, mod_s, &aarch64_ool_cas_names); ++ rval = emit_library_call_value (func, NULL_RTX, LCT_NORMAL, r_mode, ++ 3, oldval, mode, newval, mode, ++ XEXP (mem, 0), Pmode); ++ cc_reg = aarch64_gen_compare_reg_maybe_ze (NE, rval, oldval, mode); ++ } + else + { + /* The oldval predicate varies by mode. Test it and force to reg. */ +diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt +index 942a7d558f2..edfb1b92be1 100644 +--- a/gcc/config/aarch64/aarch64.opt ++++ b/gcc/config/aarch64/aarch64.opt +@@ -188,3 +188,7 @@ single precision and to 32 bits for double precision. + mverbose-cost-dump + Common Undocumented Var(flag_aarch64_verbose_cost) + Enables verbose cost model dumping in the debug dump files. ++ ++moutline-atomics ++Target Report Mask(OUTLINE_ATOMICS) Save ++Generate local calls to out-of-line atomic operations. +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index f32f5528f1a..23333a803ec 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -186,16 +186,27 @@ + (match_operand:SI 3 "const_int_operand" "")] + "" + { +- rtx (*gen) (rtx, rtx, rtx, rtx); +- + /* Use an atomic SWP when available. */ + if (TARGET_LSE) +- gen = gen_aarch64_atomic_exchange_lse; ++ { ++ emit_insn (gen_aarch64_atomic_exchange_lse ++ (operands[0], operands[1], operands[2], operands[3])); ++ } ++ else if (TARGET_OUTLINE_ATOMICS) ++ { ++ machine_mode mode = mode; ++ rtx func = aarch64_atomic_ool_func (mode, operands[3], ++ &aarch64_ool_swp_names); ++ rtx rval = emit_library_call_value (func, operands[0], LCT_NORMAL, ++ mode, 2, operands[2], mode, ++ XEXP (operands[1], 0), Pmode); ++ emit_move_insn (operands[0], rval); ++ } + else +- gen = gen_aarch64_atomic_exchange; +- +- emit_insn (gen (operands[0], operands[1], operands[2], operands[3])); +- ++ { ++ emit_insn (gen_aarch64_atomic_exchange ++ (operands[0], operands[1], operands[2], operands[3])); ++ } + DONE; + } + ) +@@ -280,6 +291,39 @@ + } + operands[1] = force_reg (mode, operands[1]); + } ++ else if (TARGET_OUTLINE_ATOMICS) ++ { ++ const atomic_ool_names *names; ++ switch () ++ { ++ case MINUS: ++ operands[1] = expand_simple_unop (mode, NEG, operands[1], ++ NULL, 1); ++ /* fallthru */ ++ case PLUS: ++ names = &aarch64_ool_ldadd_names; ++ break; ++ case IOR: ++ names = &aarch64_ool_ldset_names; ++ break; ++ case XOR: ++ names = &aarch64_ool_ldeor_names; ++ break; ++ case AND: ++ operands[1] = expand_simple_unop (mode, NOT, operands[1], ++ NULL, 1); ++ names = &aarch64_ool_ldclr_names; ++ break; ++ default: ++ gcc_unreachable (); ++ } ++ machine_mode mode = mode; ++ rtx func = aarch64_atomic_ool_func (mode, operands[2], names); ++ emit_library_call_value (func, NULL_RTX, LCT_NORMAL, mode, 2, ++ operands[1], mode, ++ XEXP (operands[0], 0), Pmode); ++ DONE; ++ } + else + gen = gen_aarch64_atomic_; + +@@ -405,6 +449,40 @@ + } + operands[2] = force_reg (mode, operands[2]); + } ++ else if (TARGET_OUTLINE_ATOMICS) ++ { ++ const atomic_ool_names *names; ++ switch () ++ { ++ case MINUS: ++ operands[2] = expand_simple_unop (mode, NEG, operands[2], ++ NULL, 1); ++ /* fallthru */ ++ case PLUS: ++ names = &aarch64_ool_ldadd_names; ++ break; ++ case IOR: ++ names = &aarch64_ool_ldset_names; ++ break; ++ case XOR: ++ names = &aarch64_ool_ldeor_names; ++ break; ++ case AND: ++ operands[2] = expand_simple_unop (mode, NOT, operands[2], ++ NULL, 1); ++ names = &aarch64_ool_ldclr_names; ++ break; ++ default: ++ gcc_unreachable (); ++ } ++ machine_mode mode = mode; ++ rtx func = aarch64_atomic_ool_func (mode, operands[3], names); ++ rtx rval = emit_library_call_value (func, operands[0], LCT_NORMAL, mode, ++ 2, operands[2], mode, ++ XEXP (operands[1], 0), Pmode); ++ emit_move_insn (operands[0], rval); ++ DONE; ++ } + else + gen = gen_aarch64_atomic_fetch_; + +@@ -494,7 +572,7 @@ + { + /* Use an atomic load-operate instruction when possible. In this case + we will re-compute the result from the original mem value. */ +- if (TARGET_LSE) ++ if (TARGET_LSE || TARGET_OUTLINE_ATOMICS) + { + rtx tmp = gen_reg_rtx (mode); + operands[2] = force_reg (mode, operands[2]); +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index d941c7b1ed4..71b8e92cf90 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -1042,7 +1042,7 @@ See RS/6000 and PowerPC Options. + -mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware @gol + -mgnu-attribute -mno-gnu-attribute @gol + -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{reg} @gol +--mstack-protector-guard-offset=@var{offset} @gol ++-mstack-protector-guard-offset=@var{offset} -moutline-atomics @gol + -mlra -mno-lra} + + @emph{RX Options} +@@ -13955,6 +13955,19 @@ This option only has an effect if @option{-ffast-math} or + precision of division results to about 16 bits for + single precision and to 32 bits for double precision. + ++@item -moutline-atomics ++@itemx -mno-outline-atomics ++Enable or disable calls to out-of-line helpers to implement atomic operations. ++These helpers will, at runtime, determine if the LSE instructions from ++ARMv8.1-A can be used; if not, they will use the load/store-exclusive ++instructions that are present in the base ARMv8.0 ISA. ++ ++This option is only applicable when compiling for the base ARMv8.0 ++instruction set. If using a later revision, e.g. @option{-march=armv8.1-a} ++or @option{-march=armv8-a+lse}, the ARMv8.1-Atomics instructions will be ++used directly. The same applies when using @option{-mcpu=} when the ++selected cpu supports the @samp{lse} feature. ++ + @item -march=@var{name} + @opindex march + Specify the name of the target architecture and, optionally, one or +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c b/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c +index 49ca5d0d09c..a828a72aa75 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-comp-swap-release-acquire.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf -mno-outline-atomics" } */ + + #include "atomic-comp-swap-release-acquire.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c +index 74f26348e42..6823ce381b2 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-acq_rel.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-acq_rel.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c +index 66c1b1efe20..87937de378a 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-acquire.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-acquire.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c +index c09d0434ecf..60955e57da3 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-char.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-char.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c +index 5783ab84f5c..16cb11aeeaf 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-consume.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-consume.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c +index 18b8f0b04e9..bcab4e481e3 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-imm.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + int v = 0; + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c +index 8520f0839ba..040e4a8d168 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-int.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-int.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c +index d011f8c5ce2..fc88b92cd3e 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-long.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + long v = 0; + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c +index ed96bfdb978..503d62b0280 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-relaxed.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-relaxed.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c +index fc4be17de89..efe14aea7e4 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-release.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-release.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c +index 613000fe490..09973bf82ba 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-seq_cst.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-seq_cst.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c b/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c +index e82c8118ece..e1dcebb0f89 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic-op-short.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "atomic-op-short.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c +index f2a21ddf2e1..29246979bfb 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_reg_1.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-O2 -march=armv8-a+nolse" } */ ++/* { dg-options "-O2 -march=armv8-a+nolse -mno-outline-atomics" } */ + /* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */ + + int +diff --git a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c +index 8d2ae67dfbe..6daf9b08f5a 100644 +--- a/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c ++++ b/gcc/testsuite/gcc.target/aarch64/atomic_cmp_exchange_zero_strong_1.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-O2 -march=armv8-a+nolse" } */ ++/* { dg-options "-O2 -march=armv8-a+nolse -mno-outline-atomics" } */ + /* { dg-skip-if "" { *-*-* } { "-mcpu=*" } { "" } } */ + + int +diff --git a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c +index e571b2f13b3..f56415f3354 100644 +--- a/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c ++++ b/gcc/testsuite/gcc.target/aarch64/sync-comp-swap.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -fno-ipa-icf -mno-outline-atomics" } */ + + #include "sync-comp-swap.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c +index 357bf1be3b2..39b3144aa36 100644 +--- a/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c ++++ b/gcc/testsuite/gcc.target/aarch64/sync-op-acquire.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "sync-op-acquire.x" + +diff --git a/gcc/testsuite/gcc.target/aarch64/sync-op-full.c b/gcc/testsuite/gcc.target/aarch64/sync-op-full.c +index c6ba1629965..6b8b2043f40 100644 +--- a/gcc/testsuite/gcc.target/aarch64/sync-op-full.c ++++ b/gcc/testsuite/gcc.target/aarch64/sync-op-full.c +@@ -1,5 +1,5 @@ + /* { dg-do compile } */ +-/* { dg-options "-march=armv8-a+nolse -O2" } */ ++/* { dg-options "-march=armv8-a+nolse -O2 -mno-outline-atomics" } */ + + #include "sync-op-full.x" + +-- +2.26.2 + + +From 6da4552680e8269b677c08770797042f70ab8fdc Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 25 Sep 2019 21:48:41 +0000 +Subject: [PATCH 17/24] aarch64: Fix store-exclusive in load-operate LSE + helpers +To: gcc-patches@gcc.gnu.org + +2019-09-25 Richard Henderson + +gcc/ + PR target/91834 + * config/aarch64/lse.S (LDNM): Ensure STXR output does not + overlap the inputs. + +(cherry picked from commit 88a51d68c4aaa61adb36a9cad6f25ef214bde853) +--- + libgcc/config/aarch64/lse.S | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S +index a5f6673596c..c7979382ad7 100644 +--- a/libgcc/config/aarch64/lse.S ++++ b/libgcc/config/aarch64/lse.S +@@ -227,8 +227,8 @@ STARTFN NAME(LDNM) + 8: mov s(tmp0), s(0) + 0: LDXR s(0), [x1] + OP s(tmp1), s(0), s(tmp0) +- STXR w(tmp1), s(tmp1), [x1] +- cbnz w(tmp1), 0b ++ STXR w(tmp2), s(tmp1), [x1] ++ cbnz w(tmp2), 0b + ret + + ENDFN NAME(LDNM) +-- +2.26.2 + + +From a5f0d552ba6d5ce02b1c2f056116a0f8532b9667 Mon Sep 17 00:00:00 2001 +From: Richard Henderson +Date: Wed, 25 Sep 2019 22:51:55 +0000 +Subject: [PATCH 18/24] aarch64: Configure for sys/auxv.h in libgcc for + lse-init.c +To: gcc-patches@gcc.gnu.org + +2019-09-25 Richard Henderson + +gcc/ + PR target/91833 + * config/aarch64/lse-init.c: Include auto-target.h. Disable + initialization if !HAVE_SYS_AUXV_H. + * configure.ac (AC_CHECK_HEADERS): Add sys/auxv.h. + * config.in, configure: Rebuild. + +(cherry picked from commit 58d169ba9ffca04d77314f525af9efd93881a86b) +--- + libgcc/config.in | 8 ++++++++ + libgcc/config/aarch64/lse-init.c | 4 +++- + libgcc/configure | 26 +++++++++++++++++++------- + libgcc/configure.ac | 2 +- + 4 files changed, 31 insertions(+), 9 deletions(-) + mode change 100644 => 100755 libgcc/configure + +diff --git a/libgcc/config.in b/libgcc/config.in +index 7de22ee0a72..89d4aba3133 100644 +--- a/libgcc/config.in ++++ b/libgcc/config.in +@@ -33,6 +33,9 @@ + /* Define to 1 if you have the header file. */ + #undef HAVE_STRING_H + ++/* Define to 1 if you have the header file. */ ++#undef HAVE_SYS_AUXV_H ++ + /* Define to 1 if you have the header file. */ + #undef HAVE_SYS_STAT_H + +@@ -72,6 +75,11 @@ + /* Define to 1 if the target use emutls for thread-local storage. */ + #undef USE_EMUTLS + ++/* Enable large inode numbers on Mac OS X 10.5. */ ++#ifndef _DARWIN_USE_64_BIT_INODE ++# define _DARWIN_USE_64_BIT_INODE 1 ++#endif ++ + /* Number of bits in a file offset, on hosts where this is settable. */ + #undef _FILE_OFFSET_BITS + +diff --git a/libgcc/config/aarch64/lse-init.c b/libgcc/config/aarch64/lse-init.c +index 33d29147479..1a8f4c55213 100644 +--- a/libgcc/config/aarch64/lse-init.c ++++ b/libgcc/config/aarch64/lse-init.c +@@ -23,12 +23,14 @@ a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + ++#include "auto-target.h" ++ + /* Define the symbol gating the LSE implementations. */ + _Bool __aarch64_have_lse_atomics + __attribute__((visibility("hidden"), nocommon)); + + /* Disable initialization of __aarch64_have_lse_atomics during bootstrap. */ +-#ifndef inhibit_libc ++#if !defined(inhibit_libc) && defined(HAVE_SYS_AUXV_H) + # include + + /* Disable initialization if the system headers are too old. */ +diff --git a/libgcc/configure b/libgcc/configure +old mode 100644 +new mode 100755 +index 441601a1f76..59e15a7f33f +--- a/libgcc/configure ++++ b/libgcc/configure +@@ -640,6 +640,7 @@ infodir + docdir + oldincludedir + includedir ++runstatedir + localstatedir + sharedstatedir + sysconfdir +@@ -727,6 +728,7 @@ datadir='${datarootdir}' + sysconfdir='${prefix}/etc' + sharedstatedir='${prefix}/com' + localstatedir='${prefix}/var' ++runstatedir='${localstatedir}/run' + includedir='${prefix}/include' + oldincludedir='/usr/include' + docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +@@ -978,6 +980,15 @@ do + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + ++ -runstatedir | --runstatedir | --runstatedi | --runstated \ ++ | --runstate | --runstat | --runsta | --runst | --runs \ ++ | --run | --ru | --r) ++ ac_prev=runstatedir ;; ++ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ ++ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ ++ | --run=* | --ru=* | --r=*) ++ runstatedir=$ac_optarg ;; ++ + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ +@@ -1115,7 +1126,7 @@ fi + for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ +- libdir localedir mandir ++ libdir localedir mandir runstatedir + do + eval ac_val=\$$ac_var + # Remove trailing slashes. +@@ -1270,6 +1281,7 @@ Fine tuning of the installation directories: + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] ++ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] +@@ -4088,7 +4100,7 @@ else + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) ++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4134,7 +4146,7 @@ else + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) ++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4158,7 +4170,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) ++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4203,7 +4215,7 @@ else + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) ++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4227,7 +4239,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) ++#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4339,7 +4351,7 @@ as_fn_arith $ac_cv_sizeof_long_double \* 8 && long_double_type_size=$as_val + + for ac_header in inttypes.h stdint.h stdlib.h ftw.h \ + unistd.h sys/stat.h sys/types.h \ +- string.h strings.h memory.h ++ string.h strings.h memory.h sys/auxv.h + do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` + ac_fn_c_check_header_preproc "$LINENO" "$ac_header" "$as_ac_Header" +diff --git a/libgcc/configure.ac b/libgcc/configure.ac +index 99b8e15562f..fdd25f295b1 100644 +--- a/libgcc/configure.ac ++++ b/libgcc/configure.ac +@@ -202,7 +202,7 @@ AC_SUBST(long_double_type_size) + + AC_CHECK_HEADERS(inttypes.h stdint.h stdlib.h ftw.h \ + unistd.h sys/stat.h sys/types.h \ +- string.h strings.h memory.h) ++ string.h strings.h memory.h sys/auxv.h) + AC_HEADER_STDC + + # Check for decimal float support. +-- +2.26.2 + + +From b5727f45769817cb8b7628abf5898ef840983425 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Tue, 31 Mar 2020 11:08:22 +0200 +Subject: [PATCH 19/24] aarch64: Fix up aarch64_compare_and_swaphi pattern + [PR94368] +To: gcc-patches@gcc.gnu.org + +The following testcase ICEs in final_scan_insn_1. The problem is in the +@aarch64_compare_and_swaphi define_insn_and_split, since 9 it uses +aarch64_plushi_operand predicate for the "expected value" operand, which +allows either 0..0xfff constants or 0x1000..0xf000 constants (i.e. HImode +values which when zero extended are either 0..0xfff or (0..0xfff) << 12). +The problem is that RA doesn't care about predicates, it honors just +constraints and the used constraint on the operand is n, which means any +HImode CONST_SCALAR_INT. In the testcase LRA thus propagates the -1 +value into the insn. +This is a define_insn_and_split which requires mandatory split. +But during split2 pass, we check the predicate (and don't check +constraints), which fails and thus we don't split it and during final ICE +because the mandatory splitting didn't happen. + +The following patch fixes it by adding a matching constraint to the +predicate and using it. + +2020-03-31 Jakub Jelinek + +gcc/ + PR target/94368 + * config/aarch64/constraints.md (Uph): New constraint. + * config/aarch64/atomics.md (cas_short_expected_imm): New mode attr. + (@aarch64_compare_and_swap): Use it instead of n in operand 2's + constraint. + +gcc/testsuite/ + * gcc.dg/pr94368.c: New test. + +(cherry picked from commit a27c534794dbe3530acae3427d2c58f937f1b050) +--- + gcc/config/aarch64/atomics.md | 5 ++++- + gcc/config/aarch64/constraints.md | 7 +++++++ + gcc/testsuite/gcc.dg/pr94368.c | 25 +++++++++++++++++++++++++ + 3 files changed, 36 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/gcc.dg/pr94368.c + +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 23333a803ec..05ed4cee75b 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -38,6 +38,8 @@ + + (define_mode_attr cas_short_expected_pred + [(QI "aarch64_reg_or_imm") (HI "aarch64_plushi_operand")]) ++(define_mode_attr cas_short_expected_imm ++ [(QI "n") (HI "Uph")]) + + (define_insn_and_split "aarch64_compare_and_swap" + [(set (reg:CC CC_REGNUM) ;; bool out +@@ -47,7 +49,8 @@ + (match_operand:SHORT 1 "aarch64_sync_memory_operand" "+Q"))) ;; memory + (set (match_dup 1) + (unspec_volatile:SHORT +- [(match_operand:SHORT 2 "" "rn") ;; expected ++ [(match_operand:SHORT 2 "" ++ "r") ;; expected + (match_operand:SHORT 3 "aarch64_reg_or_zero" "rZ") ;; desired + (match_operand:SI 4 "const_int_operand") ;; is_weak + (match_operand:SI 5 "const_int_operand") ;; mod_s +diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md +index 9b3c7339c54..8dfd9026752 100644 +--- a/gcc/config/aarch64/constraints.md ++++ b/gcc/config/aarch64/constraints.md +@@ -142,6 +142,13 @@ + (and (match_code "const_int") + (match_test "(unsigned) exact_log2 (ival) <= 4"))) + ++(define_constraint "Uph" ++ "@internal ++ A constraint that matches HImode integers zero extendable to ++ SImode plus_operand." ++ (and (match_code "const_int") ++ (match_test "aarch64_plushi_immediate (op, VOIDmode)"))) ++ + (define_memory_constraint "Q" + "A memory address which uses a single base register with no offset." + (and (match_code "mem") +diff --git a/gcc/testsuite/gcc.dg/pr94368.c b/gcc/testsuite/gcc.dg/pr94368.c +new file mode 100644 +index 00000000000..1267b822098 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/pr94368.c +@@ -0,0 +1,25 @@ ++/* PR target/94368 */ ++/* { dg-do compile { target fpic } } */ ++/* { dg-options "-fpic -O1 -fcommon" } */ ++ ++int b, c, d, e, f, h; ++short g; ++int foo (int) __attribute__ ((__const__)); ++ ++void ++bar (void) ++{ ++ while (1) ++ { ++ while (1) ++ { ++ __atomic_load_n (&e, 0); ++ if (foo (2)) ++ __sync_val_compare_and_swap (&c, 0, f); ++ b = 1; ++ if (h == e) ++ break; ++ } ++ __sync_val_compare_and_swap (&g, -1, f); ++ } ++} +-- +2.26.2 + + +From e98ee125c439b20329010b8a2386a252e9ca20cf Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Wed, 15 Apr 2020 11:01:19 +0200 +Subject: [PATCH 20/24] aarch64: Fix bootstrap with old binutils [PR93053] +To: gcc-patches@gcc.gnu.org + +As reported in the PR, GCC 10 (and also 9.3.1 but not 9.3.0) fails to build +when using older binutils which lack LSE support, because those instructions +are used in libgcc. +Thanks to Kyrylo's hint, the following patches (hopefully) allow it to build +even with older binutils by using .inst directive if LSE support isn't +available in the assembler. + +2020-04-15 Jakub Jelinek + +gcc/ + PR target/93053 + * configure.ac (LIBGCC_CHECK_AS_LSE): Add HAVE_AS_LSE checking. + * config/aarch64/lse.S: Include auto-target.h, if HAVE_AS_LSE + is not defined, use just .arch armv8-a. + (B, M, N, OPN): Define. + (COMMENT): New .macro. + (CAS, CASP, SWP, LDOP): Use .inst directive if HAVE_AS_LSE is not + defined. Otherwise, move the operands right after the glue? and + comment out operands where the macros are used. + * configure: Regenerated. + * config.in: Regenerated. + +(cherry picked from commit 5b2f76e36d861c881c6770b4f47c1fae6c0c8965) +--- + libgcc/config.in | 8 ++--- + libgcc/config/aarch64/lse.S | 57 ++++++++++++++++++++++++++++----- + libgcc/configure | 64 ++++++++++++++++++++++++++----------- + libgcc/configure.ac | 19 +++++++++++ + 4 files changed, 117 insertions(+), 31 deletions(-) + +diff --git a/libgcc/config.in b/libgcc/config.in +index 89d4aba3133..9009790625f 100644 +--- a/libgcc/config.in ++++ b/libgcc/config.in +@@ -1,5 +1,8 @@ + /* config.in. Generated from configure.ac by autoheader. */ + ++/* Define to 1 if the assembler supports LSE. */ ++#undef HAVE_AS_LSE ++ + /* Define to 1 if the target assembler supports thread-local storage. */ + #undef HAVE_CC_TLS + +@@ -75,11 +78,6 @@ + /* Define to 1 if the target use emutls for thread-local storage. */ + #undef USE_EMUTLS + +-/* Enable large inode numbers on Mac OS X 10.5. */ +-#ifndef _DARWIN_USE_64_BIT_INODE +-# define _DARWIN_USE_64_BIT_INODE 1 +-#endif +- + /* Number of bits in a file offset, on hosts where this is settable. */ + #undef _FILE_OFFSET_BITS + +diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S +index c7979382ad7..f7f1c19587b 100644 +--- a/libgcc/config/aarch64/lse.S ++++ b/libgcc/config/aarch64/lse.S +@@ -48,8 +48,14 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + * separately to minimize code size. + */ + ++#include "auto-target.h" ++ + /* Tell the assembler to accept LSE instructions. */ ++#ifdef HAVE_AS_LSE + .arch armv8-a+lse ++#else ++ .arch armv8-a ++#endif + + /* Declare the symbol gating the LSE implementations. */ + .hidden __aarch64_have_lse_atomics +@@ -58,12 +64,19 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + #if SIZE == 1 + # define S b + # define UXT uxtb ++# define B 0x00000000 + #elif SIZE == 2 + # define S h + # define UXT uxth ++# define B 0x40000000 + #elif SIZE == 4 || SIZE == 8 || SIZE == 16 + # define S + # define UXT mov ++# if SIZE == 4 ++# define B 0x80000000 ++# elif SIZE == 8 ++# define B 0xc0000000 ++# endif + #else + # error + #endif +@@ -72,18 +85,26 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + # define SUFF _relax + # define A + # define L ++# define M 0x000000 ++# define N 0x000000 + #elif MODEL == 2 + # define SUFF _acq + # define A a + # define L ++# define M 0x400000 ++# define N 0x800000 + #elif MODEL == 3 + # define SUFF _rel + # define A + # define L l ++# define M 0x008000 ++# define N 0x400000 + #elif MODEL == 4 + # define SUFF _acq_rel + # define A a + # define L l ++# define M 0x408000 ++# define N 0xc00000 + #else + # error + #endif +@@ -144,9 +165,13 @@ STARTFN NAME(cas) + JUMP_IF_NOT_LSE 8f + + #if SIZE < 16 +-#define CAS glue4(cas, A, L, S) ++#ifdef HAVE_AS_LSE ++# define CAS glue4(cas, A, L, S) s(0), s(1), [x2] ++#else ++# define CAS .inst 0x08a07c41 + B + M ++#endif + +- CAS s(0), s(1), [x2] ++ CAS /* s(0), s(1), [x2] */ + ret + + 8: UXT s(tmp0), s(0) +@@ -160,9 +185,13 @@ STARTFN NAME(cas) + #else + #define LDXP glue3(ld, A, xp) + #define STXP glue3(st, L, xp) +-#define CASP glue3(casp, A, L) ++#ifdef HAVE_AS_LSE ++# define CASP glue3(casp, A, L) x0, x1, x2, x3, [x4] ++#else ++# define CASP .inst 0x48207c82 + M ++#endif + +- CASP x0, x1, x2, x3, [x4] ++ CASP /* x0, x1, x2, x3, [x4] */ + ret + + 8: mov x(tmp0), x0 +@@ -181,12 +210,16 @@ ENDFN NAME(cas) + #endif + + #ifdef L_swp +-#define SWP glue4(swp, A, L, S) ++#ifdef HAVE_AS_LSE ++# define SWP glue4(swp, A, L, S) s(0), s(0), [x1] ++#else ++# define SWP .inst 0x38208020 + B + N ++#endif + + STARTFN NAME(swp) + JUMP_IF_NOT_LSE 8f + +- SWP s(0), s(0), [x1] ++ SWP /* s(0), s(0), [x1] */ + ret + + 8: mov s(tmp0), s(0) +@@ -204,24 +237,32 @@ ENDFN NAME(swp) + #ifdef L_ldadd + #define LDNM ldadd + #define OP add ++#define OPN 0x0000 + #elif defined(L_ldclr) + #define LDNM ldclr + #define OP bic ++#define OPN 0x1000 + #elif defined(L_ldeor) + #define LDNM ldeor + #define OP eor ++#define OPN 0x2000 + #elif defined(L_ldset) + #define LDNM ldset + #define OP orr ++#define OPN 0x3000 + #else + #error + #endif +-#define LDOP glue4(LDNM, A, L, S) ++#ifdef HAVE_AS_LSE ++# define LDOP glue4(LDNM, A, L, S) s(0), s(0), [x1] ++#else ++# define LDOP .inst 0x38200020 + OPN + B + N ++#endif + + STARTFN NAME(LDNM) + JUMP_IF_NOT_LSE 8f + +- LDOP s(0), s(0), [x1] ++ LDOP /* s(0), s(0), [x1] */ + ret + + 8: mov s(tmp0), s(0) +diff --git a/libgcc/configure b/libgcc/configure +index 59e15a7f33f..8b6f38eeddd 100755 +--- a/libgcc/configure ++++ b/libgcc/configure +@@ -640,7 +640,6 @@ infodir + docdir + oldincludedir + includedir +-runstatedir + localstatedir + sharedstatedir + sysconfdir +@@ -728,7 +727,6 @@ datadir='${datarootdir}' + sysconfdir='${prefix}/etc' + sharedstatedir='${prefix}/com' + localstatedir='${prefix}/var' +-runstatedir='${localstatedir}/run' + includedir='${prefix}/include' + oldincludedir='/usr/include' + docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +@@ -980,15 +978,6 @@ do + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + +- -runstatedir | --runstatedir | --runstatedi | --runstated \ +- | --runstate | --runstat | --runsta | --runst | --runs \ +- | --run | --ru | --r) +- ac_prev=runstatedir ;; +- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ +- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ +- | --run=* | --ru=* | --r=*) +- runstatedir=$ac_optarg ;; +- + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ +@@ -1126,7 +1115,7 @@ fi + for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ +- libdir localedir mandir runstatedir ++ libdir localedir mandir + do + eval ac_val=\$$ac_var + # Remove trailing slashes. +@@ -1281,7 +1270,6 @@ Fine tuning of the installation directories: + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] +- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] +@@ -4100,7 +4088,7 @@ else + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) ++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4146,7 +4134,7 @@ else + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) ++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4170,7 +4158,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) ++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4215,7 +4203,7 @@ else + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) ++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -4239,7 +4227,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) ++#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +@@ -5221,6 +5209,46 @@ if test "$enable_tls $gcc_cv_use_emutls" = "yes yes"; then + fi + + ++ ++ ++case "${target}" in ++aarch64*-*-*) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the assembler supports LSE" >&5 ++$as_echo_n "checking if the assembler supports LSE... " >&6; } ++if test "${libgcc_cv_as_lse+set}" = set; then : ++ $as_echo_n "(cached) " >&6 ++else ++ ++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext ++/* end confdefs.h. */ ++ ++int ++main () ++{ ++ asm(".arch armv8-a+lse\n\tcas w0, w1, [x2]"); ++ ++ ; ++ return 0; ++} ++_ACEOF ++if ac_fn_c_try_compile "$LINENO"; then : ++ libgcc_cv_as_lse=yes ++else ++ libgcc_cv_as_lse=no ++fi ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ++ ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libgcc_cv_as_lse" >&5 ++$as_echo "$libgcc_cv_as_lse" >&6; } ++ if test x$libgcc_cv_as_lse = xyes; then ++ ++$as_echo "#define HAVE_AS_LSE 1" >>confdefs.h ++ ++ fi ++ ;; ++esac ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for init priority support" >&5 + $as_echo_n "checking for init priority support... " >&6; } + if test "${libgcc_cv_init_priority+set}" = set; then : +diff --git a/libgcc/configure.ac b/libgcc/configure.ac +index fdd25f295b1..708ed19f8e4 100644 +--- a/libgcc/configure.ac ++++ b/libgcc/configure.ac +@@ -503,6 +503,25 @@ if test "$enable_tls $gcc_cv_use_emutls" = "yes yes"; then + fi + AC_SUBST(set_use_emutls) + ++dnl Check if as supports LSE instructions. ++AC_DEFUN([LIBGCC_CHECK_AS_LSE], [ ++case "${target}" in ++aarch64*-*-*) ++ AC_CACHE_CHECK([if the assembler supports LSE], libgcc_cv_as_lse, [ ++ AC_TRY_COMPILE([], ++changequote(,)dnl ++ asm(".arch armv8-a+lse\n\tcas w0, w1, [x2]"); ++changequote([,])dnl ++ , ++ [libgcc_cv_as_lse=yes], [libgcc_cv_as_lse=no]) ++ ]) ++ if test x$libgcc_cv_as_lse = xyes; then ++ AC_DEFINE(HAVE_AS_LSE, 1, [Define to 1 if the assembler supports LSE.]) ++ fi ++ ;; ++esac]) ++LIBGCC_CHECK_AS_LSE ++ + AC_CACHE_CHECK(for init priority support, libgcc_cv_init_priority, [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, + [[void ip (void) __attribute__ ((constructor (1)));]])], +-- +2.26.2 + + +From 37c58b17785af416b1d78ddd40ec3b1d394a584c Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Thu, 2 Apr 2020 12:57:11 +0200 +Subject: [PATCH 21/24] aarch64: Fix ICE due to + aarch64_gen_compare_reg_maybe_ze [PR94435] +To: gcc-patches@gcc.gnu.org + +The following testcase ICEs, because aarch64_gen_compare_reg_maybe_ze emits +invalid RTL. +For y_mode [QH]Imode it expects y to be of that mode (or CONST_INT that fits +into that mode) and x being SImode; for non-CONST_INT y it zero extends y +into SImode and compares that against x, for CONST_INT y it zero extends y +into SImode. The problem is that when the zero extended constant isn't +usable directly, it forces it into a REG, but with y_mode mode, and then +compares against y. That is wrong, because it should force it into a SImode +REG and compare that way. + +2020-04-02 Jakub Jelinek + +gcc/ + PR target/94435 + * config/aarch64/aarch64.c (aarch64_gen_compare_reg_maybe_ze): For + y_mode E_[QH]Imode and y being a CONST_INT, change y_mode to SImode. + +gcc/testsuite/ + * gcc.target/aarch64/pr94435.c: New test. + +(cherry picked from commit df562b12d90699c20923f91df48eed08ebcb572e) +--- + gcc/config/aarch64/aarch64.c | 5 ++++- + gcc/testsuite/gcc.target/aarch64/pr94435.c | 25 ++++++++++++++++++++++ + 2 files changed, 29 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/gcc.target/aarch64/pr94435.c + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 5ccb13b46fe..a0685a5ad41 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -1230,7 +1230,10 @@ aarch64_gen_compare_reg_maybe_ze (RTX_CODE code, rtx x, rtx y, + if (y_mode == QImode || y_mode == HImode) + { + if (CONST_INT_P (y)) +- y = GEN_INT (INTVAL (y) & GET_MODE_MASK (y_mode)); ++ { ++ y = GEN_INT (INTVAL (y) & GET_MODE_MASK (y_mode)); ++ y_mode = SImode; ++ } + else + { + rtx t, cc_reg; +diff --git a/gcc/testsuite/gcc.target/aarch64/pr94435.c b/gcc/testsuite/gcc.target/aarch64/pr94435.c +new file mode 100644 +index 00000000000..5713c14d5f9 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/aarch64/pr94435.c +@@ -0,0 +1,25 @@ ++/* PR target/94435 */ ++/* { dg-do compile } */ ++/* { dg-options "-march=armv8-a+nolse -moutline-atomics" } */ ++ ++int b, c, d, e, f, h; ++short g; ++int foo (int) __attribute__ ((__const__)); ++ ++void ++bar (void) ++{ ++ while (1) ++ { ++ while (1) ++ { ++ __atomic_load_n (&e, 0); ++ if (foo (2)) ++ __sync_val_compare_and_swap (&c, 0, f); ++ b = 1; ++ if (h == e) ++ break; ++ } ++ __sync_val_compare_and_swap (&g, -1, f); ++ } ++} +-- +2.26.2 + + +From 57927b2e7e2aa9c7ae703a110cc86dfc40e7659c Mon Sep 17 00:00:00 2001 +From: Prathamesh Kulkarni +Date: Wed, 21 Aug 2019 18:34:43 +0000 +Subject: [PATCH 22/24] re PR target/90724 (ICE with + __sync_bool_compare_and_swap with -march=armv8.2-a+sve) +To: gcc-patches@gcc.gnu.org + +2019-08-21 Prathamesh Kulkarni + +gcc/ + PR target/90724 + * config/aarch64/aarch64.c (aarch64_gen_compare_reg_maybe_ze): Force y + in reg if it fails aarch64_plus_operand predicate. + +(cherry picked from commit 846f78d414101dbd33ff9c370d379bae73ae0efa) +--- + gcc/config/aarch64/aarch64.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index a0685a5ad41..9535d688ee5 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -1248,6 +1248,9 @@ aarch64_gen_compare_reg_maybe_ze (RTX_CODE code, rtx x, rtx y, + } + } + ++ if (!aarch64_plus_operand (y, y_mode)) ++ y = force_reg (y_mode, y); ++ + return aarch64_gen_compare_reg (code, x, y); + } + +-- +2.26.2 + + +From d019077cc8d3c18bc510aeaf34c6c4532913f378 Mon Sep 17 00:00:00 2001 +From: Andre Vieira +Date: Tue, 28 Apr 2020 13:25:43 +0100 +Subject: [PATCH 23/24] aarch64: Fix for PR target/94814 +To: gcc-patches@gcc.gnu.org + +Backport of PR target/94518: Fix memmodel index in aarch64_store_exclusive_pair + +2020-04-28 Andre Vieira + + PR target/94814 + Backport from gcc-9. + 2020-04-07 Kyrylo Tkachov + + PR target/94518 + 2019-09-23 Richard Sandiford + +gcc/ + * config/aarch64/atomics.md (aarch64_store_exclusive_pair): Fix + memmodel index. + +(cherry picked from commit 3a30d2558b3a199fe346479e6140cddae7fba5ed) +--- + gcc/config/aarch64/atomics.md | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/atomics.md b/gcc/config/aarch64/atomics.md +index 05ed4cee75b..1fdc3092a33 100644 +--- a/gcc/config/aarch64/atomics.md ++++ b/gcc/config/aarch64/atomics.md +@@ -752,7 +752,7 @@ + UNSPECV_SX))] + "" + { +- enum memmodel model = memmodel_from_int (INTVAL (operands[3])); ++ enum memmodel model = memmodel_from_int (INTVAL (operands[4])); + if (is_mm_relaxed (model) || is_mm_consume (model) || is_mm_acquire (model)) + return "stxp\t%w0, %x2, %x3, %1"; + else +-- +2.26.2 + + +From 7c216ba945cb92bd79fbe01b35e16bd1e3cd854d Mon Sep 17 00:00:00 2001 +From: Andre Vieira +Date: Wed, 29 Apr 2020 15:42:27 +0100 +Subject: [PATCH 24/24] aarch64: Force TImode values into even registers +To: gcc-patches@gcc.gnu.org + +The LSE CASP instruction requires values to be placed in even +register pairs. A solution involving two additional register +classes was rejected in favor of the much simpler solution of +simply requiring all TImode values to be aligned. + +gcc/ChangeLog: +2020-04-29 Andre Vieira + + Backport from mainline. + 2018-10-31 Richard Henderson + + * config/aarch64/aarch64.c (aarch64_hard_regno_mode_ok): Force + 16-byte modes held in GP registers to use an even regno. + +(cherry picked from commit 563cc649beaf11d707c422e5f4e9e5cdacb818c3) +--- + gcc/config/aarch64/aarch64.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c +index 9535d688ee5..643ba7e8153 100644 +--- a/gcc/config/aarch64/aarch64.c ++++ b/gcc/config/aarch64/aarch64.c +@@ -1084,10 +1084,14 @@ aarch64_hard_regno_mode_ok (unsigned regno, machine_mode mode) + if (regno == FRAME_POINTER_REGNUM || regno == ARG_POINTER_REGNUM) + return mode == Pmode; + +- if (GP_REGNUM_P (regno) && ! aarch64_vect_struct_mode_p (mode)) +- return 1; +- +- if (FP_REGNUM_P (regno)) ++ if (GP_REGNUM_P (regno)) ++ { ++ if (GET_MODE_SIZE (mode) <= 8) ++ return true; ++ if (GET_MODE_SIZE (mode) <= 16) ++ return (regno & 1) == 0; ++ } ++ else if (FP_REGNUM_P (regno)) + { + if (aarch64_vect_struct_mode_p (mode)) + return +-- +2.26.2 + +commit 1266778548e20de82983b6446f3cb685068cfb1e +Author: Kyrylo Tkachov +Date: Wed May 6 16:20:38 2020 +0100 + + [AArch64] Use __getauxval instead of getauxval in LSE detection code in libgcc + + This version of the fix uses __getauxval instead of getauxval. + The whole thing is guarded simply on __gnu_linux__. + __getauxval was introduced in 2.16 but the aarch64 port was added in 2.17 so in practice I expect all aarch64 glibcs to support __getauxval. + + Bootstrapped and tested on aarch64-none-linux-gnu. + Also tested on aarch64-none-elf. + + 2020-05-06 Kyrylo Tkachov + + * config/aarch64/lse-init.c (init_have_lse_atomics): Use __getauxval + instead of getauxval. + (AT_HWCAP): Define. + (HWCAP_ATOMICS): Define. + Guard detection on __gnu_linux__. + +diff --git a/libgcc/config/aarch64/lse-init.c b/libgcc/config/aarch64/lse-init.c +index 74acef25cce..00e9ab8cd1c 100644 +--- a/libgcc/config/aarch64/lse-init.c ++++ b/libgcc/config/aarch64/lse-init.c +@@ -29,19 +29,20 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + _Bool __aarch64_have_lse_atomics + __attribute__((visibility("hidden"), nocommon)); + +-/* Disable initialization of __aarch64_have_lse_atomics during bootstrap. */ +-#if !defined(inhibit_libc) && defined(HAVE_SYS_AUXV_H) +-# include ++/* Gate availability of __getauxval on glibc. All AArch64-supporting glibc ++ versions support it. */ ++#ifdef __gnu_linux__ + +-/* Disable initialization if the system headers are too old. */ +-# if defined(AT_HWCAP) && defined(HWCAP_ATOMICS) ++# define AT_HWCAP 16 ++# define HWCAP_ATOMICS (1 << 8) ++ ++unsigned long int __getauxval (unsigned long int); + + static void __attribute__((constructor)) + init_have_lse_atomics (void) + { +- unsigned long hwcap = getauxval (AT_HWCAP); ++ unsigned long hwcap = __getauxval (AT_HWCAP); + __aarch64_have_lse_atomics = (hwcap & HWCAP_ATOMICS) != 0; + } + +-# endif /* HWCAP */ +-#endif /* inhibit_libc */ ++#endif /* __gnu_linux__ */ diff --git a/gcc7-aarch64-sls-miti-1.patch b/gcc7-aarch64-sls-miti-1.patch new file mode 100644 index 0000000..0755dfe --- /dev/null +++ b/gcc7-aarch64-sls-miti-1.patch @@ -0,0 +1,193 @@ +Backport to gcc7 of the below commit for bsc#1172798 + +commit 20da13e395bde597d8337167c712039c8f923c3b +Author: Matthew Malcomson +Date: Thu Jul 9 09:11:58 2020 +0100 + + aarch64: New Straight Line Speculation (SLS) mitigation flags + + Here we introduce the flags that will be used for straight line speculation. + + The new flag introduced is `-mharden-sls=`. + This flag can take arguments of `none`, `all`, or a comma seperated list + of one or more of `retbr` or `blr`. + `none` indicates no special mitigation of the straight line speculation + vulnerability. + `all` requests all mitigations currently implemented. + `retbr` requests that the RET and BR instructions have a speculation + barrier inserted after them. + `blr` requests that BLR instructions are replaced by a BL to a function + stub using a BR with a speculation barrier after it. + + Setting this on a per-function basis using attributes or the like is not + enabled, but may be in the future. + + (cherry picked from commit a9ba2a9b77bec7eacaf066801f22d1c366a2bc86) + + gcc/ChangeLog: + + 2020-06-02 Matthew Malcomson + + * config/aarch64/aarch64-protos.h (aarch64_harden_sls_retbr_p): + New. + (aarch64_harden_sls_blr_p): New. + * config/aarch64/aarch64.c (enum aarch64_sls_hardening_type): + New. + (aarch64_harden_sls_retbr_p): New. + (aarch64_harden_sls_blr_p): New. + (aarch64_validate_sls_mitigation): New. + (aarch64_override_options): Parse options for SLS mitigation. + * config/aarch64/aarch64.opt (-mharden-sls): New option. + * doc/invoke.texi: Document new option. + +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-protos.h +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64-protos.h ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-protos.h +@@ -485,4 +485,7 @@ extern const atomic_ool_names aarch64_oo + extern const atomic_ool_names aarch64_ool_ldclr_names; + extern const atomic_ool_names aarch64_ool_ldeor_names; + ++extern bool aarch64_harden_sls_retbr_p (void); ++extern bool aarch64_harden_sls_blr_p (void); ++ + #endif /* GCC_AARCH64_PROTOS_H */ +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.c ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +@@ -8814,6 +8814,79 @@ aarch64_validate_mcpu (const char *str, + return false; + } + ++/* Straight line speculation indicators. */ ++enum aarch64_sls_hardening_type ++{ ++ SLS_NONE = 0, ++ SLS_RETBR = 1, ++ SLS_BLR = 2, ++ SLS_ALL = 3, ++}; ++static enum aarch64_sls_hardening_type aarch64_sls_hardening; ++ ++/* Return whether we should mitigatate Straight Line Speculation for the RET ++ and BR instructions. */ ++bool ++aarch64_harden_sls_retbr_p (void) ++{ ++ return aarch64_sls_hardening & SLS_RETBR; ++} ++ ++/* Return whether we should mitigatate Straight Line Speculation for the BLR ++ instruction. */ ++bool ++aarch64_harden_sls_blr_p (void) ++{ ++ return aarch64_sls_hardening & SLS_BLR; ++} ++ ++/* As of yet we only allow setting these options globally, in the future we may ++ allow setting them per function. */ ++static void ++aarch64_validate_sls_mitigation (const char *const_str) ++{ ++ char *token_save = NULL; ++ char *str = NULL; ++ ++ if (strcmp (const_str, "none") == 0) ++ { ++ aarch64_sls_hardening = SLS_NONE; ++ return; ++ } ++ if (strcmp (const_str, "all") == 0) ++ { ++ aarch64_sls_hardening = SLS_ALL; ++ return; ++ } ++ ++ char *str_root = xstrdup (const_str); ++ str = strtok_r (str_root, ",", &token_save); ++ if (!str) ++ error ("invalid argument given to %<-mharden-sls=%>"); ++ ++ int temp = SLS_NONE; ++ while (str) ++ { ++ if (strcmp (str, "blr") == 0) ++ temp |= SLS_BLR; ++ else if (strcmp (str, "retbr") == 0) ++ temp |= SLS_RETBR; ++ else if (strcmp (str, "none") == 0 || strcmp (str, "all") == 0) ++ { ++ error ("%<%s%> must be by itself for %<-mharden-sls=%>", str); ++ break; ++ } ++ else ++ { ++ error ("invalid argument %<%s%> for %<-mharden-sls=%>", str); ++ break; ++ } ++ str = strtok_r (NULL, ",", &token_save); ++ } ++ aarch64_sls_hardening = (aarch64_sls_hardening_type) temp; ++ free (str_root); ++} ++ + /* Validate a command-line -march option. Parse the arch and extensions + (if any) specified in STR and throw errors if appropriate. Put the + results, if they are valid, in RES and ISA_FLAGS. Return whether the +@@ -8930,6 +9003,9 @@ aarch64_override_options (void) + selected_arch = NULL; + selected_tune = NULL; + ++ if (aarch64_harden_sls_string) ++ aarch64_validate_sls_mitigation (aarch64_harden_sls_string); ++ + /* -mcpu=CPU is shorthand for -march=ARCH_FOR_CPU, -mtune=CPU. + If either of -march or -mtune is given, they override their + respective component of -mcpu. */ +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.opt +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.opt ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.opt +@@ -68,6 +68,10 @@ mgeneral-regs-only + Target Report RejectNegative Mask(GENERAL_REGS_ONLY) Save + Generate code which uses only the general registers. + ++mharden-sls= ++Target RejectNegative Joined Var(aarch64_harden_sls_string) ++Generate code to mitigate against straight line speculation. ++ + mfix-cortex-a53-835769 + Target Report Var(aarch64_fix_a53_err835769) Init(2) Save + Workaround for ARM Cortex-A53 Erratum number 835769. +Index: gcc-7.5.0+r278197/gcc/doc/invoke.texi +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/doc/invoke.texi ++++ gcc-7.5.0+r278197/gcc/doc/invoke.texi +@@ -589,6 +589,7 @@ Objective-C and Objective-C++ Dialects}. + -mlow-precision-recip-sqrt -mno-low-precision-recip-sqrt@gol + -mlow-precision-sqrt -mno-low-precision-sqrt@gol + -mlow-precision-div -mno-low-precision-div @gol ++-mharden-sls=@var{opts} @gol + -march=@var{name} -mcpu=@var{name} -mtune=@var{name}} + + @emph{Adapteva Epiphany Options} +@@ -14143,6 +14144,17 @@ Permissible values are @samp{none}, whic + functions, and @samp{all}, which enables pointer signing for all functions. The + default value is @samp{none}. + ++@item -mharden-sls=@var{opts} ++@opindex mharden-sls ++Enable compiler hardening against straight line speculation (SLS). ++@var{opts} is a comma-separated list of the following options: ++@table @samp ++@item retbr ++@item blr ++@end table ++In addition, @samp{-mharden-sls=all} enables all SLS hardening while ++@samp{-mharden-sls=none} disables all SLS hardening. ++ + @end table + + @subsubsection @option{-march} and @option{-mcpu} Feature Modifiers diff --git a/gcc7-aarch64-sls-miti-2.patch b/gcc7-aarch64-sls-miti-2.patch new file mode 100644 index 0000000..29b0441 --- /dev/null +++ b/gcc7-aarch64-sls-miti-2.patch @@ -0,0 +1,606 @@ +Backport of below commit for bsc#1172798 +Also adds the AARCH64_FL_SB support, not originally part of +this commit. And the added test sls-miti-retbr.c has -mbranch-protection +removed as that's not supported by our gcc7. + +commit dc586a749228ecfb71f72ec2ca10e6f7b6874af3 +Author: Matthew Malcomson +Date: Thu Jul 9 09:11:59 2020 +0100 + + aarch64: Introduce SLS mitigation for RET and BR instructions + + Instructions following RET or BR are not necessarily executed. In order + to avoid speculation past RET and BR we can simply append a speculation + barrier. + + Since these speculation barriers will not be architecturally executed, + they are not expected to add a high performance penalty. + + The speculation barrier is to be SB when targeting architectures which + have this enabled, and DSB SY + ISB otherwise. + + We add tests for each of the cases where such an instruction was seen. + + This is implemented by modifying each machine description pattern that + emits either a RET or a BR instruction. We choose not to use something + like `TARGET_ASM_FUNCTION_EPILOGUE` since it does not affect the + `indirect_jump`, `jump`, `sibcall_insn` and `sibcall_value_insn` + patterns and we find it preferable to implement the functionality in the + same way for every pattern. + + There is one particular case which is slightly tricky. The + implementation of TARGET_ASM_TRAMPOLINE_TEMPLATE uses a BR which needs + to be mitigated against. The trampoline template is used *once* per + compilation unit, and the TRAMPOLINE_SIZE is exposed to the user via the + builtin macro __LIBGCC_TRAMPOLINE_SIZE__. + In the future we may implement function specific attributes to turn on + and off hardening on a per-function basis. + The fixed nature of the trampoline described above implies it will be + safer to ensure this speculation barrier is always used. + + Testing: + Bootstrap and regtest done on aarch64-none-linux + Used a temporary hack(1) to use these options on every test in the + testsuite and a script to check that the output never emitted an + unmitigated RET or BR. + + 1) Temporary hack was a change to the testsuite to always use + `-save-temps` and run a script on the assembly output of those + compilations which produced one to ensure every RET or BR is immediately + followed by a speculation barrier. + + (cherry picked from be178ecd5ac1fe1510d960ff95c66d0ff831afe1) + + gcc/ChangeLog: + + * config/aarch64/aarch64-protos.h (aarch64_sls_barrier): New. + * config/aarch64/aarch64.c (aarch64_output_casesi): Emit + speculation barrier after BR instruction if needs be. + (aarch64_trampoline_init): Handle ptr_mode value & adjust size + of code copied. + (aarch64_sls_barrier): New. + (aarch64_asm_trampoline_template): Add needed barriers. + * config/aarch64/aarch64.h (AARCH64_ISA_SB): New. + (TARGET_SB): New. + (TRAMPOLINE_SIZE): Account for barrier. + * config/aarch64/aarch64.md (indirect_jump, *casesi_dispatch, + simple_return, *do_return, *sibcall_insn, *sibcall_value_insn): + Emit barrier if needs be, also account for possible barrier using + "sls_length" attribute. + (sls_length): New attribute. + (length): Determine default using any non-default sls_length + value. + + gcc/testsuite/ChangeLog: + + * gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c: New test. + * gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c: + New test. + * gcc.target/aarch64/sls-mitigation/sls-mitigation.exp: New file. + * lib/target-supports.exp (check_effective_target_aarch64_asm_sb_ok): + New proc. + +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-protos.h +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64-protos.h ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-protos.h +@@ -485,6 +485,7 @@ extern const atomic_ool_names aarch64_oo + extern const atomic_ool_names aarch64_ool_ldclr_names; + extern const atomic_ool_names aarch64_ool_ldeor_names; + ++const char *aarch64_sls_barrier (int); + extern bool aarch64_harden_sls_retbr_p (void); + extern bool aarch64_harden_sls_blr_p (void); + +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.c ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +@@ -5736,15 +5736,28 @@ aarch64_asm_trampoline_template (FILE *f + { + if (TARGET_ILP32) + { +- asm_fprintf (f, "\tldr\tw%d, .+16\n", IP1_REGNUM - R0_REGNUM); +- asm_fprintf (f, "\tldr\tw%d, .+16\n", STATIC_CHAIN_REGNUM - R0_REGNUM); ++ asm_fprintf (f, "\tldr\tw%d, .+24\n", IP1_REGNUM - R0_REGNUM); ++ asm_fprintf (f, "\tldr\tw%d, .+24\n", STATIC_CHAIN_REGNUM - R0_REGNUM); + } + else + { +- asm_fprintf (f, "\tldr\t%s, .+16\n", reg_names [IP1_REGNUM]); +- asm_fprintf (f, "\tldr\t%s, .+20\n", reg_names [STATIC_CHAIN_REGNUM]); ++ asm_fprintf (f, "\tldr\t%s, .+24\n", reg_names [IP1_REGNUM]); ++ asm_fprintf (f, "\tldr\t%s, .+28\n", reg_names [STATIC_CHAIN_REGNUM]); + } + asm_fprintf (f, "\tbr\t%s\n", reg_names [IP1_REGNUM]); ++ ++ /* We always emit a speculation barrier. ++ This is because the same trampoline template is used for every nested ++ function. Since nested functions are not particularly common or ++ performant we don't worry too much about the extra instructions to copy ++ around. ++ This is not yet a problem, since we have not yet implemented function ++ specific attributes to choose between hardening against straight line ++ speculation or not, but such function specific attributes are likely to ++ happen in the future. */ ++ asm_fprintf (f, "\tdsb\tsy\n\tisb\n"); ++ ++ /* Padding for BTI at the beginning, which our gcc-7 backports don't do */ + assemble_aligned_integer (4, const0_rtx); + assemble_aligned_integer (POINTER_BYTES, const0_rtx); + assemble_aligned_integer (POINTER_BYTES, const0_rtx); +@@ -5754,10 +5767,14 @@ static void + aarch64_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) + { + rtx fnaddr, mem, a_tramp; +- const int tramp_code_sz = 16; ++ const int tramp_code_sz = 24; + + /* Don't need to copy the trailing D-words, we fill those in below. */ +- emit_block_move (m_tramp, assemble_trampoline_template (), ++ /* We create our own memory address in Pmode so that `emit_block_move` can ++ use parts of the backend which expect Pmode addresses. */ ++ rtx temp = convert_memory_address (Pmode, XEXP (m_tramp, 0)); ++ emit_block_move (gen_rtx_MEM (BLKmode, temp), ++ assemble_trampoline_template (), + GEN_INT (tramp_code_sz), BLOCK_OP_NORMAL); + mem = adjust_address (m_tramp, ptr_mode, tramp_code_sz); + fnaddr = XEXP (DECL_RTL (fndecl), 0); +@@ -5936,6 +5953,8 @@ aarch64_output_casesi (rtx *operands) + output_asm_insn (buf, operands); + output_asm_insn (patterns[index][1], operands); + output_asm_insn ("br\t%3", operands); ++ output_asm_insn (aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()), ++ operands); + assemble_label (asm_out_file, label); + return ""; + } +@@ -14664,6 +14683,22 @@ aarch64_sched_can_speculate_insn (rtx_in + } + } + ++/* Helper function for straight line speculation. ++ Return what barrier should be emitted for straight line speculation ++ mitigation. ++ When not mitigating against straight line speculation this function returns ++ an empty string. ++ When mitigating against straight line speculation, use: ++ * SB when the v8.5-A SB extension is enabled. ++ * DSB+ISB otherwise. */ ++const char * ++aarch64_sls_barrier (int mitigation_required) ++{ ++ return mitigation_required ++ ? (TARGET_SB ? "sb" : "dsb\tsy\n\tisb") ++ : ""; ++} ++ + /* Target-specific selftests. */ + + #if CHECKING_P +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.h +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.h ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.h +@@ -141,6 +141,9 @@ extern unsigned aarch64_architecture_ver + /* ARMv8.3-A architecture extensions. */ + #define AARCH64_FL_V8_3 (1 << 10) /* Has ARMv8.3-A features. */ + ++/* Speculation Barrier instruction supported. */ ++#define AARCH64_FL_SB (1 << 25) ++ + /* Has FP and SIMD. */ + #define AARCH64_FL_FPSIMD (AARCH64_FL_FP | AARCH64_FL_SIMD) + +@@ -168,6 +171,8 @@ extern unsigned aarch64_architecture_ver + #define AARCH64_ISA_F16 (aarch64_isa_flags & AARCH64_FL_F16) + #define AARCH64_ISA_V8_3 (aarch64_isa_flags & AARCH64_FL_V8_3) + ++#define AARCH64_ISA_SB (aarch64_isa_flags & AARCH64_FL_SB) ++ + /* Crypto is an optional extension to AdvSIMD. */ + #define TARGET_CRYPTO (TARGET_SIMD && AARCH64_ISA_CRYPTO) + +@@ -193,6 +198,9 @@ extern unsigned aarch64_architecture_ver + #define TARGET_FIX_ERR_A53_835769_DEFAULT 1 + #endif + ++/* SB instruction is enabled through +sb. */ ++#define TARGET_SB (AARCH64_ISA_SB) ++ + /* Apply the workaround for Cortex-A53 erratum 835769. */ + #define TARGET_FIX_ERR_A53_835769 \ + ((aarch64_fix_a53_err835769 == 2) \ +@@ -805,8 +813,10 @@ typedef struct + + #define RETURN_ADDR_RTX aarch64_return_addr + +-/* 3 insns + padding + 2 pointer-sized entries. */ +-#define TRAMPOLINE_SIZE (TARGET_ILP32 ? 24 : 32) ++/* BTI c + 3 insns ++ + sls barrier of DSB + ISB. ++ + 2 pointer-sized entries. */ ++#define TRAMPOLINE_SIZE (24 + (TARGET_ILP32 ? 8 : 16)) + + /* Trampolines contain dwords, so must be dword aligned. */ + #define TRAMPOLINE_ALIGNMENT 64 +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.md +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.md ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.md +@@ -187,8 +187,23 @@ + ;; will be disabled when !TARGET_SIMD. + (define_attr "simd" "no,yes" (const_string "no")) + ++;; Attribute to specify that an alternative has the length of a single ++;; instruction plus a speculation barrier. ++(define_attr "sls_length" "none,retbr,casesi" (const_string "none")) ++ + (define_attr "length" "" +- (const_int 4)) ++ (cond [ ++ (eq_attr "sls_length" "retbr") ++ (cond [(match_test "!aarch64_harden_sls_retbr_p ()") (const_int 4) ++ (match_test "TARGET_SB") (const_int 8)] ++ (const_int 12)) ++ ++ (eq_attr "sls_length" "casesi") ++ (cond [(match_test "!aarch64_harden_sls_retbr_p ()") (const_int 16) ++ (match_test "TARGET_SB") (const_int 20)] ++ (const_int 24)) ++ ] ++ (const_int 4))) + + ;; Attribute that controls whether an alternative is enabled or not. + ;; Currently it is only used to disable alternatives which touch fp or simd +@@ -235,8 +250,12 @@ + (define_insn "indirect_jump" + [(set (pc) (match_operand:DI 0 "register_operand" "r"))] + "" +- "br\\t%0" +- [(set_attr "type" "branch")] ++ { ++ output_asm_insn ("br\\t%0", operands); ++ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); ++ } ++ [(set_attr "type" "branch") ++ (set_attr "sls_length" "retbr")] + ) + + (define_insn "jump" +@@ -508,7 +527,7 @@ + "* + return aarch64_output_casesi (operands); + " +- [(set_attr "length" "16") ++ [(set_attr "sls_length" "casesi") + (set_attr "type" "branch")] + ) + +@@ -583,14 +602,18 @@ + [(return)] + "" + { ++ const char *ret = NULL; + if (aarch64_return_address_signing_enabled () + && TARGET_ARMV8_3 + && !crtl->calls_eh_return) +- return "retaa"; +- +- return "ret"; ++ ret = "retaa"; ++ else ++ ret = "ret"; ++ output_asm_insn (ret, operands); ++ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); + } +- [(set_attr "type" "branch")] ++ [(set_attr "type" "branch") ++ (set_attr "sls_length" "retbr")] + ) + + (define_expand "return" +@@ -602,8 +625,12 @@ + (define_insn "simple_return" + [(simple_return)] + "" +- "ret" +- [(set_attr "type" "branch")] ++ { ++ output_asm_insn ("ret", operands); ++ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); ++ } ++ [(set_attr "type" "branch") ++ (set_attr "sls_length" "retbr")] + ) + + (define_insn "*cb1" +@@ -903,10 +930,16 @@ + (return) + (use (match_operand 2 "" ""))] + "SIBLING_CALL_P (insn)" +- "@ +- br\\t%0 +- b\\t%a0" +- [(set_attr "type" "branch, branch")] ++ { ++ if (which_alternative == 0) ++ { ++ output_asm_insn ("br\\t%0", operands); ++ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); ++ } ++ return "b\\t%c0"; ++ } ++ [(set_attr "type" "branch, branch") ++ (set_attr "sls_length" "retbr,none")] + ) + + (define_insn "*sibcall_value_insn" +@@ -917,10 +950,16 @@ + (return) + (use (match_operand 3 "" ""))] + "SIBLING_CALL_P (insn)" +- "@ +- br\\t%1 +- b\\t%a1" +- [(set_attr "type" "branch, branch")] ++ { ++ if (which_alternative == 0) ++ { ++ output_asm_insn ("br\\t%1", operands); ++ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()); ++ } ++ return "b\\t%c1"; ++ } ++ [(set_attr "type" "branch, branch") ++ (set_attr "sls_length" "retbr,none")] + ) + + ;; Call subroutine returning any type. +Index: gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c +=================================================================== +--- /dev/null ++++ gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c +@@ -0,0 +1,15 @@ ++/* Avoid ILP32 since pacret is only available for LP64 */ ++/* { dg-do compile { target { ! ilp32 } } } */ ++/* { dg-additional-options "-mharden-sls=retbr -march=armv8.3-a" } */ ++ ++/* Testing the do_return pattern for retaa. */ ++long retbr_subcall(void); ++long retbr_do_return_retaa(void) ++{ ++ return retbr_subcall()+1; ++} ++ ++/* Ensure there are no BR or RET instructions which are not directly followed ++ by a speculation barrier. */ ++/* { dg-final { scan-assembler-not {\t(br|ret|retaa)\tx[0-9][0-9]?\n\t(?!dsb\tsy\n\tisb)} } } */ ++/* { dg-final { scan-assembler-not {ret\t} } } */ +Index: gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c +=================================================================== +--- /dev/null ++++ gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c +@@ -0,0 +1,119 @@ ++/* We ensure that -Wpedantic is off since it complains about the trampolines ++ we explicitly want to test. */ ++/* { dg-additional-options "-mharden-sls=retbr -Wno-pedantic " } */ ++/* ++ Ensure that the SLS hardening of RET and BR leaves no unprotected RET/BR ++ instructions. ++ */ ++typedef int (foo) (int, int); ++typedef void (bar) (int, int); ++struct sls_testclass { ++ foo *x; ++ bar *y; ++ int left; ++ int right; ++}; ++ ++int ++retbr_sibcall_value_insn (struct sls_testclass x) ++{ ++ return x.x(x.left, x.right); ++} ++ ++void ++retbr_sibcall_insn (struct sls_testclass x) ++{ ++ x.y(x.left, x.right); ++} ++ ++/* Aim to test two different returns. ++ One that introduces a tail call in the middle of the function, and one that ++ has a normal return. */ ++int ++retbr_multiple_returns (struct sls_testclass x) ++{ ++ int temp; ++ if (x.left % 10) ++ return x.x(x.left, 100); ++ else if (x.right % 20) ++ { ++ return x.x(x.left * x.right, 100); ++ } ++ temp = x.left % x.right; ++ temp *= 100; ++ temp /= 2; ++ return temp % 3; ++} ++ ++void ++retbr_multiple_returns_void (struct sls_testclass x) ++{ ++ if (x.left % 10) ++ { ++ x.y(x.left, 100); ++ } ++ else if (x.right % 20) ++ { ++ x.y(x.left * x.right, 100); ++ } ++ return; ++} ++ ++/* Testing the casesi jump via register. */ ++__attribute__ ((optimize ("Os"))) ++int ++retbr_casesi_dispatch (struct sls_testclass x) ++{ ++ switch (x.left) ++ { ++ case -5: ++ return -2; ++ case -3: ++ return -1; ++ case 0: ++ return 0; ++ case 3: ++ return 1; ++ case 5: ++ break; ++ default: ++ __builtin_unreachable (); ++ } ++ return x.right; ++} ++ ++/* Testing the BR in trampolines is mitigated against. */ ++void f1 (void *); ++void f3 (void *, void (*)(void *)); ++void f2 (void *); ++ ++int ++retbr_trampolines (void *a, int b) ++{ ++ if (!b) ++ { ++ f1 (a); ++ return 1; ++ } ++ if (b) ++ { ++ void retbr_tramp_internal (void *c) ++ { ++ if (c == a) ++ f2 (c); ++ } ++ f3 (a, retbr_tramp_internal); ++ } ++ return 0; ++} ++ ++/* Testing the indirect_jump pattern. */ ++void ++retbr_indirect_jump (int *buf) ++{ ++ __builtin_longjmp(buf, 1); ++} ++ ++/* Ensure there are no BR or RET instructions which are not directly followed ++ by a speculation barrier. */ ++/* { dg-final { scan-assembler-not {\t(br|ret|retaa)\tx[0-9][0-9]?\n\t(?!dsb\tsy\n\tisb|sb)} } } */ +Index: gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-mitigation.exp +=================================================================== +--- /dev/null ++++ gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-mitigation.exp +@@ -0,0 +1,73 @@ ++# Regression driver for SLS mitigation on AArch64. ++# Copyright (C) 2020 Free Software Foundation, Inc. ++# Contributed by ARM Ltd. ++# ++# This file is part of GCC. ++# ++# GCC is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3, or (at your option) ++# any later version. ++# ++# GCC is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GCC; see the file COPYING3. If not see ++# . */ ++ ++# Exit immediately if this isn't an AArch64 target. ++if {![istarget aarch64*-*-*] } then { ++ return ++} ++ ++# Load support procs. ++load_lib gcc-dg.exp ++load_lib torture-options.exp ++ ++# If a testcase doesn't have special options, use these. ++global DEFAULT_CFLAGS ++if ![info exists DEFAULT_CFLAGS] then { ++ set DEFAULT_CFLAGS " " ++} ++ ++# Initialize `dg'. ++dg-init ++torture-init ++ ++# Use different architectures as well as the normal optimisation options. ++# (i.e. use both SB and DSB+ISB barriers). ++ ++set save-dg-do-what-default ${dg-do-what-default} ++# Main loop. ++# Run with torture tests (i.e. a bunch of different optimisation levels) just ++# to increase test coverage. ++set dg-do-what-default assemble ++gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ ++ "-save-temps" $DEFAULT_CFLAGS ++ ++# Run the same tests but this time with SB extension. ++# Since not all supported assemblers will support that extension we decide ++# whether to assemble or just compile based on whether the extension is ++# supported for the available assembler. ++ ++set templist {} ++foreach x $DG_TORTURE_OPTIONS { ++ lappend templist "$x -march=armv8.3-a+sb " ++ lappend templist "$x -march=armv8-a+sb " ++} ++set-torture-options $templist ++if { [check_effective_target_aarch64_asm_sb_ok] } { ++ set dg-do-what-default assemble ++} else { ++ set dg-do-what-default compile ++} ++gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \ ++ "-save-temps" $DEFAULT_CFLAGS ++set dg-do-what-default ${save-dg-do-what-default} ++ ++# All done. ++torture-finish ++dg-finish +Index: gcc-7.5.0+r278197/gcc/testsuite/lib/target-supports.exp +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/testsuite/lib/target-supports.exp ++++ gcc-7.5.0+r278197/gcc/testsuite/lib/target-supports.exp +@@ -7929,7 +7929,7 @@ proc check_effective_target_aarch64_tiny + # Create functions to check that the AArch64 assembler supports the + # various architecture extensions via the .arch_extension pseudo-op. + +-foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse"} { ++foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse" "sb"} { + eval [string map [list FUNC $aarch64_ext] { + proc check_effective_target_aarch64_asm_FUNC_ok { } { + if { [istarget aarch64*-*-*] } { +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-option-extensions.def +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64-option-extensions.def ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-option-extensions.def +@@ -60,4 +60,7 @@ AARCH64_OPT_EXTENSION("lse", AARCH64_FL_ + Disabling "fp16" just disables "fp16". */ + AARCH64_OPT_EXTENSION("fp16", AARCH64_FL_F16, AARCH64_FL_FP, 0, "fphp asimdhp") + ++/* Enabling/Disabling "sb" only changes "sb". */ ++AARCH64_OPT_EXTENSION("sb", AARCH64_FL_SB, 0, 0, "sb") ++ + #undef AARCH64_OPT_EXTENSION diff --git a/gcc7-aarch64-sls-miti-3.patch b/gcc7-aarch64-sls-miti-3.patch new file mode 100644 index 0000000..a635af8 --- /dev/null +++ b/gcc7-aarch64-sls-miti-3.patch @@ -0,0 +1,578 @@ +Backport of below commit for bsc#1172798 + +commit 2155170525f93093b90a1a065e7ed71a925566e9 +Author: Matthew Malcomson +Date: Thu Jul 9 09:11:59 2020 +0100 + + aarch64: Mitigate SLS for BLR instruction + + This patch introduces the mitigation for Straight Line Speculation past + the BLR instruction. + + This mitigation replaces BLR instructions with a BL to a stub which uses + a BR to jump to the original value. These function stubs are then + appended with a speculation barrier to ensure no straight line + speculation happens after these jumps. + + When optimising for speed we use a set of stubs for each function since + this should help the branch predictor make more accurate predictions + about where a stub should branch. + + When optimising for size we use one set of stubs for all functions. + This set of stubs can have human readable names, and we are using + `__call_indirect_x` for register x. + + When BTI branch protection is enabled the BLR instruction can jump to a + `BTI c` instruction using any register, while the BR instruction can + only jump to a `BTI c` instruction using the x16 or x17 registers. + Hence, in order to ensure this transformation is safe we mov the value + of the original register into x16 and use x16 for the BR. + + As an example when optimising for size: + a + BLR x0 + instruction would get transformed to something like + BL __call_indirect_x0 + where __call_indirect_x0 labels a thunk that contains + __call_indirect_x0: + MOV X16, X0 + BR X16 + + + The first version of this patch used local symbols specific to a + compilation unit to try and avoid relocations. + This was mistaken since functions coming from the same compilation unit + can still be in different sections, and the assembler will insert + relocations at jumps between sections. + + On any relocation the linker is permitted to emit a veneer to handle + jumps between symbols that are very far apart. The registers x16 and + x17 may be clobbered by these veneers. + Hence the function stubs cannot rely on the values of x16 and x17 being + the same as just before the function stub is called. + + Similar can be said for the hot/cold partitioning of single functions, + so function-local stubs have the same restriction. + + This updated version of the patch never emits function stubs for x16 and + x17, and instead forces other registers to be used. + + Given the above, there is now no benefit to local symbols (since they + are not enough to avoid dealing with linker intricacies). This patch + now uses global symbols with hidden visibility each stored in their own + COMDAT section. This means stubs can be shared between compilation + units while still avoiding the PLT indirection. + + This patch also removes the `__call_indirect_x30` stub (and + function-local equivalent) which would simply jump back to the original + location. + + The function-local stubs are emitted to the assembly output file in one + chunk, which means we need not add the speculation barrier directly + after each one. + This is because we know for certain that the instructions directly after + the BR in all but the last function stub will be from another one of + these stubs and hence will not contain a speculation gadget. + Instead we add a speculation barrier at the end of the sequence of + stubs. + + The global stubs are emitted in COMDAT/.linkonce sections by + themselves so that the linker can remove duplicates from multiple object + files. This means they are not emitted in one chunk, and each one must + include the speculation barrier. + + Another difference is that since the global stubs are shared across + compilation units we do not know that all functions will be targeting an + architecture supporting the SB instruction. + Rather than provide multiple stubs for each architecture, we provide a + stub that will work for all architectures -- using the DSB+ISB barrier. + + This mitigation does not apply for BLR instructions in the following + places: + - Some accesses to thread-local variables use a code sequence with a BLR + instruction. This code sequence is part of the binary interface between + compiler and linker. If this BLR instruction needs to be mitigated, it'd + probably be best to do so in the linker. It seems that the code sequence + for thread-local variable access is unlikely to lead to a Spectre Revalation + Gadget. + - PLT stubs are produced by the linker and each contain a BLR instruction. + It seems that at most only after the last PLT stub a Spectre Revalation + Gadget might appear. + + Testing: + Bootstrap and regtest on AArch64 + (with BOOT_CFLAGS="-mharden-sls=retbr,blr") + Used a temporary hack(1) in gcc-dg.exp to use these options on every + test in the testsuite, a slight modification to emit the speculation + barrier after every function stub, and a script to check that the + output never emitted a BLR, or unmitigated BR or RET instruction. + Similar on an aarch64-none-elf cross-compiler. + + 1) Temporary hack emitted a speculation barrier at the end of every stub + function, and used a script to ensure that: + a) Every RET or BR is immediately followed by a speculation barrier. + b) No BLR instruction is emitted by compiler. + + (cherry picked from 96b7f495f9269d5448822e4fc28882edb35a58d7) + + gcc/ChangeLog: + + * config/aarch64/aarch64-protos.h (aarch64_indirect_call_asm): + New declaration. + * config/aarch64/aarch64.c (aarch64_regno_regclass): Handle new + stub registers class. + (aarch64_class_max_nregs): Likewise. + (aarch64_register_move_cost): Likewise. + (aarch64_sls_shared_thunks): Global array to store stub labels. + (aarch64_sls_emit_function_stub): New. + (aarch64_create_blr_label): New. + (aarch64_sls_emit_blr_function_thunks): New. + (aarch64_sls_emit_shared_blr_thunks): New. + (aarch64_asm_file_end): New. + (aarch64_indirect_call_asm): New. + (TARGET_ASM_FILE_END): Use aarch64_asm_file_end. + (TARGET_ASM_FUNCTION_EPILOGUE): Use + aarch64_sls_emit_blr_function_thunks. + * config/aarch64/aarch64.h (STB_REGNUM_P): New. + (enum reg_class): Add STUB_REGS class. + (machine_function): Introduce `call_via` array for + function-local stub labels. + * config/aarch64/aarch64.md (*call_insn, *call_value_insn): Use + aarch64_indirect_call_asm to emit code when hardening BLR + instructions. + * config/aarch64/constraints.md (Ucr): New constraint + representing registers for indirect calls. Is GENERAL_REGS + usually, and STUB_REGS when hardening BLR instruction against + SLS. + * config/aarch64/predicates.md (aarch64_general_reg): STUB_REGS class + is also a general register. + + gcc/testsuite/ChangeLog: + + * gcc.target/aarch64/sls-mitigation/sls-miti-blr-bti.c: New test. + * gcc.target/aarch64/sls-mitigation/sls-miti-blr.c: New test. + +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-protos.h +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64-protos.h ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64-protos.h +@@ -486,6 +486,7 @@ extern const atomic_ool_names aarch64_oo + extern const atomic_ool_names aarch64_ool_ldeor_names; + + const char *aarch64_sls_barrier (int); ++const char *aarch64_indirect_call_asm (rtx); + extern bool aarch64_harden_sls_retbr_p (void); + extern bool aarch64_harden_sls_blr_p (void); + +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.c ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +@@ -5471,6 +5471,9 @@ aarch64_label_mentioned_p (rtx x) + enum reg_class + aarch64_regno_regclass (unsigned regno) + { ++ if (STUB_REGNUM_P (regno)) ++ return STUB_REGS; ++ + if (GP_REGNUM_P (regno)) + return GENERAL_REGS; + +@@ -5799,6 +5802,7 @@ aarch64_class_max_nregs (reg_class_t reg + { + switch (regclass) + { ++ case STUB_REGS: + case TAILCALL_ADDR_REGS: + case POINTER_REGS: + case GENERAL_REGS: +@@ -7880,10 +7884,12 @@ aarch64_register_move_cost (machine_mode + = aarch64_tune_params.regmove_cost; + + /* Caller save and pointer regs are equivalent to GENERAL_REGS. */ +- if (to == TAILCALL_ADDR_REGS || to == POINTER_REGS) ++ if (to == TAILCALL_ADDR_REGS || to == POINTER_REGS ++ || to == STUB_REGS) + to = GENERAL_REGS; + +- if (from == TAILCALL_ADDR_REGS || from == POINTER_REGS) ++ if (from == TAILCALL_ADDR_REGS || from == POINTER_REGS ++ || from == STUB_REGS) + from = GENERAL_REGS; + + /* Moving between GPR and stack cost is the same as GP2GP. */ +@@ -14699,6 +14705,215 @@ aarch64_sls_barrier (int mitigation_requ + : ""; + } + ++static GTY (()) tree aarch64_sls_shared_thunks[30]; ++static GTY (()) bool aarch64_sls_shared_thunks_needed = false; ++const char *indirect_symbol_names[30] = { ++ "__call_indirect_x0", ++ "__call_indirect_x1", ++ "__call_indirect_x2", ++ "__call_indirect_x3", ++ "__call_indirect_x4", ++ "__call_indirect_x5", ++ "__call_indirect_x6", ++ "__call_indirect_x7", ++ "__call_indirect_x8", ++ "__call_indirect_x9", ++ "__call_indirect_x10", ++ "__call_indirect_x11", ++ "__call_indirect_x12", ++ "__call_indirect_x13", ++ "__call_indirect_x14", ++ "__call_indirect_x15", ++ "", /* "__call_indirect_x16", */ ++ "", /* "__call_indirect_x17", */ ++ "__call_indirect_x18", ++ "__call_indirect_x19", ++ "__call_indirect_x20", ++ "__call_indirect_x21", ++ "__call_indirect_x22", ++ "__call_indirect_x23", ++ "__call_indirect_x24", ++ "__call_indirect_x25", ++ "__call_indirect_x26", ++ "__call_indirect_x27", ++ "__call_indirect_x28", ++ "__call_indirect_x29", ++}; ++ ++/* Function to create a BLR thunk. This thunk is used to mitigate straight ++ line speculation. Instead of a simple BLR that can be speculated past, ++ we emit a BL to this thunk, and this thunk contains a BR to the relevant ++ register. These thunks have the relevant speculation barries put after ++ their indirect branch so that speculation is blocked. ++ ++ We use such a thunk so the speculation barriers are kept off the ++ architecturally executed path in order to reduce the performance overhead. ++ ++ When optimizing for size we use stubs shared by the linked object. ++ When optimizing for performance we emit stubs for each function in the hope ++ that the branch predictor can better train on jumps specific for a given ++ function. */ ++rtx ++aarch64_sls_create_blr_label (int regnum) ++{ ++ gcc_assert (STUB_REGNUM_P (regnum)); ++ if (optimize_function_for_size_p (cfun)) ++ { ++ /* For the thunks shared between different functions in this compilation ++ unit we use a named symbol -- this is just for users to more easily ++ understand the generated assembly. */ ++ aarch64_sls_shared_thunks_needed = true; ++ const char *thunk_name = indirect_symbol_names[regnum]; ++ if (aarch64_sls_shared_thunks[regnum] == NULL) ++ { ++ /* Build a decl representing this function stub and record it for ++ later. We build a decl here so we can use the GCC machinery for ++ handling sections automatically (through `get_named_section` and ++ `make_decl_one_only`). That saves us a lot of trouble handling ++ the specifics of different output file formats. */ ++ tree decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL, ++ get_identifier (thunk_name), ++ build_function_type_list (void_type_node, ++ NULL_TREE)); ++ DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL, ++ NULL_TREE, void_type_node); ++ TREE_PUBLIC (decl) = 1; ++ TREE_STATIC (decl) = 1; ++ DECL_IGNORED_P (decl) = 1; ++ DECL_ARTIFICIAL (decl) = 1; ++ make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl)); ++ resolve_unique_section (decl, 0, false); ++ aarch64_sls_shared_thunks[regnum] = decl; ++ } ++ ++ return gen_rtx_SYMBOL_REF (Pmode, thunk_name); ++ } ++ ++ if (cfun->machine->call_via[regnum] == NULL) ++ cfun->machine->call_via[regnum] ++ = gen_rtx_LABEL_REF (Pmode, gen_label_rtx ()); ++ return cfun->machine->call_via[regnum]; ++} ++ ++/* Helper function for aarch64_sls_emit_blr_function_thunks and ++ aarch64_sls_emit_shared_blr_thunks below. */ ++static void ++aarch64_sls_emit_function_stub (FILE *out_file, int regnum) ++{ ++ /* Save in x16 and branch to that function so this transformation does ++ not prevent jumping to `BTI c` instructions. */ ++ asm_fprintf (out_file, "\tmov\tx16, x%d\n", regnum); ++ asm_fprintf (out_file, "\tbr\tx16\n"); ++} ++ ++/* Emit all BLR stubs for this particular function. ++ Here we emit all the BLR stubs needed for the current function. Since we ++ emit these stubs in a consecutive block we know there will be no speculation ++ gadgets between each stub, and hence we only emit a speculation barrier at ++ the end of the stub sequences. ++ ++ This is called in the TARGET_ASM_FUNCTION_EPILOGUE hook. */ ++void ++aarch64_sls_emit_blr_function_thunks (FILE *out_file, HOST_WIDE_INT) ++{ ++ if (! aarch64_harden_sls_blr_p ()) ++ return; ++ ++ bool any_functions_emitted = false; ++ /* We must save and restore the current function section since this assembly ++ is emitted at the end of the function. This means it can be emitted *just ++ after* the cold section of a function. That cold part would be emitted in ++ a different section. That switch would trigger a `.cfi_endproc` directive ++ to be emitted in the original section and a `.cfi_startproc` directive to ++ be emitted in the new section. Switching to the original section without ++ restoring would mean that the `.cfi_endproc` emitted as a function ends ++ would happen in a different section -- leaving an unmatched ++ `.cfi_startproc` in the cold text section and an unmatched `.cfi_endproc` ++ in the standard text section. */ ++ section *save_text_section = in_section; ++ switch_to_section (function_section (current_function_decl)); ++ for (int regnum = 0; regnum < 30; ++regnum) ++ { ++ rtx specu_label = cfun->machine->call_via[regnum]; ++ if (specu_label == NULL) ++ continue; ++ ++ targetm.asm_out.print_operand (out_file, specu_label, 0); ++ asm_fprintf (out_file, ":\n"); ++ aarch64_sls_emit_function_stub (out_file, regnum); ++ any_functions_emitted = true; ++ } ++ if (any_functions_emitted) ++ /* Can use the SB if needs be here, since this stub will only be used ++ by the current function, and hence for the current target. */ ++ asm_fprintf (out_file, "\t%s\n", aarch64_sls_barrier (true)); ++ switch_to_section (save_text_section); ++} ++ ++/* Emit shared BLR stubs for the current compilation unit. ++ Over the course of compiling this unit we may have converted some BLR ++ instructions to a BL to a shared stub function. This is where we emit those ++ stub functions. ++ This function is for the stubs shared between different functions in this ++ compilation unit. We share when optimizing for size instead of speed. ++ ++ This function is called through the TARGET_ASM_FILE_END hook. */ ++void ++aarch64_sls_emit_shared_blr_thunks (FILE *out_file) ++{ ++ if (! aarch64_sls_shared_thunks_needed) ++ return; ++ ++ for (int regnum = 0; regnum < 30; ++regnum) ++ { ++ tree decl = aarch64_sls_shared_thunks[regnum]; ++ if (!decl) ++ continue; ++ ++ const char *name = indirect_symbol_names[regnum]; ++ switch_to_section (get_named_section (decl, NULL, 0)); ++ ASM_OUTPUT_ALIGN (out_file, 2); ++ targetm.asm_out.globalize_label (out_file, name); ++ /* Only emits if the compiler is configured for an assembler that can ++ handle visibility directives. */ ++ targetm.asm_out.assemble_visibility (decl, VISIBILITY_HIDDEN); ++ ASM_OUTPUT_TYPE_DIRECTIVE (out_file, name, "function"); ++ ASM_OUTPUT_LABEL (out_file, name); ++ aarch64_sls_emit_function_stub (out_file, regnum); ++ /* Use the most conservative target to ensure it can always be used by any ++ function in the translation unit. */ ++ asm_fprintf (out_file, "\tdsb\tsy\n\tisb\n"); ++ ASM_DECLARE_FUNCTION_SIZE (out_file, name, decl); ++ } ++} ++ ++/* Implement TARGET_ASM_FILE_END. */ ++void ++aarch64_asm_file_end () ++{ ++ aarch64_sls_emit_shared_blr_thunks (asm_out_file); ++ /* Since this function will be called for the ASM_FILE_END hook, we ensure ++ that what would be called otherwise (e.g. `file_end_indicate_exec_stack` ++ for FreeBSD) still gets called. */ ++#ifdef TARGET_ASM_FILE_END ++ TARGET_ASM_FILE_END (); ++#endif ++} ++ ++const char * ++aarch64_indirect_call_asm (rtx addr) ++{ ++ gcc_assert (REG_P (addr)); ++ if (aarch64_harden_sls_blr_p ()) ++ { ++ rtx stub_label = aarch64_sls_create_blr_label (REGNO (addr)); ++ output_asm_insn ("bl\t%0", &stub_label); ++ } ++ else ++ output_asm_insn ("blr\t%0", &addr); ++ return ""; ++} ++ + /* Target-specific selftests. */ + + #if CHECKING_P +@@ -15132,6 +15347,12 @@ aarch64_libgcc_floating_mode_supported_p + #define TARGET_RUN_TARGET_SELFTESTS selftest::aarch64_run_selftests + #endif /* #if CHECKING_P */ + ++#undef TARGET_ASM_FILE_END ++#define TARGET_ASM_FILE_END aarch64_asm_file_end ++ ++#undef TARGET_ASM_FUNCTION_EPILOGUE ++#define TARGET_ASM_FUNCTION_EPILOGUE aarch64_sls_emit_blr_function_thunks ++ + struct gcc_target targetm = TARGET_INITIALIZER; + + #include "gt-aarch64.h" +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.h +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.h ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.h +@@ -435,6 +435,16 @@ extern unsigned aarch64_architecture_ver + #define GP_REGNUM_P(REGNO) \ + (((unsigned) (REGNO - R0_REGNUM)) <= (R30_REGNUM - R0_REGNUM)) + ++/* Registers known to be preserved over a BL instruction. This consists of the ++ GENERAL_REGS without x16, x17, and x30. The x30 register is changed by the ++ BL instruction itself, while the x16 and x17 registers may be used by ++ veneers which can be inserted by the linker. */ ++#define STUB_REGNUM_P(REGNO) \ ++ (GP_REGNUM_P (REGNO) \ ++ && (REGNO) != R16_REGNUM \ ++ && (REGNO) != R17_REGNUM \ ++ && (REGNO) != R30_REGNUM) \ ++ + #define FP_REGNUM_P(REGNO) \ + (((unsigned) (REGNO - V0_REGNUM)) <= (V31_REGNUM - V0_REGNUM)) + +@@ -448,6 +458,7 @@ enum reg_class + { + NO_REGS, + TAILCALL_ADDR_REGS, ++ STUB_REGS, + GENERAL_REGS, + STACK_REG, + POINTER_REGS, +@@ -463,6 +474,7 @@ enum reg_class + { \ + "NO_REGS", \ + "TAILCALL_ADDR_REGS", \ ++ "STUB_REGS", \ + "GENERAL_REGS", \ + "STACK_REG", \ + "POINTER_REGS", \ +@@ -475,6 +487,7 @@ enum reg_class + { \ + { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \ + { 0x0004ffff, 0x00000000, 0x00000000 }, /* TAILCALL_ADDR_REGS */\ ++ { 0x3ffcffff, 0x00000000, 0x00000000 }, /* STUB_REGS */ \ + { 0x7fffffff, 0x00000000, 0x00000003 }, /* GENERAL_REGS */ \ + { 0x80000000, 0x00000000, 0x00000000 }, /* STACK_REG */ \ + { 0xffffffff, 0x00000000, 0x00000003 }, /* POINTER_REGS */ \ +@@ -609,6 +622,8 @@ typedef struct GTY (()) machine_function + struct aarch64_frame frame; + /* One entry for each hard register. */ + bool reg_is_wrapped_separately[LAST_SAVED_REGNUM]; ++ /* One entry for each general purpose register. */ ++ rtx call_via[SP_REGNUM]; + } machine_function; + #endif + +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.md +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.md ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.md +@@ -778,12 +778,12 @@ + ) + + (define_insn "*call_reg" +- [(call (mem:DI (match_operand:DI 0 "register_operand" "r")) ++ [(call (mem:DI (match_operand:DI 0 "register_operand" "Ucr")) + (match_operand 1 "" "")) + (use (match_operand 2 "" "")) + (clobber (reg:DI LR_REGNUM))] + "" +- "blr\\t%0" ++ "* return aarch64_indirect_call_asm (operands[0]);" + [(set_attr "type" "call")] + ) + +@@ -840,12 +840,12 @@ + + (define_insn "*call_value_reg" + [(set (match_operand 0 "" "") +- (call (mem:DI (match_operand:DI 1 "register_operand" "r")) ++ (call (mem:DI (match_operand:DI 1 "register_operand" "Ucr")) + (match_operand 2 "" ""))) + (use (match_operand 3 "" "")) + (clobber (reg:DI LR_REGNUM))] + "" +- "blr\\t%1" ++ "* return aarch64_indirect_call_asm (operands[1]);" + [(set_attr "type" "call")] + + ) +Index: gcc-7.5.0+r278197/gcc/config/aarch64/constraints.md +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/constraints.md ++++ gcc-7.5.0+r278197/gcc/config/aarch64/constraints.md +@@ -24,6 +24,15 @@ + (define_register_constraint "Ucs" "TAILCALL_ADDR_REGS" + "@internal Registers suitable for an indirect tail call") + ++(define_register_constraint "Ucr" ++ "aarch64_harden_sls_blr_p () ? STUB_REGS : GENERAL_REGS" ++ "@internal Registers to be used for an indirect call. ++ This is usually the general registers, but when we are hardening against ++ Straight Line Speculation we disallow x16, x17, and x30 so we can use ++ indirection stubs. These indirection stubs cannot use the above registers ++ since they will be reached by a BL that may have to go through a linker ++ veneer.") ++ + (define_register_constraint "w" "FP_REGS" + "Floating point and SIMD vector registers.") + +Index: gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr.c +=================================================================== +--- /dev/null ++++ gcc-7.5.0+r278197/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr.c +@@ -0,0 +1,33 @@ ++/* { dg-additional-options "-mharden-sls=blr -save-temps" } */ ++/* Ensure that the SLS hardening of BLR leaves no BLR instructions. ++ We only test that all BLR instructions have been removed, not that the ++ resulting code makes sense. */ ++typedef int (foo) (int, int); ++typedef void (bar) (int, int); ++struct sls_testclass { ++ foo *x; ++ bar *y; ++ int left; ++ int right; ++}; ++ ++/* We test both RTL patterns for a call which returns a value and a call which ++ does not. */ ++int blr_call_value (struct sls_testclass x) ++{ ++ int retval = x.x(x.left, x.right); ++ if (retval % 10) ++ return 100; ++ return 9; ++} ++ ++int blr_call (struct sls_testclass x) ++{ ++ x.y(x.left, x.right); ++ if (x.left % 10) ++ return 100; ++ return 9; ++} ++ ++/* { dg-final { scan-assembler-not {\tblr\t} } } */ ++/* { dg-final { scan-assembler {\tbr\tx[0-9][0-9]?} } } */ diff --git a/gcc7-aarch64-untyped_call.patch b/gcc7-aarch64-untyped_call.patch new file mode 100644 index 0000000..482a00c --- /dev/null +++ b/gcc7-aarch64-untyped_call.patch @@ -0,0 +1,63 @@ +From 6787268a289bdbc32920b13b4697eaf756f9f7e0 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Thu, 31 Aug 2023 16:15:10 +0100 +Subject: [PATCH] aarch64: Fix return register handling in untyped_call +To: gcc-patches@gcc.gnu.org + +While working on another patch, I hit a problem with the aarch64 +expansion of untyped_call. The expander emits the usual: + + (set (mem ...) (reg resN)) + +instructions to store the result registers to memory, but it didn't +say in RTL where those resN results came from. This eventually led +to a failure of gcc.dg/torture/stackalign/builtin-return-2.c, +via regrename. + +This patch turns the untyped call from a plain call to a call_value, +to represent that the call returns (or might return) a useful value. +The patch also uses a PARALLEL return rtx to represent all the possible +return registers. + +gcc/ + * config/aarch64/aarch64.md (untyped_call): Emit a call_value + rather than a call. List each possible destination register + in the call pattern. +--- + gcc/config/aarch64/aarch64.md | 20 +++++++++++++++++++- + 1 file changed, 19 insertions(+), 1 deletion(-) + +diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md +index 90f9ee658c5..97d27677985 100644 +--- a/gcc/config/aarch64/aarch64.md ++++ b/gcc/config/aarch64/aarch64.md +@@ -934,7 +934,25 @@ + { + int i; + +- emit_call_insn (gen_call (operands[0], const0_rtx, NULL)); ++ /* Generate a PARALLEL that contains all of the register results. ++ The offsets are somewhat arbitrary, since we don't know the ++ actual return type. The main thing we need to avoid is having ++ overlapping byte ranges, since those might give the impression ++ that two registers are known to have data in common. */ ++ rtvec rets = rtvec_alloc (XVECLEN (operands[2], 0)); ++ unsigned HOST_WIDE_INT offset = 0; ++ for (i = 0; i < XVECLEN (operands[2], 0); i++) ++ { ++ rtx reg = SET_SRC (XVECEXP (operands[2], 0, i)); ++ gcc_assert (REG_P (reg)); ++ rtx offset_rtx = gen_int_mode (offset, Pmode); ++ rtx piece = gen_rtx_EXPR_LIST (VOIDmode, reg, offset_rtx); ++ RTVEC_ELT (rets, i) = piece; ++ offset += GET_MODE_SIZE (GET_MODE (reg)); ++ } ++ rtx ret = gen_rtx_PARALLEL (VOIDmode, rets); ++ ++ emit_call_insn (gen_call_value (ret, operands[0], const0_rtx, NULL)); + + for (i = 0; i < XVECLEN (operands[2], 0); i++) + { +-- +2.35.3 + diff --git a/gcc7-ada-MINSTKSZ.patch b/gcc7-ada-MINSTKSZ.patch new file mode 100644 index 0000000..a816a7c --- /dev/null +++ b/gcc7-ada-MINSTKSZ.patch @@ -0,0 +1,51 @@ +From 331763de7d4850702a0f67298f36017c73cdb103 Mon Sep 17 00:00:00 2001 +From: Eric Botcazou +Date: Fri, 5 Mar 2021 12:45:41 +0100 +Subject: [PATCH] Fix build breakage with latest glibc release +To: gcc-patches@gcc.gnu.org + +gcc/ada/ + PR ada/99264 + * init.c (__gnat_alternate_sta) [Linux]: Remove preprocessor test on + MINSIGSTKSZ and bump size to 32KB. + * libgnarl/s-osinte__linux.ads (Alternate_Stack_Size): Bump to 32KB. +--- + gcc/ada/init.c | 8 ++------ + gcc/ada/libgnarl/s-osinte__linux.ads | 2 +- + 2 files changed, 3 insertions(+), 7 deletions(-) + +diff --git a/gcc/ada/init.c b/gcc/ada/init.c +index e76aa79c5a8..3ceb1a31b02 100644 +--- a/gcc/ada/init.c ++++ b/gcc/ada/init.c +@@ -579,12 +579,8 @@ __gnat_error_handler (int sig, siginfo_t *si ATTRIBUTE_UNUSED, void *ucontext) + + #ifndef __ia64__ + #define HAVE_GNAT_ALTERNATE_STACK 1 +-/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. +- It must be larger than MINSIGSTKSZ and hopefully near 2 * SIGSTKSZ. */ +-# if 16 * 1024 < MINSIGSTKSZ +-# error "__gnat_alternate_stack too small" +-# endif +-char __gnat_alternate_stack[16 * 1024]; ++/* This must be in keeping with System.OS_Interface.Alternate_Stack_Size. */ ++char __gnat_alternate_stack[32 * 1024]; + #endif + + #ifdef __XENO__ + +diff --git a/gcc/ada/s-osinte-linux.ads b/gcc/ada/s-osinte-linux.ads +index b0ba2296398..9e408a5b2ab 100644 +--- a/gcc/ada/s-osinte-linux.ads ++++ b/gcc/ada/s-osinte-linux.ads +@@ -325,7 +325,7 @@ package System.OS_Interface is + pragma Import (C, Alternate_Stack, "__gnat_alternate_stack"); + -- The alternate signal stack for stack overflows + +- Alternate_Stack_Size : constant := 16 * 1024; ++ Alternate_Stack_Size : constant := 32 * 1024; + -- This must be in keeping with init.c:__gnat_alternate_stack + + function Get_Stack_Base (thread : pthread_t) return Address; +-- +2.31.1 diff --git a/gcc7-ada-Target_Name.patch b/gcc7-ada-Target_Name.patch new file mode 100644 index 0000000..c764176 --- /dev/null +++ b/gcc7-ada-Target_Name.patch @@ -0,0 +1,44 @@ +From 9467e7331188705ec16c086b77e1809c5b0aab7d Mon Sep 17 00:00:00 2001 +From: Richard Biener +Date: Thu, 10 Mar 2022 13:35:46 +0100 +Subject: [PATCH] ada/104861 - use target_noncanonial for Target_Name +To: gcc-patches@gcc.gnu.org + +The following arranges for s-oscons.ads to record target_noncanonical +for Target_Name, matching the install directory layout and what +gcc -dumpmachine says. This fixes build issues with gprbuild. + +2022-03-10 Richard Biener + + PR ada/104861 +gcc/ada/ + * gcc-interface/Makefile.in (target_noncanonical): Substitute. + (OSCONS_CPP): Pass target_noncanonical as TARGET. +--- + gcc/ada/gcc-interface/Makefile.in | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in +index b8a24708280..1e9801a8b96 100644 +--- a/gcc/ada/gcc-interface/Makefile.in ++++ b/gcc/ada/gcc-interface/Makefile.in +@@ -138,6 +138,7 @@ objdir = . + + target_alias=@target_alias@ + target=@target@ ++target_noncanonical=@target_noncanonical@ + target_cpu=@target_cpu@ + target_vendor=@target_vendor@ + target_os=@target_os@ +@@ -598,7 +599,7 @@ OSCONS_CC=$(subst ./xgcc,../../xgcc,$(subst -B./, -B../../,$(GCC_FOR_TARGET))) + # has a header). + + OSCONS_CPP=$(OSCONS_CC) $(GNATLIBCFLAGS_FOR_C) -E -C \ +- -DTARGET=\"$(target)\" -iquote $(fsrcpfx)ada $(fsrcpfx)ada/s-oscons-tmplt.c > s-oscons-tmplt.i ++ -DTARGET=\"$(target_noncanonical)\" -iquote $(fsrcpfx)ada $(fsrcpfx)ada/s-oscons-tmplt.c > s-oscons-tmplt.i + OSCONS_EXTRACT=$(OSCONS_CC) $(GNATLIBCFLAGS_FOR_C) -S s-oscons-tmplt.i + + # Note: if you need to build with a non-GNU compiler, you could adapt the +-- +2.34.1 + diff --git a/gcc7-avoid-fixinc-error.diff b/gcc7-avoid-fixinc-error.diff new file mode 100644 index 0000000..bf60366 --- /dev/null +++ b/gcc7-avoid-fixinc-error.diff @@ -0,0 +1,18 @@ +Index: gcc/Makefile.in +=================================================================== +--- gcc/Makefile.in (revision 255402) ++++ gcc/Makefile.in (working copy) +@@ -2993,13 +2993,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 ${SYSTEM_HEADER_DIR}; then \ +- echo The directory that should contain system headers does not exist: >&2 ; \ +- echo " ${SYSTEM_HEADER_DIR}" >&2 ; \ +- tooldir_sysinc=`echo "${gcc_tooldir}/sys-include" | sed -e :a -e "s,[^/]*/\.\.\/,," -e ta`; \ +- if test "x${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-bsc1146475.patch b/gcc7-bsc1146475.patch new file mode 100644 index 0000000..772afce --- /dev/null +++ b/gcc7-bsc1146475.patch @@ -0,0 +1,226 @@ +2019-10-01 Alexandre Oliva + + PR debug/91507 + * dwarf2out.c (override_type_for_decl_p): New. + (gen_variable_die): Use it. + + * gcc.dg/debug/dwarf2/array-0.c: New. + * gcc.dg/debug/dwarf2/array-1.c: New. + * gcc.dg/debug/dwarf2/array-2.c: New. + * gcc.dg/debug/dwarf2/array-3.c: New. + * g++.dg/debug/dwarf2/array-0.C: New. + * g++.dg/debug/dwarf2/array-1.C: New. + * g++.dg/debug/dwarf2/array-2.C: New. Based on libstdc++-v3's + src/c++98/pool_allocator.cc:__pool_alloc_base::_S_heap_size. + * g++.dg/debug/dwarf2/array-3.C: New. Based on + gcc's config/i386/i386-features.c:xlogue_layout::s_instances. + * g++.dg/debug/dwarf2/array-4.C: New. + +Index: gcc/testsuite/gcc.dg/debug/dwarf2/array-0.c +=================================================================== +--- gcc/testsuite/gcc.dg/debug/dwarf2/array-0.c (nonexistent) ++++ gcc/testsuite/gcc.dg/debug/dwarf2/array-0.c (revision 276403) +@@ -0,0 +1,10 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++extern int array[42]; ++ ++int array[42]; ++ ++/* Verify that we get only one DW_TAG_subtrange_type (plus abbrev), ++ with a DW_AT_upper_bound. */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 2 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/testsuite/gcc.dg/debug/dwarf2/array-2.c +=================================================================== +--- gcc/testsuite/gcc.dg/debug/dwarf2/array-2.c (nonexistent) ++++ gcc/testsuite/gcc.dg/debug/dwarf2/array-2.c (revision 276403) +@@ -0,0 +1,8 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++int array[42]; ++ ++/* Verify that we get only one DW_TAG_subtrange_type (plus abbrev) ++ with DW_AT_upper_bound. */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 2 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/testsuite/gcc.dg/debug/dwarf2/array-1.c +=================================================================== +--- gcc/testsuite/gcc.dg/debug/dwarf2/array-1.c (nonexistent) ++++ gcc/testsuite/gcc.dg/debug/dwarf2/array-1.c (revision 276403) +@@ -0,0 +1,10 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++extern int array[]; ++ ++int array[42]; ++ ++/* Verify that we get two DW_TAG_subtrange_type (each with an abbrev), ++ but only one DW_AT_upper_bound. */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 4 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/testsuite/gcc.dg/debug/dwarf2/array-3.c +=================================================================== +--- gcc/testsuite/gcc.dg/debug/dwarf2/array-3.c (nonexistent) ++++ gcc/testsuite/gcc.dg/debug/dwarf2/array-3.c (revision 276403) +@@ -0,0 +1,8 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++int array[] = { 0, 1, 2 }; ++ ++/* Verify that we get only one DW_TAG_subtrange_type (plus abbrev) ++ with DW_AT_upper_bound. */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 2 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/testsuite/g++.dg/debug/dwarf2/array-1.C +=================================================================== +--- gcc/testsuite/g++.dg/debug/dwarf2/array-1.C (nonexistent) ++++ gcc/testsuite/g++.dg/debug/dwarf2/array-1.C (revision 276403) +@@ -0,0 +1,13 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++struct S ++{ ++ static int array[]; ++}; ++ ++int S::array[42]; ++ ++/* Verify that we get two DW_TAG_subrange_type, only one of which with ++ a DW_AT_upper_bound. */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 4 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/testsuite/g++.dg/debug/dwarf2/array-2.C +=================================================================== +--- gcc/testsuite/g++.dg/debug/dwarf2/array-2.C (nonexistent) ++++ gcc/testsuite/g++.dg/debug/dwarf2/array-2.C (revision 276403) +@@ -0,0 +1,15 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++struct S ++{ ++ typedef int i_t; ++ static i_t array[42]; ++}; ++ ++int S::array[42]; ++ ++/* Verify that we get two DW_TAG_subrange_type (plus abbrev), and two ++ DW_AT_upper_bound, because a different symbolic name is used for ++ the array element type. */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 3 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 2 } } */ +Index: gcc/testsuite/g++.dg/debug/dwarf2/array-3.C +=================================================================== +--- gcc/testsuite/g++.dg/debug/dwarf2/array-3.C (nonexistent) ++++ gcc/testsuite/g++.dg/debug/dwarf2/array-3.C (revision 276403) +@@ -0,0 +1,20 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++struct S ++{ ++ S() {} ++ ~S() {} ++ static const S array[2]; ++}; ++ ++const S S::array[2] = { S(), S() }; ++ ++/* Verify that we get only one DW_TAG_subrange_type (plus the abbrev), ++ and one DW_AT_upper_bound (non-abbrev), because the array ++ definition loses the readonly wrapper for the array type because of ++ the dynamic initializers. The const types are 4: S, S*, int, and ++ S[4], plus the abbrev. A const version of S[4] doesn't make sense, ++ but we output it. */ ++/* { dg-final { scan-assembler-times " DW_TAG_const_type" 5 } } */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 2 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/testsuite/g++.dg/debug/dwarf2/array-0.C +=================================================================== +--- gcc/testsuite/g++.dg/debug/dwarf2/array-0.C (nonexistent) ++++ gcc/testsuite/g++.dg/debug/dwarf2/array-0.C (revision 276403) +@@ -0,0 +1,13 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++struct S ++{ ++ static int array[42]; ++}; ++ ++int S::array[42]; ++ ++/* Verify that we get only one DW_TAG_subrange_type with a ++ DW_AT_upper_bound. */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 2 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/testsuite/g++.dg/debug/dwarf2/array-4.C +=================================================================== +--- gcc/testsuite/g++.dg/debug/dwarf2/array-4.C (nonexistent) ++++ gcc/testsuite/g++.dg/debug/dwarf2/array-4.C (revision 276403) +@@ -0,0 +1,16 @@ ++/* { dg-do compile } */ ++/* { dg-options "-gdwarf-2 -dA" } */ ++struct S ++{ ++ S() {} ++ ~S() {} ++}; ++ ++const S array[2] = { S(), S() }; ++ ++/* Like array-3, but with a non-member array without a separate ++ declaration, to check that we don't issue the nonsensical ++ DW_TAG_const_type used by the member array declaration there. */ ++/* { dg-final { scan-assembler-times " DW_TAG_const_type" 4 } } */ ++/* { dg-final { scan-assembler-times " DW_TAG_subrange_type" 2 } } */ ++/* { dg-final { scan-assembler-times " DW_AT_upper_bound" 1 } } */ +Index: gcc/dwarf2out.c +=================================================================== +--- gcc/dwarf2out.c (revision 276402) ++++ gcc/dwarf2out.c (revision 276403) +@@ -23705,6 +23705,34 @@ local_function_static (tree decl) + && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL; + } + ++/* Return true iff DECL overrides (presumably completes) the type of ++ OLD_DIE within CONTEXT_DIE. */ ++ ++static bool ++override_type_for_decl_p (tree decl, dw_die_ref old_die, ++ dw_die_ref context_die) ++{ ++ tree type = TREE_TYPE (decl); ++ int cv_quals; ++ ++ if (decl_by_reference_p (decl)) ++ { ++ type = TREE_TYPE (type); ++ cv_quals = TYPE_UNQUALIFIED; ++ } ++ else ++ cv_quals = decl_quals (decl); ++ ++ dw_die_ref type_die = modified_type_die (type, ++ cv_quals | TYPE_QUALS (type), ++ false, ++ context_die); ++ ++ dw_die_ref old_type_die = get_AT_ref (old_die, DW_AT_type); ++ ++ return type_die != old_type_die; ++} ++ + /* Generate a DIE to represent a declared data object. + Either DECL or ORIGIN must be non-null. */ + +@@ -23957,7 +23985,9 @@ gen_variable_die (tree decl, tree origin + && !DECL_ABSTRACT_P (decl_or_origin) + && variably_modified_type_p (TREE_TYPE (decl_or_origin), + decl_function_context +- (decl_or_origin)))) ++ (decl_or_origin))) ++ || (old_die && specialization_p ++ && override_type_for_decl_p (decl_or_origin, old_die, context_die))) + { + tree type = TREE_TYPE (decl_or_origin); + diff --git a/gcc7-bsc1160086.patch b/gcc7-bsc1160086.patch new file mode 100644 index 0000000..f3058da --- /dev/null +++ b/gcc7-bsc1160086.patch @@ -0,0 +1,72 @@ +2019-12-17 Andreas Krebbel + + Backport from mainline + 2019-12-16 Andreas Krebbel + + PR target/92950 + * config/s390/vector.md ("mov" for V_8): Replace lh, lhy, + and lhrl with llc. + + * gcc.target/s390/vector/pr92950.c: New test. + +Index: gcc/testsuite/gcc.target/s390/vector/pr92950.c +=================================================================== +--- gcc/testsuite/gcc.target/s390/vector/pr92950.c (nonexistent) ++++ gcc/testsuite/gcc.target/s390/vector/pr92950.c (revision 279454) +@@ -0,0 +1,24 @@ ++/* { dg-do run } */ ++/* { dg-options "-O3 -mzarch -march=z13" } */ ++ ++struct a { ++ int b; ++ char c; ++}; ++struct a d = {1, 16}; ++struct a *e = &d; ++ ++int f = 0; ++ ++int main() { ++ struct a g = {0, 0 }; ++ f = 0; ++ ++ for (; f <= 1; f++) { ++ g = d; ++ *e = g; ++ } ++ ++ if (d.c != 16) ++ __builtin_abort(); ++} +Index: gcc/config/s390/vector.md +=================================================================== +--- gcc/config/s390/vector.md (revision 279453) ++++ gcc/config/s390/vector.md (revision 279454) +@@ -289,9 +289,9 @@ (define_split + ; However, this would probably be slower. + + (define_insn "mov" +- [(set (match_operand:V_8 0 "nonimmediate_operand" "=v,v,d,v,R, v, v, v, v,d, Q, S, Q, S, d, d,d,d,d,R,T") +- (match_operand:V_8 1 "general_operand" " v,d,v,R,v,j00,jm1,jyy,jxx,d,j00,j00,jm1,jm1,j00,jm1,R,T,b,d,d"))] +- "" ++ [(set (match_operand:V_8 0 "nonimmediate_operand" "=v,v,d,v,R, v, v, v, v,d, Q, S, Q, S, d, d,d,R,T") ++ (match_operand:V_8 1 "general_operand" " v,d,v,R,v,j00,jm1,jyy,jxx,d,j00,j00,jm1,jm1,j00,jm1,T,d,d"))] ++ "TARGET_VX" + "@ + vlr\t%v0,%v1 + vlvgb\t%v0,%1,0 +@@ -309,12 +309,10 @@ (define_insn "mov" + mviy\t%0,-1 + lhi\t%0,0 + lhi\t%0,-1 +- lh\t%0,%1 +- lhy\t%0,%1 +- lhrl\t%0,%1 ++ llc\t%0,%1 + stc\t%1,%0 + stcy\t%1,%0" +- [(set_attr "op_type" "VRR,VRS,VRS,VRX,VRX,VRI,VRI,VRI,VRI,RR,SI,SIY,SI,SIY,RI,RI,RX,RXY,RIL,RX,RXY")]) ++ [(set_attr "op_type" "VRR,VRS,VRS,VRX,VRX,VRI,VRI,VRI,VRI,RR,SI,SIY,SI,SIY,RI,RI,RXY,RX,RXY")]) + + (define_insn "mov" + [(set (match_operand:V_16 0 "nonimmediate_operand" "=v,v,d,v,R, v, v, v, v,d, Q, Q, d, d,d,d,d,R,T,b") diff --git a/gcc7-bsc1216488.patch b/gcc7-bsc1216488.patch new file mode 100644 index 0000000..35b39bd --- /dev/null +++ b/gcc7-bsc1216488.patch @@ -0,0 +1,13 @@ +diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c +index 5590845d2a4..07185a1a0d3 100644 +--- a/gcc/dwarf2out.c ++++ b/gcc/dwarf2out.c +@@ -23030,7 +23031,7 @@ gen_label_die (tree decl, dw_die_ref context_die) + lbl_die = new_die (DW_TAG_label, context_die, decl); + equate_decl_number_to_die (decl, lbl_die); + +- if (origin != NULL) ++ if (origin != NULL && origin != decl) + add_abstract_origin_attribute (lbl_die, origin); + else + add_name_and_src_coords_attributes (lbl_die, decl); diff --git a/gcc7-fix-retrieval-of-testnames.patch b/gcc7-fix-retrieval-of-testnames.patch new file mode 100644 index 0000000..f328290 --- /dev/null +++ b/gcc7-fix-retrieval-of-testnames.patch @@ -0,0 +1,260 @@ +Backport of the below + +commit db489777bb0185e64cf4b9b8c7afed4dcc6669bd +Author: Thomas Preud'homme +Date: Fri Nov 10 09:42:45 2017 +0000 + + [testsuite] Fix retrieval of testname + + When gcc-dg-runtest is used to run a test the test is run several times + with different options. For clarity of the log, the test infrastructure + then append the options to the testname. This means that all the code + that must deal with the testcase itself (eg. removing the output files + after the test has run) needs to remove the option name. + + There is already a pattern (see below) for this in several place of the + testsuite framework but it is also missing in many places. This patch + fixes all of these places. The pattern is as follows: + + set testcase [testname-for-summary] + ; The name might include a list of options; extract the file name. + set testcase [lindex $testcase 0] + + 2017-11-10 Thomas Preud'homme + + gcc/testsuite/ + * lib/scanasm.exp (scan-assembler): Extract filename from testname used + in summary. + (scan-assembler-not): Likewise. + (scan-hidden): Likewise. + (scan-not-hidden): Likewise. + (scan-stack-usage): Likewise. + (scan-stack-usage-not): Likewise. + (scan-assembler-times): Likewise. + (scan-assembler-dem): Likewise. + (scan-assembler-dem-not): Likewise. + (object-size): Likewise. + (scan-lto-assembler): Likewise. + * lib/scandump.exp (scan-dump): Likewise. + (scan-dump-times): Likewise. + (scan-dump-not): Likewise. + (scan-dump-dem): Likewise. + (scan-dump-dem-not): Likewise + + From-SVN: r254622 + +Index: gcc-7.5.0+r278197/gcc/testsuite/lib/scanasm.exp +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/testsuite/lib/scanasm.exp ++++ gcc-7.5.0+r278197/gcc/testsuite/lib/scanasm.exp +@@ -78,7 +78,9 @@ proc dg-scan { name positive testcase ou + + proc scan-assembler { args } { + set testcase [testname-for-summary] +- set output_file "[file rootname [file tail $testcase]].s" ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ set output_file "[file rootname [file tail $filename]].s" + dg-scan "scan-assembler" 1 $testcase $output_file $args + } + +@@ -89,7 +91,9 @@ force_conventional_output_for scan-assem + + proc scan-assembler-not { args } { + set testcase [testname-for-summary] +- set output_file "[file rootname [file tail $testcase]].s" ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ set output_file "[file rootname [file tail $filename]].s" + + dg-scan "scan-assembler-not" 0 $testcase $output_file $args + } +@@ -117,7 +121,9 @@ proc hidden-scan-for { symbol } { + + proc scan-hidden { args } { + set testcase [testname-for-summary] +- set output_file "[file rootname [file tail $testcase]].s" ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ set output_file "[file rootname [file tail $filename]].s" + + set symbol [lindex $args 0] + +@@ -133,7 +139,9 @@ proc scan-hidden { args } { + + proc scan-not-hidden { args } { + set testcase [testname-for-summary] +- set output_file "[file rootname [file tail $testcase]].s" ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ set output_file "[file rootname [file tail $filename]].s" + + set symbol [lindex $args 0] + set hidden_scan [hidden-scan-for $symbol] +@@ -163,7 +171,9 @@ proc scan-file-not { output_file args } + + proc scan-stack-usage { args } { + set testcase [testname-for-summary] +- set output_file "[file rootname [file tail $testcase]].su" ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ set output_file "[file rootname [file tail $filename]].su" + + dg-scan "scan-file" 1 $testcase $output_file $args + } +@@ -173,7 +183,9 @@ proc scan-stack-usage { args } { + + proc scan-stack-usage-not { args } { + set testcase [testname-for-summary] +- set output_file "[file rootname [file tail $testcase]].su" ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ set output_file "[file rootname [file tail $filename]].su" + + dg-scan "scan-file-not" 0 $testcase $output_file $args + } +@@ -230,11 +242,13 @@ proc scan-assembler-times { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set pattern [lindex $args 0] + set pp_pattern [make_pattern_printable $pattern] + + # This must match the rule in gcc-dg.exp. +- set output_file "[file rootname [file tail $testcase]].s" ++ set output_file "[file rootname [file tail $filename]].s" + + set files [glob -nocomplain $output_file] + if { $files == "" } { +@@ -290,9 +304,11 @@ proc scan-assembler-dem { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set pattern [lindex $args 0] + set pp_pattern [make_pattern_printable $pattern] +- set output_file "[file rootname [file tail $testcase]].s" ++ set output_file "[file rootname [file tail $filename]].s" + + set files [glob -nocomplain $output_file] + if { $files == "" } { +@@ -344,9 +360,11 @@ proc scan-assembler-dem-not { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set pattern [lindex $args 0] + set pp_pattern [make_pattern_printable $pattern] +- set output_file "[file rootname [file tail $testcase]].s" ++ set output_file "[file rootname [file tail $filename]].s" + + set files [glob -nocomplain $output_file] + if { $files == "" } { +@@ -399,6 +417,8 @@ proc object-size { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set what [lindex $args 0] + set where [lsearch { text data bss total } $what] + if { $where == -1 } { +@@ -416,7 +436,7 @@ proc object-size { args } { + return + } + +- set output_file "[file rootname [file tail $testcase]].o" ++ set output_file "[file rootname [file tail $filename]].o" + if ![file_on_host exists $output_file] { + verbose -log "$testcase: $output_file does not exist" + unresolved "$testcase object-size $what $cmp $with" +@@ -510,7 +530,9 @@ proc dg-function-on-line { args } { + + proc scan-lto-assembler { args } { + set testcase [testname-for-summary] +- set output_file "[file rootname [file tail $testcase]].exe.ltrans0.s" ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] ++ set output_file "[file rootname [file tail $filename]].exe.ltrans0.s" + verbose "output_file: $output_file" + dg-scan "scan-assembler" 1 $testcase $output_file $args + } +Index: gcc-7.5.0+r278197/gcc/testsuite/lib/scandump.exp +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/testsuite/lib/scandump.exp ++++ gcc-7.5.0+r278197/gcc/testsuite/lib/scandump.exp +@@ -45,11 +45,13 @@ proc scan-dump { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + + set printable_pattern [make_pattern_printable [lindex $args 1]] + set suf [dump-suffix [lindex $args 2]] + set testname "$testcase scan-[lindex $args 0]-dump $suf \"$printable_pattern\"" +- set src [file tail [lindex $testcase 0]] ++ set src [file tail $filename] + set output_file "[glob -nocomplain $src.[lindex $args 2]]" + if { $output_file == "" } { + verbose -log "$testcase: dump file does not exist" +@@ -86,10 +88,12 @@ proc scan-dump-times { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set suf [dump-suffix [lindex $args 3]] + set printable_pattern [make_pattern_printable [lindex $args 1]] + set testname "$testcase scan-[lindex $args 0]-dump-times $suf \"$printable_pattern\" [lindex $args 2]" +- set src [file tail [lindex $testcase 0]] ++ set src [file tail $filename] + set output_file "[glob -nocomplain $src.[lindex $args 3]]" + if { $output_file == "" } { + verbose -log "$testcase: dump file does not exist" +@@ -126,10 +130,12 @@ proc scan-dump-not { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set printable_pattern [make_pattern_printable [lindex $args 1]] + set suf [dump-suffix [lindex $args 2]] + set testname "$testcase scan-[lindex $args 0]-dump-not $suf \"$printable_pattern\"" +- set src [file tail [lindex $testcase 0]] ++ set src [file tail $filename] + set output_file "[glob -nocomplain $src.[lindex $args 2]]" + if { $output_file == "" } { + verbose -log "$testcase: dump file does not exist" +@@ -179,10 +185,12 @@ proc scan-dump-dem { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set printable_pattern [make_pattern_printable [lindex $args 1]] + set suf [dump-suffix [lindex $args 2]] + set testname "$testcase scan-[lindex $args 0]-dump-dem $suf \"$printable_pattern\"" +- set src [file tail [lindex $testcase 0]] ++ set src [file tail $filename] + set output_file "[glob -nocomplain $src.[lindex $args 2]]" + if { $output_file == "" } { + verbose -log "$testcase: dump file does not exist" +@@ -231,10 +239,12 @@ proc scan-dump-dem-not { args } { + } + + set testcase [testname-for-summary] ++ # The name might include a list of options; extract the file name. ++ set filename [lindex $testcase 0] + set printable_pattern [make_pattern_printable [lindex $args 1] + set suf [dump-suffix [lindex $args 2]] + set testname "$testcase scan-[lindex $args 0]-dump-dem-not $suf \"$printable_pattern\"" +- set src [file tail [lindex $testcase 0]] ++ set src [file tail $filename] + set output_file "[glob -nocomplain $src.[lindex $args 2]]" + if { $output_file == "" } { + verbose -log "$testcase: dump file does not exist" diff --git a/gcc7-flive-patching.patch b/gcc7-flive-patching.patch new file mode 100644 index 0000000..354588c --- /dev/null +++ b/gcc7-flive-patching.patch @@ -0,0 +1,662 @@ +# The patch is squashed branch: +# https://github.com/marxin/gcc/tree/backport-7-live-patching +# which contains backport of following revisions: +# r270134, r266787, r266627, r265970, r265969 + +diff --git a/gcc/cgraph.h b/gcc/cgraph.h +index ee053885442..8959aee2cc2 100644 +--- a/gcc/cgraph.h ++++ b/gcc/cgraph.h +@@ -2335,7 +2335,7 @@ void record_references_in_initializer (tree, bool); + + /* In ipa.c */ + void cgraph_build_static_cdtor (char which, tree body, int priority); +-bool ipa_discover_readonly_nonaddressable_vars (void); ++bool ipa_discover_variable_flags (void); + + /* In varpool.c */ + tree ctor_for_folding (tree); +diff --git a/gcc/cif-code.def b/gcc/cif-code.def +index 966c6d6f323..dd9dc422d9f 100644 +--- a/gcc/cif-code.def ++++ b/gcc/cif-code.def +@@ -136,6 +136,12 @@ DEFCIFCODE(ATTRIBUTE_MISMATCH, CIF_FINAL_ERROR, + DEFCIFCODE(CILK_SPAWN, CIF_FINAL_ERROR, + N_("caller function contains cilk spawn")) + ++/* We can't inline because the user requests only static functions ++ but the function has external linkage for live patching purpose. */ ++DEFCIFCODE(EXTERN_LIVE_ONLY_STATIC, CIF_FINAL_ERROR, ++ N_("function has external linkage when the user requests only" ++ " inlining static for live patching")) ++ + /* We proved that the call is unreachable. */ + DEFCIFCODE(UNREACHABLE, CIF_FINAL_ERROR, + N_("unreachable")) +diff --git a/gcc/common.opt b/gcc/common.opt +index 437db8e8615..40d0ecb4fa0 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -1645,7 +1645,15 @@ Perform Identical Code Folding for variables. + + fipa-reference + Common Report Var(flag_ipa_reference) Init(0) Optimization +-Discover readonly and non addressable static variables. ++Discover read-only and non addressable static variables. ++ ++fipa-reference-addressable ++Common Report Var(flag_ipa_reference_addressable) Init(0) Optimization ++Discover read-only, write-only and non-addressable static variables. ++ ++fipa-stack-alignment ++Common Report Var(flag_ipa_stack_alignment) Init(1) Optimization ++Reduce stack alignment on call sites if possible. + + fipa-matrix-reorg + Common Ignore +@@ -2055,6 +2063,24 @@ starts and when the destructor finishes. + flifetime-dse= + Common Joined RejectNegative UInteger Var(flag_lifetime_dse) Optimization + ++flive-patching ++Common RejectNegative Alias(flive-patching=,inline-clone) Optimization ++ ++flive-patching= ++Common Report Joined RejectNegative Enum(live_patching_level) Var(flag_live_patching) Init(LIVE_PATCHING_NONE) Optimization ++-flive-patching=[inline-only-static|inline-clone] Control IPA ++optimizations to provide a safe compilation for live-patching. At the same ++time, provides multiple-level control on the enabled IPA optimizations. ++ ++Enum ++Name(live_patching_level) Type(enum live_patching_level) UnknownError(unknown Live-Patching Level %qs) ++ ++EnumValue ++Enum(live_patching_level) String(inline-only-static) Value(LIVE_PATCHING_INLINE_ONLY_STATIC) ++ ++EnumValue ++Enum(live_patching_level) String(inline-clone) Value(LIVE_PATCHING_INLINE_CLONE) ++ + flive-range-shrinkage + Common Report Var(flag_live_range_shrinkage) Init(0) Optimization + Relief of register pressure through live range shrinkage. +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 8f279e454b0..36b5ebe439f 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -375,8 +375,9 @@ Objective-C and Objective-C++ Dialects}. + -finline-functions -finline-functions-called-once -finline-limit=@var{n} @gol + -finline-small-functions -fipa-cp -fipa-cp-clone @gol + -fipa-bit-cp -fipa-vrp @gol +--fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-icf @gol +--fira-algorithm=@var{algorithm} @gol ++-fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-reference-addressable @gol ++-fipa-stack-alignment -fipa-icf -fira-algorithm=@var{algorithm} @gol ++-flive-patching=@var{level} @gol + -fira-region=@var{region} -fira-hoist-pressure @gol + -fira-loop-pressure -fno-ira-share-save-slots @gol + -fno-ira-share-spill-slots @gol +@@ -7038,6 +7039,7 @@ compilation time. + -fipa-pure-const @gol + -fipa-profile @gol + -fipa-reference @gol ++-fipa-reference-addressable @gol + -fmerge-constants @gol + -fmove-loop-invariants @gol + -freorder-blocks @gol +@@ -8068,6 +8070,16 @@ Discover which static variables do not escape the + compilation unit. + Enabled by default at @option{-O} and higher. + ++@item -fipa-reference-addressable ++@opindex fipa-reference-addressable ++Discover read-only, write-only and non-addressable static variables. ++Enabled by default at @option{-O} and higher. ++ ++@item -fipa-stack-alignment ++@opindex fipa-stack-alignment ++Reduce stack alignment on call sites if possible. ++Enabled by default. ++ + @item -fipa-pta + @opindex fipa-pta + Perform interprocedural pointer analysis and interprocedural modification +@@ -8128,6 +8140,65 @@ equivalences that are found only by GCC and equivalences found only by Gold. + + This flag is enabled by default at @option{-O2} and @option{-Os}. + ++@item -flive-patching=@var{level} ++@opindex flive-patching ++Control GCC's optimizations to provide a safe compilation for live-patching. ++ ++If the compiler's optimization uses a function's body or information extracted ++from its body to optimize/change another function, the latter is called an ++impacted function of the former. If a function is patched, its impacted ++functions should be patched too. ++ ++The impacted functions are decided by the compiler's interprocedural ++optimizations. For example, inlining a function into its caller, cloning ++a function and changing its caller to call this new clone, or extracting ++a function's pureness/constness information to optimize its direct or ++indirect callers, etc. ++ ++Usually, the more IPA optimizations enabled, the larger the number of ++impacted functions for each function. In order to control the number of ++impacted functions and computed the list of impacted function easily, ++we provide control to partially enable IPA optimizations on two different ++levels. ++ ++The @var{level} argument should be one of the following: ++ ++@table @samp ++ ++@item inline-clone ++ ++Only enable inlining and cloning optimizations, which includes inlining, ++cloning, interprocedural scalar replacement of aggregates and partial inlining. ++As a result, when patching a function, all its callers and its clones' ++callers need to be patched as well. ++ ++@option{-flive-patching=inline-clone} disables the following optimization flags: ++@gccoptlist{-fwhole-program -fipa-pta -fipa-reference -fipa-ra @gol ++-fipa-icf -fipa-icf-functions -fipa-icf-variables @gol ++-fipa-bit-cp -fipa-vrp -fipa-pure-const -fipa-reference-addressable @gol ++-fipa-stack-alignment} ++ ++@item inline-only-static ++ ++Only enable inlining of static functions. ++As a result, when patching a static function, all its callers need to be ++patches as well. ++ ++In addition to all the flags that -flive-patching=inline-clone disables, ++@option{-flive-patching=inline-only-static} disables the following additional ++optimization flags: ++@gccoptlist{-fipa-cp-clone -fipa-sra -fpartial-inlining -fipa-cp} ++ ++@end table ++ ++When -flive-patching specified without any value, the default value ++is "inline-clone". ++ ++This flag is disabled by default. ++ ++Note that -flive-patching is not supported with link-time optimizer. ++(@option{-flto}). ++ + @item -fisolate-erroneous-paths-dereference + @opindex fisolate-erroneous-paths-dereference + Detect paths that trigger erroneous or undefined behavior due to +diff --git a/gcc/final.c b/gcc/final.c +index c3023285c21..de728c23ed3 100644 +--- a/gcc/final.c ++++ b/gcc/final.c +@@ -4722,7 +4722,8 @@ rest_of_clean_state (void) + /* We can reduce stack alignment on call site only when we are sure that + the function body just produced will be actually used in the final + executable. */ +- if (decl_binds_to_current_def_p (current_function_decl)) ++ if (flag_ipa_stack_alignment ++ && decl_binds_to_current_def_p (current_function_decl)) + { + unsigned int pref = crtl->preferred_stack_boundary; + if (crtl->stack_alignment_needed > crtl->preferred_stack_boundary) +diff --git a/gcc/flag-types.h b/gcc/flag-types.h +index 27a38efdc8e..16d70e18f29 100644 +--- a/gcc/flag-types.h ++++ b/gcc/flag-types.h +@@ -124,6 +124,14 @@ enum stack_reuse_level + SR_ALL + }; + ++/* The live patching level. */ ++enum live_patching_level ++{ ++ LIVE_PATCHING_NONE = 0, ++ LIVE_PATCHING_INLINE_ONLY_STATIC, ++ LIVE_PATCHING_INLINE_CLONE ++}; ++ + /* The algorithm used for basic block reordering. */ + enum reorder_blocks_algorithm + { +diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c +index b520c6393f4..01a1f59e806 100644 +--- a/gcc/ipa-inline.c ++++ b/gcc/ipa-inline.c +@@ -381,6 +381,13 @@ can_inline_edge_p (struct cgraph_edge *e, bool report, + DECL_ATTRIBUTES (caller->decl)) + && !caller_growth_limits (e)) + inlinable = false; ++ else if (callee->externally_visible ++ && !DECL_DISREGARD_INLINE_LIMITS (callee->decl) ++ && flag_live_patching == LIVE_PATCHING_INLINE_ONLY_STATIC) ++ { ++ e->inline_failed = CIF_EXTERN_LIVE_ONLY_STATIC; ++ inlinable = false; ++ } + /* Don't inline a function with a higher optimization level than the + caller. FIXME: this is really just tip of iceberg of handling + optimization attribute. */ +@@ -506,7 +513,6 @@ can_inline_edge_p (struct cgraph_edge *e, bool report, + inlinable = false; + } + } +- + } + + if (!inlinable && report) +diff --git a/gcc/ipa-reference.c b/gcc/ipa-reference.c +index ccbfa078deb..69146962d01 100644 +--- a/gcc/ipa-reference.c ++++ b/gcc/ipa-reference.c +@@ -723,7 +723,7 @@ propagate (void) + if (dump_file) + cgraph_node::dump_cgraph (dump_file); + +- remove_p = ipa_discover_readonly_nonaddressable_vars (); ++ remove_p = ipa_discover_variable_flags (); + generate_summary (); + + /* Propagate the local information through the call graph to produce +diff --git a/gcc/ipa-visibility.c b/gcc/ipa-visibility.c +index da4a22e7329..10a5c0f8b34 100644 +--- a/gcc/ipa-visibility.c ++++ b/gcc/ipa-visibility.c +@@ -877,7 +877,7 @@ whole_program_function_and_variable_visibility (void) + { + function_and_variable_visibility (flag_whole_program); + if (optimize) +- ipa_discover_readonly_nonaddressable_vars (); ++ ipa_discover_variable_flags (); + return 0; + } + +diff --git a/gcc/ipa.c b/gcc/ipa.c +index a74f28c2aa1..110411e9e52 100644 +--- a/gcc/ipa.c ++++ b/gcc/ipa.c +@@ -782,10 +782,10 @@ clear_addressable_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED) + return false; + } + +-/* Discover variables that have no longer address taken or that are read only +- and update their flags. ++/* Discover variables that have no longer address taken, are read-only or ++ write-only and update their flags. + +- Return true when unreachable symbol removan should be done. ++ Return true when unreachable symbol removal should be done. + + FIXME: This can not be done in between gimplify and omp_expand since + readonly flag plays role on what is shared and what is not. Currently we do +@@ -794,8 +794,11 @@ clear_addressable_bit (varpool_node *vnode, void *data ATTRIBUTE_UNUSED) + make sense to do it before early optimizations. */ + + bool +-ipa_discover_readonly_nonaddressable_vars (void) ++ipa_discover_variable_flags (void) + { ++ if (!flag_ipa_reference_addressable) ++ return false; ++ + bool remove_p = false; + varpool_node *vnode; + if (dump_file) +diff --git a/gcc/opts.c b/gcc/opts.c +index b98a0ca73a8..04dfc137ecd 100644 +--- a/gcc/opts.c ++++ b/gcc/opts.c +@@ -451,6 +451,7 @@ static const struct default_options default_options_table[] = + { OPT_LEVELS_1_PLUS_NOT_DEBUG, OPT_fif_conversion2, NULL, 1 }, + { OPT_LEVELS_1_PLUS, OPT_fipa_pure_const, NULL, 1 }, + { OPT_LEVELS_1_PLUS, OPT_fipa_reference, NULL, 1 }, ++ { OPT_LEVELS_1_PLUS, OPT_fipa_reference_addressable, NULL, 1 }, + { OPT_LEVELS_1_PLUS, OPT_fipa_profile, NULL, 1 }, + { OPT_LEVELS_1_PLUS, OPT_fmerge_constants, NULL, 1 }, + { OPT_LEVELS_1_PLUS, OPT_freorder_blocks, NULL, 1 }, +@@ -696,6 +697,148 @@ default_options_optimization (struct gcc_options *opts, + lang_mask, handlers, loc, dc); + } + ++/* Control IPA optimizations based on different live patching LEVEL. */ ++static void ++control_options_for_live_patching (struct gcc_options *opts, ++ struct gcc_options *opts_set, ++ enum live_patching_level level, ++ location_t loc) ++{ ++ gcc_assert (level > LIVE_PATCHING_NONE); ++ ++ switch (level) ++ { ++ case LIVE_PATCHING_INLINE_ONLY_STATIC: ++ if (opts_set->x_flag_ipa_cp_clone && opts->x_flag_ipa_cp_clone) ++ error_at (loc, ++ "%<-fipa-cp-clone%> is incompatible with " ++ "%<-flive-patching=inline-only-static%>"); ++ else ++ opts->x_flag_ipa_cp_clone = 0; ++ ++ if (opts_set->x_flag_ipa_sra && opts->x_flag_ipa_sra) ++ error_at (loc, ++ "%<-fipa-sra%> is incompatible with " ++ "%<-flive-patching=inline-only-static%>"); ++ else ++ opts->x_flag_ipa_sra = 0; ++ ++ if (opts_set->x_flag_partial_inlining && opts->x_flag_partial_inlining) ++ error_at (loc, ++ "%<-fpartial-inlining%> is incompatible with " ++ "%<-flive-patching=inline-only-static%>"); ++ else ++ opts->x_flag_partial_inlining = 0; ++ ++ if (opts_set->x_flag_ipa_cp && opts->x_flag_ipa_cp) ++ error_at (loc, ++ "%<-fipa-cp%> is incompatible with " ++ "%<-flive-patching=inline-only-static%>"); ++ else ++ opts->x_flag_ipa_cp = 0; ++ ++ /* FALLTHROUGH. */ ++ case LIVE_PATCHING_INLINE_CLONE: ++ /* live patching should disable whole-program optimization. */ ++ if (opts_set->x_flag_whole_program && opts->x_flag_whole_program) ++ error_at (loc, ++ "%<-fwhole-program%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_whole_program = 0; ++ ++ /* visibility change should be excluded by !flag_whole_program ++ && !in_lto_p && !flag_ipa_cp_clone && !flag_ipa_sra ++ && !flag_partial_inlining. */ ++ ++ if (opts_set->x_flag_ipa_pta && opts->x_flag_ipa_pta) ++ error_at (loc, ++ "%<-fipa-pta%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_pta = 0; ++ ++ if (opts_set->x_flag_ipa_reference && opts->x_flag_ipa_reference) ++ error_at (loc, ++ "%<-fipa-reference%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_reference = 0; ++ ++ if (opts_set->x_flag_ipa_ra && opts->x_flag_ipa_ra) ++ error_at (loc, ++ "%<-fipa-ra%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_ra = 0; ++ ++ if (opts_set->x_flag_ipa_icf && opts->x_flag_ipa_icf) ++ error_at (loc, ++ "%<-fipa-icf%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_icf = 0; ++ ++ if (opts_set->x_flag_ipa_icf_functions && opts->x_flag_ipa_icf_functions) ++ error_at (loc, ++ "%<-fipa-icf-functions%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_icf_functions = 0; ++ ++ if (opts_set->x_flag_ipa_icf_variables && opts->x_flag_ipa_icf_variables) ++ error_at (loc, ++ "%<-fipa-icf-variables%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_icf_variables = 0; ++ ++ if (opts_set->x_flag_ipa_bit_cp && opts->x_flag_ipa_bit_cp) ++ error_at (loc, ++ "%<-fipa-bit-cp%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_bit_cp = 0; ++ ++ if (opts_set->x_flag_ipa_vrp && opts->x_flag_ipa_vrp) ++ error_at (loc, ++ "%<-fipa-vrp%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_vrp = 0; ++ ++ if (opts_set->x_flag_ipa_pure_const && opts->x_flag_ipa_pure_const) ++ error_at (loc, ++ "%<-fipa-pure-const%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_pure_const = 0; ++ ++ /* FIXME: disable unreachable code removal. */ ++ ++ /* discovery of functions/variables with no address taken. */ ++ if (opts_set->x_flag_ipa_reference_addressable ++ && opts->x_flag_ipa_reference_addressable) ++ error_at (loc, ++ "%<-fipa-reference-addressable%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_reference_addressable = 0; ++ ++ /* ipa stack alignment propagation. */ ++ if (opts_set->x_flag_ipa_stack_alignment ++ && opts->x_flag_ipa_stack_alignment) ++ error_at (loc, ++ "%<-fipa-stack-alignment%> is incompatible with " ++ "%<-flive-patching=inline-only-static|inline-clone%>"); ++ else ++ opts->x_flag_ipa_stack_alignment = 0; ++ break; ++ default: ++ gcc_unreachable (); ++ } ++} ++ + /* After all options at LOC have been read into OPTS and OPTS_SET, + finalize settings of those options and diagnose incompatible + combinations. */ +@@ -1043,6 +1186,18 @@ finish_options (struct gcc_options *opts, struct gcc_options *opts_set, + if (opts->x_align_labels > MAX_CODE_ALIGN_VALUE) + error_at (loc, "-falign-labels=%d is not between 0 and %d", + opts->x_align_labels, MAX_CODE_ALIGN_VALUE); ++ ++ /* Currently live patching is not support for LTO. */ ++ if (opts->x_flag_live_patching && opts->x_flag_lto) ++ sorry ("live patching is not supported with LTO"); ++ ++ /* Control IPA optimizations based on different -flive-patching level. */ ++ if (opts->x_flag_live_patching) ++ { ++ control_options_for_live_patching (opts, opts_set, ++ opts->x_flag_live_patching, ++ loc); ++ } + } + + #define LEFT_COLUMN 27 +diff --git a/gcc/testsuite/gcc.dg/live-patching-1.c b/gcc/testsuite/gcc.dg/live-patching-1.c +new file mode 100644 +index 00000000000..ab4738119b8 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/live-patching-1.c +@@ -0,0 +1,22 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -flive-patching=inline-only-static -fdump-ipa-inline" } */ ++ ++extern int sum, n, m; ++ ++int foo (int a) ++{ ++ return a + n; ++} ++ ++static int bar (int b) ++{ ++ return b * m; ++} ++ ++int main() ++{ ++ sum = foo (m) + bar (n); ++ return 0; ++} ++ ++/* { dg-final { scan-ipa-dump "foo/0 function has external linkage when the user requests only inlining static for live patching" "inline" } } */ +diff --git a/gcc/testsuite/gcc.dg/live-patching-2.c b/gcc/testsuite/gcc.dg/live-patching-2.c +new file mode 100644 +index 00000000000..0dde4e9e0c0 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/live-patching-2.c +@@ -0,0 +1,10 @@ ++/* { dg-do compile } */ ++/* { dg-require-effective-target lto } */ ++/* { dg-options "-O2 -flive-patching -flto" } */ ++ ++int main() ++{ ++ return 0; ++} ++ ++/* { dg-message "sorry, unimplemented: live patching is not supported with LTO" "-flive-patching and -flto together" { target *-*-* } 0 } */ +diff --git a/gcc/testsuite/gcc.dg/live-patching-3.c b/gcc/testsuite/gcc.dg/live-patching-3.c +new file mode 100644 +index 00000000000..b86f3c6e08a +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/live-patching-3.c +@@ -0,0 +1,9 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O1 -flive-patching -fwhole-program" } */ ++ ++int main() ++{ ++ return 0; ++} ++ ++/* { dg-message "'-fwhole-program' is incompatible with '-flive-patching=inline-only-static|inline-clone’" "" {target "*-*-*"} 0 } */ +diff --git a/gcc/testsuite/gcc.dg/live-patching-4.c b/gcc/testsuite/gcc.dg/live-patching-4.c +new file mode 100644 +index 00000000000..bde3d2ed81c +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/live-patching-4.c +@@ -0,0 +1,23 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -flive-patching=inline-only-static -fdump-tree-einline-optimized" } */ ++ ++extern int sum, n, m; ++ ++extern inline __attribute__((always_inline)) int foo (int a); ++inline __attribute__((always_inline)) int foo (int a) ++{ ++ return a + n; ++} ++ ++static int bar (int b) ++{ ++ return b * m; ++} ++ ++int main() ++{ ++ sum = foo (m) + bar (n); ++ return 0; ++} ++ ++/* { dg-final { scan-tree-dump "Inlining foo into main" "einline" } } */ +diff --git a/gcc/testsuite/gcc.dg/tree-ssa/writeonly-2.c b/gcc/testsuite/gcc.dg/tree-ssa/writeonly-2.c +new file mode 100644 +index 00000000000..78893bd7fb8 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/tree-ssa/writeonly-2.c +@@ -0,0 +1,20 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O1 -fdump-tree-optimized -fno-ipa-reference-addressable" } */ ++static struct a {int magic1,b;} a; ++volatile int magic2; ++static struct b {int a,b,c,d,e,f;} magic3; ++ ++struct b foo(); ++ ++void ++t() ++{ ++ a.magic1 = 1; ++ magic2 = 1; ++ magic3 = foo(); ++} ++/* { dg-final { scan-tree-dump "magic1" "optimized"} } */ ++/* { dg-final { scan-tree-dump "magic3" "optimized"} } */ ++/* { dg-final { scan-tree-dump "magic2" "optimized"} } */ ++/* { dg-final { scan-tree-dump "foo" "optimized"} } */ ++ +diff --git a/gcc/testsuite/gcc.dg/tree-ssa/writeonly-3.c b/gcc/testsuite/gcc.dg/tree-ssa/writeonly-3.c +new file mode 100644 +index 00000000000..b42d9374fe9 +--- /dev/null ++++ b/gcc/testsuite/gcc.dg/tree-ssa/writeonly-3.c +@@ -0,0 +1,20 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O1 -fdump-tree-optimized -flive-patching" } */ ++static struct a {int magic1,b;} a; ++volatile int magic2; ++static struct b {int a,b,c,d,e,f;} magic3; ++ ++struct b foo(); ++ ++void ++t() ++{ ++ a.magic1 = 1; ++ magic2 = 1; ++ magic3 = foo(); ++} ++/* { dg-final { scan-tree-dump "magic1" "optimized"} } */ ++/* { dg-final { scan-tree-dump "magic3" "optimized"} } */ ++/* { dg-final { scan-tree-dump "magic2" "optimized"} } */ ++/* { dg-final { scan-tree-dump "foo" "optimized"} } */ ++ +diff --git a/gcc/testsuite/gcc.target/i386/ipa-stack-alignment-2.c b/gcc/testsuite/gcc.target/i386/ipa-stack-alignment-2.c +new file mode 100644 +index 00000000000..8ba70000b7e +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/ipa-stack-alignment-2.c +@@ -0,0 +1,13 @@ ++/* { dg-do compile } */ ++/* { dg-options "-flive-patching -O" } */ ++ ++typedef struct { ++ long a; ++ long b[]; ++} c; ++ ++c *d; ++void e() { d->b[0] = 5; } ++void f() { e(); } ++ ++/* { dg-final { scan-assembler "sub.*%.sp" } } */ +diff --git a/gcc/testsuite/gcc.target/i386/ipa-stack-alignment.c b/gcc/testsuite/gcc.target/i386/ipa-stack-alignment.c +new file mode 100644 +index 00000000000..1176b59aa5f +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/ipa-stack-alignment.c +@@ -0,0 +1,13 @@ ++/* { dg-do compile } */ ++/* { dg-options "-fno-ipa-stack-alignment -O" } */ ++ ++typedef struct { ++ long a; ++ long b[]; ++} c; ++ ++c *d; ++void e() { d->b[0] = 5; } ++void f() { e(); } ++ ++/* { dg-final { scan-assembler "sub.*%.sp" } } */ diff --git a/gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch b/gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch new file mode 100644 index 0000000..e4c1ae7 --- /dev/null +++ b/gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch @@ -0,0 +1,35 @@ +From f35d65517a59565758107c5b1a51a5fa382f8d1a Mon Sep 17 00:00:00 2001 +From: Ian Lance Taylor +Date: Tue, 12 Jul 2022 19:42:43 -0700 +Subject: [PATCH] libgo: don't include when building + gen-sysinfo.go + +Removing this doesn't change anything at least with glibc 2.33. +The include was added in https://go.dev/cl/6100049 but it's not +clear why. + +Fixes PR go/106266 + +Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294 +--- + gcc/go/gofrontend/MERGE | 2 +- + libgo/sysinfo.c | 3 --- + 2 files changed, 1 insertion(+), 4 deletions(-) + +diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c +index a4259c02ded..fc0210992fa 100644 +--- a/libgo/sysinfo.c ++++ b/libgo/sysinfo.c +@@ -158,9 +158,6 @@ + #if defined(HAVE_LINUX_ETHER_H) + #include + #endif +-#if defined(HAVE_LINUX_FS_H) +-#include +-#endif + #if defined(HAVE_LINUX_REBOOT_H) + #include + #endif +-- +2.37.2 + diff --git a/gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch b/gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch new file mode 100644 index 0000000..8eb79ca --- /dev/null +++ b/gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch @@ -0,0 +1,39 @@ +From 2701442d0cf6292f6624443c15813d6d1a3562fe Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Mon, 11 Jul 2022 22:03:14 +0200 +Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream + +9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include to resolve fsconfig_command/mount_attr conflict with glibc 2.36 +--- + .../sanitizer_platform_limits_posix.cpp | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +index 97eae3f..dcedf75 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -62,7 +62,9 @@ + #include + #include + #include ++#if SANITIZER_ANDROID + #include ++#endif + #include + #include + #include +@@ -845,10 +847,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT; + unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT; + #endif +- unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS; +- unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION; +- unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS; +- unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION; ++ unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long); ++ unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long); ++ unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long); ++ unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long); + unsigned IOCTL_GIO_CMAP = GIO_CMAP; + unsigned IOCTL_GIO_FONT = GIO_FONT; + unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP; diff --git a/gcc7-lra-elim.patch b/gcc7-lra-elim.patch new file mode 100644 index 0000000..b9ecfd4 --- /dev/null +++ b/gcc7-lra-elim.patch @@ -0,0 +1,47 @@ +From 9cd11fd48509234e18122036bf504981f5a91b9a Mon Sep 17 00:00:00 2001 +From: Richard Sandiford +Date: Thu, 31 Aug 2023 11:59:56 +0100 +Subject: [PATCH] lra: Avoid unfolded plus-0 +To: gcc-patches@gcc.gnu.org + +While backporting another patch to an earlier release, I hit a +situation in which lra_eliminate_regs_1 would eliminate an address to: + + (plus (reg:P R) (const_int 0)) + +This address compared not-equal to plain: + + (reg:P R) + +which caused an ICE in a later peephole2. (The ICE showed up in +gfortran.fortran-torture/compile/pr80464.f90 on the branch but seems +to be latent on trunk.) + +These unfolded PLUSes shouldn't occur in the insn stream, and later code +in the same function tried to avoid them. + +gcc/ + * lra-eliminations.cc (lra_eliminate_regs_1): Use simplify_gen_binary + rather than gen_rtx_PLUS. +--- + gcc/lra-eliminations.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/gcc/lra-eliminations.c b/gcc/lra-eliminations.c +index 993da861cf9..a3daf443caf 100644 +--- a/gcc/lra-eliminations.c ++++ b/gcc/lra-eliminations.c +@@ -391,8 +391,8 @@ lra_eliminate_regs_1 (rtx_insn *insn, rtx x, machine_mode mem_mode, + rtx to = subst_p ? ep->to_rtx : ep->from_rtx; + + if (! update_p && ! full_p) +- return gen_rtx_PLUS (Pmode, to, XEXP (x, 1)); +- ++ return simplify_gen_binary (PLUS, Pmode, to, XEXP (x, 1)); ++ + if (update_sp_offset != 0) + offset = ep->to_rtx == stack_pointer_rtx ? update_sp_offset : 0; + else +-- +2.35.3 + diff --git a/gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch b/gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch new file mode 100644 index 0000000..0c6640b --- /dev/null +++ b/gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch @@ -0,0 +1,555 @@ +From 1258c4f8a08681cce523c40352a37584f9ba63bd Mon Sep 17 00:00:00 2001 +From: Torsten Duwe +Date: Tue, 25 Jul 2017 14:16:10 +0000 +Subject: [PATCH 01/22] Backport "Add entry for "patchable_function_entry". + +2021-10-07 Giuliano Belinassi + Backport from mainline + +2017-07-07 Torsten Duwe + + c-family/ + * c-attribs.c (c_common_attribute_table): Add entry for + "patchable_function_entry". + + lto/ + * lto-lang.c (lto_attribute_table): Add entry for + "patchable_function_entry". + + * common.opt: Introduce -fpatchable-function-entry + command line option, and its variables function_entry_patch_area_size + and function_entry_patch_area_start. + * opts.c (common_handle_option): Add -fpatchable_function_entry_ case, + including a two-value parser. + * target.def (print_patchable_function_entry): New target hook. + * targhooks.h (default_print_patchable_function_entry): New function. + * targhooks.c (default_print_patchable_function_entry): Likewise. + * toplev.c (process_options): Switch off IPA-RA if + patchable function entries are being generated. + * varasm.c (assemble_start_function): Look at the + patchable-function-entry command line switch and current + function attributes and maybe generate NOP instructions by + calling the print_patchable_function_entry hook. + * doc/extend.texi: Document patchable_function_entry attribute. + * doc/invoke.texi: Document -fpatchable_function_entry + command line option. + * doc/tm.texi.in (TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY): + New target hook. + * doc/tm.texi: Re-generate. + + * c-c++-common/patchable_function_entry-default.c: New test. + * c-c++-common/patchable_function_entry-decl.c: Likewise. + * c-c++-common/patchable_function_entry-definition.c: Likewise. +--- + gcc/c-family/c-attribs.c | 12 +++++ + gcc/common.opt | 11 +++++ + gcc/doc/extend.texi | 21 +++++++++ + gcc/doc/invoke.texi | 28 +++++++++++ + gcc/doc/tm.texi | 9 ++++ + gcc/doc/tm.texi.in | 2 + + gcc/lto/lto-lang.c | 12 +++++ + gcc/opts.c | 27 +++++++++++ + gcc/target.def | 11 +++++ + gcc/targhooks.c | 46 +++++++++++++++++++ + gcc/targhooks.h | 3 ++ + .../patchable_function_entry-decl.c | 16 +++++++ + .../patchable_function_entry-default.c | 16 +++++++ + .../patchable_function_entry-definition.c | 16 +++++++ + gcc/toplev.c | 4 +- + gcc/varasm.c | 46 +++++++++++++++++++ + 16 files changed, 279 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/c-c++-common/patchable_function_entry-decl.c + create mode 100644 gcc/testsuite/c-c++-common/patchable_function_entry-default.c + create mode 100644 gcc/testsuite/c-c++-common/patchable_function_entry-definition.c + +diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c +index 90b17bc00d2..b2820dd1586 100644 +--- a/gcc/c-family/c-attribs.c ++++ b/gcc/c-family/c-attribs.c +@@ -139,6 +139,8 @@ static tree handle_bnd_variable_size_attribute (tree *, tree, tree, int, bool *) + static tree handle_bnd_legacy (tree *, tree, tree, int, bool *); + static tree handle_bnd_instrument (tree *, tree, tree, int, bool *); + static tree handle_fallthrough_attribute (tree *, tree, tree, int, bool *); ++static tree handle_patchable_function_entry_attribute (tree *, tree, tree, ++ int, bool *); + + /* Table of machine-independent attributes common to all C-like languages. + +@@ -345,6 +347,9 @@ const struct attribute_spec c_common_attribute_table[] = + handle_bnd_instrument, false }, + { "fallthrough", 0, 0, false, false, false, + handle_fallthrough_attribute, false }, ++ { "patchable_function_entry", 1, 2, true, false, false, ++ handle_patchable_function_entry_attribute, ++ false }, + { NULL, 0, 0, false, false, false, NULL, false } + }; + +@@ -3178,3 +3183,10 @@ handle_fallthrough_attribute (tree *, tree name, tree, int, + *no_add_attrs = true; + return NULL_TREE; + } ++ ++static tree ++handle_patchable_function_entry_attribute (tree *, tree, tree, int, bool *) ++{ ++ /* Nothing to be done here. */ ++ return NULL_TREE; ++} +diff --git a/gcc/common.opt b/gcc/common.opt +index 437db8e8615..ca1613b6808 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -163,6 +163,13 @@ bool flag_stack_usage_info = false + Variable + int flag_debug_asm + ++; How many NOP insns to place at each function entry by default ++Variable ++HOST_WIDE_INT function_entry_patch_area_size ++ ++; And how far the real asm entry point is into this area ++Variable ++HOST_WIDE_INT function_entry_patch_area_start + + ; Balance between GNAT encodings and standard DWARF to emit. + Variable +@@ -2022,6 +2029,10 @@ fprofile-reorder-functions + Common Report Var(flag_profile_reorder_functions) + Enable function reordering that improves code placement. + ++fpatchable-function-entry= ++Common Joined Optimization ++Insert NOP instructions at each function entry. ++ + frandom-seed + Common Var(common_deferred_options) Defer + +diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi +index 1ef46799907..6860a391f62 100644 +--- a/gcc/doc/extend.texi ++++ b/gcc/doc/extend.texi +@@ -3083,6 +3083,27 @@ that affect more than one function. + This attribute should be used for debugging purposes only. It is not + suitable in production code. + ++@item patchable_function_entry ++@cindex @code{patchable_function_entry} function attribute ++@cindex extra NOP instructions at the function entry point ++In case the target's text segment can be made writable at run time by ++any means, padding the function entry with a number of NOPs can be ++used to provide a universal tool for instrumentation. ++ ++The @code{patchable_function_entry} function attribute can be used to ++change the number of NOPs to any desired value. The two-value syntax ++is the same as for the command-line switch ++@option{-fpatchable-function-entry=N,M}, generating @var{N} NOPs, with ++the function entry point before the @var{M}th NOP instruction. ++@var{M} defaults to 0 if omitted e.g. function entry point is before ++the first NOP. ++ ++If patchable function entries are enabled globally using the command-line ++option @option{-fpatchable-function-entry=N,M}, then you must disable ++instrumentation on all functions that are part of the instrumentation ++framework with the attribute @code{patchable_function_entry (0)} ++to prevent recursion. ++ + @item pure + @cindex @code{pure} function attribute + @cindex functions that have no side effects +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 8f279e454b0..ad71be54e07 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -11417,6 +11417,34 @@ of the function name, it is considered to be a match. For C99 and C++ + extended identifiers, the function name must be given in UTF-8, not + using universal character names. + ++@item -fpatchable-function-entry=@var{N}[,@var{M}] ++@opindex fpatchable-function-entry ++Generate @var{N} NOPs right at the beginning ++of each function, with the function entry point before the @var{M}th NOP. ++If @var{M} is omitted, it defaults to @code{0} so the ++function entry points to the address just at the first NOP. ++The NOP instructions reserve extra space which can be used to patch in ++any desired instrumentation at run time, provided that the code segment ++is writable. The amount of space is controllable indirectly via ++the number of NOPs; the NOP instruction used corresponds to the instruction ++emitted by the internal GCC back-end interface @code{gen_nop}. This behavior ++is target-specific and may also depend on the architecture variant and/or ++other compilation options. ++ ++For run-time identification, the starting addresses of these areas, ++which correspond to their respective function entries minus @var{M}, ++are additionally collected in the @code{__patchable_function_entries} ++section of the resulting binary. ++ ++Note that the value of @code{__attribute__ ((patchable_function_entry ++(N,M)))} takes precedence over command-line option ++@option{-fpatchable-function-entry=N,M}. This can be used to increase ++the area size or to remove it completely on a single function. ++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. ++ + @end table + + +diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi +index 1bb5a9d9579..b4456f7cd40 100644 +--- a/gcc/doc/tm.texi ++++ b/gcc/doc/tm.texi +@@ -4566,6 +4566,15 @@ will select the smallest suitable mode. + This section describes the macros that output function entry + (@dfn{prologue}) and exit (@dfn{epilogue}) code. + ++@deftypefn {Target Hook} void TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY (FILE *@var{file}, unsigned HOST_WIDE_INT @var{patch_area_size}, bool @var{record_p}) ++Generate a patchable area at the function start, consisting of ++@var{patch_area_size} NOP instructions. If the target supports named ++sections and if @var{record_p} is true, insert a pointer to the current ++location in the table of patchable functions. The default implementation ++of the hook places the table of pointers in the special section named ++@code{__patchable_function_entries}. ++@end deftypefn ++ + @deftypefn {Target Hook} void TARGET_ASM_FUNCTION_PROLOGUE (FILE *@var{file}, HOST_WIDE_INT @var{size}) + If defined, a function that outputs the assembler code for entry to a + function. The prologue is responsible for setting up the stack frame, +diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in +index d4047142027..b188c94ae5e 100644 +--- a/gcc/doc/tm.texi.in ++++ b/gcc/doc/tm.texi.in +@@ -3650,6 +3650,8 @@ will select the smallest suitable mode. + This section describes the macros that output function entry + (@dfn{prologue}) and exit (@dfn{epilogue}) code. + ++@hook TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY ++ + @hook TARGET_ASM_FUNCTION_PROLOGUE + + @hook TARGET_ASM_FUNCTION_END_PROLOGUE +diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c +index fdd6ae08a1c..530d9dc31d0 100644 +--- a/gcc/lto/lto-lang.c ++++ b/gcc/lto/lto-lang.c +@@ -48,6 +48,8 @@ static tree handle_sentinel_attribute (tree *, tree, tree, int, bool *); + static tree handle_type_generic_attribute (tree *, tree, tree, int, bool *); + static tree handle_transaction_pure_attribute (tree *, tree, tree, int, bool *); + static tree handle_returns_twice_attribute (tree *, tree, tree, int, bool *); ++static tree handle_patchable_function_entry_attribute (tree *, tree, tree, ++ int, bool *); + static tree ignore_attribute (tree *, tree, tree, int, bool *); + + static tree handle_format_attribute (tree *, tree, tree, int, bool *); +@@ -76,6 +78,9 @@ const struct attribute_spec lto_attribute_table[] = + handle_nonnull_attribute, false }, + { "nothrow", 0, 0, true, false, false, + handle_nothrow_attribute, false }, ++ { "patchable_function_entry", 1, 2, true, false, false, ++ handle_patchable_function_entry_attribute, ++ false }, + { "returns_twice", 0, 0, true, false, false, + handle_returns_twice_attribute, false }, + { "sentinel", 0, 1, false, true, true, +@@ -473,6 +478,13 @@ handle_returns_twice_attribute (tree *node, tree ARG_UNUSED (name), + return NULL_TREE; + } + ++static tree ++handle_patchable_function_entry_attribute (tree *, tree, tree, int, bool *) ++{ ++ /* Nothing to be done here. */ ++ return NULL_TREE; ++} ++ + /* Ignore the given attribute. Used when this attribute may be usefully + overridden by the target, but is not used generically. */ + +diff --git a/gcc/opts.c b/gcc/opts.c +index b98a0ca73a8..d0430e777ee 100644 +--- a/gcc/opts.c ++++ b/gcc/opts.c +@@ -2201,6 +2201,33 @@ common_handle_option (struct gcc_options *opts, + opts->x_flag_ipa_reference = false; + break; + ++ case OPT_fpatchable_function_entry_: ++ { ++ char *patch_area_arg = xstrdup (arg); ++ char *comma = strchr (patch_area_arg, ','); ++ if (comma) ++ { ++ *comma = '\0'; ++ function_entry_patch_area_size = ++ integral_argument (patch_area_arg); ++ function_entry_patch_area_start = ++ integral_argument (comma + 1); ++ } ++ else ++ { ++ function_entry_patch_area_size = ++ integral_argument (patch_area_arg); ++ function_entry_patch_area_start = 0; ++ } ++ if (function_entry_patch_area_size < 0 ++ || function_entry_patch_area_start < 0 ++ || function_entry_patch_area_size ++ < function_entry_patch_area_start) ++ error ("invalid arguments for %<-fpatchable_function_entry%>"); ++ free (patch_area_arg); ++ } ++ break; ++ + case OPT_ftree_vectorize: + if (!opts_set->x_flag_tree_loop_vectorize) + opts->x_flag_tree_loop_vectorize = value; +diff --git a/gcc/target.def b/gcc/target.def +index 6bebfd5b9d6..bea79404836 100644 +--- a/gcc/target.def ++++ b/gcc/target.def +@@ -288,6 +288,17 @@ hidden, protected or internal visibility as specified by @var{visibility}.", + void, (tree decl, int visibility), + default_assemble_visibility) + ++DEFHOOK ++(print_patchable_function_entry, ++ "Generate a patchable area at the function start, consisting of\n\ ++@var{patch_area_size} NOP instructions. If the target supports named\n\ ++sections and if @var{record_p} is true, insert a pointer to the current\n\ ++location in the table of patchable functions. The default implementation\n\ ++of the hook places the table of pointers in the special section named\n\ ++@code{__patchable_function_entries}.", ++ void, (FILE *file, unsigned HOST_WIDE_INT patch_area_size, bool record_p), ++ default_print_patchable_function_entry) ++ + /* Output the assembler code for entry to a function. */ + DEFHOOK + (function_prologue, +diff --git a/gcc/targhooks.c b/gcc/targhooks.c +index 1cdec068ed8..77ca69105d0 100644 +--- a/gcc/targhooks.c ++++ b/gcc/targhooks.c +@@ -72,6 +72,7 @@ along with GCC; see the file COPYING3. If not see + #include "calls.h" + #include "expr.h" + #include "output.h" ++#include "common/common-target.h" + #include "reload.h" + #include "intl.h" + #include "opts.h" +@@ -1609,6 +1610,51 @@ default_compare_by_pieces_branch_ratio (machine_mode) + return 1; + } + ++/* Write PATCH_AREA_SIZE NOPs into the asm outfile FILE around a function ++ entry. If RECORD_P is true and the target supports named sections, ++ the location of the NOPs will be recorded in a special object section ++ called "__patchable_function_entries". This routine may be called ++ twice per function to put NOPs before and after the function ++ entry. */ ++ ++void ++default_print_patchable_function_entry (FILE *file, ++ unsigned HOST_WIDE_INT patch_area_size, ++ bool record_p) ++{ ++ const char *nop_templ = 0; ++ int code_num; ++ rtx_insn *my_nop = make_insn_raw (gen_nop ()); ++ ++ /* We use the template alone, relying on the (currently sane) assumption ++ that the NOP template does not have variable operands. */ ++ code_num = recog_memoized (my_nop); ++ nop_templ = get_insn_template (code_num, my_nop); ++ ++ if (record_p && targetm_common.have_named_sections) ++ { ++ char buf[256]; ++ static int patch_area_number; ++ section *previous_section = in_section; ++ ++ patch_area_number++; ++ ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number); ++ ++ switch_to_section (get_section ("__patchable_function_entries", ++ 0, NULL)); ++ fputs (integer_asm_op (POINTER_SIZE_UNITS, false), file); ++ assemble_name_raw (file, buf); ++ fputc ('\n', file); ++ ++ switch_to_section (previous_section); ++ ASM_OUTPUT_LABEL (file, buf); ++ } ++ ++ unsigned i; ++ for (i = 0; i < patch_area_size; ++i) ++ fprintf (file, "\t%s\n", nop_templ); ++} ++ + bool + default_profile_before_prologue (void) + { +diff --git a/gcc/targhooks.h b/gcc/targhooks.h +index 18070df7839..6206fe20823 100644 +--- a/gcc/targhooks.h ++++ b/gcc/targhooks.h +@@ -203,6 +203,9 @@ extern bool default_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT, + bool); + extern int default_compare_by_pieces_branch_ratio (machine_mode); + ++extern void default_print_patchable_function_entry (FILE *, ++ unsigned HOST_WIDE_INT, ++ bool); + extern bool default_profile_before_prologue (void); + extern reg_class_t default_preferred_reload_class (rtx, reg_class_t); + extern reg_class_t default_preferred_output_reload_class (rtx, reg_class_t); +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +new file mode 100644 +index 00000000000..8514b10e820 +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -0,0 +1,16 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ ++/* { dg-final { scan-assembler-times "nop" 2 } } */ ++ ++extern int a; ++ ++/* Respect overriding attributes in the declaration. */ ++int f3 (void) __attribute__((patchable_function_entry(2))); ++ ++/* F3 should now get 2 NOPs. */ ++int ++__attribute__((noinline)) ++f3 (void) ++{ ++ return 5*a; ++} +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +new file mode 100644 +index 00000000000..0dcf1181dde +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -0,0 +1,16 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ ++/* { dg-final { scan-assembler-times "nop" 3 } } */ ++ ++extern int a; ++ ++/* Nothing declared must not mean anything. */ ++int f3 (void); ++ ++/* F3 should get a default-sized NOP area. */ ++int ++__attribute__((noinline)) ++f3 (void) ++{ ++ return 5*a; ++} +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +new file mode 100644 +index 00000000000..a007867dcb0 +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -0,0 +1,16 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ ++/* { dg-final { scan-assembler-times "nop" 1 } } */ ++ ++extern int a; ++ ++int f3 (void); ++ ++/* F3 should now get 1 NOP. */ ++int ++__attribute__((noinline)) ++__attribute__((patchable_function_entry(1))) ++f3 (void) ++{ ++ return 5*a; ++} +diff --git a/gcc/toplev.c b/gcc/toplev.c +index 6f0bc9fe736..7d3aa280f15 100644 +--- a/gcc/toplev.c ++++ b/gcc/toplev.c +@@ -1612,8 +1612,10 @@ process_options (void) + } + + /* Do not use IPA optimizations for register allocation if profiler is active ++ or patchable function entries are inserted for run-time instrumentation + or port does not emit prologue and epilogue as RTL. */ +- if (profile_flag || !targetm.have_prologue () || !targetm.have_epilogue ()) ++ if (profile_flag || function_entry_patch_area_size ++ || !targetm.have_prologue () || !targetm.have_epilogue ()) + flag_ipa_ra = 0; + + /* Enable -Werror=coverage-mismatch when -Werror and -Wno-error +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 1b9030029ac..6e9a8c3133e 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -1829,6 +1829,46 @@ assemble_start_function (tree decl, const char *fnname) + if (DECL_PRESERVE_P (decl)) + targetm.asm_out.mark_decl_preserved (fnname); + ++ unsigned HOST_WIDE_INT patch_area_size = function_entry_patch_area_size; ++ unsigned HOST_WIDE_INT patch_area_entry = function_entry_patch_area_start; ++ ++ tree patchable_function_entry_attr ++ = lookup_attribute ("patchable_function_entry", DECL_ATTRIBUTES (decl)); ++ if (patchable_function_entry_attr) ++ { ++ tree pp_val = TREE_VALUE (patchable_function_entry_attr); ++ tree patchable_function_entry_value1 = TREE_VALUE (pp_val); ++ ++ if (tree_fits_uhwi_p (patchable_function_entry_value1)) ++ patch_area_size = tree_to_uhwi (patchable_function_entry_value1); ++ else ++ gcc_unreachable (); ++ ++ patch_area_entry = 0; ++ if (list_length (pp_val) > 1) ++ { ++ tree patchable_function_entry_value2 = ++ TREE_VALUE (TREE_CHAIN (pp_val)); ++ ++ if (tree_fits_uhwi_p (patchable_function_entry_value2)) ++ patch_area_entry = tree_to_uhwi (patchable_function_entry_value2); ++ else ++ gcc_unreachable (); ++ } ++ } ++ ++ if (patch_area_entry > patch_area_size) ++ { ++ if (patch_area_size > 0) ++ warning (OPT_Wattributes, "Patchable function entry > size"); ++ patch_area_entry = 0; ++ } ++ ++ /* Emit the patching area before the entry label, if any. */ ++ if (patch_area_entry > 0) ++ targetm.asm_out.print_patchable_function_entry (asm_out_file, ++ patch_area_entry, true); ++ + /* Do any machine/system dependent processing of the function name. */ + #ifdef ASM_DECLARE_FUNCTION_NAME + ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl); +@@ -1837,6 +1877,12 @@ assemble_start_function (tree decl, const char *fnname) + ASM_OUTPUT_FUNCTION_LABEL (asm_out_file, fnname, current_function_decl); + #endif /* ASM_DECLARE_FUNCTION_NAME */ + ++ /* And the area after the label. Record it if we haven't done so yet. */ ++ if (patch_area_size > patch_area_entry) ++ targetm.asm_out.print_patchable_function_entry (asm_out_file, ++ patch_area_size-patch_area_entry, ++ patch_area_entry == 0); ++ + if (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (decl))) + saw_no_split_stack = true; + } +-- +2.33.1 + diff --git a/gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch b/gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch new file mode 100644 index 0000000..38ffdb1 --- /dev/null +++ b/gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch @@ -0,0 +1,53 @@ +From c375b71b3f7e6801a5e5a10275b1a0e405f0ab6a Mon Sep 17 00:00:00 2001 +From: Tom de Vries +Date: Thu, 3 Aug 2017 07:07:38 +0000 +Subject: [PATCH 02/22] Backport Skip fpatchable-function-entry tests for nvptx + +gcc/testsuite/ChangeLog +2021-10-07 Giuliano Belinassi + + 2017-08-03 Tom de Vries + + PR target/81662 + * c-c++-common/patchable_function_entry-decl.c: Skip for nvptx. + * c-c++-common/patchable_function_entry-default.c: Same. + * c-c++-common/patchable_function_entry-definition.c: Same. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 2 +- + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 2 +- + .../c-c++-common/patchable_function_entry-definition.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index 8514b10e820..5c39a354559 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,4 +1,4 @@ +-/* { dg-do compile } */ ++/* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ + /* { dg-final { scan-assembler-times "nop" 2 } } */ + +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 0dcf1181dde..48094f75f78 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,4 +1,4 @@ +-/* { dg-do compile } */ ++/* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ + /* { dg-final { scan-assembler-times "nop" 3 } } */ + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index a007867dcb0..af8202f283b 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,4 +1,4 @@ +-/* { dg-do compile } */ ++/* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ + /* { dg-final { scan-assembler-times "nop" 1 } } */ + +-- +2.33.1 + diff --git a/gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch b/gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch new file mode 100644 index 0000000..2fa0938 --- /dev/null +++ b/gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch @@ -0,0 +1,61 @@ +From cbc0c2840906ad6fee93a7423a0212713949e90e Mon Sep 17 00:00:00 2001 +From: Tom de Vries +Date: Thu, 3 Aug 2017 11:18:09 +0000 +Subject: [PATCH 03/22] Backport Error out on nvptx for + fpatchable-function-entry + +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2017-08-03 Tom de Vries + + PR target/81662 + * config/nvptx/nvptx.c (nvptx_option_override): Emit sorry if + function_entry_patch_area_size > 0. + + * gcc.target/nvptx/patchable_function_entry-default.c: New test. +--- + gcc/config/nvptx/nvptx.c | 4 ++++ + .../nvptx/patchable_function_entry-default.c | 15 +++++++++++++++ + 2 files changed, 19 insertions(+) + create mode 100644 gcc/testsuite/gcc.target/nvptx/patchable_function_entry-default.c + +diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c +index 74bce3ec8d0..b0470836fb8 100644 +--- a/gcc/config/nvptx/nvptx.c ++++ b/gcc/config/nvptx/nvptx.c +@@ -178,6 +178,10 @@ nvptx_option_override (void) + if (!global_options_set.x_flag_no_common) + flag_no_common = 1; + ++ /* The patch area requires nops, which we don't have. */ ++ if (function_entry_patch_area_size > 0) ++ sorry ("not generating patch area, nops not supported"); ++ + /* Assumes that it will see only hard registers. */ + flag_var_tracking = 0; + +diff --git a/gcc/testsuite/gcc.target/nvptx/patchable_function_entry-default.c b/gcc/testsuite/gcc.target/nvptx/patchable_function_entry-default.c +new file mode 100644 +index 00000000000..42544562725 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/nvptx/patchable_function_entry-default.c +@@ -0,0 +1,15 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ ++ ++extern int a; ++ ++int f3 (void); ++ ++int ++__attribute__((noinline)) ++f3 (void) ++{ ++ return 5*a; ++} ++ ++/* { dg-excess-errors "sorry, unimplemented: not generating patch area, nops not supported" } */ +-- +2.33.1 + diff --git a/gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch b/gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch new file mode 100644 index 0000000..3c798fc --- /dev/null +++ b/gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch @@ -0,0 +1,63 @@ +From 96c0b9515d054bdc339bc379610a9c6b383b5977 Mon Sep 17 00:00:00 2001 +From: Uros Bizjak +Date: Wed, 16 Aug 2017 20:44:28 +0200 +Subject: [PATCH 04/22] Backport Adapt scan-assembler-times for alpha*-*-* + +testsuite/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2017-08-16 Uros Bizjak + + * c-c++-common/patchable_function_entry-decl.c (dg-final): Adapt + scan-assembler-times for alpha*-*-*. + * c-c++-common/patchable_function_entry-default.c (dg-final): Ditto. + * c-c++-common/patchable_function_entry-definition.c (dg-final): Ditto. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 3 ++- + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 3 ++- + .../c-c++-common/patchable_function_entry-definition.c | 3 ++- + 3 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index 5c39a354559..fb61ac31795 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,6 +1,7 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 2 } } */ ++/* { dg-final { scan-assembler-times "nop" 2 { target { ! alpha*-*-* } } } } */ ++/* { dg-final { scan-assembler-times "bis" 2 { target alpha*-*-* } } } */ + + extern int a; + +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 48094f75f78..c18f9e6bd39 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,6 +1,7 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 3 } } */ ++/* { dg-final { scan-assembler-times "nop" 3 { target { ! alpha*-*-* } } } } */ ++/* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ + + extern int a; + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index af8202f283b..54a57ba7226 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,6 +1,7 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 1 } } */ ++/* { dg-final { scan-assembler-times "nop" 1 { target { ! alpha*-*-* } } } } */ ++/* { dg-final { scan-assembler-times "bis" 1 { target alpha*-*-* } } } */ + + extern int a; + +-- +2.33.1 + diff --git a/gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch b/gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch new file mode 100644 index 0000000..ead31dd --- /dev/null +++ b/gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch @@ -0,0 +1,66 @@ +From 73fddef0fed58c74a8d6bcd40c632f1b31a23108 Mon Sep 17 00:00:00 2001 +From: Eric Botcazou +Date: Tue, 16 Jan 2018 21:21:29 +0000 +Subject: [PATCH 05/22] Backport patchable_function_entry-decl.c: Use 3 NOPs on + Visium. + +testsuite/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2018-01-16 Eric Botcazou + + * c-c++-common/patchable_function_entry-decl.c: Use 3 NOPs on Visium. + * c-c++-common/patchable_function_entry-default.c: 4 NOPs on Visium. + * c-c++-common/patchable_function_entry-definition.c: 2 NOPs on Visium. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 3 ++- + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 3 ++- + .../c-c++-common/patchable_function_entry-definition.c | 3 ++- + 3 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index fb61ac31795..32e2c06eae3 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,7 +1,8 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 2 { target { ! alpha*-*-* } } } } */ ++/* { dg-final { scan-assembler-times "nop" 2 { target { ! { alpha*-*-* visium-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 2 { target alpha*-*-* } } } */ ++/* { dg-final { scan-assembler-times "nop" 3 { target visium-*-* } } } */ + + extern int a; + +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 c18f9e6bd39..be88e431e30 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,7 +1,8 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 3 { target { ! alpha*-*-* } } } } */ ++/* { dg-final { scan-assembler-times "nop" 3 { target { ! { alpha*-*-* visium-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ ++/* { dg-final { scan-assembler-times "nop" 4 { target visium-*-* } } } */ + + extern int a; + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index 54a57ba7226..af18dbcd5e6 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,7 +1,8 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 1 { target { ! alpha*-*-* } } } } */ ++/* { dg-final { scan-assembler-times "nop" 1 { target { ! { alpha*-*-* visium-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 1 { target alpha*-*-* } } } */ ++/* { dg-final { scan-assembler-times "nop" 2 { target visium-*-* } } } */ + + extern int a; + +-- +2.33.1 + diff --git a/gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch b/gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch new file mode 100644 index 0000000..03ffa61 --- /dev/null +++ b/gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch @@ -0,0 +1,387 @@ +From 93132e0ab8aacedc740513c8e3d4ffd3bb0b8db7 Mon Sep 17 00:00:00 2001 +From: Andreas Krebbel +Date: Fri, 6 Apr 2018 07:45:42 +0000 +Subject: [PATCH 06/22] Backport IBM Z: Use the dedicated NOP instructions for + "nop" + +We still use lr r0,r0 as a NOP instruction although we have some kind +of dedicated NOP instruction (nopr) which maps to a "branch never". + +As a side-effect this fixes testcases scanning for NOPs +e.g. patchable_function_entry-*. + +As another side-effect this makes it difficult to distingiush NOPs +generated for hotpatching from NOPs added when using -O0 to attach +location information to it. Hence I had to make sure that the hotpatch +testcases get skipped when compiling without optimization. + +2021-10-07 Giuliano Belinassi + + Backport from mainline + gcc/ChangeLog: + + 2018-04-06 Andreas Krebbel + + * config/s390/s390.c (s390_z10_optimize_cmp): Expand dedicated NOP + instructions. + * config/s390/s390.md (UNSPECV_NOP_LR_0, UNSPECV_NOP_LR_1): New + constant definitions. + ("nop"): lr 0,0 -> nopr r0 + ("nop_lr0", "nop_lr1"): New insn definitions. + + gcc/testsuite/ChangeLog: + + 2018-04-06 Andreas Krebbel + + * gcc.target/s390/s390.exp: Remove -O0 from list of torture + options. + * gcc.target/s390/hotpatch-1.c: Skip when building without + optimization. + * gcc.target/s390/hotpatch-10.c: Likewise. + * gcc.target/s390/hotpatch-11.c: Likewise. + * gcc.target/s390/hotpatch-12.c: Likewise. + * gcc.target/s390/hotpatch-13.c: Likewise. + * gcc.target/s390/hotpatch-14.c: Likewise. + * gcc.target/s390/hotpatch-15.c: Likewise. + * gcc.target/s390/hotpatch-16.c: Likewise. + * gcc.target/s390/hotpatch-17.c: Likewise. + * gcc.target/s390/hotpatch-18.c: Likewise. + * gcc.target/s390/hotpatch-19.c: Likewise. + * gcc.target/s390/hotpatch-2.c: Likewise. + * gcc.target/s390/hotpatch-3.c: Likewise. + * gcc.target/s390/hotpatch-4.c: Likewise. + * gcc.target/s390/hotpatch-5.c: Likewise. + * gcc.target/s390/hotpatch-6.c: Likewise. + * gcc.target/s390/hotpatch-7.c: Likewise. + * gcc.target/s390/hotpatch-8.c: Likewise. + * gcc.target/s390/hotpatch-9.c: Likewise. +--- + gcc/config/s390/s390.c | 4 ++-- + gcc/config/s390/s390.md | 17 +++++++++++++++-- + gcc/testsuite/gcc.target/s390/hotpatch-1.c | 7 +++++++ + gcc/testsuite/gcc.target/s390/hotpatch-10.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-11.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-12.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-13.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-14.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-15.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-16.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-17.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-18.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-19.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-2.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-3.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-4.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-5.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-6.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-7.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-8.c | 1 + + gcc/testsuite/gcc.target/s390/hotpatch-9.c | 1 + + gcc/testsuite/gcc.target/s390/s390.exp | 2 +- + 22 files changed, 43 insertions(+), 5 deletions(-) + +diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c +index 0161ba03ff3..b1db263d37c 100644 +--- a/gcc/config/s390/s390.c ++++ b/gcc/config/s390/s390.c +@@ -13966,9 +13966,9 @@ s390_z10_optimize_cmp (rtx_insn *insn) + && s390_non_addr_reg_read_p (*op0, prev_insn)) + { + if (REGNO (*op1) == 0) +- emit_insn_after (gen_nop1 (), insn); ++ emit_insn_after (gen_nop_lr1 (), insn); + else +- emit_insn_after (gen_nop (), insn); ++ emit_insn_after (gen_nop_lr0 (), insn); + insn_added_p = true; + } + else +diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md +index bb399354855..e134d7f2972 100644 +--- a/gcc/config/s390/s390.md ++++ b/gcc/config/s390/s390.md +@@ -267,6 +267,10 @@ + UNSPECV_CAS + UNSPECV_ATOMIC_OP + ++ ; Non-branch nops used for compare-and-branch adjustments on z10 ++ UNSPECV_NOP_LR_0 ++ UNSPECV_NOP_LR_1 ++ + ; Hotpatching (unremovable NOPs) + UNSPECV_NOP_2_BYTE + UNSPECV_NOP_4_BYTE +@@ -11006,12 +11010,21 @@ + (define_insn "nop" + [(const_int 0)] + "" ++ "nopr\t%%r0" ++ [(set_attr "op_type" "RR")]) ++ ++; non-branch NOPs required for optimizing compare-and-branch patterns ++; on z10 ++ ++(define_insn "nop_lr0" ++ [(unspec_volatile [(const_int 0)] UNSPECV_NOP_LR_0)] ++ "" + "lr\t0,0" + [(set_attr "op_type" "RR") + (set_attr "z10prop" "z10_fr_E1")]) + +-(define_insn "nop1" +- [(const_int 1)] ++(define_insn "nop_lr1" ++ [(unspec_volatile [(const_int 0)] UNSPECV_NOP_LR_1)] + "" + "lr\t1,1" + [(set_attr "op_type" "RR")]) +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-1.c b/gcc/testsuite/gcc.target/s390/hotpatch-1.c +index 5f0f2e19349..67e101ee318 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-1.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-1.c +@@ -3,6 +3,13 @@ + /* { dg-do compile } */ + /* { dg-options "-mzarch" } */ + ++/* Without optimization extra NOPs will be added just to attach ++ location info to it. Don't run the test in that case. The torture ++ framework always appears to run the testcase without -O option ++ first. */ ++ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ ++ + #include + + void hp1(void) +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-10.c b/gcc/testsuite/gcc.target/s390/hotpatch-10.c +index 2308d3331a0..21d499e6204 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-10.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-10.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,0" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-11.c b/gcc/testsuite/gcc.target/s390/hotpatch-11.c +index 56b3596d497..a37f3117c64 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-11.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-11.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=1,0" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-12.c b/gcc/testsuite/gcc.target/s390/hotpatch-12.c +index 8a91c1b8b06..cb8d1521bfa 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-12.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-12.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=999,0" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-13.c b/gcc/testsuite/gcc.target/s390/hotpatch-13.c +index 70fab74d18d..fb037c2040f 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-13.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-13.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-14.c b/gcc/testsuite/gcc.target/s390/hotpatch-14.c +index 389bf42aee8..fd0368a55ae 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-14.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-14.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-15.c b/gcc/testsuite/gcc.target/s390/hotpatch-15.c +index 0b10fb18b41..a1c3e7c694b 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-15.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-15.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-16.c b/gcc/testsuite/gcc.target/s390/hotpatch-16.c +index 2fcdf1ce765..737c3a1c071 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-16.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-16.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,0" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-17.c b/gcc/testsuite/gcc.target/s390/hotpatch-17.c +index 299f82505ee..6d8c40c65c0 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-17.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-17.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=1,2" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-18.c b/gcc/testsuite/gcc.target/s390/hotpatch-18.c +index fd44d118323..02807ff7b6e 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-18.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-18.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=1,2 -mhotpatch=0,0" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-19.c b/gcc/testsuite/gcc.target/s390/hotpatch-19.c +index 899e000a71f..71c2ed13d18 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-19.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-19.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=1,2" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-2.c b/gcc/testsuite/gcc.target/s390/hotpatch-2.c +index 99fe9114f24..ece6cb37e57 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-2.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-2.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,1" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-3.c b/gcc/testsuite/gcc.target/s390/hotpatch-3.c +index 20f43c6b458..65ebe353688 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-3.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-3.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,2" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-4.c b/gcc/testsuite/gcc.target/s390/hotpatch-4.c +index 32a3c032d65..d0956f14240 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-4.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-4.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,3" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-5.c b/gcc/testsuite/gcc.target/s390/hotpatch-5.c +index 72ee5a30056..64d49eecb13 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-5.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-5.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,4" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-6.c b/gcc/testsuite/gcc.target/s390/hotpatch-6.c +index 1e1d0e6973a..e6753c8385d 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-6.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-6.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,5" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-7.c b/gcc/testsuite/gcc.target/s390/hotpatch-7.c +index 3f60e61e7e2..3f1c9f0e294 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-7.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-7.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile } */ + /* { dg-options "-mzarch -mhotpatch=0,6" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-8.c b/gcc/testsuite/gcc.target/s390/hotpatch-8.c +index 012a4ebd44d..a2fb83f2977 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-8.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-8.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile { target { ! lp64 } } } */ + /* { dg-options "-mesa -march=g5 -Wno-deprecated -mhotpatch=0,3" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/hotpatch-9.c b/gcc/testsuite/gcc.target/s390/hotpatch-9.c +index b7d557e43a2..34fae55d3ad 100644 +--- a/gcc/testsuite/gcc.target/s390/hotpatch-9.c ++++ b/gcc/testsuite/gcc.target/s390/hotpatch-9.c +@@ -2,6 +2,7 @@ + + /* { dg-do compile { target { ! lp64 } } } */ + /* { dg-options "-mesa -march=g5 -Wno-deprecated -mhotpatch=0,4" } */ ++/* { dg-skip-if "" { *-*-* } { "*" } { "-O*" } } */ + + #include + +diff --git a/gcc/testsuite/gcc.target/s390/s390.exp b/gcc/testsuite/gcc.target/s390/s390.exp +index 420aff19a3f..8489a51693b 100644 +--- a/gcc/testsuite/gcc.target/s390/s390.exp ++++ b/gcc/testsuite/gcc.target/s390/s390.exp +@@ -220,7 +220,7 @@ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/md/*.{c,S,C}]] \ + + # Additional hotpatch torture tests. + torture-init +-set-torture-options [list -Os -O0 -O1 -O2 -O3] ++set-torture-options [list -Os -O1 -O2 -O3] + gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/hotpatch-\[0-9\]*.c]] \ + "" $DEFAULT_CFLAGS + torture-finish +-- +2.33.1 + diff --git a/gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch b/gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch new file mode 100644 index 0000000..23f5456 --- /dev/null +++ b/gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch @@ -0,0 +1,60 @@ +From 74d2c825af4a197de0aecbaadb66f5ad6d65cbdb Mon Sep 17 00:00:00 2001 +From: Jozef Lawrynowicz +Date: Thu, 8 Nov 2018 16:31:27 +0000 +Subject: [PATCH 07/22] Backport Add regex to search for uppercase "NOP" + instructions in assembler output. + +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2018-11-08 Jozef Lawrynowicz + + * c-c++-common/patchable_function_entry-decl.c: Add regex to search for + uppercase "NOP" instructions in assembler output. + * c-c++-common/patchable_function_entry-default.c: Likewise. + * c-c++-common/patchable_function_entry-definition.c: Likewise. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 2 +- + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 2 +- + .../c-c++-common/patchable_function_entry-definition.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index 32e2c06eae3..3bfb7568bee 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,6 +1,6 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 2 { target { ! { alpha*-*-* visium-*-* } } } } } */ ++/* { dg-final { scan-assembler-times "nop|NOP" 2 { target { ! { alpha*-*-* visium-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 2 { target alpha*-*-* } } } */ + /* { dg-final { scan-assembler-times "nop" 3 { target visium-*-* } } } */ + +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 be88e431e30..bd7c6e98fc6 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,6 +1,6 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 3 { target { ! { alpha*-*-* visium-*-* } } } } } */ ++/* { dg-final { scan-assembler-times "nop|NOP" 3 { target { ! { alpha*-*-* visium-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ + /* { dg-final { scan-assembler-times "nop" 4 { target visium-*-* } } } */ + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index af18dbcd5e6..709113890ef 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,6 +1,6 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop" 1 { target { ! { alpha*-*-* visium-*-* } } } } } */ ++/* { dg-final { scan-assembler-times "nop|NOP" 1 { target { ! { alpha*-*-* visium-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 1 { target alpha*-*-* } } } */ + /* { dg-final { scan-assembler-times "nop" 2 { target visium-*-* } } } */ + +-- +2.33.1 + diff --git a/gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch b/gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch new file mode 100644 index 0000000..e5bf11c --- /dev/null +++ b/gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch @@ -0,0 +1,205 @@ +From c3982f5bddf56bbc96d838ea35540eae81504bb3 Mon Sep 17 00:00:00 2001 +From: Jozef Lawrynowicz +Date: Fri, 16 Nov 2018 23:53:30 +0000 +Subject: [PATCH 08/22] Backport: ICE: segmentation fault with + patchable_function_entry attribute for msp430-elf -mlarge) + +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2018-11-16 Jozef Lawrynowicz + + PR target/87927 + * target-def.h: Initialize TARGET_ASM_{,UN}ALIGNED_P{S,D,T}I_OP. + Add them to the TARGET_ASM_{,UN}ALIGNED_INT_OP structs. + * target.def: Enumerate TARGET_ASM_{,UN}ALIGNED_P{S,D,T}I_OP in + the byte_op hook. + * target.h: Add psi, pdi, pti to struct asm_int_op definition. + * targhooks.c (default_print_patchable_function_entry): Assert + asm_int_op does not return a NULL string. + * varasm.c (integer_asm_op): Return the op for a partial int type + when the requested size does not correspond to an integer type. + * config/msp430/msp430.c: Initialize TARGET_ASM_{,UN}ALIGNED_PSI_OP. + * doc/tm.texi: Regenerate. +--- + gcc/config/msp430/msp430.c | 5 +++++ + gcc/doc/tm.texi | 6 ++++++ + gcc/target-def.h | 15 +++++++++++++++ + gcc/target.def | 6 ++++++ + gcc/target.h | 3 +++ + gcc/targhooks.c | 4 +++- + gcc/varasm.c | 14 ++++++++++++++ + 7 files changed, 52 insertions(+), 1 deletion(-) + +diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c +index c1f0d5b0026..3ad552d9e94 100644 +--- a/gcc/config/msp430/msp430.c ++++ b/gcc/config/msp430/msp430.c +@@ -3391,6 +3391,11 @@ msp430_print_operand_raw (FILE * file, rtx op) + } + } + ++#undef TARGET_ASM_ALIGNED_PSI_OP ++#define TARGET_ASM_ALIGNED_PSI_OP "\t.long\t" ++#undef TARGET_ASM_UNALIGNED_PSI_OP ++#define TARGET_ASM_UNALIGNED_PSI_OP TARGET_ASM_ALIGNED_PSI_OP ++ + #undef TARGET_PRINT_OPERAND_ADDRESS + #define TARGET_PRINT_OPERAND_ADDRESS msp430_print_operand_addr + +diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi +index b4456f7cd40..cb9fabb4295 100644 +--- a/gcc/doc/tm.texi ++++ b/gcc/doc/tm.texi +@@ -7798,12 +7798,18 @@ hook. + + @deftypevr {Target Hook} {const char *} TARGET_ASM_BYTE_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_HI_OP ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PSI_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_SI_OP ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PDI_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_DI_OP ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PTI_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_TI_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_HI_OP ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PSI_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_SI_OP ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PDI_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_DI_OP ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PTI_OP + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_TI_OP + These hooks specify assembly directives for creating certain kinds + of integer object. The @code{TARGET_ASM_BYTE_OP} directive creates a +diff --git a/gcc/target-def.h b/gcc/target-def.h +index c99bfaa0105..cbd9fe6b967 100644 +--- a/gcc/target-def.h ++++ b/gcc/target-def.h +@@ -47,6 +47,15 @@ + #define TARGET_ASM_UNALIGNED_TI_OP NULL + #endif /* OBJECT_FORMAT_ELF */ + ++/* There is no standard way to handle P{S,D,T}Imode, targets must implement them ++ if required. */ ++#define TARGET_ASM_ALIGNED_PSI_OP NULL ++#define TARGET_ASM_UNALIGNED_PSI_OP NULL ++#define TARGET_ASM_ALIGNED_PDI_OP NULL ++#define TARGET_ASM_UNALIGNED_PDI_OP NULL ++#define TARGET_ASM_ALIGNED_PTI_OP NULL ++#define TARGET_ASM_UNALIGNED_PTI_OP NULL ++ + #if !defined(TARGET_ASM_CONSTRUCTOR) && !defined(USE_COLLECT2) + # ifdef CTORS_SECTION_ASM_OP + # define TARGET_ASM_CONSTRUCTOR default_ctor_section_asm_out_constructor +@@ -89,14 +98,20 @@ + + #define TARGET_ASM_ALIGNED_INT_OP \ + {TARGET_ASM_ALIGNED_HI_OP, \ ++ TARGET_ASM_ALIGNED_PSI_OP, \ + TARGET_ASM_ALIGNED_SI_OP, \ ++ TARGET_ASM_ALIGNED_PDI_OP, \ + TARGET_ASM_ALIGNED_DI_OP, \ ++ TARGET_ASM_ALIGNED_PTI_OP, \ + TARGET_ASM_ALIGNED_TI_OP} + + #define TARGET_ASM_UNALIGNED_INT_OP \ + {TARGET_ASM_UNALIGNED_HI_OP, \ ++ TARGET_ASM_UNALIGNED_PSI_OP, \ + TARGET_ASM_UNALIGNED_SI_OP, \ ++ TARGET_ASM_UNALIGNED_PDI_OP, \ + TARGET_ASM_UNALIGNED_DI_OP, \ ++ TARGET_ASM_UNALIGNED_PTI_OP, \ + TARGET_ASM_UNALIGNED_TI_OP} + + #if !defined (TARGET_FUNCTION_INCOMING_ARG) +diff --git a/gcc/target.def b/gcc/target.def +index bea79404836..c50ed9445cd 100644 +--- a/gcc/target.def ++++ b/gcc/target.def +@@ -45,12 +45,18 @@ DEFHOOKPODX (close_paren, const char *, ")") + DEFHOOKPOD + (byte_op, + "@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_HI_OP\n\ ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PSI_OP\n\ + @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_SI_OP\n\ ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PDI_OP\n\ + @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_DI_OP\n\ ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_PTI_OP\n\ + @deftypevrx {Target Hook} {const char *} TARGET_ASM_ALIGNED_TI_OP\n\ + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_HI_OP\n\ ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PSI_OP\n\ + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_SI_OP\n\ ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PDI_OP\n\ + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_DI_OP\n\ ++@deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_PTI_OP\n\ + @deftypevrx {Target Hook} {const char *} TARGET_ASM_UNALIGNED_TI_OP\n\ + These hooks specify assembly directives for creating certain kinds\n\ + of integer object. The @code{TARGET_ASM_BYTE_OP} directive creates a\n\ +diff --git a/gcc/target.h b/gcc/target.h +index 393de408b97..5f2b1d6d9cc 100644 +--- a/gcc/target.h ++++ b/gcc/target.h +@@ -158,8 +158,11 @@ extern bool stmt_in_inner_loop_p (struct _stmt_vec_info *); + struct asm_int_op + { + const char *hi; ++ const char *psi; + const char *si; ++ const char *pdi; + const char *di; ++ const char *pti; + const char *ti; + }; + +diff --git a/gcc/targhooks.c b/gcc/targhooks.c +index 77ca69105d0..c57967966c5 100644 +--- a/gcc/targhooks.c ++++ b/gcc/targhooks.c +@@ -1636,13 +1636,15 @@ default_print_patchable_function_entry (FILE *file, + char buf[256]; + static int patch_area_number; + section *previous_section = in_section; ++ const char *asm_op = integer_asm_op (POINTER_SIZE_UNITS, false); + ++ gcc_assert (asm_op != NULL); + patch_area_number++; + ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number); + + switch_to_section (get_section ("__patchable_function_entries", + 0, NULL)); +- fputs (integer_asm_op (POINTER_SIZE_UNITS, false), file); ++ fputs (asm_op, file); + assemble_name_raw (file, buf); + fputc ('\n', file); + +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 6e9a8c3133e..5711ba69555 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -2713,10 +2713,24 @@ integer_asm_op (int size, int aligned_p) + return targetm.asm_out.byte_op; + case 2: + return ops->hi; ++ case 3: ++ return ops->psi; + case 4: + return ops->si; ++ case 5: ++ case 6: ++ case 7: ++ return ops->pdi; + case 8: + return ops->di; ++ case 9: ++ case 10: ++ case 11: ++ case 12: ++ case 13: ++ case 14: ++ case 15: ++ return ops->pti; + case 16: + return ops->ti; + default: +-- +2.33.1 + diff --git a/gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch b/gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch new file mode 100644 index 0000000..698198f --- /dev/null +++ b/gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch @@ -0,0 +1,70 @@ +From 7e12d4ef76f860574dd7a822522238bdec2687d3 Mon Sep 17 00:00:00 2001 +From: Eric Botcazou +Date: Mon, 10 Dec 2018 11:16:47 +0000 +Subject: [PATCH 09/22] Backport patchable_function_entry-decl.c: Pass + -mcpu=gr6 for Visium and remove other specific handling. + +gcc/testsuite/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2018-12-10 Eric Botcazou + + * c-c++-common/patchable_function_entry-decl.c: Pass -mcpu=gr6 for + Visium and remove other specific handling. + * c-c++-common/patchable_function_entry-default.c: Likewise. + * c-c++-common/patchable_function_entry-definition.c: Likewise. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 4 ++-- + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 4 ++-- + .../c-c++-common/patchable_function_entry-definition.c | 4 ++-- + 3 files changed, 6 insertions(+), 6 deletions(-) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index 3bfb7568bee..572297ca1f4 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,8 +1,8 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop|NOP" 2 { target { ! { alpha*-*-* visium-*-* } } } } } */ ++/* { dg-additional-options "-mcpu=gr6" { target visium-*-* } } ++/* { dg-final { scan-assembler-times "nop|NOP" 2 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 2 { target alpha*-*-* } } } */ +-/* { dg-final { scan-assembler-times "nop" 3 { target visium-*-* } } } */ + + extern int a; + +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 bd7c6e98fc6..942ec14c8e5 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,8 +1,8 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop|NOP" 3 { target { ! { alpha*-*-* visium-*-* } } } } } */ ++/* { dg-additional-options "-mcpu=gr6" { target visium-*-* } } ++/* { dg-final { scan-assembler-times "nop|NOP" 3 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ +-/* { dg-final { scan-assembler-times "nop" 4 { target visium-*-* } } } */ + + extern int a; + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index 709113890ef..e88b0eb15c1 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,8 +1,8 @@ + /* { dg-do compile { target { ! nvptx*-*-* } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-final { scan-assembler-times "nop|NOP" 1 { target { ! { alpha*-*-* visium-*-* } } } } } */ ++/* { dg-additional-options "-mcpu=gr6" { target visium-*-* } } ++/* { dg-final { scan-assembler-times "nop|NOP" 1 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 1 { target alpha*-*-* } } } */ +-/* { dg-final { scan-assembler-times "nop" 2 { target visium-*-* } } } */ + + extern int a; + +-- +2.33.1 + diff --git a/gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch b/gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch new file mode 100644 index 0000000..5741250 --- /dev/null +++ b/gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch @@ -0,0 +1,60 @@ +From 7314f1ac164bde51f43dd1c96fe2f1e7be5dfe77 Mon Sep 17 00:00:00 2001 +From: Eric Botcazou +Date: Fri, 15 Feb 2019 10:50:27 +0000 +Subject: [PATCH 10/22] Backport patchable_function_entry-decl.c: Do not run on + Visium. + +gcc/testsuite/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2019-02-15 Eric Botcazou + + * c-c++-common/patchable_function_entry-decl.c: Do not run on Visium. + * c-c++-common/patchable_function_entry-default.c: Likewise. + * c-c++-common/patchable_function_entry-definition.c: Likewise. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 3 +-- + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 3 +-- + .../c-c++-common/patchable_function_entry-definition.c | 3 +-- + 3 files changed, 3 insertions(+), 6 deletions(-) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index 572297ca1f4..1f8009b0faa 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,6 +1,5 @@ +-/* { dg-do compile { target { ! nvptx*-*-* } } } */ ++/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-additional-options "-mcpu=gr6" { target visium-*-* } } + /* { dg-final { scan-assembler-times "nop|NOP" 2 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 2 { target alpha*-*-* } } } */ + +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 942ec14c8e5..6b0318f0d66 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,6 +1,5 @@ +-/* { dg-do compile { target { ! nvptx*-*-* } } } */ ++/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-additional-options "-mcpu=gr6" { target visium-*-* } } + /* { dg-final { scan-assembler-times "nop|NOP" 3 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index e88b0eb15c1..6667d3c558c 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,6 +1,5 @@ +-/* { dg-do compile { target { ! nvptx*-*-* } } } */ ++/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ +-/* { dg-additional-options "-mcpu=gr6" { target visium-*-* } } + /* { dg-final { scan-assembler-times "nop|NOP" 1 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 1 { target alpha*-*-* } } } */ + +-- +2.33.1 + diff --git a/gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch b/gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch new file mode 100644 index 0000000..dc18eb6 --- /dev/null +++ b/gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch @@ -0,0 +1,57 @@ +From 030d757e6f0f86b5f899737ab2fe73261a759dc7 Mon Sep 17 00:00:00 2001 +From: Eric Botcazou +Date: Sat, 16 Feb 2019 14:40:53 +0000 +Subject: [PATCH 11/22] Backport patchable_function_entry-decl.c: Add -fno-pie + on SPARC. + +gcc/testsuite/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2019-02-16 Eric Botcazou + + * c-c++-common/patchable_function_entry-decl.c: Add -fno-pie on SPARC. + * c-c++-common/patchable_function_entry-default.c: Likewise. + * c-c++-common/patchable_function_entry-definition.c: Likewise. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 1 + + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 1 + + gcc/testsuite/c-c++-common/patchable_function_entry-definition.c | 1 + + 3 files changed, 3 insertions(+) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index 1f8009b0faa..4f707b31f0d 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,5 +1,6 @@ + /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ ++/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ + /* { dg-final { scan-assembler-times "nop|NOP" 2 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 2 { target alpha*-*-* } } } */ + +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 6b0318f0d66..97d8a81fbc6 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,5 +1,6 @@ + /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ ++/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ + /* { dg-final { scan-assembler-times "nop|NOP" 3 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index 6667d3c558c..ab94533ffec 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,5 +1,6 @@ + /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ ++/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ + /* { dg-final { scan-assembler-times "nop|NOP" 1 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 1 { target alpha*-*-* } } } */ + +-- +2.33.1 + diff --git a/gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch b/gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch new file mode 100644 index 0000000..b8f6312 --- /dev/null +++ b/gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch @@ -0,0 +1,153 @@ +From dd42709efc288ce501b52d95b8ef0d05713a07f6 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Fri, 12 Apr 2019 09:28:35 +0200 +Subject: [PATCH 12/22] Backport PR c/89946 (ICE in assemble_start_function, at + varasm.c:1871) + +gcc/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2019-04-12 Jakub Jelinek + + PR c/89946 + * varasm.c (assemble_start_function): Don't use tree_fits_uhwi_p + and gcc_unreachable if it fails, just call tree_to_uhwi which + verifies that too. Test TREE_CHAIN instead of list_length > 1. + Start warning message with a lower-case letter. Formatting fixes. + + PR rtl-optimization/90026 + * cfgcleanup.c (try_optimize_cfg): When removing empty bb with no + successors, look for BARRIERs inside of the whole BB_FOOTER chain + rather than just at the start of it. If e->src BB_FOOTER is not NULL + in cfglayout mode, use emit_barrier_after_bb. + +gcc/c-family/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport of mainline + 2019-04-12 Jakub Jelinek + + PR c/89946 + * c-attribs.c (handle_patchable_function_entry_attribute): Add + function comment. Warn if arguments of the attribute are not positive + integer constants. + +gcc/testsuite/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2019-04-12 Jakub Jelinek + + PR c/89946 + * c-c++-common/pr89946.c: New test. + + PR rtl-optimization/90026 + * g++.dg/opt/pr90026.C: New test. +--- + gcc/c-family/c-attribs.c | 23 +++++++++++++++++++++-- + gcc/testsuite/c-c++-common/pr89946.c | 7 +++++++ + gcc/varasm.c | 23 ++++++++--------------- + 3 files changed, 36 insertions(+), 17 deletions(-) + create mode 100644 gcc/testsuite/c-c++-common/pr89946.c + +diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c +index b2820dd1586..f0d2b1ed500 100644 +--- a/gcc/c-family/c-attribs.c ++++ b/gcc/c-family/c-attribs.c +@@ -3184,9 +3184,28 @@ handle_fallthrough_attribute (tree *, tree name, tree, int, + return NULL_TREE; + } + ++/* Handle a "patchable_function_entry" attributes; arguments as in ++ struct attribute_spec.handler. */ ++ + static tree +-handle_patchable_function_entry_attribute (tree *, tree, tree, int, bool *) ++handle_patchable_function_entry_attribute (tree *, tree name, tree args, ++ int, bool *no_add_attrs) + { +- /* Nothing to be done here. */ ++ for (; args; args = TREE_CHAIN (args)) ++ { ++ tree val = TREE_VALUE (args); ++ if (val && TREE_CODE (val) != IDENTIFIER_NODE ++ && TREE_CODE (val) != FUNCTION_DECL) ++ val = default_conversion (val); ++ ++ if (!tree_fits_uhwi_p (val)) ++ { ++ warning (OPT_Wattributes, ++ "%qE attribute argument %qE is not an integer constant", ++ name, val); ++ *no_add_attrs = true; ++ return NULL_TREE; ++ } ++ } + return NULL_TREE; + } +diff --git a/gcc/testsuite/c-c++-common/pr89946.c b/gcc/testsuite/c-c++-common/pr89946.c +new file mode 100644 +index 00000000000..23acd63fc6a +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/pr89946.c +@@ -0,0 +1,7 @@ ++/* PR c/89946 */ ++ ++__attribute__((patchable_function_entry (-1))) void foo (void) {} /* { dg-warning "'patchable_function_entry' attribute argument '-1' is not an integer constant" } */ ++__attribute__((patchable_function_entry (5, -5))) void bar (void) {} /* { dg-warning "'patchable_function_entry' attribute argument '-5' is not an integer constant" } */ ++int i, j; ++__attribute__((patchable_function_entry (i))) void baz (void) {} /* { dg-warning "'patchable_function_entry' attribute argument 'i' is not an integer constant" } */ ++__attribute__((patchable_function_entry (2, j))) void qux (void) {} /* { dg-warning "'patchable_function_entry' attribute argument 'j' is not an integer constant" } */ +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 5711ba69555..0e6f20db361 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -1839,28 +1839,20 @@ assemble_start_function (tree decl, const char *fnname) + tree pp_val = TREE_VALUE (patchable_function_entry_attr); + tree patchable_function_entry_value1 = TREE_VALUE (pp_val); + +- if (tree_fits_uhwi_p (patchable_function_entry_value1)) +- patch_area_size = tree_to_uhwi (patchable_function_entry_value1); +- else +- gcc_unreachable (); +- ++ patch_area_size = tree_to_uhwi (patchable_function_entry_value1); + patch_area_entry = 0; +- if (list_length (pp_val) > 1) ++ if (TREE_CHAIN (pp_val) != NULL_TREE) + { +- tree patchable_function_entry_value2 = +- TREE_VALUE (TREE_CHAIN (pp_val)); +- +- if (tree_fits_uhwi_p (patchable_function_entry_value2)) +- patch_area_entry = tree_to_uhwi (patchable_function_entry_value2); +- else +- gcc_unreachable (); ++ tree patchable_function_entry_value2 ++ = TREE_VALUE (TREE_CHAIN (pp_val)); ++ patch_area_entry = tree_to_uhwi (patchable_function_entry_value2); + } + } + + if (patch_area_entry > patch_area_size) + { + if (patch_area_size > 0) +- warning (OPT_Wattributes, "Patchable function entry > size"); ++ warning (OPT_Wattributes, "patchable function entry > size"); + patch_area_entry = 0; + } + +@@ -1880,7 +1872,8 @@ assemble_start_function (tree decl, const char *fnname) + /* And the area after the label. Record it if we haven't done so yet. */ + if (patch_area_size > patch_area_entry) + targetm.asm_out.print_patchable_function_entry (asm_out_file, +- patch_area_size-patch_area_entry, ++ patch_area_size ++ - patch_area_entry, + patch_area_entry == 0); + + if (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (decl))) +-- +2.33.1 + diff --git a/gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch b/gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch new file mode 100644 index 0000000..6145ea4 --- /dev/null +++ b/gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch @@ -0,0 +1,36 @@ +From 2d35914acc611b8780c52c2e6df78d56da37a61d Mon Sep 17 00:00:00 2001 +From: Joao Moreira +Date: Wed, 17 Apr 2019 18:24:23 +0000 +Subject: [PATCH 13/22] Backport targhooks.c + (default_print_patchable_function_entry): Emit __patchable_function_entries + section with writable flags to allow... + +gcc/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2019-04-10 Joao Moreira + + * targhooks.c (default_print_patchable_function_entry): Emit + __patchable_function_entries section with writable flags to allow + relocation resolution. +--- + gcc/targhooks.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/targhooks.c b/gcc/targhooks.c +index c57967966c5..be0c557f1a2 100644 +--- a/gcc/targhooks.c ++++ b/gcc/targhooks.c +@@ -1643,7 +1643,7 @@ default_print_patchable_function_entry (FILE *file, + ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number); + + switch_to_section (get_section ("__patchable_function_entries", +- 0, NULL)); ++ SECTION_WRITE | SECTION_RELRO, NULL)); + fputs (asm_op, file); + assemble_name_raw (file, buf); + fputc ('\n', file); +-- +2.33.1 + diff --git a/gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch b/gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch new file mode 100644 index 0000000..5db3e4a --- /dev/null +++ b/gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch @@ -0,0 +1,34 @@ +From e469ad6db5edd55f07cbf1ba5b4a49e2e9c7c72b Mon Sep 17 00:00:00 2001 +From: Fangrui Song +Date: Tue, 7 Jan 2020 20:46:26 -0800 +Subject: [PATCH 14/22] Backport Align __patchable_function_entries to + POINTER_SIZE [PR93194] + +gcc/ChangeLog +2021-10-07 Giuliano Belinassi + Backport from mainline + + 2020-01-20 Fangrui Song + + PR middle-end/93194 + * targhooks.c (default_print_patchable_function_entry): Align to + POINTER_SIZE. +--- + gcc/targhooks.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/gcc/targhooks.c b/gcc/targhooks.c +index be0c557f1a2..aaf536acf17 100644 +--- a/gcc/targhooks.c ++++ b/gcc/targhooks.c +@@ -1644,6 +1644,7 @@ default_print_patchable_function_entry (FILE *file, + + switch_to_section (get_section ("__patchable_function_entries", + SECTION_WRITE | SECTION_RELRO, NULL)); ++ assemble_align (POINTER_SIZE); + fputs (asm_op, file); + assemble_name_raw (file, buf); + fputc ('\n', file); +-- +2.33.1 + diff --git a/gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch b/gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch new file mode 100644 index 0000000..a4505cd --- /dev/null +++ b/gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch @@ -0,0 +1,43 @@ +From 770fcd0a31f3d557e5c79004161fa4c14fdaeced Mon Sep 17 00:00:00 2001 +From: Andrew Pinski +Date: Sat, 18 Jan 2020 00:41:06 +0000 +Subject: [PATCH 15/22] Backport Fix PR 93242: patchable-function-entry broken + on MIPS + +On MIPS, .set noreorder/reorder needs to emitted around +the nop. The template for the nop instruction uses %(/%) to +do that. But default_print_patchable_function_entry uses +fprintf rather than output_asm_insn to output the instruction. + +This fixes the problem by using output_asm_insn to emit the nop +instruction. + +gcc/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2020-01-20 Andrew Pinski + + PR middle-end/93242 + * targhooks.c (default_print_patchable_function_entry): use + output_asm_insn to emit the nop instruction. +--- + gcc/targhooks.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gcc/targhooks.c b/gcc/targhooks.c +index aaf536acf17..185dc7b0b6b 100644 +--- a/gcc/targhooks.c ++++ b/gcc/targhooks.c +@@ -1655,7 +1655,7 @@ default_print_patchable_function_entry (FILE *file, + + unsigned i; + for (i = 0; i < patch_area_size; ++i) +- fprintf (file, "\t%s\n", nop_templ); ++ output_asm_insn (nop_templ, NULL); + } + + bool +-- +2.33.1 + diff --git a/gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch b/gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch new file mode 100644 index 0000000..811f44c --- /dev/null +++ b/gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch @@ -0,0 +1,38 @@ +From 3775c56f07ebfba1155721bdaa948a71e26df6b0 Mon Sep 17 00:00:00 2001 +From: Andrew Pinski +Date: Wed, 22 Jan 2020 23:34:34 +0000 +Subject: [PATCH 16/22] Backport Fix patchable-function-entry on arc + +The problem here is arc looks at current_output_insn unconditional +but sometimes current_output_insn is NULL. With patchable-function-entry, +it will be. This is similar to how the nios2, handles "%.". + +Committed as obvious after a simple test with -fpatchable-function-entry=1. + +gcc/ChangeLog +2021-10-07 Giuliano Belinassi + + Backport from mainline + 2020-01-22 Andrew Pinski + + * config/arc/arc.c (output_short_suffix): Check insn for nullness. +--- + gcc/config/arc/arc.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c +index 92fecad93d9..5e92983929d 100644 +--- a/gcc/config/arc/arc.c ++++ b/gcc/config/arc/arc.c +@@ -4195,6 +4195,8 @@ static void + output_short_suffix (FILE *file) + { + rtx_insn *insn = current_output_insn; ++ if (!insn) ++ return; + + if (arc_verify_short (insn, cfun->machine->unalign, 1)) + { +-- +2.33.1 + diff --git a/gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch b/gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch new file mode 100644 index 0000000..9e0e94b --- /dev/null +++ b/gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch @@ -0,0 +1,249 @@ +From 961670bae0c7b37073dbc0bb58d730d1ed603d5d Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Fri, 1 May 2020 21:03:10 -0700 +Subject: [PATCH 17/22] Backport Add patch_area_size and patch_area_entry to + crtl + +Currently patchable area is at the wrong place. It is placed immediately +after function label and before .cfi_startproc. A backend should be able +to add a pseudo patchable area instruction durectly into RTL. This patch +adds patch_area_size and patch_area_entry to crtl so that the patchable +area info is available in RTL passes. + +It also limits patch_area_size and patch_area_entry to 65535, which is +a reasonable maximum size for patchable area. + +gcc/ + + PR target/93492 + * cfgexpand.c (pass_expand::execute): Set crtl->patch_area_size + and crtl->patch_area_entry. + * emit-rtl.h (rtl_data): Add patch_area_size and patch_area_entry. + * opts.c (common_handle_option): Limit + function_entry_patch_area_size and function_entry_patch_area_start + to USHRT_MAX. Fix a typo in error message. + * varasm.c (assemble_start_function): Use crtl->patch_area_size + and crtl->patch_area_entry. + * doc/invoke.texi: Document the maximum value for + -fpatchable-function-entry. + +gcc/c-family/ + + PR target/93492 + * c-attribs.c (handle_patchable_function_entry_attribute): Limit + value to USHRT_MAX (65535). + +gcc/testsuite/ + + PR target/93492 + * c-c++-common/patchable_function_entry-error-1.c: New test. + * c-c++-common/patchable_function_entry-error-2.c: Likewise. + * c-c++-common/patchable_function_entry-error-3.c: Likewise. +--- + gcc/c-family/c-attribs.c | 9 ++++ + gcc/cfgexpand.c | 44 +++++++++++++++++++ + gcc/doc/invoke.texi | 1 + + gcc/emit-rtl.h | 6 +++ + gcc/opts.c | 4 +- + .../patchable_function_entry-error-1.c | 9 ++++ + .../patchable_function_entry-error-2.c | 9 ++++ + .../patchable_function_entry-error-3.c | 17 +++++++ + gcc/varasm.c | 4 +- + 9 files changed, 100 insertions(+), 3 deletions(-) + create mode 100644 gcc/testsuite/c-c++-common/patchable_function_entry-error-1.c + create mode 100644 gcc/testsuite/c-c++-common/patchable_function_entry-error-2.c + create mode 100644 gcc/testsuite/c-c++-common/patchable_function_entry-error-3.c + +diff --git a/gcc/c-family/c-attribs.c b/gcc/c-family/c-attribs.c +index f0d2b1ed500..c01baffbc57 100644 +--- a/gcc/c-family/c-attribs.c ++++ b/gcc/c-family/c-attribs.c +@@ -3206,6 +3206,15 @@ handle_patchable_function_entry_attribute (tree *, tree name, tree args, + *no_add_attrs = true; + return NULL_TREE; + } ++ ++ if (tree_to_uhwi (val) > USHRT_MAX) ++ { ++ warning (OPT_Wattributes, ++ "%qE attribute argument %qE is out of range (> 65535)", ++ name, val); ++ *no_add_attrs = true; ++ return NULL_TREE; ++ } + } + return NULL_TREE; + } +diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c +index 7fd3916a3c7..2a603823a71 100644 +--- a/gcc/cfgexpand.c ++++ b/gcc/cfgexpand.c +@@ -6481,6 +6481,50 @@ pass_expand::execute (function *fun) + if (crtl->tail_call_emit) + fixup_tail_calls (); + ++ unsigned HOST_WIDE_INT patch_area_size = function_entry_patch_area_size; ++ unsigned HOST_WIDE_INT patch_area_entry = function_entry_patch_area_start; ++ ++ tree patchable_function_entry_attr ++ = lookup_attribute ("patchable_function_entry", ++ DECL_ATTRIBUTES (cfun->decl)); ++ if (patchable_function_entry_attr) ++ { ++ tree pp_val = TREE_VALUE (patchable_function_entry_attr); ++ tree patchable_function_entry_value1 = TREE_VALUE (pp_val); ++ ++ patch_area_size = tree_to_uhwi (patchable_function_entry_value1); ++ patch_area_entry = 0; ++ if (TREE_CHAIN (pp_val) != NULL_TREE) ++ { ++ tree patchable_function_entry_value2 ++ = TREE_VALUE (TREE_CHAIN (pp_val)); ++ patch_area_entry = tree_to_uhwi (patchable_function_entry_value2); ++ } ++ } ++ ++ if (patch_area_entry > patch_area_size) ++ { ++ if (patch_area_size > 0) ++ warning (OPT_Wattributes, ++ "patchable function entry %wu exceeds size %wu", ++ patch_area_entry, patch_area_size); ++ patch_area_entry = 0; ++ } ++ ++ crtl->patch_area_size = patch_area_size; ++ crtl->patch_area_entry = patch_area_entry; ++ ++ /* This function is not present in gcc 7, nor the profile_count datastructures, ++ so it may be safe to assume that there is not enough engine implemented so ++ far to support that. */ ++#if 0 ++ /* BB subdivision may have created basic blocks that are only reachable ++ from unlikely bbs but not marked as such in the profile. */ ++ ++ if (optimize) ++ propagate_unlikely_bbs_forward (); ++#endif ++ + /* Remove unreachable blocks, otherwise we cannot compute dominators + which are needed for loop state verification. As a side-effect + this also compacts blocks. +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index ad71be54e07..9fd3b013ff7 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -11445,6 +11445,7 @@ 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. + ++The maximum value of @var{N} and @var{M} is 65535. + @end table + + +diff --git a/gcc/emit-rtl.h b/gcc/emit-rtl.h +index da60a2d808c..66bc1bef391 100644 +--- a/gcc/emit-rtl.h ++++ b/gcc/emit-rtl.h +@@ -163,6 +163,12 @@ struct GTY(()) rtl_data { + local stack. */ + unsigned int stack_alignment_estimated; + ++ /* How many NOP insns to place at each function entry by default. */ ++ unsigned short patch_area_size; ++ ++ /* How far the real asm entry point is into this area. */ ++ unsigned short patch_area_entry; ++ + /* For reorg. */ + + /* Nonzero if function being compiled called builtin_return_addr or +diff --git a/gcc/opts.c b/gcc/opts.c +index d0430e777ee..3de12b3662f 100644 +--- a/gcc/opts.c ++++ b/gcc/opts.c +@@ -2220,10 +2220,12 @@ common_handle_option (struct gcc_options *opts, + function_entry_patch_area_start = 0; + } + if (function_entry_patch_area_size < 0 ++ || function_entry_patch_area_size > USHRT_MAX + || function_entry_patch_area_start < 0 ++ || function_entry_patch_area_start > USHRT_MAX + || function_entry_patch_area_size + < function_entry_patch_area_start) +- error ("invalid arguments for %<-fpatchable_function_entry%>"); ++ error ("invalid arguments for %<-fpatchable-function-entry%>"); + free (patch_area_arg); + } + break; +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-error-1.c b/gcc/testsuite/c-c++-common/patchable_function_entry-error-1.c +new file mode 100644 +index 00000000000..f60bf46cfe3 +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-error-1.c +@@ -0,0 +1,9 @@ ++/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ ++/* { dg-options "-O2 -fpatchable-function-entry=65536,1" } */ ++/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ ++/* { dg-error "invalid arguments for '-fpatchable-function-entry'" "" { target *-*-* } 0 } */ ++ ++void ++foo (void) ++{ ++} +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-error-2.c b/gcc/testsuite/c-c++-common/patchable_function_entry-error-2.c +new file mode 100644 +index 00000000000..90f88c78be7 +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-error-2.c +@@ -0,0 +1,9 @@ ++/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ ++/* { dg-options "-O2 -fpatchable-function-entry=1,65536" } */ ++/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ ++/* { dg-error "invalid arguments for '-fpatchable-function-entry'" "" { target *-*-* } 0 } */ ++ ++void ++foo (void) ++{ ++} +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-error-3.c b/gcc/testsuite/c-c++-common/patchable_function_entry-error-3.c +new file mode 100644 +index 00000000000..4490e5c15ca +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-error-3.c +@@ -0,0 +1,17 @@ ++/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ ++/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ ++ ++void ++ __attribute__((patchable_function_entry(65536))) ++foo1 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' is out of range" } */ ++} ++ ++void ++ __attribute__((patchable_function_entry(65536,1))) ++foo2 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' is out of range" } */ ++} ++ ++void ++ __attribute__((patchable_function_entry(65536,65536))) ++foo3 (void) { /* { dg-warning "'patchable_function_entry' attribute argument '65536' is out of range" } */ ++} +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 0e6f20db361..8d4c0386fe3 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -1829,8 +1829,8 @@ assemble_start_function (tree decl, const char *fnname) + if (DECL_PRESERVE_P (decl)) + targetm.asm_out.mark_decl_preserved (fnname); + +- unsigned HOST_WIDE_INT patch_area_size = function_entry_patch_area_size; +- unsigned HOST_WIDE_INT patch_area_entry = function_entry_patch_area_start; ++ unsigned short patch_area_size = crtl->patch_area_size; ++ unsigned short patch_area_entry = crtl->patch_area_entry; + + tree patchable_function_entry_attr + = lookup_attribute ("patchable_function_entry", DECL_ATTRIBUTES (decl)); +-- +2.33.1 + diff --git a/gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch b/gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch new file mode 100644 index 0000000..488209a --- /dev/null +++ b/gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch @@ -0,0 +1,66 @@ +From 269286fbce10ce33e07a11f9abab60c74ba84e33 Mon Sep 17 00:00:00 2001 +From: Hans-Peter Nilsson +Date: Fri, 24 Jul 2020 23:50:05 +0200 +Subject: [PATCH 18/22] Backport testsuite: Adjust patchable_function tests for + mmix. + +There's no reason anyone would want to use the "patchable function" +feature for MMIX and also no reason to exclude those tests. For MMIX, +the NOP equivalent is SWYM ("swymming" is a healthy exercise). +Text-wise, making the tests pass by adjusting the regexp, is shorter, +and it seems unlikely to both appear as a mnemonic for other targets +*and* being emitted in uppercase. + +gcc/testsuite: + + * c-c++-common/patchable_function_entry-decl.c, + c-c++-common/patchable_function_entry-default.c, + c-c++-common/patchable_function_entry-definition.c: Adjust for mmix. +--- + gcc/testsuite/c-c++-common/patchable_function_entry-decl.c | 2 +- + gcc/testsuite/c-c++-common/patchable_function_entry-default.c | 2 +- + .../c-c++-common/patchable_function_entry-definition.c | 2 +- + 3 files changed, 3 insertions(+), 3 deletions(-) + +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +index 4f707b31f0d..3ce7a5b8790 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-decl.c +@@ -1,7 +1,7 @@ + /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ + /* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ +-/* { dg-final { scan-assembler-times "nop|NOP" 2 { target { ! { alpha*-*-* } } } } } */ ++/* { dg-final { scan-assembler-times "nop|NOP|SWYM" 2 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 2 { target alpha*-*-* } } } */ + + extern int a; +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 97d8a81fbc6..7036f7bfbea 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-default.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-default.c +@@ -1,7 +1,7 @@ + /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ + /* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ +-/* { dg-final { scan-assembler-times "nop|NOP" 3 { target { ! { alpha*-*-* } } } } } */ ++/* { dg-final { scan-assembler-times "nop|NOP|SWYM" 3 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 3 { target alpha*-*-* } } } */ + + extern int a; +diff --git a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +index ab94533ffec..ad7d7a9e076 100644 +--- a/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c ++++ b/gcc/testsuite/c-c++-common/patchable_function_entry-definition.c +@@ -1,7 +1,7 @@ + /* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ + /* { dg-options "-O2 -fpatchable-function-entry=3,1" } */ + /* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ +-/* { dg-final { scan-assembler-times "nop|NOP" 1 { target { ! { alpha*-*-* } } } } } */ ++/* { dg-final { scan-assembler-times "nop|NOP|SWYM" 1 { target { ! { alpha*-*-* } } } } } */ + /* { dg-final { scan-assembler-times "bis" 1 { target alpha*-*-* } } } */ + + extern int a; +-- +2.33.1 + diff --git a/gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch b/gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch new file mode 100644 index 0000000..f137dd3 --- /dev/null +++ b/gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch @@ -0,0 +1,973 @@ +From 8ef0203090dab33a177f0b45f6bf69246047e463 Mon Sep 17 00:00:00 2001 +From: "H.J. Lu" +Date: Wed, 2 Dec 2020 05:32:37 -0800 +Subject: [PATCH 19/22] Backport Use the section flag 'o' for + __patchable_function_entries + +This commit in GNU binutils 2.35: + +https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=b7d072167715829eed0622616f6ae0182900de3e + +added the section flag 'o' to .section directive: + +.section __patchable_function_entries,"awo",@progbits,foo + +which specifies the symbol name which the section references. Assembler +creates a unique __patchable_function_entries section with the section, +where foo is defined, as its linked-to section. Linker keeps a section +if its linked-to section is kept during garbage collection. + +This patch checks assembler support for the section flag 'o' and uses +it to implement __patchable_function_entries section. Since Solaris may +use GNU assembler with Solairs ld. Even if GNU assembler supports the +section flag 'o', it doesn't mean that Solairs ld supports it. This +feature is disabled for Solairs targets. + +gcc/ + + PR middle-end/93195 + PR middle-end/93197 + * configure.ac (HAVE_GAS_SECTION_LINK_ORDER): New. Define 1 if + the assembler supports the section flag 'o' for specifying + section with link-order. + * output.h (SECTION_LINK_ORDER): New. Defined to 0x8000000. + (SECTION_MACH_DEP): Changed from 0x8000000 to 0x10000000. + * targhooks.c (default_print_patchable_function_entry): Pass + SECTION_LINK_ORDER to switch_to_section if the section flag 'o' + works. Pass current_function_decl to switch_to_section. + * varasm.c (default_elf_asm_named_section): Use 'o' flag for + SECTION_LINK_ORDER if assembler supports it. + * config.in: Regenerated. + * configure: Likewise. + * doc/sourcebuild.texi: Document o_flag_in_section. + +gcc/testsuite/ + + PR middle-end/93195 + * g++.dg/pr93195b.C: New test. + * lib/target-supports.exp + (check_effective_target_o_flag_in_section): New proc. +--- + gcc/config.in | 13 + + gcc/configure | 186 ++++++++++ + gcc/configure.ac | 70 ++++ + gcc/doc/sourcebuild.texi | 9 + + gcc/output.h | 7 +- + gcc/targhooks.c | 5 +- + gcc/testsuite/g++.dg/pr93195b.C | 14 + + gcc/testsuite/lib/target-supports.exp | 493 ++++++++++++++++++++++++++ + gcc/varasm.c | 12 + + 9 files changed, 807 insertions(+), 2 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/pr93195b.C + +diff --git a/gcc/config.in b/gcc/config.in +index eca3fd810fb..12b61991ff2 100644 +--- a/gcc/config.in ++++ b/gcc/config.in +@@ -1315,6 +1315,19 @@ + #endif + + ++/* Define 0/1 if your assembler supports 'o' flag in .section directive. */ ++#ifndef USED_FOR_TARGET ++#undef HAVE_GAS_SECTION_LINK_ORDER ++#endif ++ ++ ++/* Define 0/1 if your assembler supports marking sections with SHF_GNU_RETAIN ++ flag. */ ++#ifndef USED_FOR_TARGET ++#undef HAVE_GAS_SHF_GNU_RETAIN ++#endif ++ ++ + /* Define 0/1 if your assembler supports marking sections with SHF_MERGE flag. + */ + #ifndef USED_FOR_TARGET +diff --git a/gcc/configure b/gcc/configure +index 5dab9142e1a..06ff33c271b 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -23505,6 +23505,192 @@ $as_echo "#define USE_AS_TRADITIONAL_FORMAT 1" >>confdefs.h + + fi + ++# Test if the assembler supports the section flag 'e' or #exclude for ++# specifying an excluded section. ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section exclude flag" >&5 ++$as_echo_n "checking assembler for section exclude flag... " >&6; } ++if ${gcc_cv_as_section_exclude_e+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ gcc_cv_as_section_exclude_e=no ++ if test $in_tree_gas = yes; then ++ if test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 22 \) \* 1000 + 51` ++ then gcc_cv_as_section_exclude_e=yes ++fi ++ elif test x$gcc_cv_as != x; then ++ $as_echo '.section foo1,"e" ++ .byte 0,0,0,0' > conftest.s ++ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --fatal-warnings -o conftest.o conftest.s >&5' ++ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; } ++ then ++ gcc_cv_as_section_exclude_e=yes ++ else ++ echo "configure: failed program was" >&5 ++ cat conftest.s >&5 ++ fi ++ rm -f conftest.o conftest.s ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_section_exclude_e" >&5 ++$as_echo "$gcc_cv_as_section_exclude_e" >&6; } ++ ++ ++if test $gcc_cv_as_section_exclude_e = no; then ++ case "${target}" in ++ # Solaris as uses #exclude instead. ++ *-*-solaris2*) ++ case "${target}" in ++ sparc*-*-solaris2*) ++ conftest_s='.section "foo1", #exclude' ++ ;; ++ i?86-*-solaris2* | x86_64-*-solaris2*) ++ conftest_s='.section foo1, #exclude' ++ ;; ++ esac ++ ;; ++ esac ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section exclude flag" >&5 ++$as_echo_n "checking assembler for section exclude flag... " >&6; } ++if ${gcc_cv_as_section_exclude_hash+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ gcc_cv_as_section_exclude_hash=no ++ if test x$gcc_cv_as != x; then ++ $as_echo "$conftest_s ++ .byte 0,0,0,0" > conftest.s ++ if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5' ++ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; } ++ then ++ gcc_cv_as_section_exclude_hash=yes ++ else ++ echo "configure: failed program was" >&5 ++ cat conftest.s >&5 ++ fi ++ rm -f conftest.o conftest.s ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_section_exclude_hash" >&5 ++$as_echo "$gcc_cv_as_section_exclude_hash" >&6; } ++ ++ ++fi ++ ++cat >>confdefs.h <<_ACEOF ++#define HAVE_GAS_SECTION_EXCLUDE `if test $gcc_cv_as_section_exclude_e = yes || test $gcc_cv_as_section_exclude_hash = yes; then echo 1; else echo 0; fi` ++_ACEOF ++ ++ ++# Test if the assembler supports the section flag 'R' for specifying ++# section with SHF_GNU_RETAIN. ++case "${target}" in ++ # Solaris may use GNU assembler with Solairs ld. Even if GNU ++ # assembler supports the section flag 'R', it doesn't mean that ++ # Solairs ld supports it. ++ *-*-solaris2*) ++ gcc_cv_as_shf_gnu_retain=no ++ ;; ++ *) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section 'R' flag" >&5 ++$as_echo_n "checking assembler for section 'R' flag... " >&6; } ++if ${gcc_cv_as_shf_gnu_retain+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ gcc_cv_as_shf_gnu_retain=no ++ if test $in_tree_gas = yes; then ++ if test $in_tree_gas_is_elf = yes \ ++ && test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 36 \) \* 1000 + 0` ++ then gcc_cv_as_shf_gnu_retain=yes ++fi ++ elif test x$gcc_cv_as != x; then ++ $as_echo '.section .foo,"awR",%progbits ++.byte 0' > conftest.s ++ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --fatal-warnings -o conftest.o conftest.s >&5' ++ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; } ++ then ++ gcc_cv_as_shf_gnu_retain=yes ++ else ++ echo "configure: failed program was" >&5 ++ cat conftest.s >&5 ++ fi ++ rm -f conftest.o conftest.s ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_shf_gnu_retain" >&5 ++$as_echo "$gcc_cv_as_shf_gnu_retain" >&6; } ++ ++ ++ ;; ++esac ++ ++cat >>confdefs.h <<_ACEOF ++#define HAVE_GAS_SHF_GNU_RETAIN `if test $gcc_cv_as_shf_gnu_retain = yes; then echo 1; else echo 0; fi` ++_ACEOF ++ ++ ++# Test if the assembler supports the section flag 'o' for specifying ++# section with link-order. ++case "${target}" in ++ # Solaris may use GNU assembler with Solairs ld. Even if GNU ++ # assembler supports the section flag 'o', it doesn't mean that ++ # Solairs ld supports it. ++ *-*-solaris2*) ++ gcc_cv_as_section_link_order=no ++ ;; ++ *) ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section 'o' flag" >&5 ++$as_echo_n "checking assembler for section 'o' flag... " >&6; } ++if ${gcc_cv_as_section_link_order+:} false; then : ++ $as_echo_n "(cached) " >&6 ++else ++ gcc_cv_as_section_link_order=no ++ if test $in_tree_gas = yes; then ++ if test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 35 \) \* 1000 + 0` ++ then gcc_cv_as_section_link_order=yes ++fi ++ elif test x$gcc_cv_as != x; then ++ $as_echo '.section .foo,"a" ++.byte 0 ++.section __patchable_function_entries,"awo",%progbits,.foo ++.byte 0' > conftest.s ++ if { ac_try='$gcc_cv_as $gcc_cv_as_flags --fatal-warnings -o conftest.o conftest.s >&5' ++ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 ++ (eval $ac_try) 2>&5 ++ ac_status=$? ++ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 ++ test $ac_status = 0; }; } ++ then ++ gcc_cv_as_section_link_order=yes ++ else ++ echo "configure: failed program was" >&5 ++ cat conftest.s >&5 ++ fi ++ rm -f conftest.o conftest.s ++ fi ++fi ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_section_link_order" >&5 ++$as_echo "$gcc_cv_as_section_link_order" >&6; } ++ ++ ++ ;; ++esac ++ ++cat >>confdefs.h <<_ACEOF ++#define HAVE_GAS_SECTION_LINK_ORDER `if test $gcc_cv_as_section_link_order = yes; then echo 1; else echo 0; fi` ++_ACEOF ++ ++ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section merging support" >&5 + $as_echo_n "checking assembler for section merging support... " >&6; } + if test "${gcc_cv_as_shf_merge+set}" = set; then : +diff --git a/gcc/configure.ac b/gcc/configure.ac +index e1fa8af5e4f..8bef9fd27b4 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -2938,6 +2938,76 @@ if test $gcc_cv_as_eh_frame = buggy; then + [Define if your assembler mis-optimizes .eh_frame data.]) + fi + ++# Test if the assembler supports the section flag 'e' or #exclude for ++# specifying an excluded section. ++gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_e, ++ [2,22,51], [--fatal-warnings], ++ [.section foo1,"e" ++ .byte 0,0,0,0]) ++if test $gcc_cv_as_section_exclude_e = no; then ++ case "${target}" in ++ # Solaris as uses #exclude instead. ++ *-*-solaris2*) ++ case "${target}" in ++ sparc*-*-solaris2*) ++ conftest_s='.section "foo1", #exclude' ++ ;; ++ i?86-*-solaris2* | x86_64-*-solaris2*) ++ conftest_s='.section foo1, #exclude' ++ ;; ++ esac ++ ;; ++ esac ++ gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_hash,,, ++ [$conftest_s ++ .byte 0,0,0,0]) ++fi ++AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_EXCLUDE, ++ [`if test $gcc_cv_as_section_exclude_e = yes || test $gcc_cv_as_section_exclude_hash = yes; then echo 1; else echo 0; fi`], ++[Define if your assembler supports specifying the exclude section flag.]) ++ ++# Test if the assembler supports the section flag 'R' for specifying ++# section with SHF_GNU_RETAIN. ++case "${target}" in ++ # Solaris may use GNU assembler with Solairs ld. Even if GNU ++ # assembler supports the section flag 'R', it doesn't mean that ++ # Solairs ld supports it. ++ *-*-solaris2*) ++ gcc_cv_as_shf_gnu_retain=no ++ ;; ++ *) ++ gcc_GAS_CHECK_FEATURE([section 'R' flag], gcc_cv_as_shf_gnu_retain, ++ [elf,2,36,0], [--fatal-warnings], ++ [.section .foo,"awR",%progbits ++.byte 0]) ++ ;; ++esac ++AC_DEFINE_UNQUOTED(HAVE_GAS_SHF_GNU_RETAIN, ++ [`if test $gcc_cv_as_shf_gnu_retain = yes; then echo 1; else echo 0; fi`], ++ [Define 0/1 if your assembler supports marking sections with SHF_GNU_RETAIN flag.]) ++ ++# Test if the assembler supports the section flag 'o' for specifying ++# section with link-order. ++case "${target}" in ++ # Solaris may use GNU assembler with Solairs ld. Even if GNU ++ # assembler supports the section flag 'o', it doesn't mean that ++ # Solairs ld supports it. ++ *-*-solaris2*) ++ gcc_cv_as_section_link_order=no ++ ;; ++ *) ++ gcc_GAS_CHECK_FEATURE([section 'o' flag], gcc_cv_as_section_link_order, ++ [2,35,0], [--fatal-warnings], ++ [.section .foo,"a" ++.byte 0 ++.section __patchable_function_entries,"awo",%progbits,.foo ++.byte 0]) ++ ;; ++esac ++AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_LINK_ORDER, ++ [`if test $gcc_cv_as_section_link_order = yes; then echo 1; else echo 0; fi`], ++ [Define 0/1 if your assembler supports 'o' flag in .section directive.]) ++ + gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge, + [elf,2,12,0], [--fatal-warnings], + [.section .rodata.str, "aMS", @progbits, 1]) +diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi +index f0e9bb8d35f..6d81c4a937d 100644 +--- a/gcc/doc/sourcebuild.texi ++++ b/gcc/doc/sourcebuild.texi +@@ -2072,6 +2072,15 @@ Target uses natural alignment (aligned to type size) for types of + @item nonpic + Target does not generate PIC by default. + ++@item o_flag_in_section ++Target supports the 'o' flag in .section directive in assembly inputs. ++ ++@item offload_gcn ++Target has been configured for OpenACC/OpenMP offloading on AMD GCN. ++ ++@item persistent ++Target supports the @code{persistent} variable attribute. ++ + @item pie_enabled + Target generates PIE by default. + +diff --git a/gcc/output.h b/gcc/output.h +index 7a93fa89cab..049f184e009 100644 +--- a/gcc/output.h ++++ b/gcc/output.h +@@ -383,7 +383,12 @@ extern void no_asm_to_stream (FILE *); + #define SECTION_COMMON 0x800000 /* contains common data */ + #define SECTION_RELRO 0x1000000 /* data is readonly after relocation processing */ + #define SECTION_EXCLUDE 0x2000000 /* discarded by the linker */ +-#define SECTION_MACH_DEP 0x4000000 /* subsequent bits reserved for target */ ++#define SECTION_RETAIN 0x4000000 /* retained by the linker. */ ++#define SECTION_LINK_ORDER 0x8000000 /* section needs link-order. */ ++ ++/* NB: The maximum SECTION_MACH_DEP is 0x10000000 since AVR needs 4 bits ++ in SECTION_MACH_DEP. */ ++#define SECTION_MACH_DEP 0x10000000 /* subsequent bits reserved for target */ + + /* This SECTION_STYLE is used for unnamed sections that we can switch + to using a special assembler directive. */ +diff --git a/gcc/targhooks.c b/gcc/targhooks.c +index 185dc7b0b6b..8aa610f5cde 100644 +--- a/gcc/targhooks.c ++++ b/gcc/targhooks.c +@@ -1642,8 +1642,11 @@ default_print_patchable_function_entry (FILE *file, + patch_area_number++; + ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number); + ++ unsigned int flags = SECTION_WRITE | SECTION_RELRO; ++ if (HAVE_GAS_SECTION_LINK_ORDER) ++ flags |= SECTION_LINK_ORDER; + switch_to_section (get_section ("__patchable_function_entries", +- SECTION_WRITE | SECTION_RELRO, NULL)); ++ flags, current_function_decl)); + assemble_align (POINTER_SIZE); + fputs (asm_op, file); + assemble_name_raw (file, buf); +diff --git a/gcc/testsuite/g++.dg/pr93195b.C b/gcc/testsuite/g++.dg/pr93195b.C +new file mode 100644 +index 00000000000..303d8588c0f +--- /dev/null ++++ b/gcc/testsuite/g++.dg/pr93195b.C +@@ -0,0 +1,14 @@ ++/* { dg-do compile { target { ! { nvptx*-*-* visium-*-* } } } } */ ++/* { dg-options "-O0 -fpatchable-function-entry=1" } */ ++/* { dg-additional-options "-fno-pie" { target sparc*-*-* } } */ ++ ++inline void ++foo (void) ++{ ++} ++ ++void ++bar1 (void) ++{ ++ foo (); ++} +diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp +index d33136f7aa4..37d5d5432f8 100644 +--- a/gcc/testsuite/lib/target-supports.exp ++++ b/gcc/testsuite/lib/target-supports.exp +@@ -8445,3 +8445,496 @@ proc check_effective_target_arm_coproc4_ok { } { + return [check_cached_effective_target arm_coproc4_ok \ + check_effective_target_arm_coproc4_ok_nocache] + } ++ ++# Return 1 if the target supports the auto_inc_dec optimization pass. ++proc check_effective_target_autoincdec { } { ++ if { ![check_no_compiler_messages auto_incdec assembly { void f () { } ++ } "-O2 -fdump-rtl-auto_inc_dec" ] } { ++ return 0 ++ } ++ ++ set dumpfile [glob -nocomplain "auto_incdec[pid].c.\[0-9\]\[0-9\]\[0-9\]r.auto_inc_dec"] ++ if { [file exists $dumpfile ] } { ++ file delete $dumpfile ++ return 1 ++ } ++ return 0 ++} ++ ++# Return 1 if the target has support for stack probing designed ++# to avoid stack-clash style attacks. ++# ++# This is used to restrict the stack-clash mitigation tests to ++# just those targets that have been explicitly supported. ++# ++# In addition to the prologue work on those targets, each target's ++# properties should be described in the functions below so that ++# tests do not become a mess of unreadable target conditions. ++# ++proc check_effective_target_supports_stack_clash_protection { } { ++ ++ if { [istarget x86_64-*-*] || [istarget i?86-*-*] ++ || [istarget powerpc*-*-*] || [istarget rs6000*-*-*] ++ || [istarget aarch64*-**] || [istarget s390*-*-*] } { ++ return 1 ++ } ++ return 0 ++} ++ ++# Return 1 if the target creates a frame pointer for non-leaf functions ++# Note we ignore cases where we apply tail call optimization here. ++proc check_effective_target_frame_pointer_for_non_leaf { } { ++ # Solaris/x86 defaults to -fno-omit-frame-pointer. ++ if { [istarget i?86-*-solaris*] || [istarget x86_64-*-solaris*] } { ++ return 1 ++ } ++ ++ return 0 ++} ++ ++# Return 1 if the target's calling sequence or its ABI ++# create implicit stack probes at or prior to function entry. ++proc check_effective_target_caller_implicit_probes { } { ++ ++ # On x86/x86_64 the call instruction itself pushes the return ++ # address onto the stack. That is an implicit probe of *sp. ++ if { [istarget x86_64-*-*] || [istarget i?86-*-*] } { ++ return 1 ++ } ++ ++ # On PPC, the ABI mandates that the address of the outer ++ # frame be stored at *sp. Thus each allocation of stack ++ # space is itself an implicit probe of *sp. ++ if { [istarget powerpc*-*-*] || [istarget rs6000*-*-*] } { ++ return 1 ++ } ++ ++ # s390's ABI has a register save area allocated by the ++ # caller for use by the callee. The mere existence does ++ # not constitute a probe by the caller, but when the slots ++ # used by the callee those stores are implicit probes. ++ if { [istarget s390*-*-*] } { ++ return 1 ++ } ++ ++ # Not strictly true on aarch64, but we have agreed that we will ++ # consider any function that pushes SP more than 3kbytes into ++ # the guard page as broken. This essentially means that we can ++ # consider the aarch64 as having a caller implicit probe at ++ # *(sp + 1k). ++ if { [istarget aarch64*-*-*] } { ++ return 1; ++ } ++ ++ return 0 ++} ++ ++# Targets that potentially realign the stack pointer often cause residual ++# stack allocations and make it difficult to elimination loops or residual ++# allocations for dynamic stack allocations ++proc check_effective_target_callee_realigns_stack { } { ++ if { [istarget x86_64-*-*] || [istarget i?86-*-*] } { ++ return 1 ++ } ++ return 0 ++} ++ ++# Return 1 if CET instructions can be compiled. ++proc check_effective_target_cet { } { ++ if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { ++ return 0 ++ } ++ return [check_no_compiler_messages cet object { ++ void foo (void) ++ { ++ asm ("setssbsy"); ++ } ++ } "-O2 -fcf-protection" ] ++} ++ ++# Return 1 if target supports floating point "infinite" ++proc check_effective_target_inf { } { ++ return [check_no_compiler_messages supports_inf assembly { ++ const double pinf = __builtin_inf (); ++ }] ++} ++ ++# Return 1 if target supports floating point "infinite" for float. ++proc check_effective_target_inff { } { ++ return [check_no_compiler_messages supports_inff assembly { ++ const float pinf = __builtin_inff (); ++ }] ++} ++ ++# Return 1 if the target supports ARMv8.3 Adv.SIMD Complex instructions ++# instructions, 0 otherwise. The test is valid for ARM and for AArch64. ++# Record the command line options needed. ++ ++proc check_effective_target_arm_v8_3a_complex_neon_ok_nocache { } { ++ global et_arm_v8_3a_complex_neon_flags ++ set et_arm_v8_3a_complex_neon_flags "" ++ ++ if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } { ++ return 0; ++ } ++ ++ # Iterate through sets of options to find the compiler flags that ++ # need to be added to the -march option. ++ foreach flags {"" "-mfloat-abi=softfp -mfpu=auto" "-mfloat-abi=hard -mfpu=auto"} { ++ if { [check_no_compiler_messages_nocache \ ++ arm_v8_3a_complex_neon_ok object { ++ #if !defined (__ARM_FEATURE_COMPLEX) ++ #error "__ARM_FEATURE_COMPLEX not defined" ++ #endif ++ } "$flags -march=armv8.3-a"] } { ++ set et_arm_v8_3a_complex_neon_flags "$flags -march=armv8.3-a" ++ return 1 ++ } ++ } ++ ++ return 0; ++} ++ ++proc check_effective_target_arm_v8_3a_complex_neon_ok { } { ++ return [check_cached_effective_target arm_v8_3a_complex_neon_ok \ ++ check_effective_target_arm_v8_3a_complex_neon_ok_nocache] ++} ++ ++proc add_options_for_arm_v8_3a_complex_neon { flags } { ++ if { ! [check_effective_target_arm_v8_3a_complex_neon_ok] } { ++ return "$flags" ++ } ++ global et_arm_v8_3a_complex_neon_flags ++ return "$flags $et_arm_v8_3a_complex_neon_flags" ++} ++ ++# Return 1 if the target supports executing AdvSIMD instructions from ARMv8.3 ++# with the complex instruction extension, 0 otherwise. The test is valid for ++# ARM and for AArch64. ++ ++proc check_effective_target_arm_v8_3a_complex_neon_hw { } { ++ if { ![check_effective_target_arm_v8_3a_complex_neon_ok] } { ++ return 0; ++ } ++ return [check_runtime arm_v8_3a_complex_neon_hw_available { ++ #include "arm_neon.h" ++ int ++ main (void) ++ { ++ ++ float32x2_t results = {-4.0,5.0}; ++ float32x2_t a = {1.0,3.0}; ++ float32x2_t b = {2.0,5.0}; ++ ++ #ifdef __ARM_ARCH_ISA_A64 ++ asm ("fcadd %0.2s, %1.2s, %2.2s, #90" ++ : "=w"(results) ++ : "w"(a), "w"(b) ++ : /* No clobbers. */); ++ ++ #else ++ asm ("vcadd.f32 %P0, %P1, %P2, #90" ++ : "=w"(results) ++ : "w"(a), "w"(b) ++ : /* No clobbers. */); ++ #endif ++ ++ return (results[0] == 8 && results[1] == 24) ? 1 : 0; ++ } ++ } [add_options_for_arm_v8_3a_complex_neon ""]] ++} ++ ++# Return 1 if the assembler supports assembling the Armv8.3 pointer authentication B key directive ++proc check_effective_target_arm_v8_3a_bkey_directive { } { ++ return [check_no_compiler_messages cet object { ++ int main(void) { ++ asm (".cfi_b_key_frame"); ++ return 0; ++ } ++ }] ++} ++ ++# Return 1 if the target supports executing the Armv8.1-M Mainline Low ++# Overhead Loop, 0 otherwise. The test is valid for ARM. ++ ++proc check_effective_target_arm_v8_1_lob_ok { } { ++ if { ![check_effective_target_arm_cortex_m] } { ++ return 0; ++ } else { ++ return [check_runtime arm_v8_1_lob_hw_available { ++ int ++ main (void) ++ { int i = 0; ++ asm ("movw r3, #10\n\t" /* movs? */ ++ "dls lr, r3" : : : "r3", "lr"); ++ loop: ++ i++; ++ asm goto ("le lr, %l0" : : : "lr" : loop); ++ return i != 10; ++ } ++ } "-march=armv8.1-m.main -mthumb" ] ++ } ++} ++ ++# Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be ++# used and the target does not support executing the Armv8.1-M ++# Mainline Low Overhead Loop, 0 otherwise. The test is valid for ARM. ++ ++proc check_effective_target_arm_thumb2_ok_no_arm_v8_1_lob { } { ++ if { [check_effective_target_arm_thumb2_ok] ++ && ![check_effective_target_arm_v8_1_lob_ok] } { ++ return 1 ++ } ++ return 0 ++} ++ ++# Returns 1 if the target is using glibc, 0 otherwise. ++ ++proc check_effective_target_glibc { } { ++ return [check_no_compiler_messages glibc_object assembly { ++ #include ++ #if !defined(__GLIBC__) ++ #error undefined ++ #endif ++ }] ++} ++ ++# Return 1 if the target plus current options supports a vector ++# complex addition with rotate of half and single float modes, 0 otherwise. ++# ++# This won't change for different subtargets so cache the result. ++ ++foreach N {hf sf} { ++ eval [string map [list N $N] { ++ proc check_effective_target_vect_complex_rot_N { } { ++ return [check_cached_effective_target_indexed vect_complex_rot_N { ++ expr { [istarget aarch64*-*-*] ++ || [istarget arm*-*-*] }}] ++ } ++ }] ++} ++ ++# Return 1 if the target plus current options supports a vector ++# complex addition with rotate of double float modes, 0 otherwise. ++# ++# This won't change for different subtargets so cache the result. ++ ++foreach N {df} { ++ eval [string map [list N $N] { ++ proc check_effective_target_vect_complex_rot_N { } { ++ return [check_cached_effective_target_indexed vect_complex_rot_N { ++ expr { [istarget aarch64*-*-*] }}] ++ } ++ }] ++} ++ ++# Return 1 if this target uses an LLVM assembler and/or linker ++proc check_effective_target_llvm_binutils { } { ++ return [check_cached_effective_target llvm_binutils { ++ expr { [istarget amdgcn*-*-*] ++ || [check_effective_target_offload_gcn] }}] ++} ++ ++# Return 1 if the compiler supports '-mfentry'. ++ ++proc check_effective_target_mfentry { } { ++ if { !([istarget i?86-*-*] || [istarget x86_64-*-*]) } { ++ return 0 ++ } ++ return [check_no_compiler_messages mfentry object { ++ void foo (void) { } ++ } "-mfentry"] ++} ++ ++# Return 1 if this target supports indirect calls ++proc check_effective_target_indirect_calls { } { ++ if { [istarget bpf-*-*] } { ++ return 0 ++ } ++ return 1 ++} ++ ++# Return 1 if we can use the -lgccjit option, 0 otherwise. ++ ++proc check_effective_target_lgccjit { } { ++ if { [info procs jit_target_compile] == "" } then { ++ global GCC_UNDER_TEST ++ if ![info exists GCC_UNDER_TEST] { ++ set GCC_UNDER_TEST "[find_gcc]" ++ } ++ proc jit_target_compile { source dest type options } [info body gcc_target_compile] ++ } ++ return [check_no_compiler_messages lgccjit executable { ++ int main() { return 0; } ++ } "-lgccjit"] ++} ++ ++# Return 1 if the MSP430 small memory model is in use. ++proc check_effective_target_msp430_small {} { ++ return [check_no_compiler_messages msp430_small assembly { ++ #if (!defined __MSP430__ || defined __MSP430X_LARGE__) ++ #error !msp430 || __MSP430X_LARGE__ ++ #endif ++ } ""] ++} ++ ++# Return 1 if the MSP430 large memory model is in use. ++proc check_effective_target_msp430_large {} { ++ return [check_no_compiler_messages msp430_large assembly { ++ #ifndef __MSP430X_LARGE__ ++ #error __MSP430X_LARGE__ ++ #endif ++ } ""] ++} ++ ++# Return 1 if the target has an efficient means to encode large initializers ++# in the assembly. ++ ++proc check_effective_target_large_initializer { } { ++ if { [istarget nvptx*-*-*] } { ++ return 0 ++ } ++ ++ return 1 ++} ++ ++# Return 1 if the target allows function prototype mismatches ++# in the assembly. ++ ++proc check_effective_target_non_strict_prototype { } { ++ if { [istarget nvptx*-*-*] } { ++ return 0 ++ } ++ ++ return 1 ++} ++ ++# Returns 1 if the target toolchain supports extended ++# syntax of .symver directive, 0 otherwise. ++ ++proc check_symver_available { } { ++ return [check_no_compiler_messages symver_available object { ++ int foo(void) { return 0; } ++ int main (void) { ++ asm volatile (".symver foo,foo@VER_1, local"); ++ return 0; ++ } ++ }] ++} ++ ++# Return 1 if emitted assembly contains .ident directive. ++ ++proc check_effective_target_ident_directive {} { ++ return [check_no_messages_and_pattern ident_directive \ ++ "(?n)^\[\t\]+\\.ident" assembly { ++ int i; ++ }] ++} ++ ++# Return 1 if we're able to assemble movdiri and movdir64b ++ ++proc check_effective_target_movdir { } { ++ return [check_no_compiler_messages movdir object { ++ void ++ foo (unsigned int *d, unsigned int s) ++ { ++ __builtin_ia32_directstoreu_u32 (d, s); ++ } ++ void ++ bar (void *d, const void *s) ++ { ++ __builtin_ia32_movdir64b (d, s); ++ } ++ } "-mmovdiri -mmovdir64b" ] ++} ++ ++# Return 1 if target is not support address sanitize, 1 otherwise. ++ ++proc check_effective_target_no_fsanitize_address {} { ++ if ![check_no_compiler_messages fsanitize_address executable { ++ int main (void) { return 0; } ++ }] { ++ return 1; ++ } ++ return 0; ++} ++ ++# Return 1 if this target supports 'R' flag in .section directive, 0 ++# otherwise. Cache the result. ++ ++proc check_effective_target_R_flag_in_section { } { ++ global tool ++ global GCC_UNDER_TEST ++ ++ # Need auto-host.h to check linker support. ++ if { ![file exists ../../auto-host.h ] } { ++ return 0 ++ } ++ ++ return [check_cached_effective_target R_flag_in_section { ++ ++ set src pie[pid].c ++ set obj pie[pid].o ++ ++ set f [open $src "w"] ++ puts $f "#include \"../../auto-host.h\"" ++ puts $f "#if HAVE_GAS_SHF_GNU_RETAIN == 0" ++ puts $f "# error Assembler does not support 'R' flag in .section directive." ++ puts $f "#endif" ++ close $f ++ ++ verbose "check_effective_target_R_flag_in_section compiling testfile $src" 2 ++ set lines [${tool}_target_compile $src $obj assembly ""] ++ ++ file delete $src ++ file delete $obj ++ ++ if [string match "" $lines] then { ++ verbose "check_effective_target_R_flag_in_section testfile compilation passed" 2 ++ return 1 ++ } else { ++ verbose "check_effective_target_R_flag_in_section testfile compilation failed" 2 ++ return 0 ++ } ++ }] ++} ++ ++# Return 1 if this target supports 'o' flag in .section directive, 0 ++# otherwise. Cache the result. ++ ++proc check_effective_target_o_flag_in_section { } { ++ global tool ++ global GCC_UNDER_TEST ++ ++ # Need auto-host.h to check linker support. ++ if { ![file exists ../../auto-host.h ] } { ++ return 0 ++ } ++ ++ return [check_cached_effective_target o_flag_in_section { ++ ++ set src pie[pid].c ++ set obj pie[pid].o ++ ++ set f [open $src "w"] ++ puts $f "#include \"../../auto-host.h\"" ++ puts $f "#if HAVE_GAS_SECTION_LINK_ORDER == 0" ++ puts $f "# error Assembler does not support 'o' flag in .section directive." ++ puts $f "#endif" ++ close $f ++ ++ verbose "check_effective_target_o_flag_in_section compiling testfile $src" 2 ++ set lines [${tool}_target_compile $src $obj object ""] ++ ++ file delete $src ++ file delete $obj ++ ++ if [string match "" $lines] then { ++ verbose "check_effective_target_o_flag_in_section testfile compilation passed" 2 ++ return 1 ++ } else { ++ verbose "check_effective_target_o_flag_in_section testfile compilation failed" 2 ++ return 0 ++ } ++ }] ++} +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 8d4c0386fe3..7b0792ddaed 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -6398,6 +6398,10 @@ default_elf_asm_named_section (const char *name, unsigned int flags, + *f++ = TLS_SECTION_ASM_FLAG; + if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) + *f++ = 'G'; ++ if (flags & SECTION_RETAIN) ++ *f++ = 'R'; ++ if (flags & SECTION_LINK_ORDER) ++ *f++ = 'o'; + #ifdef MACH_DEP_SECTION_ASM_FLAG + if (flags & SECTION_MACH_DEP) + *f++ = MACH_DEP_SECTION_ASM_FLAG; +@@ -6426,6 +6430,14 @@ default_elf_asm_named_section (const char *name, unsigned int flags, + + if (flags & SECTION_ENTSIZE) + fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE); ++ if (flags & SECTION_LINK_ORDER) ++ { ++ tree id = DECL_ASSEMBLER_NAME (decl); ++ ultimate_transparent_alias_target (&id); ++ const char *name = IDENTIFIER_POINTER (id); ++ name = targetm.strip_name_encoding (name); ++ fprintf (asm_out_file, ",%s", name); ++ } + if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) + { + if (TREE_CODE (decl) == IDENTIFIER_NODE) +-- +2.33.1 + diff --git a/gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch b/gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch new file mode 100644 index 0000000..041a19a --- /dev/null +++ b/gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch @@ -0,0 +1,88 @@ +From 686af21802e691f3b08cc45a5cb2c961b9676675 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Wed, 16 Dec 2020 16:15:35 +0100 +Subject: [PATCH 20/22] Backport varasm: Fix up __patchable_function_entries + handling + +The SECTION_LINK_ORDER changes don't seem to work properly. + +If I compile: +static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((patchable_function_entry(0, 0))) int foo (int x) +{ + return x + 1; +} + +static inline __attribute__((__gnu_inline__)) __attribute__((__unused__)) __attribute__((patchable_function_entry(0, 0))) int bar (int x) +{ + return x + 2; +} + +int +baz (int x) +{ + return foo (x) + 1; +} + +int +qux (int x) +{ + return bar (x) + 2; +} +(distilled from aarch64 Linux kernel) with +-O2 -fpatchable-function-entry=2 on aarch64 compiler configured against +latest binutils, I get: +... + .section __patchable_function_entries,"awo",@progbits,baz +... + .section __patchable_function_entries +... +in the assembly, but when it is assembled, one gets: + [ 4] __patchable_function_entries PROGBITS 0000000000000000 000060 000008 00 WAL 1 0 8 + [ 5] .rela__patchable_function_entries RELA 0000000000000000 000280 000018 18 I 12 4 8 + [ 6] __patchable_function_entries PROGBITS 0000000000000000 000068 000008 00 0 0 8 + [ 7] .rela__patchable_function_entries RELA 0000000000000000 000298 000018 18 I 12 6 8 +i.e. one writable allocated section with SHF_LINK_ORDER and another +non-allocated non-writable without link order. In the kernel case there is +always one entry in the WAL section and then dozens or more in the +non-allocated one. +The kernel then fails to link: +WARNING: modpost: vmlinux.o (__patchable_function_entries): unexpected non-allocatable section. +Did you forget to use "ax"/"aw" in a .S file? +Note that for example contains +section definitions for use in .S files. +ld: .init.data has both ordered [`__patchable_function_entries' in init/main.o] and unordered [`.init.data' in ++./drivers/firmware/efi/libstub/vsprintf.stub.o] sections +ld: final link failed: bad value +make: *** [Makefile:1175: vmlinux] Error 1 + +The following patch fixes it by always forcing full section flags for +SECTION_LINK_ORDER sections. + +2020-12-16 Jakub Jelinek + + * varasm.c (default_elf_asm_named_section): Always force + section flags even for sections with SECTION_LINK_ORDER flag. +--- + gcc/varasm.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 7b0792ddaed..9e0e7c0976f 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -6363,9 +6363,10 @@ 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, in which case GAS requires the full +- declaration every time. */ ++ 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. */ + if (!(HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) ++ && !(flags & (SECTION_RETAIN | SECTION_LINK_ORDER)) + && (flags & SECTION_DECLARED)) + { + fprintf (asm_out_file, "\t.section\t%s\n", name); +-- +2.33.1 + diff --git a/gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch b/gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch new file mode 100644 index 0000000..2a478b8 --- /dev/null +++ b/gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch @@ -0,0 +1,198 @@ +From 8e8d2277ff4a6d22467736de3acabaedd0a3a003 Mon Sep 17 00:00:00 2001 +From: Jakub Jelinek +Date: Sat, 3 Apr 2021 10:03:15 +0200 +Subject: [PATCH 21/22] Backport rs6000: Avoid -fpatchable-function-entry* + regressions on powerpc64 be [PR98125] + +The SECTION_LINK_ORDER changes broke powerpc64-linux ELFv1. Seems +that the assembler/linker relies on the symbol mentioned for the +"awo" section to be in the same section as the symbols mentioned in +the relocations in that section (i.e. labels for the patchable area +in this case). That is the case for most targets, including powerpc-linux +32-bit or powerpc64 ELFv2 (that one has -fpatchable-function-entry* +support broken for other reasons and it doesn't seem to be a regression). +But it doesn't work on powerpc64-linux ELFv1. +We emit: + .section ".opd","aw" + .align 3 +_Z3foov: + .quad .L._Z3foov,.TOC.@tocbase,0 + .previous + .type _Z3foov, @function +.L._Z3foov: + .section __patchable_function_entries,"awo",@progbits,_Z3foov + .align 3 + .8byte .LPFE1 + .section .text._Z3foov,"axG",@progbits,_Z3foov,comdat +.LPFE1: + nop +.LFB0: + .cfi_startproc +and because _Z3foov is in the .opd section rather than the function text +section, it doesn't work. + +I'm afraid I don't know what exactly should be done, whether e.g. +it could use + .section __patchable_function_entries,"awo",@progbits,.L._Z3foov +instead, or whether the linker should be changed to handle it as is, or +something else. + +But because we have a P1 regression that didn't see useful progress over the +4 months since it has been filed and we don't really have much time, below +is an attempt to do a targetted reversion of H.J's patch, basically act as +if HAVE_GAS_SECTION_LINK_ORDER is never true for powerpc64-linux ELFv1, +but for 32-bit or 64-bit ELFv2 keep working as is. +This would give us time to resolve it for GCC 12 properly. + +2021-10-21 Giuliano Belinassi + +Backport from mainline + 2021-04-03 Jakub Jelinek + + PR testsuite/98125 + * targhooks.h (default_print_patchable_function_entry_1): Declare. + * targhooks.c (default_print_patchable_function_entry_1): New function, + copied from default_print_patchable_function_entry with an added flags + argument. + (default_print_patchable_function_entry): Rewritten into a small + wrapper around default_print_patchable_function_entry_1. + * config/rs6000/rs6000.c (TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY): + Redefine. + (rs6000_print_patchable_function_entry): New function. + + * g++.dg/pr93195a.C: Skip on powerpc*-*-* 64-bit. +--- + gcc/config/rs6000/rs6000.c | 29 +++++++++++++++++++++++++++++ + gcc/targhooks.c | 38 ++++++++++++++++++++++++++------------ + gcc/targhooks.h | 3 +++ + 3 files changed, 58 insertions(+), 12 deletions(-) + +diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c +index af0c7ce1656..d0e3ba29c7d 100644 +--- a/gcc/config/rs6000/rs6000.c ++++ b/gcc/config/rs6000/rs6000.c +@@ -1615,6 +1615,10 @@ static const struct attribute_spec rs6000_attribute_table[] = + #define TARGET_ASM_ASSEMBLE_VISIBILITY rs6000_assemble_visibility + #endif + ++#undef TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY ++#define TARGET_ASM_PRINT_PATCHABLE_FUNCTION_ENTRY \ ++ rs6000_print_patchable_function_entry ++ + #undef TARGET_SET_UP_BY_PROLOGUE + #define TARGET_SET_UP_BY_PROLOGUE rs6000_set_up_by_prologue + +@@ -24446,6 +24450,31 @@ rs6000_assemble_visibility (tree decl, int vis) + default_assemble_visibility (decl, vis); + } + #endif ++ ++/* Write PATCH_AREA_SIZE NOPs into the asm outfile FILE around a function ++ entry. If RECORD_P is true and the target supports named sections, ++ the location of the NOPs will be recorded in a special object section ++ called "__patchable_function_entries". This routine may be called ++ twice per function to put NOPs before and after the function ++ entry. */ ++ ++void ++rs6000_print_patchable_function_entry (FILE *file, ++ unsigned HOST_WIDE_INT patch_area_size, ++ bool record_p) ++{ ++ unsigned int flags = SECTION_WRITE | SECTION_RELRO; ++ /* When .opd section is emitted, the function symbol ++ default_print_patchable_function_entry_1 is emitted into the .opd section ++ while the patchable area is emitted into the function section. ++ Don't use SECTION_LINK_ORDER in that case. */ ++ if (!(TARGET_64BIT && DEFAULT_ABI != ABI_ELFv2) ++ && HAVE_GAS_SECTION_LINK_ORDER) ++ flags |= SECTION_LINK_ORDER; ++ default_print_patchable_function_entry_1 (file, patch_area_size, record_p, ++ flags); ++} ++ + + enum rtx_code + rs6000_reverse_condition (machine_mode mode, enum rtx_code code) +diff --git a/gcc/targhooks.c b/gcc/targhooks.c +index 8aa610f5cde..958ec4ba6ff 100644 +--- a/gcc/targhooks.c ++++ b/gcc/targhooks.c +@@ -1610,17 +1610,15 @@ default_compare_by_pieces_branch_ratio (machine_mode) + return 1; + } + +-/* Write PATCH_AREA_SIZE NOPs into the asm outfile FILE around a function +- entry. If RECORD_P is true and the target supports named sections, +- the location of the NOPs will be recorded in a special object section +- called "__patchable_function_entries". This routine may be called +- twice per function to put NOPs before and after the function +- entry. */ ++/* Helper for default_print_patchable_function_entry and other ++ print_patchable_function_entry hook implementations. */ + + void +-default_print_patchable_function_entry (FILE *file, +- unsigned HOST_WIDE_INT patch_area_size, +- bool record_p) ++default_print_patchable_function_entry_1 (FILE *file, ++ unsigned HOST_WIDE_INT ++ patch_area_size, ++ bool record_p, ++ unsigned int flags) + { + const char *nop_templ = 0; + int code_num; +@@ -1642,9 +1640,6 @@ default_print_patchable_function_entry (FILE *file, + patch_area_number++; + ASM_GENERATE_INTERNAL_LABEL (buf, "LPFE", patch_area_number); + +- unsigned int flags = SECTION_WRITE | SECTION_RELRO; +- if (HAVE_GAS_SECTION_LINK_ORDER) +- flags |= SECTION_LINK_ORDER; + switch_to_section (get_section ("__patchable_function_entries", + flags, current_function_decl)); + assemble_align (POINTER_SIZE); +@@ -1661,6 +1656,25 @@ default_print_patchable_function_entry (FILE *file, + output_asm_insn (nop_templ, NULL); + } + ++/* Write PATCH_AREA_SIZE NOPs into the asm outfile FILE around a function ++ entry. If RECORD_P is true and the target supports named sections, ++ the location of the NOPs will be recorded in a special object section ++ called "__patchable_function_entries". This routine may be called ++ twice per function to put NOPs before and after the function ++ entry. */ ++ ++void ++default_print_patchable_function_entry (FILE *file, ++ unsigned HOST_WIDE_INT patch_area_size, ++ bool record_p) ++{ ++ unsigned int flags = SECTION_WRITE | SECTION_RELRO; ++ if (HAVE_GAS_SECTION_LINK_ORDER) ++ flags |= SECTION_LINK_ORDER; ++ default_print_patchable_function_entry_1 (file, patch_area_size, record_p, ++ flags); ++} ++ + bool + default_profile_before_prologue (void) + { +diff --git a/gcc/targhooks.h b/gcc/targhooks.h +index 6206fe20823..7b6d2fb9138 100644 +--- a/gcc/targhooks.h ++++ b/gcc/targhooks.h +@@ -203,6 +203,9 @@ extern bool default_use_by_pieces_infrastructure_p (unsigned HOST_WIDE_INT, + bool); + extern int default_compare_by_pieces_branch_ratio (machine_mode); + ++extern void default_print_patchable_function_entry_1 (FILE *, ++ unsigned HOST_WIDE_INT, ++ bool, unsigned int); + extern void default_print_patchable_function_entry (FILE *, + unsigned HOST_WIDE_INT, + bool); +-- +2.33.1 + diff --git a/gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch b/gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch new file mode 100644 index 0000000..f5ffe96 --- /dev/null +++ b/gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch @@ -0,0 +1,355 @@ +From e534bd23ac8d259768d67db6f876f75687b109e7 Mon Sep 17 00:00:00 2001 +From: Giuliano Belinassi +Date: Mon, 18 Oct 2021 18:00:28 -0300 +Subject: [PATCH 22/22] Fix unwinding issues when pfe is enabled. + +This patch has basically the same behaviour as 3dcea658c, but avoid +relying on the backend and CET mechanisms which are not implemented in +gcc-7. + +gcc/ChangeLog +2021-10-18 Michael Matz + + * final.c (get_some_local_dynamic_name): Call + emit_patchable_function_entry. + * varasm.c (emit_patchable_function_entry): New. + +gcc/testsuite/ChangeLog +2021-10-18 Giuliano Belinassi + + Backport from mainline + 2020-02-03 H.J. Lu + + PR target/93492 + * gcc.target/i386/pr93492-1.c: New test. + * gcc.target/i386/pr93492-2.c: Likewise. + * gcc.target/i386/pr93492-3.c: Likewise. + * gcc.target/i386/pr93492-4.c: Likewise. + * gcc.target/i386/pr93492-5.c: Likewise. + +Authored-by: Michael Matz +--- + gcc/ChangeLog | 6 ++ + gcc/final.c | 4 + + gcc/testsuite/gcc.target/i386/pr93492-1.c | 76 +++++++++++++++++++ + gcc/testsuite/gcc.target/i386/pr93492-2.c | 12 +++ + gcc/testsuite/gcc.target/i386/pr93492-3.c | 13 ++++ + gcc/testsuite/gcc.target/i386/pr93492-4.c | 11 +++ + gcc/testsuite/gcc.target/i386/pr93492-5.c | 12 +++ + gcc/varasm.c | 91 +++++++++++++---------- + 8 files changed, 187 insertions(+), 38 deletions(-) + create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-1.c + create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-2.c + create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-3.c + create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-4.c + create mode 100644 gcc/testsuite/gcc.target/i386/pr93492-5.c + +diff --git a/gcc/ChangeLog b/gcc/ChangeLog +index 51fed5508dc..537c343e6f1 100644 +--- a/gcc/ChangeLog ++++ b/gcc/ChangeLog +@@ -1,3 +1,9 @@ ++2021-10-18 Michael Matz ++ ++ * final.c (get_some_local_dynamic_name): Call ++ emit_patchable_function_entry. ++ * varasm.c (emit_patchable_function_entry): New. ++ + 2019-11-14 Release Manager + + * GCC 7.5.0 released. +diff --git a/gcc/final.c b/gcc/final.c +index 43743f05d84..53528620545 100644 +--- a/gcc/final.c ++++ b/gcc/final.c +@@ -1745,6 +1745,8 @@ get_some_local_dynamic_name () + return 0; + } + ++void emit_patchable_function_entry (tree decl, bool before); ++ + /* Output assembler code for the start of a function, + and initialize some of the variables in this file + for the new function. The label for the function and associated +@@ -1781,6 +1783,8 @@ final_start_function (rtx_insn *first, FILE *file, + if (!dwarf2_debug_info_emitted_p (current_function_decl)) + dwarf2out_begin_prologue (0, 0, NULL); + ++ emit_patchable_function_entry (current_function_decl, false); ++ + #ifdef LEAF_REG_REMAP + if (crtl->uses_only_leaf_regs) + leaf_renumber_regs (first); +diff --git a/gcc/testsuite/gcc.target/i386/pr93492-1.c b/gcc/testsuite/gcc.target/i386/pr93492-1.c +new file mode 100644 +index 00000000000..3383b0dc27b +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/pr93492-1.c +@@ -0,0 +1,76 @@ ++/* { dg-do "compile" } */ ++/* { dg-options "-O1" } */ ++ ++/* Note: this test only checks the instructions in the function bodies, ++ not the placement of the patch label or nops before the function. */ ++ ++/* ++**f10_none: ++** nop ++** ret ++*/ ++void ++__attribute__ ((patchable_function_entry (1, 0))) ++f10_none (void) ++{ ++} ++ ++/* ++**f10_endbr: ++** endbr(32|64) ++** nop ++** ret ++*/ ++void ++__attribute__ ((patchable_function_entry (1, 0))) ++f10_endbr (void) ++{ ++} ++ ++/* ++**f11_none: ++** ret ++*/ ++void ++__attribute__ ((patchable_function_entry (1, 1))) ++f11_none (void) ++{ ++} ++ ++/* ++**f11_endbr: ++** endbr(32|64) ++** ret ++*/ ++void ++__attribute__ ((patchable_function_entry (1, 1))) ++f11_endbr (void) ++{ ++} ++ ++/* ++**f21_none: ++** nop ++** ret ++*/ ++void ++__attribute__ ((patchable_function_entry (2, 1))) ++f21_none (void) ++{ ++} ++ ++/* ++**f21_endbr: ++** endbr(32|64) ++** nop ++** ret ++*/ ++void ++__attribute__ ((patchable_function_entry (2, 1))) ++f21_endbr (void) ++{ ++} ++ ++/* { dg-final { scan-assembler "\.LPFE1:\n\tnop\n\trep ret" } } */ ++/* { dg-final { scan-assembler "\.LPFE2:\n\tnop\n\trep ret" } } */ ++/* { dg-final { scan-assembler "f11_none:\n\.LFB2:\n\t\.cfi_startproc\n\trep ret" } } */ +diff --git a/gcc/testsuite/gcc.target/i386/pr93492-2.c b/gcc/testsuite/gcc.target/i386/pr93492-2.c +new file mode 100644 +index 00000000000..d52d7a41637 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/pr93492-2.c +@@ -0,0 +1,12 @@ ++/* { dg-do "compile" } */ ++/* { dg-options "-O1 -fasynchronous-unwind-tables -Wno-attributes" } */ ++ ++/* Test the placement of the .LPFE1 label. */ ++ ++void ++__attribute__ ((cf_check,patchable_function_entry (1, 0))) ++f10_endbr (void) ++{ ++} ++ ++/* { dg-final { scan-assembler "\.cfi_startproc\n.*\.LPFE1:\n\tnop\n\trep ret" } } */ +diff --git a/gcc/testsuite/gcc.target/i386/pr93492-3.c b/gcc/testsuite/gcc.target/i386/pr93492-3.c +new file mode 100644 +index 00000000000..a3ba22da17d +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/pr93492-3.c +@@ -0,0 +1,13 @@ ++/* { dg-do "compile" } */ ++/* { dg-require-effective-target mfentry } */ ++/* { dg-options "-O1 -mfentry -pg -fasynchronous-unwind-tables -Wno-attributes" } */ ++ ++/* Test the placement of the .LPFE1 label. */ ++ ++void ++__attribute__ ((cf_check,patchable_function_entry (1, 0))) ++f10_endbr (void) ++{ ++} ++ ++/* { dg-final { scan-assembler "\t\.cfi_startproc\n.*\.LPFE1:\n\tnop\n1:\tcall\t__fentry__\n.*\t(rep )?ret\n" } } */ +diff --git a/gcc/testsuite/gcc.target/i386/pr93492-4.c b/gcc/testsuite/gcc.target/i386/pr93492-4.c +new file mode 100644 +index 00000000000..d5bfc58f7d8 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/pr93492-4.c +@@ -0,0 +1,11 @@ ++/* { dg-do "compile" } */ ++/* { dg-options "-O1 -fpatchable-function-entry=1 -fasynchronous-unwind-tables -Wno-attributes" } */ ++ ++/* Test the placement of the .LPFE1 label. */ ++ ++void ++foo (void) ++{ ++} ++ ++/* { dg-final { scan-assembler "\t\.cfi_startproc\n.*\.LPFE1:\n\tnop\n\trep ret\n" } } */ +diff --git a/gcc/testsuite/gcc.target/i386/pr93492-5.c b/gcc/testsuite/gcc.target/i386/pr93492-5.c +new file mode 100644 +index 00000000000..69e706ff38e +--- /dev/null ++++ b/gcc/testsuite/gcc.target/i386/pr93492-5.c +@@ -0,0 +1,12 @@ ++/* { dg-do "compile" } */ ++/* { dg-require-effective-target mfentry } */ ++/* { dg-options "-O1 -fpatchable-function-entry=1 -mfentry -pg -fasynchronous-unwind-tables -Wno-attributes" } */ ++ ++/* Test the placement of the .LPFE1 label. */ ++ ++void ++foo (void) ++{ ++} ++ ++/* { dg-final { scan-assembler "\t\.cfi_startproc\n.*\.LPFE1:\n\tnop\n1:\tcall\t__fentry__\n.*\t(rep )?ret\n" } } */ +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 9e0e7c0976f..e197fbdaed5 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -1698,6 +1698,58 @@ get_fnname_from_decl (tree decl) + return XSTR (x, 0); + } + ++/* Emit the patchable function entry NOPs for function DECL. ++ BEFORE is true if we should emit the nops in front of the function ++ label (i.e. before prologue), or the ones after the function label ++ (part of the prologue). */ ++void ++emit_patchable_function_entry (tree decl, bool before) ++{ ++ unsigned short patch_area_size = crtl->patch_area_size; ++ unsigned short patch_area_entry = crtl->patch_area_entry; ++ ++ tree patchable_function_entry_attr ++ = lookup_attribute ("patchable_function_entry", DECL_ATTRIBUTES (decl)); ++ if (patchable_function_entry_attr) ++ { ++ tree pp_val = TREE_VALUE (patchable_function_entry_attr); ++ tree patchable_function_entry_value1 = TREE_VALUE (pp_val); ++ ++ patch_area_size = tree_to_uhwi (patchable_function_entry_value1); ++ patch_area_entry = 0; ++ if (TREE_CHAIN (pp_val) != NULL_TREE) ++ { ++ tree patchable_function_entry_value2 ++ = TREE_VALUE (TREE_CHAIN (pp_val)); ++ patch_area_entry = tree_to_uhwi (patchable_function_entry_value2); ++ } ++ } ++ ++ if (patch_area_entry > patch_area_size) ++ { ++ if (patch_area_size > 0 && before) ++ warning (OPT_Wattributes, "patchable function entry > size"); ++ patch_area_entry = 0; ++ } ++ ++ if (before) ++ { ++ /* Emit the patching area before the entry label, if any. */ ++ if (patch_area_entry > 0) ++ targetm.asm_out.print_patchable_function_entry (asm_out_file, ++ patch_area_entry, true); ++ } ++ else ++ { ++ /* And the area after the label. Record it if we haven't done so yet. */ ++ if (patch_area_size > patch_area_entry) ++ targetm.asm_out.print_patchable_function_entry (asm_out_file, ++ patch_area_size ++ - patch_area_entry, ++ patch_area_entry == 0); ++ } ++} ++ + /* Output assembler code for the constant pool of a function and associated + with defining the name of the function. DECL describes the function. + NAME is the function's name. For the constant pool, we use the current +@@ -1829,37 +1881,7 @@ assemble_start_function (tree decl, const char *fnname) + if (DECL_PRESERVE_P (decl)) + targetm.asm_out.mark_decl_preserved (fnname); + +- unsigned short patch_area_size = crtl->patch_area_size; +- unsigned short patch_area_entry = crtl->patch_area_entry; +- +- tree patchable_function_entry_attr +- = lookup_attribute ("patchable_function_entry", DECL_ATTRIBUTES (decl)); +- if (patchable_function_entry_attr) +- { +- tree pp_val = TREE_VALUE (patchable_function_entry_attr); +- tree patchable_function_entry_value1 = TREE_VALUE (pp_val); +- +- patch_area_size = tree_to_uhwi (patchable_function_entry_value1); +- patch_area_entry = 0; +- if (TREE_CHAIN (pp_val) != NULL_TREE) +- { +- tree patchable_function_entry_value2 +- = TREE_VALUE (TREE_CHAIN (pp_val)); +- patch_area_entry = tree_to_uhwi (patchable_function_entry_value2); +- } +- } +- +- if (patch_area_entry > patch_area_size) +- { +- if (patch_area_size > 0) +- warning (OPT_Wattributes, "patchable function entry > size"); +- patch_area_entry = 0; +- } +- +- /* Emit the patching area before the entry label, if any. */ +- if (patch_area_entry > 0) +- targetm.asm_out.print_patchable_function_entry (asm_out_file, +- patch_area_entry, true); ++ emit_patchable_function_entry (decl, true); + + /* Do any machine/system dependent processing of the function name. */ + #ifdef ASM_DECLARE_FUNCTION_NAME +@@ -1869,13 +1891,6 @@ assemble_start_function (tree decl, const char *fnname) + ASM_OUTPUT_FUNCTION_LABEL (asm_out_file, fnname, current_function_decl); + #endif /* ASM_DECLARE_FUNCTION_NAME */ + +- /* And the area after the label. Record it if we haven't done so yet. */ +- if (patch_area_size > patch_area_entry) +- targetm.asm_out.print_patchable_function_entry (asm_out_file, +- patch_area_size +- - patch_area_entry, +- patch_area_entry == 0); +- + if (lookup_attribute ("no_split_stack", DECL_ATTRIBUTES (decl))) + saw_no_split_stack = true; + } +-- +2.33.1 + diff --git a/gcc7-pr55917.patch b/gcc7-pr55917.patch new file mode 100644 index 0000000..0ae8696 --- /dev/null +++ b/gcc7-pr55917.patch @@ -0,0 +1,117 @@ +From 754d67d5ba4a1f9994210d402893a4cf49ce6a71 Mon Sep 17 00:00:00 2001 +From: Jonathan Wakely +Date: Mon, 12 Jun 2017 17:37:28 +0100 +Subject: [PATCH] PR libstdc++/55917 do not handle exceptions in std::thread + + PR libstdc++/55917 + * src/c++11/thread.cc (execute_native_thread_routine): Remove + try-block so that exceptions propagate out of the thread and terminate + is called by the exception-handling runtime. + (execute_native_thread_routine_compat): Likewise. + * testsuite/30_threads/thread/cons/terminate.cc: New. + +diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc +index 44a230a708e..4a94bdd2f8c 100644 +--- a/libstdc++-v3/src/c++11/thread.cc ++++ b/libstdc++-v3/src/c++11/thread.cc +@@ -77,20 +77,7 @@ namespace std _GLIBCXX_VISIBILITY(default) + execute_native_thread_routine(void* __p) + { + thread::_State_ptr __t{ static_cast(__p) }; +- +- __try +- { +- __t->_M_run(); +- } +- __catch(const __cxxabiv1::__forced_unwind&) +- { +- __throw_exception_again; +- } +- __catch(...) +- { +- std::terminate(); +- } +- ++ __t->_M_run(); + return nullptr; + } + +@@ -104,20 +91,7 @@ namespace std _GLIBCXX_VISIBILITY(default) + // the thread state to a local object, breaking the reference cycle + // created in thread::_M_start_thread. + __local.swap(__t->_M_this_ptr); +- +- __try +- { +- __t->_M_run(); +- } +- __catch(const __cxxabiv1::__forced_unwind&) +- { +- __throw_exception_again; +- } +- __catch(...) +- { +- std::terminate(); +- } +- ++ __t->_M_run(); + return nullptr; + } + #endif +diff --git a/libstdc++-v3/testsuite/30_threads/thread/cons/terminate.cc b/libstdc++-v3/testsuite/30_threads/thread/cons/terminate.cc +new file mode 100644 +index 00000000000..4b35b6c6024 +--- /dev/null ++++ b/libstdc++-v3/testsuite/30_threads/thread/cons/terminate.cc +@@ -0,0 +1,48 @@ ++// Copyright (C) 2017 Free Software Foundation, Inc. ++// ++// This file is part of the GNU ISO C++ Library. This library is free ++// software; you can redistribute it and/or modify it under the ++// terms of the GNU General Public License as published by the ++// Free Software Foundation; either version 3, or (at your option) ++// any later version. ++ ++// This library is distributed in the hope that it will be useful, ++// but WITHOUT ANY WARRANTY; without even the implied warranty of ++// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++// GNU General Public License for more details. ++ ++// You should have received a copy of the GNU General Public License along ++// with this library; see the file COPYING3. If not see ++// . ++ ++// { dg-do run { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* *-*-cygwin *-*-rtems* *-*-darwin* powerpc-ibm-aix* } } ++// { dg-options "-pthread" { target *-*-freebsd* *-*-dragonfly* *-*-netbsd* *-*-linux* *-*-gnu* *-*-solaris* powerpc-ibm-aix* } } ++// { dg-require-effective-target c++11 } ++// { dg-require-cstdint "" } ++// { dg-require-gthreads "" } ++ ++#include ++#include ++#include ++ ++void handle_terminate() ++{ ++ std::_Exit(0); ++} ++ ++void f() { throw 1; } ++ ++void ++test01() ++{ ++ std::set_terminate(handle_terminate); ++ std::thread t(f); ++ t.join(); ++ std::abort(); ++} ++ ++int ++main() ++{ ++ test01(); ++} +-- +2.27.0 + diff --git a/gcc7-pr72764.patch b/gcc7-pr72764.patch new file mode 100644 index 0000000..c52f396 --- /dev/null +++ b/gcc7-pr72764.patch @@ -0,0 +1,109 @@ +From cffc4a68d759fdca588cdf9ece998862b76141e6 Mon Sep 17 00:00:00 2001 +From: Jason Merrill +Date: Wed, 28 Jun 2017 17:06:35 -0400 +Subject: [PATCH] PR c++/72764 - ICE with invalid template typename. +To: gcc-patches@gcc.gnu.org + + * decl.c (build_typename_type): No longer static. + * tree.c (strip_typedefs): Use it instead of make_typename_type. + +From-SVN: r249760 +--- + gcc/cp/cp-tree.h | 1 + + gcc/cp/decl.c | 2 +- + gcc/cp/tree.c | 17 ++++++++++------- + gcc/testsuite/g++.dg/cpp0x/alias-decl-60.C | 16 ++++++++++++++++ + 5 files changed, 32 insertions(+), 8 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-60.C + +diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h +index f82b1b6ae10..946a9167992 100644 +--- a/gcc/cp/cp-tree.h ++++ b/gcc/cp/cp-tree.h +@@ -6087,6 +6087,7 @@ extern tree define_label (location_t, tree); + extern void check_goto (tree); + extern bool check_omp_return (void); + extern tree make_typename_type (tree, tree, enum tag_types, tsubst_flags_t); ++extern tree build_typename_type (tree, tree, tree, tag_types); + extern tree make_unbound_class_template (tree, tree, tree, tsubst_flags_t); + extern tree build_library_fn_ptr (const char *, tree, int); + extern tree build_cp_library_fn_ptr (const char *, tree, int); +diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c +index 93e24fc8984..3d96a3ea0fd 100644 +--- a/gcc/cp/decl.c ++++ b/gcc/cp/decl.c +@@ -3594,7 +3594,7 @@ struct typename_hasher : ggc_ptr_hash + + static GTY (()) hash_table *typename_htab; + +-static tree ++tree + build_typename_type (tree context, tree name, tree fullname, + enum tag_types tag_type) + { +diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c +index bb17278c611..4535af64dc6 100644 +--- a/gcc/cp/tree.c ++++ b/gcc/cp/tree.c +@@ -1503,13 +1503,13 @@ strip_typedefs (tree t, bool *remove_attributes) + break; + case TYPENAME_TYPE: + { ++ bool changed = false; + tree fullname = TYPENAME_TYPE_FULLNAME (t); + if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR + && TREE_OPERAND (fullname, 1)) + { + tree args = TREE_OPERAND (fullname, 1); + tree new_args = copy_node (args); +- bool changed = false; + for (int i = 0; i < TREE_VEC_LENGTH (args); ++i) + { + tree arg = TREE_VEC_ELT (args, i); +@@ -1533,12 +1533,15 @@ strip_typedefs (tree t, bool *remove_attributes) + else + ggc_free (new_args); + } +- result = make_typename_type (strip_typedefs (TYPE_CONTEXT (t), +- remove_attributes), +- fullname, typename_type, tf_none); +- /* Handle 'typedef typename A::N N;' */ +- if (typedef_variant_p (result)) +- result = TYPE_MAIN_VARIANT (DECL_ORIGINAL_TYPE (TYPE_NAME (result))); ++ tree ctx = strip_typedefs (TYPE_CONTEXT (t), remove_attributes); ++ if (!changed && ctx == TYPE_CONTEXT (t) && !typedef_variant_p (t)) ++ return t; ++ tree name = fullname; ++ if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR) ++ name = TREE_OPERAND (fullname, 0); ++ /* Use build_typename_type rather than make_typename_type because we ++ don't want to resolve it here, just strip typedefs. */ ++ result = build_typename_type (ctx, name, fullname, typename_type); + } + break; + case DECLTYPE_TYPE: +diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-60.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-60.C +new file mode 100644 +index 00000000000..6bf9b7b1666 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-60.C +@@ -0,0 +1,16 @@ ++// PR c++/72764 ++// { dg-do compile { target c++11 } } ++ ++template < typename > struct A; ++template < typename > struct B {}; ++ ++template < typename T > ++using C = typename A < T >::template D < T >; ++ ++template < typename T > struct A ++{ ++ // should be: template < typename > struct D : B < C < T > > {}; ++ struct D : B < C < T > > {}; // { dg-error "not a class template" } ++}; ++ ++A < int >::D a; // { dg-message "required" } +-- +2.35.3 + diff --git a/gcc7-pr78263.patch b/gcc7-pr78263.patch new file mode 100644 index 0000000..61e4f66 --- /dev/null +++ b/gcc7-pr78263.patch @@ -0,0 +1,155 @@ +From e756e900e911fdbc57cd76d6c12d20a9b1892e55 Mon Sep 17 00:00:00 2001 +From: Bill Schmidt +Date: Tue, 4 Jun 2019 21:52:32 +0000 +Subject: [PATCH] re PR target/78263 (Compile failure with AltiVec library on + PPC64le and -std=c++11 flag) + +[gcc] + +2019-06-04 Bill Schmidt + + PR target/78263 + * config/rs6000/altivec.h: Don't #define vector, pixel, bool for + C++ with strict ANSI requirements. + +[gcc/testsuite] + +2019-06-04 Bill Schmidt + + PR target/78263 + * g++.target/powerpc: New directory. + * g++.target/powerpc/powerpc.exp: New test driver. + * g++.target/powerpc/undef-bool-3.C: New. + +From-SVN: r271927 +--- + gcc/ChangeLog | 6 +++ + gcc/config/rs6000/altivec.h | 8 ++-- + gcc/testsuite/ChangeLog | 7 +++ + gcc/testsuite/g++.target/powerpc/powerpc.exp | 44 +++++++++++++++++++ + .../g++.target/powerpc/undef-bool-3.C | 13 ++++++ + 5 files changed, 75 insertions(+), 3 deletions(-) + create mode 100644 gcc/testsuite/g++.target/powerpc/powerpc.exp + create mode 100644 gcc/testsuite/g++.target/powerpc/undef-bool-3.C + +#diff --git a/gcc/ChangeLog b/gcc/ChangeLog +#index 30febc6fecc..8b3fe98771d 100644 +#--- a/gcc/ChangeLog +#+++ b/gcc/ChangeLog +#@@ -1,3 +1,9 @@ +#+2019-06-04 Bill Schmidt +#+ +#+ PR target/78263 +#+ * config/rs6000/altivec.h: Don't #define vector, pixel, bool for +#+ C++ with strict ANSI requirements. +#+ +# 2019-06-04 Marc Glisse +# +# * tree-ssa-loop-niter.c (number_of_iterations_ne): Skip +diff --git a/gcc/config/rs6000/altivec.h b/gcc/config/rs6000/altivec.h +index d66ae7ca2c7..dafc76aeafa 100644 +--- a/gcc/config/rs6000/altivec.h ++++ b/gcc/config/rs6000/altivec.h +@@ -37,10 +37,12 @@ + /* If __APPLE_ALTIVEC__ is defined, the compiler supports 'vector', + 'pixel' and 'bool' as context-sensitive AltiVec keywords (in + non-AltiVec contexts, they revert to their original meanings, +- if any), so we do not need to define them as macros. */ ++ if any), so we do not need to define them as macros. Also, ++ avoid defining them as macros for C++ with strict ANSI, as ++ this is not compatible. */ + +-#if !defined(__APPLE_ALTIVEC__) +-/* You are allowed to undef these for C++ compatibility. */ ++#if !defined(__APPLE_ALTIVEC__) \ ++ && (!defined(__STRICT_ANSI__) || !defined(__cplusplus)) + #define vector __vector + #define pixel __pixel + #define bool __bool +#diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog +#index 5978f7905f3..7bcc461327d 100644 +#--- a/gcc/testsuite/ChangeLog +#+++ b/gcc/testsuite/ChangeLog +#@@ -1,3 +1,10 @@ +#+2019-06-04 Bill Schmidt +#+ +#+ PR target/78263 +#+ * g++.target/powerpc: New directory. +#+ * g++.target/powerpc/powerpc.exp: New test driver. +#+ * g++.target/powerpc/undef-bool-3.C: New. +#+ +# 2019-06-04 Jakub Jelinek +# +# * c-c++-common/gomp/lastprivate-conditional-2.c (foo): Don't expect +diff --git a/gcc/testsuite/g++.target/powerpc/powerpc.exp b/gcc/testsuite/g++.target/powerpc/powerpc.exp +new file mode 100644 +index 00000000000..4e7ea3311e6 +--- /dev/null ++++ b/gcc/testsuite/g++.target/powerpc/powerpc.exp +@@ -0,0 +1,44 @@ ++# Specific regression driver for PowerPC. ++# Copyright (C) 2019 Free Software Foundation, Inc. ++# ++# This file is part of GCC. ++# ++# GCC is free software; you can redistribute it and/or modify it ++# under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3, or (at your option) ++# any later version. ++# ++# GCC is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++# General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with GCC; see the file COPYING3. If not see ++# . */ ++ ++# GCC testsuite that uses the `dg.exp' driver. ++ ++# Exit immediately if this isn't a PowerPC target. ++if {![istarget powerpc*-*-*] } then { ++ return ++} ++ ++# Load support procs. ++load_lib g++-dg.exp ++ ++global DEFAULT_CXXFLAGS ++if ![info exists DEFAULT_CXXFLAGS] then { ++ set DEFAULT_CXXFLAGS " -pedantic-errors" ++} ++ ++# Initialize `dg'. ++dg-init ++ ++# Main loop. ++dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] \ ++ "" $DEFAULT_CXXFLAGS ++ ++# All done. ++dg-finish ++ +diff --git a/gcc/testsuite/g++.target/powerpc/undef-bool-3.C b/gcc/testsuite/g++.target/powerpc/undef-bool-3.C +new file mode 100644 +index 00000000000..27f3da58217 +--- /dev/null ++++ b/gcc/testsuite/g++.target/powerpc/undef-bool-3.C +@@ -0,0 +1,13 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O2 -std=c++11" } */ ++ ++/* Test to ensure that "bool" is not #define'd in altivec.h for C++ when ++ we require strict ANSI. We should compile without errors. */ ++ ++#include ++ ++bool foo (int x) ++{ ++ return x == 2; ++} ++ +-- +2.27.0 + diff --git a/gcc7-pr81942.patch b/gcc7-pr81942.patch new file mode 100644 index 0000000..f7d7870 --- /dev/null +++ b/gcc7-pr81942.patch @@ -0,0 +1,116 @@ +From d49318d9bc3e63251aada27b322e7756eab19884 Mon Sep 17 00:00:00 2001 +From: Paolo Carlini +Date: Tue, 5 Sep 2017 13:33:44 +0000 +Subject: [PATCH 1/1] re PR c++/81942 (ICE on empty constexpr constructor with + C++14) + +/cp +2017-09-05 Paolo Carlini + + PR c++/81942 + * cp-tree.h (LABEL_DECL_CDTOR): Add and document. + * decl.c (start_preparsed_function): Set LABEL_DECL_CDTOR when + creating cdtor_label. + * constexpr.c (returns): Add the case of a constructor/destructor + returning via a LABEL_DECL_CDTOR label. + (cxx_eval_constant_expression, case [GOTO_EXPR]): Likewise. + +/testsuite +2017-09-05 Paolo Carlini + + PR c++/81942 + * g++.dg/cpp1y/constexpr-return3.C: New. + +From-SVN: r251714 +--- + gcc/cp/ChangeLog | 10 ++++++++++ + gcc/cp/constexpr.c | 8 ++++++-- + gcc/cp/cp-tree.h | 6 ++++++ + gcc/cp/decl.c | 5 ++++- + gcc/testsuite/ChangeLog | 5 +++++ + gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C | 11 +++++++++++ + 6 files changed, 42 insertions(+), 3 deletions(-) + create mode 100644 gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C + +Index: gcc-7.5.0+r278197/gcc/cp/constexpr.c +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/cp/constexpr.c ++++ gcc-7.5.0+r278197/gcc/cp/constexpr.c +@@ -3744,7 +3744,9 @@ static bool + returns (tree *jump_target) + { + return *jump_target +- && TREE_CODE (*jump_target) == RETURN_EXPR; ++ && (TREE_CODE (*jump_target) == RETURN_EXPR ++ || (TREE_CODE (*jump_target) == LABEL_DECL ++ && LABEL_DECL_CDTOR (*jump_target))); + } + + static bool +@@ -4641,7 +4643,9 @@ cxx_eval_constant_expression (const cons + + case GOTO_EXPR: + *jump_target = TREE_OPERAND (t, 0); +- gcc_assert (breaks (jump_target) || continues (jump_target)); ++ gcc_assert (breaks (jump_target) || continues (jump_target) ++ /* Allow for jumping to a cdtor_label. */ ++ || returns (jump_target)); + break; + + case LOOP_EXPR: +Index: gcc-7.5.0+r278197/gcc/cp/cp-tree.h +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/cp/cp-tree.h ++++ gcc-7.5.0+r278197/gcc/cp/cp-tree.h +@@ -229,6 +229,7 @@ operator == (const cp_expr &lhs, tree rh + DECL_CONSTRAINT_VAR_P (in a PARM_DECL) + TEMPLATE_DECL_COMPLEX_ALIAS_P (in TEMPLATE_DECL) + DECL_INSTANTIATING_NSDMI_P (in a FIELD_DECL) ++ LABEL_DECL_CDTOR (in LABEL_DECL) + 3: DECL_IN_AGGR_P. + 4: DECL_C_BIT_FIELD (in a FIELD_DECL) + DECL_ANON_UNION_VAR_P (in a VAR_DECL) +@@ -3610,6 +3611,11 @@ more_aggr_init_expr_args_p (const aggr_i + #define LABEL_DECL_CONTINUE(NODE) \ + DECL_LANG_FLAG_1 (LABEL_DECL_CHECK (NODE)) + ++/* Nonzero if NODE is the target for genericization of 'return' stmts ++ in constructors/destructors of targetm.cxx.cdtor_returns_this targets. */ ++#define LABEL_DECL_CDTOR(NODE) \ ++ DECL_LANG_FLAG_2 (LABEL_DECL_CHECK (NODE)) ++ + /* True if NODE was declared with auto in its return type, but it has + started compilation and so the return type might have been changed by + return type deduction; its declared return type should be found in +Index: gcc-7.5.0+r278197/gcc/cp/decl.c +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/cp/decl.c ++++ gcc-7.5.0+r278197/gcc/cp/decl.c +@@ -15253,7 +15253,10 @@ start_preparsed_function (tree decl1, tr + if (DECL_DESTRUCTOR_P (decl1) + || (DECL_CONSTRUCTOR_P (decl1) + && targetm.cxx.cdtor_returns_this ())) +- cdtor_label = create_artificial_label (input_location); ++ { ++ cdtor_label = create_artificial_label (input_location); ++ LABEL_DECL_CDTOR (cdtor_label) = true; ++ } + + start_fname_decls (); + +Index: gcc-7.5.0+r278197/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C +=================================================================== +--- /dev/null ++++ gcc-7.5.0+r278197/gcc/testsuite/g++.dg/cpp1y/constexpr-return3.C +@@ -0,0 +1,11 @@ ++// PR c++/81942 ++// { dg-do compile { target c++14 } } ++ ++class A { ++public: ++ constexpr A() { ++ return; ++ } ++}; ++ ++A mwi; diff --git a/gcc7-pr82248.diff b/gcc7-pr82248.diff new file mode 100644 index 0000000..e0281a5 --- /dev/null +++ b/gcc7-pr82248.diff @@ -0,0 +1,13 @@ +Index: gcc/config/arm/arm.md +=================================================================== +--- gcc/config/arm/arm.md (revision 255006) ++++ gcc/config/arm/arm.md (working copy) +@@ -8613,7 +8613,7 @@ (define_insn "blockage" + ) + + (define_insn "probe_stack" +- [(set (match_operand:SI 0 "memory_operand" "=m") ++ [(set (match_operand:SI 0 "memory_operand" "=o") + (unspec:SI [(const_int 0)] UNSPEC_PROBE_STACK))] + "TARGET_32BIT" + "str%?\\tr0, %0" diff --git a/gcc7-pr85887.patch b/gcc7-pr85887.patch new file mode 100644 index 0000000..585b189 --- /dev/null +++ b/gcc7-pr85887.patch @@ -0,0 +1,28 @@ +2019-10-22 Jakub Jelinek + + PR tree-optimization/85887 + * decl.c (expand_static_init): Drop ECF_LEAF from __cxa_guard_acquire + and __cxa_guard_release. + +Index: gcc/cp/decl.c +=================================================================== +--- gcc/cp/decl.c (revision 277292) ++++ gcc/cp/decl.c (revision 277293) +@@ -8589,14 +8589,14 @@ expand_static_init (tree decl, tree init + (acquire_name, build_function_type_list (integer_type_node, + TREE_TYPE (guard_addr), + NULL_TREE), +- NULL_TREE, ECF_NOTHROW | ECF_LEAF); ++ NULL_TREE, ECF_NOTHROW); + if (!release_fn || !abort_fn) + vfntype = build_function_type_list (void_type_node, + TREE_TYPE (guard_addr), + NULL_TREE); + if (!release_fn) + release_fn = push_library_fn (release_name, vfntype, NULL_TREE, +- ECF_NOTHROW | ECF_LEAF); ++ ECF_NOTHROW); + if (!abort_fn) + abort_fn = push_library_fn (abort_name, vfntype, NULL_TREE, + ECF_NOTHROW | ECF_LEAF); + diff --git a/gcc7-pr87723.patch b/gcc7-pr87723.patch new file mode 100644 index 0000000..f32babf --- /dev/null +++ b/gcc7-pr87723.patch @@ -0,0 +1,81 @@ +From 8c21b0d164f33d9d47acc26f4f9b99b53e3b1945 Mon Sep 17 00:00:00 2001 +From: Andreas Krebbel +Date: Tue, 6 Nov 2018 10:22:05 +0000 +Subject: [PATCH] S/390: Fix PR87723 +To: gcc-patches@gcc.gnu.org + +gcc/ChangeLog: + +2018-11-06 Andreas Krebbel + + PR target/87723 + * config/s390/s390.md ("*rsbg_di_rotl"): Remove mode + attributes for operands 3 and 4. + +gcc/testsuite/ChangeLog: + +2018-11-06 Andreas Krebbel + + PR target/87723 + * gcc.target/s390/pr87723.c: New test. + +From-SVN: r265832 +--- + gcc/ChangeLog | 6 +++++ + gcc/config/s390/s390.md | 2 +- + gcc/testsuite/ChangeLog | 5 +++++ + gcc/testsuite/gcc.target/s390/pr87723.c | 29 +++++++++++++++++++++++++ + 4 files changed, 41 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/gcc.target/s390/pr87723.c + +diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md +index 8e7b285e1c3..4ffd438c07c 100644 +--- a/gcc/config/s390/s390.md ++++ b/gcc/config/s390/s390.md +@@ -4230,7 +4230,7 @@ + (match_operand:DI 4 "nonimmediate_operand" "0"))) + (clobber (reg:CC CC_REGNUM))] + "TARGET_Z10" +- "rsbg\t%0,%1,%2,%2,%b3" ++ "rsbg\t%0,%1,%s2,%e2,%b3" + [(set_attr "op_type" "RIE")]) + + ; rosbg, rxsbg +diff --git a/gcc/testsuite/gcc.target/s390/pr87723.c b/gcc/testsuite/gcc.target/s390/pr87723.c +new file mode 100644 +index 00000000000..b0e8a5a3118 +--- /dev/null ++++ b/gcc/testsuite/gcc.target/s390/pr87723.c +@@ -0,0 +1,29 @@ ++/* { dg-do compile } */ ++/* { dg-options "-O3 -march=z196 -m64 -mzarch" } */ ++ ++unsigned long a; ++int b; ++void c(char* i) { ++ for (;;) { ++ char g = 0; ++ for (; g < 24; ++g) ++ b = a << g | a >> 64 - g; ++ { ++ char *d = i; ++ long h = b; ++ char e = 0; ++ for (; e < 8; ++e) ++ d[e] = h; ++ } ++ char *d = i; ++ signed e; ++ unsigned long f = 0; ++ e = 7; ++ for (; e; --e) { ++ f <<= 8; ++ f |= d[e]; ++ } ++ for (; e < 8; ++e) ++ d[e] = f; ++ } ++} +-- +2.35.3 + diff --git a/gcc7-pr88345-min-func-alignment.diff b/gcc7-pr88345-min-func-alignment.diff new file mode 100644 index 0000000..b98bb42 --- /dev/null +++ b/gcc7-pr88345-min-func-alignment.diff @@ -0,0 +1,141 @@ +From 874b0e7d0c16653beeed2ce8d92363cc0c1580cd Mon Sep 17 00:00:00 2001 +From: Martin Jambor +Date: Thu, 25 Jan 2024 14:15:10 +0100 +Subject: [PATCH] Add -fmin-function-alignmnet +To: gcc-patches@gcc.gnu.org + +This is a manual backport of gcc master ommit r14-8395-g0f5a9a00e3ab1f +without alphabetical reordering of parameters in common.opt. Commit +message of that commit (without Changelog): + + commit 0f5a9a00e3ab1fe96142f304cfbcf3f63b15f326 + Author: Jan Hubicka + Date: Wed Jan 24 18:13:17 2024 +0100 + + Add -fmin-function-alignmnet + + -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: + +2024-01-25 Jan Hubicka + Martin Jambor + + * common.opt (fmin-function-alignment): New parameter. + * doc/invoke.texi: (-fmin-function-alignment): Document. + (-falign-functions,-falign-loops,-falign-labels): Mention that + * varasm.c (assemble_start_function): Handle min-function-alignment. + * lto-streamer.h (LTO_minor_version): Bump. +--- + gcc/common.opt | 4 ++++ + gcc/doc/invoke.texi | 17 +++++++++++++++++ + gcc/lto-streamer.h | 2 +- + gcc/varasm.c | 5 +++++ + 4 files changed, 27 insertions(+), 1 deletion(-) + +diff --git a/gcc/common.opt b/gcc/common.opt +index 437db8e8615..8eadae558f3 100644 +--- a/gcc/common.opt ++++ b/gcc/common.opt +@@ -1824,6 +1824,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 Report Var(flag_modulo_sched) Optimization + Perform SMS based modulo scheduling before the first scheduling pass. +diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi +index 8f279e454b0..bed117fa542 100644 +--- a/gcc/doc/invoke.texi ++++ b/gcc/doc/invoke.texi +@@ -355,6 +355,7 @@ Objective-C and Objective-C++ Dialects}. + @gccoptlist{-faggressive-loop-optimizations -falign-functions[=@var{n}] @gol + -falign-jumps[=@var{n}] @gol + -falign-labels[=@var{n}] -falign-loops[=@var{n}] @gol ++-fmin-function-alignment=[@var{n}] @gol + -fassociative-math -fauto-profile -fauto-profile[=@var{path}] @gol + -fauto-inc-dec -fbranch-probabilities @gol + -fbranch-target-load-optimize -fbranch-target-load-optimize2 @gol +@@ -8688,6 +8689,9 @@ Align the start of functions to the next power-of-two greater than + @option{-falign-functions=32} aligns functions to the next 32-byte + boundary, but @option{-falign-functions=24} aligns to the next + 32-byte boundary only if this can be done by skipping 23 bytes or less. ++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}. + + @option{-fno-align-functions} and @option{-falign-functions=1} are + equivalent and mean that functions are not aligned. +@@ -8733,6 +8737,8 @@ Align loops to a power-of-two boundary, skipping up to @var{n} bytes + like @option{-falign-functions}. If the loops are + executed many times, this makes up for any execution of the dummy + operations. ++This is an optimization of code performance and alignment is ignored for ++loops considered cold. + + @option{-fno-align-loops} and @option{-falign-loops=1} are + equivalent and mean that loops are not aligned. +@@ -8749,6 +8755,8 @@ Align branch targets to a power-of-two boundary, for branch targets + where the targets can only be reached by jumping, skipping up to @var{n} + bytes like @option{-falign-functions}. In this case, no dummy operations + need be executed. ++This is an optimization of code performance and alignment is ignored for ++jumps considered cold. + + @option{-fno-align-jumps} and @option{-falign-jumps=1} are + equivalent and mean that loops are not aligned. +@@ -8758,6 +8766,15 @@ The maximum allowed @var{n} option value is 65536. + + Enabled at levels @option{-O2}, @option{-O3}. + ++@item -fmin-function-alignment ++@itemx -fmin-function-alignment=@var{n} ++@opindex 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} ++ ++ + @item -funit-at-a-time + @opindex funit-at-a-time + This option is left for compatibility reasons. @option{-funit-at-a-time} +diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h +index 689fbcf64ee..ef0aec79863 100644 +--- a/gcc/lto-streamer.h ++++ b/gcc/lto-streamer.h +@@ -129,7 +129,7 @@ along with GCC; see the file COPYING3. If not see + form followed by the data for the string. */ + + #define LTO_major_version 6 +-#define LTO_minor_version 2 ++#define LTO_minor_version 3 + + typedef unsigned char lto_decl_flags_t; + +diff --git a/gcc/varasm.c b/gcc/varasm.c +index 1b9030029ac..311b899ced7 100644 +--- a/gcc/varasm.c ++++ b/gcc/varasm.c +@@ -1778,6 +1778,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/gcc7-pr88522.patch b/gcc7-pr88522.patch new file mode 100644 index 0000000..88dd9d7 --- /dev/null +++ b/gcc7-pr88522.patch @@ -0,0 +1,149 @@ +backport: re PR target/88522 (Error: operand size mismatch for `vpgatherqq') + +Backported from mainline +2018-12-21 Jakub Jelinek + +PR target/88522 +* config/i386/sse.md (*avx512pf_gatherpfsf_mask, +*avx512pf_gatherpfdf_mask, *avx512pf_scatterpfsf_mask, +*avx512pf_scatterpfdf_mask): Use %X5 instead of %5 for +-masm=intel. +(gatherq_mode): Remove mode iterator. +(*avx512f_gathersi, *avx512f_gathersi_2): Use X instead +of . +(*avx512f_gatherdi): Use X instead of . +(*avx512f_gatherdi_2, *avx512f_scattersi, +*avx512f_scatterdi): Use %X5 for -masm=intel. + + +diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md +index c8b314abaa6..aecd98851a5 100644 +--- a/gcc/config/i386/sse.md ++++ b/gcc/config/i386/sse.md +@@ -16039,9 +16039,9 @@ + switch (INTVAL (operands[4])) + { + case 3: +- return "%M2vgatherpf0ps\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vgatherpf0ps\t{%5%{%0%}|%X5%{%0%}}"; + case 2: +- return "%M2vgatherpf1ps\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vgatherpf1ps\t{%5%{%0%}|%X5%{%0%}}"; + default: + gcc_unreachable (); + } +@@ -16084,9 +16084,9 @@ + switch (INTVAL (operands[4])) + { + case 3: +- return "%M2vgatherpf0pd\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vgatherpf0pd\t{%5%{%0%}|%X5%{%0%}}"; + case 2: +- return "%M2vgatherpf1pd\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vgatherpf1pd\t{%5%{%0%}|%X5%{%0%}}"; + default: + gcc_unreachable (); + } +@@ -16130,10 +16130,10 @@ + { + case 3: + case 7: +- return "%M2vscatterpf0ps\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vscatterpf0ps\t{%5%{%0%}|%X5%{%0%}}"; + case 2: + case 6: +- return "%M2vscatterpf1ps\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vscatterpf1ps\t{%5%{%0%}|%X5%{%0%}}"; + default: + gcc_unreachable (); + } +@@ -16177,10 +16177,10 @@ + { + case 3: + case 7: +- return "%M2vscatterpf0pd\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vscatterpf0pd\t{%5%{%0%}|%X5%{%0%}}"; + case 2: + case 6: +- return "%M2vscatterpf1pd\t{%5%{%0%}|%5%{%0%}}"; ++ return "%M2vscatterpf1pd\t{%5%{%0%}|%X5%{%0%}}"; + default: + gcc_unreachable (); + } +@@ -19180,12 +19180,6 @@ + (set_attr "prefix" "vex") + (set_attr "mode" "")]) + +-;; Memory operand override for -masm=intel of the v*gatherq* patterns. +-(define_mode_attr gatherq_mode +- [(V4SI "q") (V2DI "x") (V4SF "q") (V2DF "x") +- (V8SI "x") (V4DI "t") (V8SF "x") (V4DF "t") +- (V16SI "t") (V8DI "g") (V16SF "t") (V8DF "g")]) +- + (define_expand "_gathersi" + [(parallel [(set (match_operand:VI48F 0 "register_operand") + (unspec:VI48F +@@ -19219,7 +19213,7 @@ + UNSPEC_GATHER)) + (clobber (match_scratch: 2 "=&Yk"))] + "TARGET_AVX512F" +- "%M4vgatherd\t{%6, %0%{%2%}|%0%{%2%}, %6}" ++ "%M4vgatherd\t{%6, %0%{%2%}|%0%{%2%}, %X6}" + [(set_attr "type" "ssemov") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) +@@ -19238,7 +19232,7 @@ + UNSPEC_GATHER)) + (clobber (match_scratch: 1 "=&Yk"))] + "TARGET_AVX512F" +- "%M3vgatherd\t{%5, %0%{%1%}|%0%{%1%}, %5}" ++ "%M3vgatherd\t{%5, %0%{%1%}|%0%{%1%}, %X5}" + [(set_attr "type" "ssemov") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) +@@ -19278,7 +19272,7 @@ + (clobber (match_scratch:QI 2 "=&Yk"))] + "TARGET_AVX512F" + { +- return "%M4vgatherq\t{%6, %1%{%2%}|%1%{%2%}, %6}"; ++ return "%M4vgatherq\t{%6, %1%{%2%}|%1%{%2%}, %X6}"; + } + [(set_attr "type" "ssemov") + (set_attr "prefix" "evex") +@@ -19302,11 +19296,11 @@ + if (mode != mode) + { + if ( != 64) +- return "%M3vgatherq\t{%5, %x0%{%1%}|%x0%{%1%}, %5}"; ++ return "%M3vgatherq\t{%5, %x0%{%1%}|%x0%{%1%}, %X5}"; + else +- return "%M3vgatherq\t{%5, %t0%{%1%}|%t0%{%1%}, %t5}"; ++ return "%M3vgatherq\t{%5, %t0%{%1%}|%t0%{%1%}, %X5}"; + } +- return "%M3vgatherq\t{%5, %0%{%1%}|%0%{%1%}, %5}"; ++ return "%M3vgatherq\t{%5, %0%{%1%}|%0%{%1%}, %X5}"; + } + [(set_attr "type" "ssemov") + (set_attr "prefix" "evex") +@@ -19343,7 +19337,7 @@ + UNSPEC_SCATTER)) + (clobber (match_scratch: 1 "=&Yk"))] + "TARGET_AVX512F" +- "%M0vscatterd\t{%3, %5%{%1%}|%5%{%1%}, %3}" ++ "%M0vscatterd\t{%3, %5%{%1%}|%X5%{%1%}, %3}" + [(set_attr "type" "ssemov") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) +@@ -19379,11 +19373,7 @@ + UNSPEC_SCATTER)) + (clobber (match_scratch:QI 1 "=&Yk"))] + "TARGET_AVX512F" +-{ +- if (GET_MODE_SIZE (GET_MODE_INNER (mode)) == 8) +- return "%M0vscatterq\t{%3, %5%{%1%}|%5%{%1%}, %3}"; +- return "%M0vscatterq\t{%3, %5%{%1%}|%t5%{%1%}, %3}"; +-} ++ "%M0vscatterq\t{%3, %5%{%1%}|%X5%{%1%}, %3}" + [(set_attr "type" "ssemov") + (set_attr "prefix" "evex") + (set_attr "mode" "")]) diff --git a/gcc7-pr89124.patch b/gcc7-pr89124.patch new file mode 100644 index 0000000..6408293 --- /dev/null +++ b/gcc7-pr89124.patch @@ -0,0 +1,68 @@ +From 9d983fd1b9611631fdd5efd26b3b7bdc1ab6dc24 Mon Sep 17 00:00:00 2001 +From: Martin Jambor +Date: Mon, 7 Nov 2022 17:42:01 +0100 +Subject: [PATCH] Backport of fix to PR sanitizer/89124 + +gcc/ChangeLog: + +2019-01-31 Jakub Jelinek + + PR sanitizer/89124 + * ipa-inline.c (sanitize_attrs_match_for_inline_p): Allow inlining + always_inline callees into no_sanitize_address callers. + +gcc/testsuite/ChangeLog: + +2019-01-31 Jakub Jelinek + + PR sanitizer/89124 + * c-c++-common/asan/pr89124.c: New test. + +From-SVN: r268415 +Git commit 6206a883fe7a741dbb9e09d88255a170a75950f5 +--- + gcc/ipa-inline.c | 6 ++++++ + gcc/testsuite/c-c++-common/asan/pr89124.c | 14 ++++++++++++++ + 2 files changed, 20 insertions(+) + create mode 100644 gcc/testsuite/c-c++-common/asan/pr89124.c + +diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c +index b520c6393f4..64542238fdd 100644 +--- a/gcc/ipa-inline.c ++++ b/gcc/ipa-inline.c +@@ -263,6 +263,12 @@ sanitize_attrs_match_for_inline_p (const_tree caller, const_tree callee) + if (!caller || !callee) + return true; + ++ /* Allow inlining always_inline functions into no_sanitize_address ++ functions. */ ++ if (lookup_attribute ("no_sanitize_address", DECL_ATTRIBUTES (caller)) ++ && lookup_attribute ("always_inline", DECL_ATTRIBUTES (callee))) ++ return true; ++ + return !!lookup_attribute ("no_sanitize_address", + DECL_ATTRIBUTES (caller)) == + !!lookup_attribute ("no_sanitize_address", +diff --git a/gcc/testsuite/c-c++-common/asan/pr89124.c b/gcc/testsuite/c-c++-common/asan/pr89124.c +new file mode 100644 +index 00000000000..c9c870b76c6 +--- /dev/null ++++ b/gcc/testsuite/c-c++-common/asan/pr89124.c +@@ -0,0 +1,14 @@ ++/* PR sanitizer/89124 */ ++/* { dg-do compile } */ ++ ++static int inline __attribute__ ((always_inline)) ++foo (int x) ++{ ++ return x + 1; ++} ++ ++__attribute__ ((no_sanitize_address)) int ++bar (int x) ++{ ++ return foo (x); ++} +-- +2.38.0 + diff --git a/gcc7-pr92154.patch b/gcc7-pr92154.patch new file mode 100644 index 0000000..9e39f97 --- /dev/null +++ b/gcc7-pr92154.patch @@ -0,0 +1,56 @@ +2019-11-26 Jakub Jelinek + + PR sanitizer/92154 + * sanitizer_common/sanitizer_platform_limits_posix.h: Cherry-pick + llvm-project revision 947f9692440836dcb8d88b74b69dd379d85974ce. + * sanitizer_common/sanitizer_platform_limits_posix.cc: Likewise. + +Index: gcc-7.5.0+r278197/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +=================================================================== +--- gcc-7.5.0+r278197.orig/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ gcc-7.5.0+r278197/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -1145,8 +1145,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid); + CHECK_SIZE_AND_OFFSET(ipc_perm, gid); + CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); + CHECK_SIZE_AND_OFFSET(ipc_perm, cgid); +-#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21) +-/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */ ++#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31) ++/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit ++ on many architectures. */ + CHECK_SIZE_AND_OFFSET(ipc_perm, mode); + #endif + +Index: gcc-7.5.0+r278197/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +=================================================================== +--- gcc-7.5.0+r278197.orig/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h ++++ gcc-7.5.0+r278197/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +@@ -204,27 +204,14 @@ namespace __sanitizer { + unsigned __seq; + u64 __unused1; + u64 __unused2; +-#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__) +- unsigned int mode; +- unsigned short __seq; +- unsigned short __pad1; +- unsigned long __unused1; +- unsigned long __unused2; + #elif defined(__sparc__) +-# if defined(__arch64__) + unsigned mode; +- unsigned short __pad1; +-# else +- unsigned short __pad1; +- unsigned short mode; + unsigned short __pad2; +-# endif + unsigned short __seq; + unsigned long long __unused1; + unsigned long long __unused2; + #else +- unsigned short mode; +- unsigned short __pad1; ++ unsigned int mode; + unsigned short __seq; + unsigned short __pad2; + #if defined(__x86_64__) && !defined(_LP64) diff --git a/gcc7-pr92692.patch b/gcc7-pr92692.patch new file mode 100644 index 0000000..7397980 --- /dev/null +++ b/gcc7-pr92692.patch @@ -0,0 +1,139 @@ +Backported to gcc7 from: + +From: Wilco Dijkstra +Date: Fri, 17 Jan 2020 13:17:21 +0000 (+0000) +Subject: [AArch64] Fix shrinkwrapping interactions with atomics (PR92692) +X-Git-Url: https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;a=commitdiff_plain;h=e5e07b68187b9aa334519746c45b8cffc5eb7e5c + +[AArch64] Fix shrinkwrapping interactions with atomics (PR92692) + +The separate shrinkwrapping pass may insert stores in the middle +of atomics loops which can cause issues on some implementations. +Avoid this by delaying splitting atomics patterns until after +prolog/epilog generation. + +gcc/ + PR target/92692 + * config/aarch64/aarch64.c (aarch64_split_compare_and_swap) + Add assert to ensure prolog has been emitted. + (aarch64_split_atomic_op): Likewise. + * config/aarch64/atomics.md (aarch64_compare_and_swap) + Use epilogue_completed rather than reload_completed. + (aarch64_atomic_exchange): Likewise. + (aarch64_atomic_): Likewise. + (atomic_nand): Likewise. + (aarch64_atomic_fetch_): Likewise. + (atomic_fetch_nand): Likewise. + (aarch64_atomic__fetch): Likewise. + (atomic_nand_fetch): Likewise. +--- + +Index: gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/aarch64.c ++++ gcc-7.5.0+r278197/gcc/config/aarch64/aarch64.c +@@ -12121,6 +12121,9 @@ aarch64_emit_post_barrier (enum memmodel + void + aarch64_split_compare_and_swap (rtx operands[]) + { ++ /* Split after prolog/epilog to avoid interactions with shrinkwrapping. */ ++ gcc_assert (epilogue_completed); ++ + rtx rval, mem, oldval, newval, scratch, x, model_rtx; + machine_mode mode; + bool is_weak; +@@ -12205,6 +12208,9 @@ void + aarch64_split_atomic_op (enum rtx_code code, rtx old_out, rtx new_out, rtx mem, + rtx value, rtx model_rtx, rtx cond) + { ++ /* Split after prolog/epilog to avoid interactions with shrinkwrapping. */ ++ gcc_assert (epilogue_completed); ++ + machine_mode mode = GET_MODE (mem); + machine_mode wmode = (mode == DImode ? DImode : SImode); + const enum memmodel model = memmodel_from_int (INTVAL (model_rtx)); +Index: gcc-7.5.0+r278197/gcc/config/aarch64/atomics.md +=================================================================== +--- gcc-7.5.0+r278197.orig/gcc/config/aarch64/atomics.md ++++ gcc-7.5.0+r278197/gcc/config/aarch64/atomics.md +@@ -59,7 +59,7 @@ + (clobber (match_scratch:SI 7 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_compare_and_swap (operands); +@@ -83,7 +83,7 @@ + (clobber (match_scratch:SI 7 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_compare_and_swap (operands); +@@ -226,7 +226,7 @@ + (clobber (match_scratch:SI 4 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_atomic_op (SET, operands[0], NULL, operands[1], +@@ -347,7 +347,7 @@ + (clobber (match_scratch:SI 4 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_atomic_op (, NULL, operands[3], operands[0], +@@ -403,7 +403,7 @@ + (clobber (match_scratch:SI 4 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_atomic_op (NOT, NULL, operands[3], operands[0], +@@ -507,7 +507,7 @@ + (clobber (match_scratch:SI 5 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_atomic_op (, operands[0], operands[4], operands[1], +@@ -554,7 +554,7 @@ + (clobber (match_scratch:SI 5 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_atomic_op (NOT, operands[0], operands[4], operands[1], +@@ -607,7 +607,7 @@ + (clobber (match_scratch:SI 4 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_atomic_op (, NULL, operands[0], operands[1], +@@ -631,7 +631,7 @@ + (clobber (match_scratch:SI 4 "=&r"))] + "" + "#" +- "&& reload_completed" ++ "&& epilogue_completed" + [(const_int 0)] + { + aarch64_split_atomic_op (NOT, NULL, operands[0], operands[1], diff --git a/gcc7-pr93246.patch b/gcc7-pr93246.patch new file mode 100644 index 0000000..f4ce558 --- /dev/null +++ b/gcc7-pr93246.patch @@ -0,0 +1,128 @@ +commit 20e9d78543493f2f6aeef19af4cea54696247fc8 +Author: Richard Biener +Date: Tue Jan 14 08:43:32 2020 +0100 + + PR middle-end/93246 - missing alias subsets + + Starting with the introduction of TYPE_TYPELESS_STORAGE the situation + of having a alias-set zero aggregate field became more common which + prevents recording alias-sets of fields of said aggregate as subset + of the outer aggregate. component_uses_parent_alias_set_from in the + past fended off some of the issues with that but the alias oracles + use of the alias set of the base of an access path never appropriately + handled it. + + The following makes it so that alias-sets of fields of alias-set zero + aggregate fields are still recorded as subset of the container. + + 2020-01-14 Richard Biener + + PR middle-end/93246 + * alias.c (record_component_aliases): Take superset to record + into, recurse for alias-set zero fields. + (record_component_aliases): New oveerload wrapping around the above. + + * g++.dg/torture/pr93246.C: New testcase. + +diff --git a/gcc/alias.c b/gcc/alias.c +index b64e3ea264d..053c3494e79 100644 +--- a/gcc/alias.c ++++ b/gcc/alias.c +@@ -1186,15 +1186,14 @@ record_alias_subset (alias_set_type superset, alias_set_type subset) + } + } + +-/* Record that component types of TYPE, if any, are part of that type for ++/* Record that component types of TYPE, if any, are part of SUPERSET for + aliasing purposes. For record types, we only record component types + for fields that are not marked non-addressable. For array types, we + only record the component type if it is not marked non-aliased. */ + + void +-record_component_aliases (tree type) ++record_component_aliases (tree type, alias_set_type superset) + { +- alias_set_type superset = get_alias_set (type); + tree field; + + if (superset == 0) +@@ -1244,7 +1243,21 @@ record_component_aliases (tree type) + == get_alias_set (TREE_TYPE (field))); + } + +- record_alias_subset (superset, get_alias_set (t)); ++ alias_set_type set = get_alias_set (t); ++ record_alias_subset (superset, set); ++ /* If the field has alias-set zero make sure to still record ++ any componets of it. This makes sure that for ++ struct A { ++ struct B { ++ int i; ++ char c[4]; ++ } b; ++ }; ++ in C++ even though 'B' has alias-set zero because ++ TYPE_TYPELESS_STORAGE is set, 'A' has the alias-set of ++ 'int' as subset. */ ++ if (set == 0) ++ record_component_aliases (t, superset); + } + break; + +@@ -1260,6 +1273,19 @@ record_component_aliases (tree type) + } + } + ++/* Record that component types of TYPE, if any, are part of that type for ++ aliasing purposes. For record types, we only record component types ++ for fields that are not marked non-addressable. For array types, we ++ only record the component type if it is not marked non-aliased. */ ++ ++void ++record_component_aliases (tree type) ++{ ++ alias_set_type superset = get_alias_set (type); ++ record_component_aliases (type, superset); ++} ++ ++ + /* Allocate an alias set for use in storing and reading from the varargs + spill area. */ + +diff --git a/gcc/testsuite/g++.dg/torture/pr93246.C b/gcc/testsuite/g++.dg/torture/pr93246.C +new file mode 100644 +index 00000000000..4c523443175 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/torture/pr93246.C +@@ -0,0 +1,31 @@ ++// { dg-do run } ++// { dg-additional-options "-fstrict-aliasing" } ++ ++template struct Optional { ++ auto is_present() const { const bool &p = inner.present; return p; } ++ auto set_present() { if (not is_present()) inner.present = true; } ++ struct InnerType { ++ bool present = false; ++ char padding[1] = {0}; ++ }; ++ using inner_t = InnerType; ++ inner_t inner = {}; ++}; ++ ++template struct Wrapper { ++ auto operator-> () { return value; } ++ WrappedType *value; ++}; ++ ++void __attribute__((noinline,noclone)) foo(Optional<>& x) { __asm__ volatile ("":::"memory"); } ++ ++int main() ++{ ++ Optional<> buf{}; ++ foo(buf); ++ Wrapper> wo = {&buf}; ++ wo->set_present(); ++ auto x = wo->is_present(); ++ if (!x) ++ __builtin_abort (); ++} diff --git a/gcc7-pr93888.patch b/gcc7-pr93888.patch new file mode 100644 index 0000000..1bce066 --- /dev/null +++ b/gcc7-pr93888.patch @@ -0,0 +1,41 @@ +commit 64ba6d17022eeb65f56f0b141c2640f9ab938f97 +Author: Jakub Jelinek +Date: Wed Mar 4 12:59:04 2020 +0100 + + inliner: Copy DECL_BY_REFERENCE in copy_decl_to_var [PR93888] + + In the following testcase we emit wrong debug info for the karg + parameter in the DW_TAG_inlined_subroutine into main. + The problem is that the karg PARM_DECL is DECL_BY_REFERENCE and thus + in the IL has const K & type, but in the source just const K. + When the function is inlined, we create a VAR_DECL for it, but don't + set DECL_BY_REFERENCE, so when emitting DW_AT_location, we treat it like + a const K & typed variable, but it has DW_AT_abstract_origin which has + just the const K type and thus the debugger thinks the variable has + const K type. + + Fixed by copying the DECL_BY_REFERENCE flag. Not doing it in + copy_decl_for_dup_finish, because copy_decl_no_change already copies + that flag through copy_node and in copy_result_decl_to_var it is + undesirable, as we handle DECL_BY_REFERENCE in that case instead + by changing the type. + + 2020-03-04 Jakub Jelinek + + PR debug/93888 + * tree-inline.c (copy_decl_to_var): Copy DECL_BY_REFERENCE flag. + + * g++.dg/guality/pr93888.C: New test. + +diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c +index 23941dade55..59798ec0454 100644 +--- a/gcc/tree-inline.c ++++ b/gcc/tree-inline.c +@@ -5929,6 +5929,7 @@ copy_decl_to_var (tree decl, copy_body_data *id) + TREE_READONLY (copy) = TREE_READONLY (decl); + TREE_THIS_VOLATILE (copy) = TREE_THIS_VOLATILE (decl); + DECL_GIMPLE_REG_P (copy) = DECL_GIMPLE_REG_P (decl); ++ DECL_BY_REFERENCE (copy) = DECL_BY_REFERENCE (decl); + + return copy_decl_for_dup_finish (id, decl, copy); + } diff --git a/gcc7-pr93965.patch b/gcc7-pr93965.patch new file mode 100644 index 0000000..34d535b --- /dev/null +++ b/gcc7-pr93965.patch @@ -0,0 +1,44 @@ +From 08bf7bde9f2987b1c623d272cc71fc14a1622442 Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Fri, 28 Feb 2020 17:52:57 +0100 +Subject: [PATCH] Improve detection of ld_date. + + PR other/93965 + * configure.ac: Improve detection of ld_date by requiring + either two dashes or none. + * configure: Regenerate. +--- + gcc/ChangeLog | 7 +++++++ + gcc/configure | 2 +- + gcc/configure.ac | 2 +- + 3 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/gcc/configure b/gcc/configure +index f55cdb8c77f..5381e107bce 100755 +--- a/gcc/configure ++++ b/gcc/configure +@@ -23384,7 +23384,7 @@ if test $in_tree_ld != yes ; then + ld_vers=`echo $ld_ver | sed -n \ + -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'` + fi +- ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'` ++ ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)\(-*\)\([01][0-9]\)\2\([0-3][0-9]\).*$,\1\3\4,p'` + ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'` + ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'` + ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'` +diff --git a/gcc/configure.ac b/gcc/configure.ac +index 0e6e475950d..0d6230e0ca1 100644 +--- a/gcc/configure.ac ++++ b/gcc/configure.ac +@@ -2804,7 +2804,7 @@ if test $in_tree_ld != yes ; then + ld_vers=`echo $ld_ver | sed -n \ + -e 's,^.*[ ]\([0-9][0-9]*\.[0-9][0-9]*.*\)$,\1,p'` + fi +- ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)[-]*\([01][0-9]\)[-]*\([0-3][0-9]\).*$,\1\2\3,p'` ++ ld_date=`echo $ld_ver | sed -n 's,^.*\([2-9][0-9][0-9][0-9]\)\(-*\)\([01][0-9]\)\2\([0-3][0-9]\).*$,\1\3\4,p'` + ld_vers_major=`expr "$ld_vers" : '\([0-9]*\)'` + ld_vers_minor=`expr "$ld_vers" : '[0-9]*\.\([0-9]*\)'` + ld_vers_patch=`expr "$ld_vers" : '[0-9]*\.[0-9]*\.\([0-9]*\)'` +-- +2.25.0 + diff --git a/gcc7-pr94148.patch b/gcc7-pr94148.patch new file mode 100644 index 0000000..69f1f2f --- /dev/null +++ b/gcc7-pr94148.patch @@ -0,0 +1,140 @@ +commit 5c7e6d4bdf879b437b43037e10453275acabf521 +Author: Segher Boessenkool +Date: Thu Mar 12 07:12:50 2020 +0000 + + df: Don't abuse bb->aux (PR94148, PR94042) + + The df dataflow solvers use the aux field in the basic_block struct, + although that is reserved for any use by passes. And not only that, + it is required that you set all such fields to NULL before calling + the solvers, or you quietly get wrong results. + + This changes the solvers to use a local array for last_change_age + instead, just like it already had a local array for last_visit_age. + + PR rtl-optimization/94148 + PR rtl-optimization/94042 + * df-core.c (BB_LAST_CHANGE_AGE): Delete. + (df_worklist_propagate_forward): New parameter last_change_age, use + that instead of bb->aux. + (df_worklist_propagate_backward): Ditto. + (df_worklist_dataflow_doublequeue): Use a local array last_change_age. + +diff --git a/gcc/df-core.c b/gcc/df-core.c +index 346849e31be..9875a26895c 100644 +--- a/gcc/df-core.c ++++ b/gcc/df-core.c +@@ -871,9 +871,6 @@ make_pass_df_finish (gcc::context *ctxt) + The general data flow analysis engine. + ----------------------------------------------------------------------------*/ + +-/* Return time BB when it was visited for last time. */ +-#define BB_LAST_CHANGE_AGE(bb) ((ptrdiff_t)(bb)->aux) +- + /* Helper function for df_worklist_dataflow. + Propagate the dataflow forward. + Given a BB_INDEX, do the dataflow propagation +@@ -897,7 +894,8 @@ df_worklist_propagate_forward (struct dataflow *dataflow, + unsigned *bbindex_to_postorder, + bitmap pending, + sbitmap considered, +- ptrdiff_t age) ++ vec &last_change_age, ++ int age) + { + edge e; + edge_iterator ei; +@@ -908,7 +906,8 @@ df_worklist_propagate_forward (struct dataflow *dataflow, + if (EDGE_COUNT (bb->preds) > 0) + FOR_EACH_EDGE (e, ei, bb->preds) + { +- if (age <= BB_LAST_CHANGE_AGE (e->src) ++ if (bbindex_to_postorder[e->src->index] < last_change_age.length () ++ && age <= last_change_age[bbindex_to_postorder[e->src->index]] + && bitmap_bit_p (considered, e->src->index)) + changed |= dataflow->problem->con_fun_n (e); + } +@@ -942,7 +941,8 @@ df_worklist_propagate_backward (struct dataflow *dataflow, + unsigned *bbindex_to_postorder, + bitmap pending, + sbitmap considered, +- ptrdiff_t age) ++ vec &last_change_age, ++ int age) + { + edge e; + edge_iterator ei; +@@ -953,7 +953,8 @@ df_worklist_propagate_backward (struct dataflow *dataflow, + if (EDGE_COUNT (bb->succs) > 0) + FOR_EACH_EDGE (e, ei, bb->succs) + { +- if (age <= BB_LAST_CHANGE_AGE (e->dest) ++ if (bbindex_to_postorder[e->dest->index] < last_change_age.length () ++ && age <= last_change_age[bbindex_to_postorder[e->dest->index]] + && bitmap_bit_p (considered, e->dest->index)) + changed |= dataflow->problem->con_fun_n (e); + } +@@ -991,10 +992,10 @@ df_worklist_propagate_backward (struct dataflow *dataflow, + worklists (we are processing WORKLIST and storing new BBs to visit in + PENDING). + +- As an optimization we maintain ages when BB was changed (stored in bb->aux) +- and when it was last visited (stored in last_visit_age). This avoids need +- to re-do confluence function for edges to basic blocks whose source +- did not change since destination was visited last time. */ ++ As an optimization we maintain ages when BB was changed (stored in ++ last_change_age) and when it was last visited (stored in last_visit_age). ++ This avoids need to re-do confluence function for edges to basic blocks ++ whose source did not change since destination was visited last time. */ + + static void + df_worklist_dataflow_doublequeue (struct dataflow *dataflow, +@@ -1010,11 +1011,11 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow, + int age = 0; + bool changed; + vec last_visit_age = vNULL; ++ vec last_change_age = vNULL; + int prev_age; +- basic_block bb; +- int i; + + last_visit_age.safe_grow_cleared (n_blocks); ++ last_change_age.safe_grow_cleared (n_blocks); + + /* Double-queueing. Worklist is for the current iteration, + and pending is for the next. */ +@@ -1032,30 +1033,30 @@ df_worklist_dataflow_doublequeue (struct dataflow *dataflow, + + bitmap_clear_bit (pending, index); + bb_index = blocks_in_postorder[index]; +- bb = BASIC_BLOCK_FOR_FN (cfun, bb_index); + prev_age = last_visit_age[index]; + if (dir == DF_FORWARD) + changed = df_worklist_propagate_forward (dataflow, bb_index, + bbindex_to_postorder, + pending, considered, ++ last_change_age, + prev_age); + else + changed = df_worklist_propagate_backward (dataflow, bb_index, + bbindex_to_postorder, + pending, considered, ++ last_change_age, + prev_age); + last_visit_age[index] = ++age; + if (changed) +- bb->aux = (void *)(ptrdiff_t)age; ++ last_change_age[index] = age; + } + bitmap_clear (worklist); + } +- for (i = 0; i < n_blocks; i++) +- BASIC_BLOCK_FOR_FN (cfun, blocks_in_postorder[i])->aux = NULL; + + BITMAP_FREE (worklist); + BITMAP_FREE (pending); + last_visit_age.release (); ++ last_change_age.release (); + + /* Dump statistics. */ + if (dump_file) diff --git a/gcc7-pr97535.patch b/gcc7-pr97535.patch new file mode 100644 index 0000000..ab37328 --- /dev/null +++ b/gcc7-pr97535.patch @@ -0,0 +1,23 @@ +Backport of 0f801e0b6cc9f67c9a8983127e23161f6025c5b6 + +Index: gcc/config/aarch64/aarch64.c +=================================================================== +--- gcc/config/aarch64/aarch64.c (revision 278213) ++++ gcc/config/aarch64/aarch64.c (working copy) +@@ -13453,7 +13453,6 @@ aarch64_copy_one_block_and_progress_poin + bool + aarch64_expand_movmem (rtx *operands) + { +- unsigned int n; + rtx dst = operands[0]; + rtx src = operands[1]; + rtx base; +@@ -13467,7 +13466,7 @@ aarch64_expand_movmem (rtx *operands) + if (!CONST_INT_P (operands[2])) + return false; + +- n = UINTVAL (operands[2]); ++ unsigned HOST_WIDE_INT n = UINTVAL (operands[2]); + + /* Try to keep the number of instructions low. For cases below 16 bytes we + need to make at most two moves. For cases above 16 bytes it will be one 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..6bd10e2 --- /dev/null +++ b/gcc7-remove-Wexpansion-to-defined-from-Wextra.patch @@ -0,0 +1,26 @@ +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 gcc/testsuite/gcc.dg/cpp/defined-Wextra.c gcc/testsuite/gcc.dg/cpp/defined-Wextra.c +index 460a1cb43b2..b4de2b72d97 100644 +--- gcc/testsuite/gcc.dg/cpp/defined-Wextra.c ++++ gcc/testsuite/gcc.dg/cpp/defined-Wextra.c +@@ -1,7 +1,7 @@ + /* Copyright (C) 2000 Free Software Foundation, Inc. */ + + /* { dg-do preprocess } */ +-/* { dg-options "-Wextra" } */ ++/* { dg-options "-Wextra -Wexpansion-to-defined" } */ + + /* Use of defined in different contexts. */ + diff --git a/gcc7-rpmlintrc b/gcc7-rpmlintrc new file mode 100644 index 0000000..f40af91 --- /dev/null +++ b/gcc7-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/gcc7-sanitizer-cyclades.patch b/gcc7-sanitizer-cyclades.patch new file mode 100644 index 0000000..d7616ae --- /dev/null +++ b/gcc7-sanitizer-cyclades.patch @@ -0,0 +1,87 @@ +Pick a7e72b282177fbaa6a852324641c871313d326da to remove cyclades from +libsanitizer + +diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +index a68534c5a0a..85ab53e7430 100755 +--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc ++++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors_ioctl.inc +@@ -361,15 +361,6 @@ static void ioctl_table_fill() { + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE +- _(CYGETDEFTHRESH, WRITE, sizeof(int)); +- _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); +- _(CYGETMON, WRITE, struct_cyclades_monitor_sz); +- _(CYGETTHRESH, WRITE, sizeof(int)); +- _(CYGETTIMEOUT, WRITE, sizeof(int)); +- _(CYSETDEFTHRESH, NONE, 0); +- _(CYSETDEFTIMEOUT, NONE, 0); +- _(CYSETTHRESH, NONE, 0); +- _(CYSETTIMEOUT, NONE, 0); + _(EQL_EMANCIPATE, WRITE, struct_ifreq_sz); + _(EQL_ENSLAVE, WRITE, struct_ifreq_sz); + _(EQL_GETMASTRCFG, WRITE, struct_ifreq_sz); +diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +index 97eae3fc7bc..a5e02947696 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc +@@ -154,7 +154,6 @@ typedef struct user_fpregs elf_fpregset_t; + # include + #endif + #include +-#include + #include + #include + #include +@@ -454,7 +453,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); +- unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); + #if EV_VERSION > (0x010000) + unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry); + #else +@@ -821,15 +819,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + + #if SANITIZER_LINUX && !SANITIZER_ANDROID +- unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; +- unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; +- unsigned IOCTL_CYGETMON = CYGETMON; +- unsigned IOCTL_CYGETTHRESH = CYGETTHRESH; +- unsigned IOCTL_CYGETTIMEOUT = CYGETTIMEOUT; +- unsigned IOCTL_CYSETDEFTHRESH = CYSETDEFTHRESH; +- unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT; +- unsigned IOCTL_CYSETTHRESH = CYSETTHRESH; +- unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT; + unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE; + unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE; + unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG; +diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +index c139322839a..10f7a4f6502 100644 +--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h ++++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h +@@ -1000,7 +1000,6 @@ struct __sanitizer_cookie_io_functions_t { + + #if SANITIZER_LINUX && !SANITIZER_ANDROID + extern unsigned struct_ax25_parms_struct_sz; +- extern unsigned struct_cyclades_monitor_sz; + extern unsigned struct_input_keymap_entry_sz; + extern unsigned struct_ipx_config_data_sz; + extern unsigned struct_kbdiacrs_sz; +@@ -1345,15 +1344,6 @@ struct __sanitizer_cookie_io_functions_t { + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD + + #if SANITIZER_LINUX && !SANITIZER_ANDROID +- extern unsigned IOCTL_CYGETDEFTHRESH; +- extern unsigned IOCTL_CYGETDEFTIMEOUT; +- extern unsigned IOCTL_CYGETMON; +- extern unsigned IOCTL_CYGETTHRESH; +- extern unsigned IOCTL_CYGETTIMEOUT; +- extern unsigned IOCTL_CYSETDEFTHRESH; +- extern unsigned IOCTL_CYSETDEFTIMEOUT; +- extern unsigned IOCTL_CYSETTHRESH; +- extern unsigned IOCTL_CYSETTIMEOUT; + extern unsigned IOCTL_EQL_EMANCIPATE; + extern unsigned IOCTL_EQL_ENSLAVE; + extern unsigned IOCTL_EQL_GETMASTRCFG; diff --git a/gcc7-stack-probe.diff b/gcc7-stack-probe.diff new file mode 100644 index 0000000..28fc481 --- /dev/null +++ b/gcc7-stack-probe.diff @@ -0,0 +1,111 @@ +Index: gcc/common.opt +=================================================================== +--- gcc/common.opt (revision 244266) ++++ gcc/common.opt (working copy) +@@ -2295,6 +2299,10 @@ fstack-check + Common Alias(fstack-check=, specific, no) + Insert stack checking code into the program. Same as -fstack-check=specific. + ++fstack-clash-protection ++Common Report Var(flag_stack_clash_protection) ++Insert probes per page for dynamically allocated stack space ++ + fstack-limit + Common Var(common_deferred_options) Defer + +Index: gcc/explow.c +=================================================================== +--- gcc/explow.c (revision 244266) ++++ gcc/explow.c (working copy) +@@ -1277,6 +1277,8 @@ get_dynamic_stack_size (rtx *psize, unsi + *psize = size; + } + ++#define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP) ++ + /* Return an rtx representing the address of an area of memory dynamically + pushed on the stack. + +@@ -1305,6 +1307,8 @@ allocate_dynamic_stack_space (rtx size, + HOST_WIDE_INT stack_usage_size = -1; + rtx_code_label *final_label; + rtx final_target, target; ++ rtx loop_lab, end_lab, skip_lab, last_size, before_skip; ++ int probe_pass = 0; + + /* If we're asking for zero bytes, it doesn't matter what we point + to since we can't dereference it. But return a reasonable +@@ -1440,6 +1444,30 @@ allocate_dynamic_stack_space (rtx size, + /* Don't let anti_adjust_stack emit notes. */ + suppress_reg_args_size = true; + ++ if (flag_stack_clash_protection) ++ { ++#ifndef STACK_GROWS_DOWNWARD ++ sorry("-fstack-clash-protection is incompatible with upward growing stack"); ++#endif ++ size = copy_to_mode_reg (Pmode, convert_to_mode (Pmode, size, 1)); ++ loop_lab = gen_label_rtx (); ++ end_lab = gen_label_rtx (); ++ skip_lab = gen_label_rtx (); ++ /* We insert 'target = virtual_stack_dynamic_rtx' here, but target ++ is changed later, so that insn can be constructed only later. */ ++ before_skip = get_last_insn (); ++ emit_cmp_and_jump_insns (size, CONST0_RTX (Pmode), EQ, NULL_RTX, ++ Pmode, 1, skip_lab); ++ emit_label (loop_lab); ++ emit_cmp_and_jump_insns (size, GEN_INT (PROBE_INTERVAL), LTU, ++ NULL_RTX, Pmode, 1, end_lab); ++ last_size = expand_binop (Pmode, sub_optab, size, GEN_INT (PROBE_INTERVAL), size, ++ 1, OPTAB_WIDEN); ++ gcc_assert (last_size == size); ++ size = GEN_INT (PROBE_INTERVAL); ++ } ++ ++again: + /* Perform the required allocation from the stack. Some systems do + this differently than simply incrementing/decrementing from the + stack pointer, such as acquiring the space by calling malloc(). */ +@@ -1499,6 +1527,15 @@ allocate_dynamic_stack_space (rtx size, + if (STACK_GROWS_DOWNWARD) + emit_move_insn (target, virtual_stack_dynamic_rtx); + } ++ if (flag_stack_clash_protection && probe_pass == 0) ++ { ++ probe_pass = 1; ++ emit_stack_probe (target); ++ emit_jump (loop_lab); ++ emit_label (end_lab); ++ size = last_size; ++ goto again; ++ } + + suppress_reg_args_size = false; + +@@ -1510,6 +1547,17 @@ allocate_dynamic_stack_space (rtx size, + emit_label (final_label); + target = final_target; + } ++ if (flag_stack_clash_protection) ++ { ++ rtx seq; ++ emit_stack_probe (target); ++ emit_label (skip_lab); ++ start_sequence (); ++ emit_move_insn (target, virtual_stack_dynamic_rtx); ++ seq = get_insns (); ++ end_sequence (); ++ emit_insn_after (seq, before_skip); ++ } + + target = align_dynamic_address (target, required_align); + +@@ -1593,8 +1641,6 @@ emit_stack_probe (rtx address) + the current stack pointer. STACK_GROWS_DOWNWARD says whether to add + or subtract them from the stack pointer. */ + +-#define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP) +- + #if STACK_GROWS_DOWNWARD + #define STACK_GROW_OP MINUS + #define STACK_GROW_OPTAB sub_optab diff --git a/gcc7-testresults.spec b/gcc7-testresults.spec new file mode 100644 index 0000000..8f12bfa --- /dev/null +++ b/gcc7-testresults.spec @@ -0,0 +1,922 @@ +# +# spec file for package gcc7-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 gcc7 +# +# Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# 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 + +# 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 +%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 +%define tsan_arch x86_64 aarch64 ppc ppc64 ppc64le +%define asan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %sparc %arm aarch64 +%define itm_arch x86_64 %ix86 %arm aarch64 ppc ppc64 ppc64le 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 +%define ubsan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %arm aarch64 +%if 0%{?build_libvtv:1} +%define vtv_arch x86_64 %ix86 +%endif +%define cilkrts_arch x86_64 %ix86 +%if %{suse_version} >= 1310 +%define mpx_arch x86_64 %ix86 +%endif + +%define build_cp 1 +%define build_fortran 1 +%define build_objc 1 +%define build_objcp 1 +%ifarch riscv64 +%define build_go 0 +%else +%define build_go 1 +%endif + +%if %{build_objcp} +%define build_cp 1 +%define build_objc 1 +%endif + +# For optional compilers only build C, C++, Fortran, Ada and Go +%if 0%{?build_optional_compiler_languages:1} +%define build_objc 0 +%define build_objcp 0 +%endif + +%ifarch x86_64 +%define build_hsa 1 +%define build_nvptx 1 +%else +%define build_hsa 0 +%define build_nvptx 0 +%endif + +# Enable plugins just for Tumbleweed, not for SLES +%if 0%{!?sle_version:1} +%define enable_plugins 1 +%else +%define enable_plugins 0 +%endif + +# 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 4 +%define libquadmath_sover 0 +%define libasan_sover 4 +%define libtsan_sover 0 +%define libatomic_sover 1 +%define libitm_sover 1 +%define libubsan_sover 0 +%define liblsan_sover 0 +%define libvtv_sover 0 +%define libcilkrts_sover 5 +%define libgo_sover 11 +%define libmpx_sover 2 +%define libmpxwrappers_sover 2 + +# 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 itsme7 1 +%define plv_ %{!?product_libs_gcc_ver:7}%{?product_libs_gcc_ver} +%define plv() %{expand:%%{!?itsme%{expand:%%{!?product_libs_gcc_ver_%{1}%{2}:%%{plv_}}%%{?product_libs_gcc_ver_%{1}%{2}}}:-gcc7}} + +%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 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 libcilkrts_suffix %{plv libcilkrts %{libcilkrts_sover}} +%define libgo_suffix %{plv libgo %{libgo_sover}} +%define libmpx_suffix %{plv libmpx %{libmpx_sover}} +%define libmpxwrappers_suffix %{plv libmpxwrappers %{libmpx_sover}} + +# libFOO-devel package suffix +%define libdevel_suffix -gcc7 + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: gcc7-testresults +BuildRequires: xz +# With generated files in src we could drop the following +BuildRequires: bison +BuildRequires: flex +BuildRequires: gettext-devel +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +# until here, but at least renaming and patching info files breaks this +BuildRequires: gcc-c++ +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +BuildRequires: zlib-devel +%if %{suse_version} >= 1230 +BuildRequires: isl-devel +%endif +%if %{build_ada} +%if 0%{?gcc_version:%{gcc_version}} > 7 +%define hostsuffix %{binsuffix} +BuildRequires: gcc7-ada +BuildRequires: gcc7-c++ +%else +%if %{suse_version} < 1310 +%define hostsuffix -4.8 +BuildRequires: gcc48-ada +BuildRequires: gcc48-c++ +%else +%define hostsuffix %{nil} +BuildRequires: gcc-ada +%endif +%endif +%endif +%if 0%{?building_testsuite:1} +# For building the libstdc++ API reference +BuildRequires: doxygen +BuildRequires: graphviz +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{?run_tests:1} +BuildRequires: dejagnu +BuildRequires: expect +BuildRequires: gdb +%if %{build_nvptx} +BuildRequires: cross-nvptx-gcc7 +BuildRequires: cross-nvptx-newlib7-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 +%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 + +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 + +%if !0%{?building_testsuite:1} +Requires: binutils +Requires: cpp7 = %{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 %atomic_arch +Requires: libatomic%{libatomic_sover} >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover} >= %{version}-%{release} +%endif +%ifarch %cilkrts_arch +Requires: libcilkrts%{libcilkrts_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 +%ifarch %mpx_arch +Requires: libmpx%{libmpx_sover} >= %{version}-%{release} +Requires: libmpxwrappers%{libmpxwrappers_sover} >= %{version}-%{release} +%endif +Suggests: gcc7-info gcc7-locale +%endif + +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +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 + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +STAGE1_FLAGS="-g -O2" +%if 0%{?do_profiling} +%define profiledbootstraprule profiledbootstrap +%endif +# Only run profiled bootstrap on archs where it works and matters +%ifarch x86_64 %ix86 ppc64le s390x aarch64 +setarch `arch` -R make %{?profiledbootstraprule} STAGE1_CFLAGS="$STAGE1_FLAGS" BOOT_CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} +%else +make STAGE1_CFLAGS="$STAGE1_FLAGS" BOOT_CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} +%endif +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' ` ../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/gcc7-testsuite-fixes.patch b/gcc7-testsuite-fixes.patch new file mode 100644 index 0000000..ad075a6 --- /dev/null +++ b/gcc7-testsuite-fixes.patch @@ -0,0 +1,60 @@ +diff --git a/gcc/testsuite/gcc.dg/strncmp-2.c b/gcc/testsuite/gcc.dg/strncmp-2.c +index ed6c5fa0880..db46d0af4e0 100644 +--- a/gcc/testsuite/gcc.dg/strncmp-2.c ++++ b/gcc/testsuite/gcc.dg/strncmp-2.c +@@ -40,6 +40,7 @@ static void test_driver_strncmp (void (test_strncmp)(const char *, const char *, + e = lib_memcmp(buf1,p2,sz); + (*test_memcmp)(buf1,p2,e); + } ++ mprotect (buf2+pgsz,pgsz,PROT_READ|PROT_WRITE); + free(buf2); + } + +diff --git a/libstdc++-v3/testsuite/ext/stdio_filebuf/char/79820.cc b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/79820.cc +index ba566f869c6..ca51d6d1a78 100644 +--- a/libstdc++-v3/testsuite/ext/stdio_filebuf/char/79820.cc ++++ b/libstdc++-v3/testsuite/ext/stdio_filebuf/char/79820.cc +@@ -26,10 +26,12 @@ void + test01() + { + FILE* f = std::fopen("79820.txt", "w"); ++ { ++ errno = 127; ++ __gnu_cxx::stdio_filebuf b(f, std::ios::out, BUFSIZ); ++ VERIFY(errno == 127); // PR libstdc++/79820 ++ } + std::fclose(f); +- errno = 127; +- __gnu_cxx::stdio_filebuf b(f, std::ios::out, BUFSIZ); +- VERIFY(errno == 127); // PR libstdc++/79820 + } + + int +diff --git a/gcc/testsuite/gcc.target/i386/xop-hsubX.c b/gcc/testsuite/gcc.target/i386/xop-hsubX.c +index f0fa9b312f2..dc7944d8bb7 100644 +--- a/gcc/testsuite/gcc.target/i386/xop-hsubX.c ++++ b/gcc/testsuite/gcc.target/i386/xop-hsubX.c +@@ -58,6 +58,7 @@ check_sbyte2word () + check_fails++; + } + } ++ return check_fails; + } + + static int +@@ -75,6 +76,7 @@ check_sword2dword () + check_fails++; + } + } ++ return check_fails; + } + + static int +@@ -92,6 +94,7 @@ check_dword2qword () + check_fails++; + } + } ++ return check_fails; + } + + static void diff --git a/gcc7.changes b/gcc7.changes new file mode 100644 index 0000000..5b69b9e --- /dev/null +++ b/gcc7.changes @@ -0,0 +1,809 @@ +------------------------------------------------------------------- +Tue Oct 22 08:04:13 UTC 2024 - Richard Biener + +- Remove epiphany build, newlib no longer builds for it. + +------------------------------------------------------------------- +Thu Feb 22 14:19:43 UTC 2024 - Richard Biener + +- Use %patch -P N instead of %patchN. + +------------------------------------------------------------------- +Tue Feb 6 08:04:04 UTC 2024 - Richard Biener + +- Add gcc7-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 18 09:58:44 UTC 2024 - Richard Biener + +- Add gcc7-pr87723.patch to avoid ICE when hitting a broken pattern + in the s390 backend. + +------------------------------------------------------------------- +Mon Oct 30 12:59:18 UTC 2023 - Richard Biener + +- Add gcc7-bsc1216488.patch to avoid creating recursive DIE references + through DW_AT_abstract_origin when using LTO. [bsc#1216488] + +------------------------------------------------------------------- +Thu Aug 17 06:37:28 UTC 2023 - Richard Biener + +- Add gcc7-aarch64-bsc1214052.patch to fix -fstack-protector issues + with variable length stack allocations on aarch64. + Fixes CVE-2023-4039. [bsc#1214052] +- Add gcc7-aarch64-untyped_call.patch to fix issue with __builtin_apply +- Add gcc7-lra-elim.patch to fix internal compiler error when forming + paired loads and stores on aarch64. + +------------------------------------------------------------------- +Tue May 23 13:29:37 UTC 2023 - Andreas Schwab + +- Disable multilib and go on riscv64 +- libgcc-riscv-div.patch: Backport of r12-5799-g45116f342057b7 to fix + build with current binutils + +------------------------------------------------------------------- +Tue May 9 13:12:55 UTC 2023 - Richard Biener + +- Backport _multibuild auto-generation. Remove redundant + .changes files. + +------------------------------------------------------------------- +Fri May 5 15:02:29 UTC 2023 - Dominique Leuenberger + +- Add _multibuild to define 2nd spec file as additional flavor. + Eliminates the need for source package links in OBS. + +------------------------------------------------------------------- +Tue Nov 8 09:09:26 UTC 2022 - Richard Biener + +- Add gcc7-pr89124.patch to fix KASAN kernel compile. [bsc#1205145] + +------------------------------------------------------------------- +Thu Oct 20 09:38:24 UTC 2022 - Richard Biener + +- Add gcc7-pr72764.patch to fix ICE with C++17 code as reported + in [bsc#1204505] + +------------------------------------------------------------------- +Thu Sep 1 10:15:12 UTC 2022 - Martin Liška + +- Add gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch + and gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch + in order to support glibc 2.36. +- Enable format_spec_file otherwise one gets huge diff after + running change_spec. +- Remove fixed sys/mount.h. + +------------------------------------------------------------------- +Fri Apr 29 04:47:58 UTC 2022 - Antonio Larrosa + +- Add patch from upstream to fix altivec.h redefining bool in C++ + which makes bool unusable (boo#1195517): + * gcc7-pr78263.patch + +------------------------------------------------------------------- +Fri Mar 11 07:10:31 UTC 2022 - Richard Biener + +- Add gcc7-ada-Target_Name.patch to adjust gnats idea of the + target, fixing the build of gprbuild. [bsc#1196861] + +------------------------------------------------------------------- +Mon Feb 28 07:21:45 UTC 2022 - Richard Biener + +- Remove include-fixed/sys/rseq.h to fix build on openSUSE:Factory. +- Avoid duplicate license in cross packages. + +------------------------------------------------------------------- +Tue Oct 26 06:20:55 UTC 2021 - Richard Biener + +- Adjust some ambiguous SPDX license specifications to prevent + spec-cleaner from messing up. + +------------------------------------------------------------------- +Mon Oct 25 11:40:00 UTC 2021 - Lukas Lansky + +- Add gcc7-pr55917.patch to do not handle exceptions in std::thread + (jsc#CAR-1182) + +------------------------------------------------------------------- +Wed Oct 20 16:52:20 UTC 2021 - Giuliano Belinassi + +- Add gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch, + gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch, + gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch, + gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch, + gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch, + gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch, + gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch, + gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch, + gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch, + gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch, + gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch, + gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch, + gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch, + gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch, + gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch, + gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch, + gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch, + gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch, + gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch, + gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch, + gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch, + and gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch + to add -fpatchable-function-entry feature to gcc-7. + +------------------------------------------------------------------- +Mon Sep 27 07:35:46 UTC 2021 - Richard Biener + +- Add gcc7-ada-MINSTKSZ.patch to fix build with glibc 2.34. +- Add bits/unistd_ext.h to the list of removed fixed includes. + +------------------------------------------------------------------- +Wed Jul 21 06:27:06 UTC 2021 - Richard Biener + +- Add gcc7-sanitizer-cyclades.patch to remove cyclades.h use from + libsanitizer fixing builds with recent kernels. + +------------------------------------------------------------------- +Wed Feb 3 09:31:02 UTC 2021 - Richard Biener + +- Remove include-fixed/pthread.h +- Change GCC exception licenses to SPDX format + +------------------------------------------------------------------- +Sun Jan 31 16:41:10 UTC 2021 - Dirk Müller + +- add gcc7-pr81942.patch [bsc#1181618] + +------------------------------------------------------------------- +Mon Jan 4 09:29:07 UTC 2021 - Richard Biener + +- Amend gcc7-aarch64-moutline-atomics.patch for glibc namespace + violation with getauxval. [bsc#1167939] + +------------------------------------------------------------------- +Thu Nov 26 17:17:44 UTC 2020 - Michael Matz + +- Add gcc7-aarch64-sls-miti-1.patch, gcc7-aarch64-sls-miti-2.patch, + gcc7-aarch64-sls-miti-3.patch to backport aarch64 Straight Line + Speculation mitigation [bsc#1172798, CVE-2020-13844] +- Add gcc7-fix-retrieval-of-testnames.patch to support usage in + testcases added by the above. + +------------------------------------------------------------------- +Thu Nov 26 15:06:50 UTC 2020 - Richard Biener + +- Enable fortran for the nvptx offload compiler. +- Do not specify alternate offload compiler location at + configure time. +- Update README.First-for.SuSE.packagers + +------------------------------------------------------------------- +Thu Nov 26 07:58:17 UTC 2020 - Richard Biener + +- Add gcc7-pr88522.patch to avoid assembler errors with AVX512 + gather and scatter instructions when using -masm=intel. +- Amend gcc7-remove-Wexpansion-to-defined-from-Wextra.patch to + reflect changes in option handling in the testsuite. +- Add gcc7-testsuite-fixes.patch to fix PR98001 and PR98002 which + are broken testcases showing with malloc debugging enabled. + +------------------------------------------------------------------- +Thu Nov 19 08:22:09 UTC 2020 - Richard Biener + +- Add gcc7-aarch64-moutline-atomics.patch to backport the aarch64 + -moutline-atomics feature and accumulated fixes but not its + default enabling. [jsc#SLE-12209, bsc#1167939] +- Order gcc7-pr92692.patch after gcc7-aarch64-moutline-atomics.patch + and refresh. + +------------------------------------------------------------------- +Mon Nov 16 07:45:55 UTC 2020 - Richard Biener + +- Revert gcc7-pr97774.patch as it causes gdb to crash. + +------------------------------------------------------------------- +Thu Nov 12 13:51:26 UTC 2020 - Richard Biener + +- Fix 32bit libgnat.so link. [bsc#1178675] +- Quote %{cross_arch} consistently when comparing expansion + against string in RPM %if condition. + +------------------------------------------------------------------- +Tue Nov 10 15:24:57 UTC 2020 - Richard Biener + +- Add gcc7-pr97535.patch to fix memcpy miscompilation on aarch64. + [bsc#1178624, bsc#1178577] + +------------------------------------------------------------------- +Tue Nov 10 10:11:33 UTC 2020 - Richard Biener + +- Add gcc7-pr97774.patch to fix debug line info for try/catch. + [bsc#1178614] + +------------------------------------------------------------------- +Fri Sep 18 07:25:53 UTC 2020 - Guillaume GARDET + +- Remove -mbranch-protection=standard (aarch64 flag) when gcc7 is + used to build gcc7 (ie when ada is enabled) + +------------------------------------------------------------------- +Mon Mar 16 07:20:32 UTC 2020 - Richard Biener + +- Add gcc7-pr94148.patch to fix corruption of pass private ->aux + via DF. [gcc#94148] + +------------------------------------------------------------------- +Wed Mar 4 12:58:17 UTC 2020 - Richard Biener + +- Add gcc7-pr93888.patch to fix debug information issue with + inlined functions and passed by reference arguments. [gcc#93888] + +------------------------------------------------------------------- +Fri Feb 28 16:59:30 UTC 2020 - Martin Liška + +- Add gcc7-pr93965.patch in order to fix binutils release + date detection issue. + +------------------------------------------------------------------- +Wed Jan 29 09:56:19 UTC 2020 - Richard Biener + +- Add gcc48-bsc1161913.patch to fix register allocation issue with + exception handling code on s390x. [bsc#1161913] + +------------------------------------------------------------------- +Wed Jan 22 17:25:50 UTC 2020 - matz@suse.com + +- Add gcc7-pr92692.patch: Backport PR target/92692 to fix + miscompilation of some atomic code on aarch64. [bsc#1150164] + +------------------------------------------------------------------- +Mon Jan 20 12:04:04 UTC 2020 - Richard Biener + +- Add gcc7-pr93246.patch: Backport PR middle-end/93246 + +------------------------------------------------------------------- +Thu Jan 9 14:26:17 UTC 2020 - Andreas Schwab + +- gcc7-pr92154.patch: Backport PR sanitizer/92154 + +------------------------------------------------------------------- +Tue Jan 7 08:38:25 UTC 2020 - Richard Biener + +- Add gcc7-bsc1160086.patch to fix miscompilation in vectorized code + for s390x. [bsc#1160086] [gcc#92950] + +------------------------------------------------------------------- +Thu Nov 14 09:29:39 UTC 2019 - Richard Biener + +- Update to GCC 7.5.0 release. +- Add gcc7-pr85887.patch to fix miscompilation with thread-safe local + static initialization. [gcc#85887] + +------------------------------------------------------------------- +Wed Oct 2 07:46:40 UTC 2019 - Richard Biener + +- Add gcc7-bsc1146475.patch to fix debug info created for array + definitions that complete an earlier declaration. [bsc#1146475] + +------------------------------------------------------------------- +Mon Sep 9 07:33:54 UTC 2019 - Richard Biener + +- Rework shared spec file parts to allow custom Summary and + Description for cross compilers. Clarify their Summary + and Description. [bsc#1148517] +- Reorder things in cross.spec.in so the Version define comes before + the first use of %version. + +------------------------------------------------------------------- +Thu Sep 5 13:29:56 UTC 2019 - Richard Biener + +- Update to gcc-7-branch head (r275405). + * Pulls fix for POWER9 DARN miscompilation. + (bsc#1149145, CVE-2019-15847) + * Includes gcc8-pr89752.patch + +------------------------------------------------------------------- +Fri Aug 16 09:51:33 UTC 2019 - Richard Biener + +- Remove bogus fixed include bits/statx.h from glibc 2.30. [gcc#91085] + +------------------------------------------------------------------- +Thu Jul 25 10:51:53 UTC 2019 - rguenther@suse.com + +- Update to gcc-7-branch head (r273795). + * Includes fix for LTO linker plugin heap overflow. + (bsc#1142649, CVE-2019-14250) + +------------------------------------------------------------------- +Mon Jul 22 09:47:10 UTC 2019 - rguenther@suse.com + +- Update to gcc-7-branch head (r273666). + * Fixes build with -Werror=return-type. + +------------------------------------------------------------------- +Thu Jul 18 07:10:26 UTC 2019 - rguenther@suse.com + +- Update to gcc-7-branch head (r273559). + * Includes fix for vector shift miscompilation on s390. [bsc#1141897] + +------------------------------------------------------------------- +Wed Jun 12 10:37:51 UTC 2019 - Martin Liška + +- Add gcc7-flive-patching.patch patch. [bsc#1071995, fate#323487] + +------------------------------------------------------------------- +Wed May 22 12:56:05 UTC 2019 - Martin Liška + +- Strip -flto from $optflags. + +------------------------------------------------------------------- +Wed Apr 24 09:52:10 UTC 2019 - rguenther@suse.com + +- Update to gcc-7-branch head (r270528). + * Disables switch jump-tables when retpolines are used. + [bsc#1131264, jsc#SLE-6738] + +------------------------------------------------------------------- +Thu Mar 28 08:21:08 UTC 2019 - rguenther@suse.com + +- Add gcc8-pr89752.patch to fix ICE compiling tensorflow on aarch64. + [bsc#1129389] + +------------------------------------------------------------------- +Thu Mar 14 09:19:08 UTC 2019 - rguenther@suse.com + +- Update to gcc-7-branch head (r269676). + * Pulls fix for aarch64 FMA steering pass use-after-free. [bsc#1128794] + * Fixes ICE compiling tensorflow. [bsc#1129389] +- Change URLs to use https. + +------------------------------------------------------------------- +Fri Feb 8 07:50:27 UTC 2019 - rguenther@suse.com + +- Update to gcc-7-branch head (r268660). + * Pulls fix for s390x FP load-and-test issue. [bnc#1124644] +- Improve build reproducability by disabling address-space randomization + during build. + +------------------------------------------------------------------- +Mon Jan 7 08:35:49 UTC 2019 - rguenther@suse.com + +- Update gcc44-rename-info-files.patch to adjust gnat manual + entries in the info directory. [bnc#1114592] + +------------------------------------------------------------------- +Thu Dec 6 12:07:47 UTC 2018 - rguenther@suse.com + +- Update to GCC 7.4 release. +- Fix AVR configuration to not use __cxa_atexit or libstdc++ headers. + Point to /usr/avr/sys-root/include as system header include directory. + +------------------------------------------------------------------- +Fri Aug 17 08:36:04 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r263609). + * Includes fix for build with ISL 0.20. + * Includes fix to no longer try linking -lieee with -mieee-fp. + [bnc#1084842] + +------------------------------------------------------------------- +Fri Jun 29 10:25:01 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r262243). + * Pulls fix for libcpp lexing bug on ppc64le manifesting during + build with gcc8. [bnc#1099119] + * Pulls fix for forcing compile-time tuning even when building + with -march=z13 on s390x. [bnc#1099192] + +------------------------------------------------------------------- +Thu Jun 7 10:20:14 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r261272). + * Fixes support for 32bit ASAN with glibc 2.27+ + * Includes gcc7-bnc1087550.diff + +------------------------------------------------------------------- +Wed Apr 18 14:02:32 UTC 2018 - rguenther@suse.com + +- Update gcc7-bnc1087550.diff with latest changes. [bnc#1087550] + +------------------------------------------------------------------- +Wed Apr 11 07:35:40 UTC 2018 - rguenther@suse.com + +- Update gcc7-bnc1087550.diff with fix from upstream that supports + both ABIs for ios_base::failure. [bnc#1087550] + +------------------------------------------------------------------- +Mon Apr 9 13:51:55 UTC 2018 - rguenther@suse.com + +- Set SUSE_ASNEEDED to zero during %install so libasan keeps its + NEEDED entry for libstdc++.so. [GCC#84428] + +------------------------------------------------------------------- +Fri Apr 6 09:05:43 UTC 2018 - rguenther@suse.com + +- Enable --enable-fix-cortex-a53-835769 for aarch64. +- Add gcc7-bnc1087550.diff to revert the ios_base::failure ABI + back to compatible behavior with the default ABI. [bnc#1087550] + +------------------------------------------------------------------- +Tue Apr 3 12:54:54 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r258812). + * Picks fix to no longer enable -mpc-relative-literal-loads by default + with --enable-fix-cortex-a53-843419. +- Enable --enable-fix-cortex-a53-843419 on aarch64. [bnc#1084812] + [bnc#1087930] + +------------------------------------------------------------------- +Wed Mar 7 08:59:22 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r258313). + * includes spectre V2 mitigation patch for s390x. [bnc#1083946] + +------------------------------------------------------------------- +Thu Mar 1 13:03:25 UTC 2018 - rguenther@suse.com + +- Fix nvptx offload target compiler install so GCC can pick up + required files. Split out the newlib part into cross-nvptx-newlib7-devel + and avoid conflicts with GCC 8 variant via Provides/Conflicts + of cross-nvptx-newlib-devel. + +------------------------------------------------------------------- +Tue Feb 27 08:37:14 UTC 2018 - mliska@suse.cz + +- Update to gcc-7-branch head (r258025). + * includes fix for chromium build failure. [bnc#1083290] + +------------------------------------------------------------------- +Mon Feb 26 09:02:16 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r257981). +- Add conflicts to non-bootstrap variant for cross packages to silence + repo-checker. +- Amend gcc48-remove-mpfr-2.4.0-requirement.patch to fix build on SLE11. + +------------------------------------------------------------------- +Thu Feb 1 09:26:51 UTC 2018 - rguenther@suse.com + +- Use %{?_smp_mflags} everywhere. +- Update _constraints to bump physicalmemory and general simplification. + +------------------------------------------------------------------- +Thu Jan 25 09:46:10 UTC 2018 - rguenther@suse.com + +- Update to GCC 7.3 release. + +------------------------------------------------------------------- +Mon Jan 22 11:29:58 UTC 2018 - schwab@suse.de + +- Move misplaced %endif + +------------------------------------------------------------------- +Wed Jan 17 13:13:12 UTC 2018 - rguenther@suse.com + +- Update to GCC 7.3.0 RC1 (r256792). + +------------------------------------------------------------------- +Tue Jan 16 11:29:06 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r256737) + * Includes gcc7-pr81481.diff + * Adds backport of retpoline support via -mindirect-branch=, + -mfunction-return= and friends. [bnc#1074621] + +------------------------------------------------------------------- +Mon Jan 15 12:24:39 UTC 2018 - rguenther@suse.com + +- Handle new debug sources filelist variant debugsourcefiles.list. +- Prune libstdc++ includes for crosses. + +------------------------------------------------------------------- +Wed Jan 10 08:01:42 UTC 2018 - rguenther@suse.com + +- Do not install target parts of cross compilers into the sysroot + but instead fixup manually (once required). + +------------------------------------------------------------------- +Tue Jan 2 13:29:18 UTC 2018 - rguenther@suse.com + +- Update to gcc-7-branch head (r256067). +- Deal with C++ being disabled for crosses. +- For crosses that have a target triplet not matching that of binutils + create symlinks to as and ld in the GCC private directory. + +------------------------------------------------------------------- +Tue Dec 12 12:41:34 UTC 2017 - rguenther@suse.com + +- Split cross-avr into -bootstrap and non-bootstrap variant for avr-libc + integration. + +------------------------------------------------------------------- +Fri Dec 8 10:32:47 UTC 2017 - rguenther@suse.com + +- Add gcc7-avoid-fixinc-error.diff to avoid install-host aborting + on non-existing target include directory. Remove --with-build-sysroot=/ + hack from icecream cross configs, no longer prune include-fixed for + them to retain a GCC provided limits.h. Remove installed install-tools. + +------------------------------------------------------------------- +Thu Nov 23 09:30:47 UTC 2017 - rguenther@suse.com + +- Add gcc7-pr82248.diff to fix bogus stack probe instruction on ARM. + [bnc#1068967] + +------------------------------------------------------------------- +Fri Oct 20 11:12:53 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r253932). + * contains fix for PR82445 which is about a RPI1 bootloader + miscompile. [bnc#1061667] + +------------------------------------------------------------------- +Thu Oct 5 09:00:25 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r253435). [fate#321452, fate#321496] + [fate#323972] + * contains fix for PR82406 which blocks chromium build. +- Add gcc7-pr81481.diff to fix a register allocation issue. + [bnc#1048861] + +------------------------------------------------------------------- +Wed Sep 27 12:24:55 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r253221). + * Includes similar fix to gcc41-ppc32-retaddr.patch, disable the + patch but keep the testcase. + +------------------------------------------------------------------- +Mon Sep 25 20:22:09 UTC 2017 - matz@suse.de + +- Add support for zero-sized VLAs and allocas with + -fstack-clash-protection. [bnc #1059075] + Changes gcc7-stack-probe.diff. + +------------------------------------------------------------------- +Tue Aug 29 07:17:15 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r251579). + * Includes GCC 7.2 release. + * Includes gcc7-pr81766.diff and gcc7-go-sigrtmax.patch. + +------------------------------------------------------------------- +Fri Aug 25 04:40:35 UTC 2017 - bwiedemann@suse.com + +- Sort tar file list to make cross-* packages build reproducibly + (boo#1041090) + +------------------------------------------------------------------- +Tue Aug 8 12:38:37 UTC 2017 - rguenther@suse.com + +- Add gcc7-pr81766.diff to fix grub2 build. + +------------------------------------------------------------------- +Fri Aug 4 11:41:36 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r250819). + * Includes GCC 7.2 RC1. + * Includes fix for gcov crash. [bnc#1050487] +- Add gcc7-stack-probe.diff for support of -fstack-clash-protection + [bnc#1039513]. +- Add gcc7-go-sigrtmax.patch to fix Go build with glibc 2.26. + +------------------------------------------------------------------- +Thu Jun 29 08:54:57 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r249772). + * Includes patch for PR81080. [bnc#1044016] + * Includes patch for PR81204. [bnc#1045732] + * Includes patch for PR81112. [bnc#1043966] + +------------------------------------------------------------------- +Tue Jun 13 08:42:45 UTC 2017 - rguenther@suse.com + +- Fix cross compiler update-alternatives machinery to make rpmlint + happy. + +------------------------------------------------------------------- +Fri Jun 9 11:20:46 UTC 2017 - rguenther@suse.com + +- Update plugin enablement guard to use %sle_version. [bnc#1043590] + +------------------------------------------------------------------- +Wed Jun 7 13:18:16 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r248970). + * Includes gcc7-pr80593.patch. + +------------------------------------------------------------------- +Tue May 30 07:39:56 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r248590). +- Add #!BuildIgnore: gcc-PIE also to cross compiler builds. + +------------------------------------------------------------------- +Wed May 17 12:09:04 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r248152) +- Drop not working SLE-10 build support. +- For SLE-15 make the i586 compiler generate code for architecture + level of x86_64. +- Add gcc7-pr80593.patch to fix ceph build. [bnc#1025891] + +------------------------------------------------------------------- +Thu May 4 10:12:09 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r247545) + * Includes GCC 7.1 release +- For SLE15 change ppc64le tuning to power9. [fate#322728] +- Change tarball compression to xz, BuildRequire xz. + +------------------------------------------------------------------- +Fri Apr 28 12:26:08 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r247368) + * Includes GCC 7.1 RC2 + * Includes ARM ABI fix for PR77728, fixing ABI incompatibility + with GCC 4.8. + +------------------------------------------------------------------- +Thu Apr 20 11:17:21 UTC 2017 - rguenther@suse.com + +- Update to gcc-7-branch head (r247019). +- Always create nvptx offloading cross spec file. +- Fix libada provides/conflicts. +- Package gcov.h. +- Add #!BuildIgnore: gcc-PIE. +- Fix update-alternatives. + +------------------------------------------------------------------- +Tue Apr 4 14:44:52 UTC 2017 - mliska@suse.cz + +- Add update-alternatives for binaries produces by cross compilers. +- Add nospeccleaner comment, remove legacy norootforbuild and + icecream. + +------------------------------------------------------------------- +Fri Mar 31 08:51:09 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r246609). +- Add cross-binutils Requires to cross-gcc packages. + +------------------------------------------------------------------- +Mon Mar 27 14:06:43 UTC 2017 - rguenther@suse.com + +- Really fix libtsan requirement on ppc. [boo#1030623] +- Also fix liblsan requirement on pcc. + +------------------------------------------------------------------- +Thu Mar 23 09:59:21 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r246414). +- Package gcov-dump. +- Remove gcc7-debug-dwarf2out-ice.patch. +- Add gcc7-remove-Wexpansion-to-defined-from-Wextra.patch to remove + useless warning from Wextra that causes build fails due to excessive + log file size. +- Remove libtsan Requires from the gcc7-32bit package, tsan doesn't have + a 32bit multilib on any arch. [boo#1030623] + +------------------------------------------------------------------- +Mon Mar 13 10:56:29 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r246083). + +------------------------------------------------------------------- +Wed Mar 8 14:10:58 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r245976). +- BuildRequire at least gcc-4.8 Ada. +- Enable asan and ubsan for s390. +- Also require gcc-c++ of the host compiler version used when that + is changed due to Ada requirements. + +------------------------------------------------------------------- +Tue Feb 14 08:00:25 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r245417). +- Enable profiledbootstrap for %ix86, build with release checking. +- Build stage1 with -O2 -g. +- Enable Ada for s390x. +- Enable asan and ubsan for s390x. +- Refresh gcc44-rename-info-files.patch. + +------------------------------------------------------------------- +Thu Feb 2 13:44:56 UTC 2017 - rguenther@suse.com + +- Fix up nvptx offloading so that it actually works. + +------------------------------------------------------------------- +Tue Jan 31 12:25:34 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r245052). +- Use plain avr as gcc target for AVR to match what binutils does. + [bnc#1022404] +- Cleanup spec file and gcc7-rpmlintrc a bit. + +------------------------------------------------------------------- +Thu Jan 26 15:10:21 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r244934). +- Add accelerator offloading cross to nvptx-none, for this also + add nvptx-newlib.tar.bz2. + +------------------------------------------------------------------- +Tue Jan 24 12:56:39 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r244867). +- Bump libgo SO version to 11. +- PowerPC now supports lsan and tsan. +- Correct lsan/tsan packaging who are 64bits only. + +------------------------------------------------------------------- +Fri Jan 20 08:36:18 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r244684). +- Use --with-gcc-major-version-only and drop gcc-dir-version.patch. +- Enable offloading for nvptx-none on the host (offload compiler still + missing). Re-enable HSA offloading. +- Re-add missing cross.spec.in and enable crosses. + +------------------------------------------------------------------- +Thu Jan 12 12:01:01 UTC 2017 - rguenther@suse.com + +- Update to gcc trunk head (r244350). +- Package avx512vpopcntdqintrin.h and sgxintrin.h on x86_64/i?86. + +------------------------------------------------------------------- +Wed Dec 14 14:34:22 UTC 2016 - rguenther@suse.com + +- Update to gcc trunk head (r243648). +- Package {arm,aarch64}/arm_fp16.h and arm/arm_cmse.h. + +------------------------------------------------------------------- +Mon Nov 28 10:43:45 UTC 2016 - rguenther@suse.com + +- Remove broken libffi build support. +- Remove more Java remanents. + +------------------------------------------------------------------- +Fri Nov 25 08:30:28 UTC 2016 - mliska@suse.cz + +- Update to gcc trunk (r242874). +- Add avx5124fmapsintrin.h and avx5124vnniwintrin.h header files. + +------------------------------------------------------------------- +Wed Nov 23 15:36:06 UTC 2016 - mliska@suse.cz + +- New package, inherits from gcc6 + * gcc-dir-version.patch, drop patchlevel from install directory names + * 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 + * 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 +- Drops + * libjava-no-multilib.diff, gcc41-java-slow_pthread_self.patch + and all Java related hunks in included patches + because Java is no longer included in GCC 7. + * gcc6-hsa-enablement.patch as it's part of trunk + * gcc6-libsanitizer-aarch64-vma48.patch as it's part of trunk + * gcc6-SOURCE_DATE_EPOCH.patch as it's part of trunk diff --git a/gcc7.spec b/gcc7.spec new file mode 100644 index 0000000..a8a04d1 --- /dev/null +++ b/gcc7.spec @@ -0,0 +1,3322 @@ +# +# spec file for package gcc7 +# +# 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/ +# + + +# 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 +%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 +%define tsan_arch x86_64 aarch64 ppc ppc64 ppc64le +%define asan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %sparc %arm aarch64 +%define itm_arch x86_64 %ix86 %arm aarch64 ppc ppc64 ppc64le 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 +%define ubsan_arch x86_64 %ix86 ppc ppc64 ppc64le s390 s390x %arm aarch64 +%if 0%{?build_libvtv:1} +%define vtv_arch x86_64 %ix86 +%endif +%define cilkrts_arch x86_64 %ix86 +%if %{suse_version} >= 1310 +%define mpx_arch x86_64 %ix86 +%endif + +%define build_cp 1 +%define build_fortran 1 +%define build_objc 1 +%define build_objcp 1 +%ifarch riscv64 +%define build_go 0 +%else +%define build_go 1 +%endif + +%if %{build_objcp} +%define build_cp 1 +%define build_objc 1 +%endif + +# For optional compilers only build C, C++, Fortran, Ada and Go +%if 0%{?build_optional_compiler_languages:1} +%define build_objc 0 +%define build_objcp 0 +%endif + +%ifarch x86_64 +%define build_hsa 1 +%define build_nvptx 1 +%else +%define build_hsa 0 +%define build_nvptx 0 +%endif + +# Enable plugins just for Tumbleweed, not for SLES +%if 0%{!?sle_version:1} +%define enable_plugins 1 +%else +%define enable_plugins 0 +%endif + +# 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 4 +%define libquadmath_sover 0 +%define libasan_sover 4 +%define libtsan_sover 0 +%define libatomic_sover 1 +%define libitm_sover 1 +%define libubsan_sover 0 +%define liblsan_sover 0 +%define libvtv_sover 0 +%define libcilkrts_sover 5 +%define libgo_sover 11 +%define libmpx_sover 2 +%define libmpxwrappers_sover 2 + +# 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 itsme7 1 +%define plv_ %{!?product_libs_gcc_ver:7}%{?product_libs_gcc_ver} +%define plv() %{expand:%%{!?itsme%{expand:%%{!?product_libs_gcc_ver_%{1}%{2}:%%{plv_}}%%{?product_libs_gcc_ver_%{1}%{2}}}:-gcc7}} + +%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 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 libcilkrts_suffix %{plv libcilkrts %{libcilkrts_sover}} +%define libgo_suffix %{plv libgo %{libgo_sover}} +%define libmpx_suffix %{plv libmpx %{libmpx_sover}} +%define libmpxwrappers_suffix %{plv libmpxwrappers %{libmpx_sover}} + +# libFOO-devel package suffix +%define libdevel_suffix -gcc7 + +%if %{suse_version} >= 1220 +%define selfconflict() %1 +%else +%define selfconflict() otherproviders(%1) +%endif + +Name: gcc7 +BuildRequires: xz +# With generated files in src we could drop the following +BuildRequires: bison +BuildRequires: flex +BuildRequires: gettext-devel +%if %{suse_version} > 1220 +BuildRequires: makeinfo +%else +BuildRequires: texinfo +%endif +# until here, but at least renaming and patching info files breaks this +BuildRequires: gcc-c++ +BuildRequires: glibc-devel-32bit +BuildRequires: mpc-devel +BuildRequires: mpfr-devel +BuildRequires: perl +BuildRequires: zlib-devel +%if %{suse_version} >= 1230 +BuildRequires: isl-devel +%endif +%if %{build_ada} +%if 0%{?gcc_version:%{gcc_version}} > 7 +%define hostsuffix %{binsuffix} +BuildRequires: gcc7-ada +BuildRequires: gcc7-c++ +%else +%if %{suse_version} < 1310 +%define hostsuffix -4.8 +BuildRequires: gcc48-ada +BuildRequires: gcc48-c++ +%else +%define hostsuffix %{nil} +BuildRequires: gcc-ada +%endif +%endif +%endif +%if 0%{?building_testsuite:1} +# For building the libstdc++ API reference +BuildRequires: doxygen +BuildRequires: graphviz +%endif +%ifarch ia64 +BuildRequires: libunwind-devel +%endif +%if 0%{?run_tests:1} +BuildRequires: dejagnu +BuildRequires: expect +BuildRequires: gdb +%if %{build_nvptx} +BuildRequires: cross-nvptx-gcc7 +BuildRequires: cross-nvptx-newlib7-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 +%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 + +%define biarch_targets x86_64 s390x powerpc64 powerpc sparc sparc64 + +URL: https://gcc.gnu.org/ +Version: 7.5.0+r278197 +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 -7 + +%if !0%{?building_testsuite:1} +Requires: binutils +Requires: cpp7 = %{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 %atomic_arch +Requires: libatomic%{libatomic_sover} >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover} >= %{version}-%{release} +%endif +%ifarch %cilkrts_arch +Requires: libcilkrts%{libcilkrts_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 +%ifarch %mpx_arch +Requires: libmpx%{libmpx_sover} >= %{version}-%{release} +Requires: libmpxwrappers%{libmpxwrappers_sover} >= %{version}-%{release} +%endif +Suggests: gcc7-info gcc7-locale +%endif + +Group: Development/Languages/C and C++ +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Source: gcc-%{version}.tar.xz +Source1: change_spec +Source3: gcc7-rpmlintrc +Source4: README.First-for.SuSE.packagers +Source5: nvptx-newlib.tar.xz +Patch2: gcc-add-defaultsspec.diff +Patch5: tls-no-direct.diff +Patch6: gcc43-no-unwind-tables.diff +Patch7: gcc48-libstdc++-api-reference.patch +Patch9: gcc48-remove-mpfr-2.4.0-requirement.patch +Patch10: gcc5-no-return-gcc43-workaround.patch +Patch11: gcc7-remove-Wexpansion-to-defined-from-Wextra.patch +Patch12: gcc7-stack-probe.diff +Patch14: gcc7-pr82248.diff +Patch15: gcc7-avoid-fixinc-error.diff +Patch17: gcc7-flive-patching.patch +Patch18: gcc7-bsc1146475.patch +Patch19: gcc7-pr85887.patch +Patch20: gcc7-bsc1160086.patch +Patch21: gcc7-pr92154.patch +Patch22: gcc7-pr93246.patch +Patch23: gcc7-pr92692.patch +Patch24: gcc48-bsc1161913.patch +Patch25: gcc7-pr93965.patch +Patch26: gcc7-pr93888.patch +Patch27: gcc7-pr94148.patch +Patch29: gcc7-pr97535.patch +Patch30: gcc7-pr88522.patch +Patch31: gcc7-testsuite-fixes.patch +Patch32: gcc7-pr81942.patch +Patch33: gcc7-sanitizer-cyclades.patch +Patch34: gcc7-ada-MINSTKSZ.patch +Patch35: gcc7-pr55917.patch +Patch36: gcc7-ada-Target_Name.patch +Patch37: gcc7-pr78263.patch +Patch38: gcc7-libsanitizer-cherry-pick-9cf13067cb5088626ba7-from-u.patch +Patch39: gcc7-libgo-don-t-include-linux-fs.h-when-building-gen-sys.patch +Patch40: gcc7-pr72764.patch +Patch41: gcc7-pr89124.patch +Patch42: libgcc-riscv-div.patch +Patch43: gcc7-aarch64-bsc1214052.patch +Patch44: gcc7-aarch64-untyped_call.patch +Patch45: gcc7-lra-elim.patch +Patch46: gcc7-bsc1216488.patch +Patch47: gcc7-pr87723.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: gcc7-aarch64-moutline-atomics.patch +Patch101: gcc7-fix-retrieval-of-testnames.patch +Patch102: gcc7-aarch64-sls-miti-1.patch +Patch103: gcc7-aarch64-sls-miti-2.patch +Patch104: gcc7-aarch64-sls-miti-3.patch +Patch105: gcc7-pfe-0001-Backport-Add-entry-for-patchable_function_entry.patch +Patch106: gcc7-pfe-0002-Backport-Skip-fpatchable-function-entry-tests-for-nv.patch +Patch107: gcc7-pfe-0003-Backport-Error-out-on-nvptx-for-fpatchable-function-.patch +Patch108: gcc7-pfe-0004-Backport-Adapt-scan-assembler-times-for-alpha.patch +Patch109: gcc7-pfe-0005-Backport-patchable_function_entry-decl.c-Use-3-NOPs-.patch +Patch110: gcc7-pfe-0006-Backport-IBM-Z-Use-the-dedicated-NOP-instructions-fo.patch +Patch111: gcc7-pfe-0007-Backport-Add-regex-to-search-for-uppercase-NOP-instr.patch +Patch112: gcc7-pfe-0008-Backport-ICE-segmentation-fault-with-patchable_funct.patch +Patch113: gcc7-pfe-0009-Backport-patchable_function_entry-decl.c-Pass-mcpu-g.patch +Patch114: gcc7-pfe-0010-Backport-patchable_function_entry-decl.c-Do-not-run-.patch +Patch115: gcc7-pfe-0011-Backport-patchable_function_entry-decl.c-Add-fno-pie.patch +Patch116: gcc7-pfe-0012-Backport-PR-c-89946-ICE-in-assemble_start_function-a.patch +Patch117: gcc7-pfe-0013-Backport-targhooks.c-default_print_patchable_functio.patch +Patch118: gcc7-pfe-0014-Backport-Align-__patchable_function_entries-to-POINT.patch +Patch119: gcc7-pfe-0015-Backport-Fix-PR-93242-patchable-function-entry-broke.patch +Patch120: gcc7-pfe-0016-Backport-Fix-patchable-function-entry-on-arc.patch +Patch121: gcc7-pfe-0017-Backport-Add-patch_area_size-and-patch_area_entry-to.patch +Patch122: gcc7-pfe-0018-Backport-testsuite-Adjust-patchable_function-tests-f.patch +Patch123: gcc7-pfe-0019-Backport-Use-the-section-flag-o-for-__patchable_func.patch +Patch124: gcc7-pfe-0020-Backport-varasm-Fix-up-__patchable_function_entries-.patch +Patch125: gcc7-pfe-0021-Backport-rs6000-Avoid-fpatchable-function-entry-regr.patch +Patch126: gcc7-pfe-0022-Fix-unwinding-issues-when-pfe-is-enabled.patch +Patch127: gcc7-pr88345-min-func-alignment.diff + +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++ and gcc-go. + +%package -n gcc7-32bit +Summary: The GNU C Compiler 32bit support +Group: Development/Languages/C and C++ +Requires: gcc7 = %{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 %cilkrts_arch +Requires: libcilkrts%{libcilkrts_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 +%ifarch %mpx_arch +Requires: libmpx%{libmpx_sover}-32bit >= %{version}-%{release} +Requires: libmpxwrappers%{libmpxwrappers_sover}-32bit >= %{version}-%{release} +%endif +Requires: glibc-devel-32bit + +%description -n gcc7-32bit +This package contains 32bit support for the GNU Compiler Collection. + +%package -n gcc7-64bit +Summary: The GNU C Compiler 64bit support +Group: Development/Languages/C and C++ +Requires: gcc7 = %{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 %atomic_arch +Requires: libatomic%{libatomic_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %itm_arch +Requires: libitm%{libitm_sover}-64bit >= %{version}-%{release} +%endif +%ifarch %cilkrts_arch +Requires: libcilkrts%{libcilkrts_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 +%ifarch %mpx_arch +Requires: libmpx%{libmpx_sover}-64bit >= %{version}-%{release} +Requires: libmpxwrappers%{libmpxwrappers_sover}-64bit >= %{version}-%{release} +%endif +Requires: glibc-devel-64bit + +%description -n gcc7-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: gcc7 = %{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: gcc7 = %{version}-%{release} + +%description locale +Locale data for the GNU Compiler Collection (GCC) to give error message +in the current locale. + +%package c++ +Summary: The GNU C++ Compiler +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ +Requires: gcc7 = %{version}-%{release} +Requires: gcc7-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: gcc7-32bit = %{version}-%{release} +Requires: gcc7-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: gcc7-64bit = %{version}-%{release} +Requires: gcc7-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 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} + +%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 + +%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 + +%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: gcc7 = %{version}-%{release} +Requires: gcc7-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: gcc7-32bit = %{version}-%{release} +Requires: gcc7-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: gcc7-64bit = %{version}-%{release} +Requires: gcc7-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: gcc7-c++ = %{version}-%{release} +Requires: gcc7-obj-c++ = %{version}-%{release} +Requires: gcc7-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: gcc7-c++-32bit = %{version}-%{release} +Requires: gcc7-obj-c++ = %{version}-%{release} +Requires: gcc7-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: gcc7-c++-64bit = %{version}-%{release} +Requires: gcc7-obj-c++ = %{version}-%{release} +Requires: gcc7-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 cpp7 +Summary: The GCC Preprocessor +License: GPL-3.0-or-later +Group: Development/Languages/C and C++ + +%description -n cpp7 +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: gcc7 = %{version}-%{release} +Requires: gcc7-ada = %{version}-%{release} +Requires: libada7 = %{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: gcc7-32bit = %{version}-%{release} +Requires: gcc7-ada = %{version}-%{release} +Requires: libada7-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: gcc7-64bit = %{version}-%{release} +Requires: gcc7-ada = %{version}-%{release} +Requires: libada7-64bit = %{version}-%{release} + +%description ada-64bit +This package contains an Ada compiler and associated development +tools based on the GNU GCC technology. + +%package -n libada7 +Summary: GNU Ada Runtime Libraries +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libgnarl-7 = %{version}-%{release} +Conflicts: %selfconflict libgnarl-7 +Provides: libgnat-7 = %{version}-%{release} +Conflicts: %selfconflict libgnat-7 + +%description -n libada7 +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 libada7 -p /sbin/ldconfig + +%postun -n libada7 -p /sbin/ldconfig + +%package -n libada7-32bit +Summary: GNU Ada Runtime Libraries +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libgnarl-7-32bit = %{version}-%{release} +Conflicts: %selfconflict libgnarl-7-32bit +Provides: libgnat-7-32bit = %{version}-%{release} +Conflicts: %selfconflict libgnat-7-32bit + +%description -n libada7-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 libada7-32bit -p /sbin/ldconfig + +%postun -n libada7-32bit -p /sbin/ldconfig + +%package -n libada7-64bit +Summary: GNU Ada Runtime Libraries +License: GPL-3.0-or-later WITH GCC-exception-3.1 +Group: System/Libraries +Provides: libgnarl-7-64bit = %{version}-%{release} +Conflicts: %selfconflict libgnarl-7-64bit +Provides: libgnat-7-64bit = %{version}-%{release} +Conflicts: %selfconflict libgnat-7-64bit + +%description -n libada7-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 libada7-64bit -p /sbin/ldconfig + +%postun -n libada7-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: gcc7 = %{version}-%{release} +Requires: gcc7-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: gcc7-32bit = %{version}-%{release} +Requires: gcc7-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: gcc7-64bit = %{version}-%{release} +Requires: gcc7-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 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 libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix} +Summary: The GNU Compiler Cilk+ Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libcilkrts%{libcilkrts_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 libcilkrts%{libcilkrts_sover} + +%description -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix} +The runtime library needed to run programs compiled with the +-fcilkplus option of the GNU Compiler Collection (GCC). + +%post -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix} -p /sbin/ldconfig + +%postun -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix} -p /sbin/ldconfig + +%package -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}-32bit +Summary: The GNU Compiler Cilk+ Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libcilkrts%{libcilkrts_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 libcilkrts%{libcilkrts_sover}-32bit + +%description -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}-32bit +The runtime library needed to run programs compiled with the +-fcilkplus option of the GNU Compiler Collection (GCC). + +%post -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}-32bit -p /sbin/ldconfig + +%postun -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}-32bit -p /sbin/ldconfig + +%package -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}-64bit +Summary: The GNU Compiler Cilk+ Runtime Library +License: MIT +Group: Development/Languages/C and C++ +Provides: libcilkrts%{libcilkrts_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 libcilkrts%{libcilkrts_sover}-64bit + +%description -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}-64bit +The runtime library needed to run programs compiled with the +-fcilkplus option of the GNU Compiler Collection (GCC). + +%post -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}-64bit -p /sbin/ldconfig + +%postun -n libcilkrts%{libcilkrts_sover}%{libcilkrts_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 -n libmpx%{libmpx_sover}%{libmpx_suffix} +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpx%{libmpx_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 libmpx%{libmpx_sover} + +%description -n libmpx%{libmpx_sover}%{libmpx_suffix} +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpx%{libmpx_sover}%{libmpx_suffix} -p /sbin/ldconfig + +%postun -n libmpx%{libmpx_sover}%{libmpx_suffix} -p /sbin/ldconfig + +%package -n libmpx%{libmpx_sover}%{libmpx_suffix}-32bit +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpx%{libmpx_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 libmpx%{libmpx_sover}-32bit + +%description -n libmpx%{libmpx_sover}%{libmpx_suffix}-32bit +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpx%{libmpx_sover}%{libmpx_suffix}-32bit -p /sbin/ldconfig + +%postun -n libmpx%{libmpx_sover}%{libmpx_suffix}-32bit -p /sbin/ldconfig + +%package -n libmpx%{libmpx_sover}%{libmpx_suffix}-64bit +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpx%{libmpx_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 libmpx%{libmpx_sover}-64bit + +%description -n libmpx%{libmpx_sover}%{libmpx_suffix}-64bit +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpx%{libmpx_sover}%{libmpx_suffix}-64bit -p /sbin/ldconfig + +%postun -n libmpx%{libmpx_sover}%{libmpx_suffix}-64bit -p /sbin/ldconfig + +%package -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix} +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpxwrappers%{libmpxwrappers_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 libmpxwrappers%{libmpxwrappers_sover} + +%description -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix} +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix} -p /sbin/ldconfig + +%postun -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix} -p /sbin/ldconfig + +%package -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-32bit +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpxwrappers%{libmpxwrappers_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 libmpxwrappers%{libmpxwrappers_sover}-32bit + +%description -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-32bit +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-32bit -p /sbin/ldconfig + +%postun -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-32bit -p /sbin/ldconfig + +%package -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-64bit +Summary: The GNU Compiler MPX Runtime Library +License: BSD-3-Clause +Group: Development/Languages/C and C++ +Provides: libmpxwrappers%{libmpxwrappers_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 libmpxwrappers%{libmpxwrappers_sover}-64bit + +%description -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-64bit +The runtime library needed to run programs compiled with the +-fcheck-pointer-bounds option of the GNU Compiler Collection (GCC). + +%post -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-64bit -p /sbin/ldconfig + +%postun -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}-64bit -p /sbin/ldconfig + +%package -n libstdc++%{libstdcxx_sover}%{libdevel_suffix}-doc +Summary: Documentation for the GNU C++ standard library +License: GPL-3.0-or-later +Group: Documentation/HTML +%if 0%{?suse_version} >= 1120 +BuildArch: noarch +%endif + +%description -n libstdc++%{libstdcxx_sover}%{libdevel_suffix}-doc +Extensive HTML documentation for the GNU C++ standard library. + +%package go +Summary: GNU Go Compiler +License: GPL-3.0-or-later +Group: Development/Languages/Other +Requires: gcc7 = %{version}-%{release} +Requires: gcc7-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: gcc7-32bit = %{version}-%{release} +Requires: gcc7-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: gcc7-64bit = %{version}-%{release} +Requires: gcc7-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 -n gcc7-testresults +Summary: Testsuite results +License: SUSE-Public-Domain +Group: Development/Languages/C and C++ + +%description -n gcc7-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 + +%prep +%if 0%{?nvptx_newlib:1} +%setup -q -n gcc-%{version} -a 5 +ln -s nvptx-newlib/newlib . +%else +%setup -q -n gcc-%{version} +%endif + +#test patching start + +%patch -P 2 +%patch -P 5 +%patch -P 6 +%patch -P 7 +%if %{suse_version} < 1310 +%patch -P 9 +%endif +%patch -P 10 +%patch -P 11 +%patch -P 12 +%patch -P 14 +%patch -P 15 +%patch -P 17 -p1 +%patch -P 18 +%patch -P 19 +%patch -P 20 +%patch -P 21 -p1 +%patch -P 22 -p1 +%patch -P 24 -p1 +%patch -P 25 -p1 +%patch -P 26 -p1 +%patch -P 27 -p1 +%patch -P 29 +%patch -P 30 -p1 +%patch -P 31 -p1 +%patch -P 32 -p1 +%patch -P 33 -p1 +%patch -P 34 -p1 +%patch -P 35 -p1 +%patch -P 36 -p1 +%patch -P 37 -p1 +%patch -P 38 -p1 +%patch -P 39 -p1 +%patch -P 40 -p1 +%patch -P 41 -p1 +%patch -P 42 -p1 +%patch -P 43 -p1 +%patch -P 44 -p1 +%patch -P 45 -p1 +%patch -P 46 -p1 +%patch -P 47 -p1 +%patch -P 51 +%patch -P 60 +%patch -P 61 +%patch -P 100 -p1 +%patch -P 23 -p1 +%patch -P 101 -p1 +%patch -P 102 -p1 +%patch -P 103 -p1 +%patch -P 104 -p1 +%patch -P 105 -p1 +%patch -P 106 -p1 +%patch -P 107 -p1 +%patch -P 108 -p1 +%patch -P 109 -p1 +%patch -P 110 -p1 +%patch -P 111 -p1 +%patch -P 112 -p1 +%patch -P 113 -p1 +%patch -P 114 -p1 +%patch -P 115 -p1 +%patch -P 116 -p1 +%patch -P 117 -p1 +%patch -P 118 -p1 +%patch -P 119 -p1 +%patch -P 120 -p1 +%patch -P 121 -p1 +%patch -P 122 -p1 +%patch -P 123 -p1 +%patch -P 124 -p1 +%patch -P 125 -p1 +%patch -P 126 -p1 +%patch -P 127 -p1 + +#test patching end + +%build +%define _lto_cflags %{nil} +# Avoid rebuilding of generated files +contrib/gcc_update --touch + +# SLE11 does not allow empty rpms +%if %{suse_version} < 1310 +echo "This is a dummy package to provide a dependency." > README +%endif + +rm -rf obj-%{GCCDIST} +mkdir obj-%{GCCDIST} +cd obj-%{GCCDIST} +RPM_OPT_FLAGS="$RPM_OPT_FLAGS -U_FORTIFY_SOURCE" +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fno-rtti//g' -e 's/-fno-exceptions//g' -e 's/-Wmissing-format-attribute//g' -e 's/-fstack-protector[^ ]*//g' -e 's/-ffortify=.//g' -e 's/-Wall//g' -e 's/-m32//g' -e 's/-m64//g'` +%ifarch %ix86 +# -mcpu is superceded by -mtune but -mtune is not supported by +# our bootstrap compiler. -mcpu gives a warning that stops +# the build process, so remove it for now. Also remove all other +# -march and -mtune flags. They are superseeded by proper +# default compiler settings now. +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mcpu=i.86//g' -e 's/-march=i.86//g' -e 's/-mtune=i.86//g'` +%endif +%ifarch s390 s390x +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-fsigned-char//g'` +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-O1/-O2/g'` +%endif +%ifarch aarch64 +%if %{build_ada} +# -mbranch-protection=standard flag is unsupported in gcc7 and we use GCC7 to build GCC7 +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-mbranch-protection=standard//g'` +%endif +%endif +%if 0%{?gcc_target_arch:1} +# Kill all -march/tune/cpu because that screws building the target libs +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/-m\(arch\|tune\|cpu\)=[^ ]*//g'` +%endif +# Replace 2 spaces by one finally +RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS|sed -e 's/ / /g'` + +languages=c +%if %{build_cp} +languages=$languages,c++ +%endif +%if %{build_objc} +languages=$languages,objc +%endif +%if %{build_fortran} +languages=$languages,fortran +%endif +%if %{build_objcp} +languages=$languages,obj-c++ +%endif +%if %{build_ada} +languages=$languages,ada +%endif +%if %{build_go} +languages=$languages,go +%endif + +# 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 %{build_ada} +# 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 +mkdir -p host-tools/bin +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 +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 +CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" XCFLAGS="$RPM_OPT_FLAGS" \ +TCFLAGS="$RPM_OPT_FLAGS" \ +../configure \ + --prefix=%{_prefix} \ + --infodir=%{_infodir} \ + --mandir=%{_mandir} \ + --libdir=%{_libdir} \ + --libexecdir=%{_libdir} \ + --enable-languages=$languages \ +%if %{build_hsa} || %{build_nvptx} + --enable-offload-targets=\ +%if %{build_hsa} +hsa,\ +%endif +%if %{build_nvptx} +nvptx-none, \ +%endif +%endif +%if %{build_nvptx} + --without-cuda-driver \ +%endif + $ENABLE_CHECKING \ + --disable-werror \ + --with-gxx-include-dir=%{_prefix}/include/c++/%{gcc_dir_version} \ + --enable-ssp \ + --disable-libssp \ +%if 0%{!?build_libvtv:1} + --disable-libvtv \ +%endif +%ifnarch %mpx_arch + --disable-libmpx \ +%endif + --disable-libcc1 \ +%if %{enable_plugins} + --enable-plugin \ +%else + --disable-plugin \ +%endif + --with-bugurl="https://bugs.opensuse.org/" \ + --with-pkgversion="SUSE Linux" \ + --with-slibdir=/%{_lib} \ + --with-system-zlib \ + --enable-libstdcxx-allocator=new \ + --disable-libstdcxx-pch \ +%if 0%{suse_version} <= 1320 + --with-default-libstdcxx-abi=gcc4-compatible \ +%endif + --enable-version-specific-runtime-libs \ + --with-gcc-major-version-only \ + --enable-linker-build-id \ + --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} \ +%if 0%{?disable_32bit:1} + --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} + --without-headers \ +%endif +%endif +%if "%{TARGET_ARCH}" == "spu" + --with-gxx-include-dir=%sysroot/include/c++/%{gcc_dir_version} \ + --with-newlib \ +%endif +%if "%{TARGET_ARCH}" == "nvptx" + --enable-as-accelerator-for=%{GCCDIST} \ + --disable-sjlj-exceptions \ + --enable-newlib-io-long-long \ +%endif +%if "%{TARGET_ARCH}" == "avr" + --enable-lto \ + --without-gxx-include-dir \ + --with-native-system-header-dir=/include \ +%endif +%endif +%if "%{TARGET_ARCH}" == "arm" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv5tel" + --with-arch=armv5te \ + --with-float=soft \ + --with-mode=arm \ + --with-abi=aapcs-linux \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv6hl" + --with-arch=armv6zk \ + --with-tune=arm1176jzf-s \ + --with-float=hard \ + --with-abi=aapcs-linux \ + --with-fpu=vfp \ + --disable-sjlj-exceptions \ +%endif +%if "%{TARGET_ARCH}" == "armv7hl" + --with-arch=armv7-a \ + --with-tune=cortex-a15 \ + --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}" == "powerpc" || "%{TARGET_ARCH}" == "powerpc64" || "%{TARGET_ARCH}" == "powerpc64le" +%if "%{TARGET_ARCH}" == "powerpc" + --with-cpu=default32 \ +%endif +%if "%{TARGET_ARCH}" == "powerpc64le" +%if %{suse_version} >= 1350 + --with-cpu=power8 \ + --with-tune=power9 \ +%else +%if %{suse_version} >= 1315 && %{suse_version} != 1320 + --with-cpu=power8 \ + --with-tune=power8 \ +%else + --with-cpu=power7 \ + --with-tune=power7 \ +%endif +%endif +%else + --with-cpu-64=power4 \ +%endif + --enable-secureplt \ + --with-long-double-128 \ +%if "%{TARGET_ARCH}" == "powerpc64le" + --enable-targets=powerpcle-linux \ + --disable-multilib \ +%endif +%endif +%if "%{TARGET_ARCH}" == "sparc64" + --with-cpu=ultrasparc \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "sparc" + --with-cpu=v8 \ + --with-long-double-128 \ +%endif +%if "%{TARGET_ARCH}" == "i586" +%if 0%{?sle_version:%sle_version} >= 150000 + --with-arch-32=x86-64 \ +%else + --with-arch-32=i586 \ +%endif + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "x86_64" + --enable-multilib \ + --with-arch-32=x86-64 \ + --with-tune=generic \ +%endif +%if "%{TARGET_ARCH}" == "s390" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "s390x" +%if %{suse_version} >= 1310 + --with-tune=zEC12 --with-arch=z196 \ +%else + --with-tune=z9-109 --with-arch=z900 \ +%endif + --with-long-double-128 \ + --enable-decimal-float \ +%endif +%if "%{TARGET_ARCH}" == "m68k" + --disable-multilib \ +%endif +%if "%{TARGET_ARCH}" == "riscv64" + --disable-multilib \ +%endif + --build=%{GCCDIST} \ + --host=%{GCCDIST} + +STAGE1_FLAGS="-g -O2" +%if 0%{?do_profiling} +%define profiledbootstraprule profiledbootstrap +%endif +# Only run profiled bootstrap on archs where it works and matters +%ifarch x86_64 %ix86 ppc64le s390x aarch64 +setarch `arch` -R make %{?profiledbootstraprule} STAGE1_CFLAGS="$STAGE1_FLAGS" BOOT_CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} +%else +make STAGE1_CFLAGS="$STAGE1_FLAGS" BOOT_CFLAGS="$RPM_OPT_FLAGS" %{?_smp_mflags} +%endif +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=$RPM_BUILD_ROOT%{libsubdir}:$RPM_BUILD_ROOT%{mainlibdirbi} +make install DESTDIR=$RPM_BUILD_ROOT + +# verify libasan really ended up with libstdc++ as NEEDED. +%ifarch %asan_arch + readelf -d $RPM_BUILD_ROOT%{versmainlibdir}/libasan.so.%{libasan_sover}* | grep 'NEEDED.*libstdc++' || exit 1 +%if %{biarch} + readelf -d $RPM_BUILD_ROOT%{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 libatomic libitm libtsan libcilkrts liblsan libubsan libvtv \ + libmpx libmpxwrappers libstdc++fs libgomp-plugin-nvptx; do + rm -f $RPM_BUILD_ROOT%{versmainlibdir}/$lib.la +%if %{biarch} + rm -f $RPM_BUILD_ROOT%{versmainlibdirbi}/$lib.la +%endif +done + +mkdir -p $RPM_BUILD_ROOT%{_libdir} +%if %{biarch} +%if %{build_primary_64bit} +mkdir -p $RPM_BUILD_ROOT%{_prefix}/lib +%else +mkdir -p $RPM_BUILD_ROOT%{_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 > $RPM_BUILD_ROOT%{_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 $RPM_BUILD_ROOT%{_prefix}/include/c++/%{gcc_dir_version}/%{GCCDIST}/[36]* +if ! test -z "$dir_ml"; then + ln -s . $RPM_BUILD_ROOT%{_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 + libgomp \ +%if %{build_hsa} + libgomp-plugin-hsa \ +%endif +%if %{build_nvptx} + libgomp-plugin-nvptx \ +%endif +%ifarch %atomic_arch + libatomic \ +%endif +%ifarch %itm_arch + libitm \ +%endif +%ifarch %asan_arch + libasan \ +%endif +%ifarch %tsan_arch + libtsan \ +%endif +%ifarch %cilkrts_arch + libcilkrts \ +%endif +%ifarch %lsan_arch + liblsan \ +%endif +%ifarch %ubsan_arch + libubsan \ +%endif +%ifarch %vtv_arch + libvtv \ +%endif +%ifarch %mpx_arch + libmpx libmpxwrappers \ +%endif + ; do + for lib in `find $RPM_BUILD_ROOT%{versmainlibdir} -maxdepth 1 -name $libname.so.*`; do + mv $lib $RPM_BUILD_ROOT%{mainlibdir}/ + done + if test -L $RPM_BUILD_ROOT%{versmainlibdir}/$libname.so; then + ln -sf %{mainlibdir}/`readlink $RPM_BUILD_ROOT%{versmainlibdir}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + $RPM_BUILD_ROOT%{versmainlibdir}/$libname.so + fi +%if %{biarch} + if test -d $RPM_BUILD_ROOT%{versmainlibdirbi}; then + for lib in `find $RPM_BUILD_ROOT%{versmainlibdirbi} -maxdepth 1 -name "$libname.so.*"`; do + mv $lib $RPM_BUILD_ROOT%{mainlibdirbi}/ + done + if test -L $RPM_BUILD_ROOT%{versmainlibdirbi}/$libname.so; then + ln -sf %{mainlibdirbi}/`readlink $RPM_BUILD_ROOT%{versmainlibdirbi}/$libname.so | sed -e 's/\(.*\.so\.[^\.]*\).*/\1/'` \ + $RPM_BUILD_ROOT%{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 $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdir} +mv $RPM_BUILD_ROOT%{mainlibdir}/libstdc++.so.*-gdb.py $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdir}/ +sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdir}/libstdc++.so.*-gdb.py +%if %{biarch} + if test -d $RPM_BUILD_ROOT%{versmainlibdirbi}; then + mkdir -p $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdirbi} + mv $RPM_BUILD_ROOT%{mainlibdirbi}/libstdc++.so.*-gdb.py $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdirbi}/ + sed -i -e '/^libdir/s/\/gcc\/%{GCCDIST}\/%{gcc_dir_version}//g' $RPM_BUILD_ROOT%{_datadir}/gdb/auto-load%{mainlibdirbi}/libstdc++.so.*-gdb.py + fi +%endif +%endif + +# Move libgcc_s around +if test -L $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so; then + rm -f $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so + ln -sf /%{_lib}/libgcc_s.so.%{libgcc_s} $RPM_BUILD_ROOT%{versmainlibdir}/libgcc_s.so +else + mv $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdir}/ +fi +chmod a+x $RPM_BUILD_ROOT/%{_lib}/libgcc_s.so.%{libgcc_s} +%if %{biarch} +%if %{build_primary_64bit} +if test -L $RPM_BUILD_ROOT/lib/libgcc_s.so; then + rm -f $RPM_BUILD_ROOT/lib/libgcc_s.so + ln -sf /lib/libgcc_s.so.%{libgcc_s} $RPM_BUILD_ROOT%{versmainlibdirbi32}/libgcc_s.so +else + mv $RPM_BUILD_ROOT/lib/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi32}/ +fi +ln -sf %{versmainlibdirbi32}/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi32}/libgcc_s_32.so +chmod a+x $RPM_BUILD_ROOT/lib/libgcc_s.so.%{libgcc_s} +%else +# 32-bit biarch systems +if test -L $RPM_BUILD_ROOT/lib64/libgcc_s.so; then + rm -f $RPM_BUILD_ROOT/lib64/libgcc_s.so + ln -sf /lib64/libgcc_s.so.%{libgcc_s} $RPM_BUILD_ROOT%{versmainlibdirbi64}/libgcc_s.so +else + mv $RPM_BUILD_ROOT/lib64/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi64}/ +fi +ln -sf %{versmainlibdirbi64}/libgcc_s.so $RPM_BUILD_ROOT%{versmainlibdirbi64}/libgcc_s_64.so +chmod a+x $RPM_BUILD_ROOT/lib64/libgcc_s.so.%{libgcc_s} +%endif +%endif + +%if %{build_ada} +mv $RPM_BUILD_ROOT%{libsubdir}/adalib/lib*-*.so $RPM_BUILD_ROOT%{_libdir} +ln -sf %{_libdir}/libgnarl%{binsuffix}.so $RPM_BUILD_ROOT%{libsubdir}/adalib/libgnarl.so +ln -sf %{_libdir}/libgnat%{binsuffix}.so $RPM_BUILD_ROOT%{libsubdir}/adalib/libgnat.so +chmod a+x $RPM_BUILD_ROOT%{_libdir}/libgna*-*.so +%if %{biarch} +mv $RPM_BUILD_ROOT%{versmainlibdirbi}/adalib/lib*-*.so $RPM_BUILD_ROOT%{mainlibdirbi}/ +ln -sf %{mainlibdirbi}/libgnarl%{binsuffix}.so $RPM_BUILD_ROOT%{versmainlibdirbi}/adalib/libgnarl.so +ln -sf %{mainlibdirbi}/libgnat%{binsuffix}.so $RPM_BUILD_ROOT%{versmainlibdirbi}/adalib/libgnat.so +chmod a+x $RPM_BUILD_ROOT%{mainlibdirbi}/libgna*-*.so +%endif +%endif + +rm -f $RPM_BUILD_ROOT%{_prefix}/bin/c++%{binsuffix} + +# Remove some crap from the .la files: +for l in `find $RPM_BUILD_ROOT -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 + +%if 0%{?run_tests:1} +cp `find . -name "*.sum"` ../testresults/ +cp `find . -name "*.log" \! -name "config.log" | grep -v 'acats.\?/tests' ` ../testresults/ +chmod 644 ../testresults/* +%endif +# Remove files that we do not need to clean up filelist +rm -f $RPM_BUILD_ROOT%{_prefix}/bin/%{GCCDIST}-* +rm -rf $RPM_BUILD_ROOT%{libsubdir}/install-tools +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/zutil.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/linux/a.out.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/linux/vt.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/asm-generic/socket.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/bits/mathdef.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/sys/ucontext.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/bits/statx.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/pthread.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/bits/unistd_ext.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/sys/rseq.h +rm -f $RPM_BUILD_ROOT%{libsubdir}/include-fixed/sys/mount.h +%if !%{enable_plugins} +# no plugins +rm -rf $RPM_BUILD_ROOT%{libsubdir}/plugin +%endif +rm -f $RPM_BUILD_ROOT%{_infodir}/dir + +rm -f $RPM_BUILD_ROOT%{_mandir}/man7/fsf-funding.7 +rm -f $RPM_BUILD_ROOT%{_mandir}/man7/gfdl.7 +rm -f $RPM_BUILD_ROOT%{_mandir}/man7/gpl.7 +rm -f $RPM_BUILD_ROOT%{_libdir}/libiberty.a +%if %{biarch} +%if %{build_primary_64bit} +rm -f $RPM_BUILD_ROOT%{_prefix}/lib/libiberty.a +%else +rm -f $RPM_BUILD_ROOT%{_prefix}/lib64/libiberty.a +%endif +%endif +rm -f $RPM_BUILD_ROOT%{libsubdir}/liblto_plugin.a +rm -f $RPM_BUILD_ROOT%{libsubdir}/liblto_plugin.la +%if %{build_go} +# gccgo.info isn't properly versioned +rm $RPM_BUILD_ROOT%{_infodir}/gccgo.info* +%endif + +# For regular build, some info files do not get renamed properly. +# Do so here. +mv $RPM_BUILD_ROOT%{_infodir}/libgomp.info $RPM_BUILD_ROOT%{_infodir}/libgomp%{binsuffix}.info +%ifarch %itm_arch +mv $RPM_BUILD_ROOT%{_infodir}/libitm.info $RPM_BUILD_ROOT%{_infodir}/libitm%{binsuffix}.info +%endif +%if %{build_fortran} +%ifarch %quadmath_arch +mv $RPM_BUILD_ROOT%{_infodir}/libquadmath.info $RPM_BUILD_ROOT%{_infodir}/libquadmath%{binsuffix}.info +%endif +%endif +%if %{build_ada} +mv $RPM_BUILD_ROOT%{_infodir}/gnat-style.info $RPM_BUILD_ROOT%{_infodir}/gnat-style%{binsuffix}.info +mv $RPM_BUILD_ROOT%{_infodir}/gnat_rm.info $RPM_BUILD_ROOT%{_infodir}/gnat_rm%{binsuffix}.info +mv $RPM_BUILD_ROOT%{_infodir}/gnat_ugn.info $RPM_BUILD_ROOT%{_infodir}/gnat_ugn%{binsuffix}.info +%endif + +cd .. +%find_lang cpplib%{binsuffix} +%find_lang gcc%{binsuffix} +%find_lang libstdc++ +cat cpplib%{binsuffix}.lang gcc%{binsuffix}.lang > gcc7-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 +%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/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} +%{libsubdir}/collect2 +%{libsubdir}/lto1 +%{libsubdir}/lto-wrapper +%{libsubdir}/liblto_plugin.so* +%{libsubdir}/include-fixed/README +%{libsubdir}/include-fixed/limits.h +%{libsubdir}/include-fixed/syslimits.h +%{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 +%ifarch %sparc +%{libsubdir}/include/visintrin.h +%endif +%ifarch ppc ppc64 ppc64le +%{libsubdir}/include/altivec.h +%{libsubdir}/include/ppc-asm.h +%{libsubdir}/include/paired.h +%{libsubdir}/include/ppu_intrinsics.h +%{libsubdir}/include/si2vmx.h +%{libsubdir}/include/spe.h +%{libsubdir}/include/spu2vmx.h +%{libsubdir}/include/vec_types.h +%{libsubdir}/include/htmintrin.h +%{libsubdir}/include/htmxlintrin.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 +%endif +%ifarch %arm aarch64 +%{libsubdir}/include/arm_neon.h +%{libsubdir}/include/arm_acle.h +%{libsubdir}/include/arm_fp16.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/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 +%endif +%ifarch m68k +%{libsubdir}/include/math-68881.h +%endif +%ifarch %cilkrts_arch +%{libsubdir}/include/cilk +%endif +%ifarch %asan_arch +%{libsubdir}/include/sanitizer +%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_hsa} +%versmainlib libgomp-plugin-hsa.so +%endif +%if %{build_nvptx} +%versmainlib libgomp-plugin-nvptx.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 %cilkrts_arch +%versmainlib libcilkrts.so +%versmainlib libcilkrts.a +%versmainlib libcilkrts.spec +%endif +%ifarch %lsan_arch +%if %build_primary_64bit +%versmainlib liblsan.so +%versmainlib liblsan.a +%endif +%endif +%ifarch %ubsan_arch +%versmainlib libubsan.so +%versmainlib libubsan.a +%endif +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch +%versmainlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versmainlib libvtv.so +%versmainlib libvtv.a +%endif +%ifarch %mpx_arch +%versmainlib libmpx.so +%versmainlib libmpx.a +%versmainlib libmpxwrappers.so +%versmainlib libmpxwrappers.a +%versmainlib libmpx.spec +%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 + +%if %{separate_biarch} +%files -n gcc7%{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 +%if %{build_nvptx} +%versbiarchlib libgomp-plugin-nvptx.so +%endif +%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 %cilkrts_arch +%versbiarchlib libcilkrts.a +%versbiarchlib libcilkrts.so +%versbiarchlib libcilkrts.spec +%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 +%endif +%endif +%ifarch %asan_arch %ubsan_arch %tsan_arch %lsan_arch +%versbiarchlib libsanitizer.spec +%endif +%ifarch %vtv_arch +%versbiarchlib libvtv.a +%versbiarchlib libvtv.so +%endif +%ifarch %mpx_arch +%versbiarchlib libmpx.so +%versbiarchlib libmpx.a +%versbiarchlib libmpxwrappers.so +%versbiarchlib libmpxwrappers.a +%versbiarchlib libmpx.spec +%endif +%endif + +%if %{enable_plugins} +%files devel +%defattr(-,root,root) +%dir %{libsubdir}/plugin +%{libsubdir}/plugin +%endif + +%files locale -f gcc7-locale.lang + +%files -n libstdc++%{libstdcxx_sover}%{libstdcxx_suffix}-locale -f libstdc++.lang + +%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 + +%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) +%versmainlib libstdc++.a +%versmainlib libstdc++fs.a +%versmainlib libstdc++.so +%versmainlib libsupc++.a +%{_prefix}/include/c++ +%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) +%versbiarchlib libstdc++.a +%versbiarchlib libstdc++fs.a +%versbiarchlib libstdc++.so +%versbiarchlib libsupc++.a +%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) +/%{_lib}/libgcc_s.so.%{libgcc_s} +%if %{biarch} +%if %{build_primary_64bit} +%if !%{separate_bi32} +/lib/libgcc_s.so.%{libgcc_s} +%endif +%else +%if !%{separate_bi64} +/lib64/libgcc_s.so.%{libgcc_s} +%endif +%endif +%endif + +%if %{separate_bi64} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-64bit +%defattr(-,root,root) +/lib64/libgcc_s.so.%{libgcc_s} +%endif + +%if %{separate_bi32} +%files -n libgcc_s%{libgcc_s}%{libgcc_s_suffix}-32bit +%defattr(-,root,root) +/lib/libgcc_s.so.%{libgcc_s} +%endif + +%files -n libgomp%{libgomp_sover}%{libgomp_suffix} +%defattr(-,root,root) +%mainlib libgomp.so.%{libgomp_sover}* +%if %{build_hsa} +%mainlib libgomp-plugin-hsa.so.%{libgomp_sover}* +%endif +%if %{build_nvptx} +%mainlib libgomp-plugin-nvptx.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 +%if %{build_nvptx} +%biarchlib libgomp-plugin-nvptx.so.%{libgomp_sover}* +%endif + +%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 %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 %cilkrts_arch +%files -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix} +%defattr(-,root,root) +%mainlib libcilkrts.so.%{libcilkrts_sover}* + +%if %{separate_biarch} +%files -n libcilkrts%{libcilkrts_sover}%{libcilkrts_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libcilkrts.so.%{libcilkrts_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 + +%ifarch %mpx_arch +%files -n libmpx%{libmpx_sover}%{libmpx_suffix} +%defattr(-,root,root) +%mainlib libmpx.so.%{libmpx_sover}* + +%if %{separate_biarch} +%files -n libmpx%{libmpx_sover}%{libmpx_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libmpx.so.%{libmpx_sover}* +%endif + +%files -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix} +%defattr(-,root,root) +%mainlib libmpxwrappers.so.%{libmpxwrappers_sover}* + +%if %{separate_biarch} +%files -n libmpxwrappers%{libmpxwrappers_sover}%{libmpxwrappers_suffix}%{separate_biarch_suffix} +%defattr(-,root,root) +%biarchlib libmpxwrappers.so.%{libmpxwrappers_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 + +%files -n cpp7 +%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 + +%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 +%endif + +%files -n libada7 +%defattr(-,root,root) +%mainlib libgnarl%{binsuffix}.so +%mainlib libgnat%{binsuffix}.so + +%if %{separate_biarch} +%files -n libada7%{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/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 0%{?run_tests:1} +%files -n gcc7-testresults +%defattr(-,root,root) +%doc testresults/test_summary.txt +%doc testresults/*.sum +%doc testresults/*.log +%endif + +%changelog diff --git a/libgcc-riscv-div.patch b/libgcc-riscv-div.patch new file mode 100644 index 0000000..76fb75d --- /dev/null +++ b/libgcc-riscv-div.patch @@ -0,0 +1,121 @@ +From 485b0a0039a29cf046fe97c7d72aefe49275b141 Mon Sep 17 00:00:00 2001 +From: Nelson Chu +Date: Mon, 29 Nov 2021 04:48:20 -0800 +Subject: [PATCH] RISC-V: jal cannot refer to a default visibility symbol for + shared object. + +This is the original binutils bugzilla report, +https://sourceware.org/bugzilla/show_bug.cgi?id=28509 + +And this is the first version of the proposed binutils patch, +https://sourceware.org/pipermail/binutils/2021-November/118398.html + +After applying the binutils patch, I get the the unexpected error when +building libgcc, + +/scratch/nelsonc/riscv-gnu-toolchain/riscv-gcc/libgcc/config/riscv/div.S:42: +/scratch/nelsonc/build-upstream/rv64gc-linux/build-install/riscv64-unknown-linux-gnu/bin/ld: relocation R_RISCV_JAL against `__udivdi3' which may bind externally can not be used when making a shared object; recompile with -fPIC + +Therefore, this patch add an extra hidden alias symbol for __udivdi3, and +then use HIDDEN_JUMPTARGET to target a non-preemptible symbol instead. +The solution is similar to glibc as follows, +https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b + +libgcc/ChangeLog: + + * config/riscv/div.S: Add the hidden alias symbol for __udivdi3, and + then use HIDDEN_JUMPTARGET to target it since it is non-preemptible. + * config/riscv/riscv-asm.h: Added new macros HIDDEN_JUMPTARGET and + HIDDEN_DEF. +--- + libgcc/config/riscv/div.S | 23 ++++++++++++++++------- + 1 file changed, 16 insertions(+), 7 deletions(-) + +diff --git a/libgcc/config/riscv/div.S b/libgcc/config/riscv/div.S +index 63d542e846c..2d43a48a302 100644 +--- a/libgcc/config/riscv/div.S ++++ b/libgcc/config/riscv/div.S +@@ -23,6 +23,14 @@ a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + ++#define FUNC_ALIAS(X,Y) \ ++ .globl X; \ ++ X = Y ++#define CONCAT1(a, b) CONCAT2(a, b) ++#define CONCAT2(a, b) a ## b ++#define HIDDEN_JUMPTARGET(X) CONCAT1(__hidden_, X) ++#define HIDDEN_DEF(X) FUNC_ALIAS(HIDDEN_JUMPTARGET(X), X); \ ++ .hidden HIDDEN_JUMPTARGET(X) + .text + .align 2 + +@@ -39,7 +47,7 @@ __udivsi3: + sll a0, a0, 32 + sll a1, a1, 32 + move t0, ra +- jal __udivdi3 ++ jal HIDDEN_JUMPTARGET(__udivdi3) + sext.w a0, a0 + jr t0 + +@@ -51,7 +59,7 @@ __umodsi3: + srl a0, a0, 32 + srl a1, a1, 32 + move t0, ra +- jal __udivdi3 ++ jal HIDDEN_JUMPTARGET(__udivdi3) + sext.w a0, a1 + jr t0 + +@@ -96,12 +104,13 @@ __udivdi3: + bnez a3, .L3 + .L5: + ret ++HIDDEN_DEF (__udivdi3) + + .globl __umoddi3 + __umoddi3: + /* Call __udivdi3(a0, a1), then return the remainder, which is in a1. */ + move t0, ra +- jal __udivdi3 ++ jal HIDDEN_JUMPTARGET(__udivdi3) + move a0, a1 + jr t0 + +@@ -110,12 +119,12 @@ __umoddi3: + neg a0, a0 + bgez a1, .L12 /* Compute __udivdi3(-a0, a1), then negate the result. */ + neg a1, a1 +- j __udivdi3 /* Compute __udivdi3(-a0, -a1). */ ++ j HIDDEN_JUMPTARGET(__udivdi3) /* Compute __udivdi3(-a0, -a1). */ + .L11: /* Compute __udivdi3(a0, -a1), then negate the result. */ + neg a1, a1 + .L12: + move t0, ra +- jal __udivdi3 ++ jal HIDDEN_JUMPTARGET(__udivdi3) + neg a0, a0 + jr t0 + +@@ -125,7 +134,7 @@ __moddi3: + bltz a1, .L31 + bltz a0, .L32 + .L30: +- jal __udivdi3 /* The dividend is not negative. */ ++ jal HIDDEN_JUMPTARGET(__udivdi3) /* The dividend is not negative. */ + move a0, a1 + jr t0 + .L31: +@@ -133,7 +142,7 @@ __moddi3: + bgez a0, .L30 + .L32: + neg a0, a0 +- jal __udivdi3 /* The dividend is hella negative. */ ++ jal HIDDEN_JUMPTARGET(__udivdi3) /* The dividend is hella negative. */ + neg a0, a1 + jr t0 + +-- +2.40.1 + diff --git a/nvptx-newlib.tar.xz b/nvptx-newlib.tar.xz new file mode 100644 index 0000000..ee374e5 --- /dev/null +++ b/nvptx-newlib.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f16edd6dd88631ef5f5fbdad9c100cf338126957926c74fea46f34094c945871 +size 7396228 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