- Remove epiphany build, newlib no longer builds for it.

OBS-URL: https://build.opensuse.org/package/show/devel:gcc/gcc7?expand=0&rev=250
This commit is contained in:
Richard Biener 2024-10-22 08:05:40 +00:00 committed by Git OBS Bridge
commit f4e8489180
108 changed files with 43220 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

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

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.osc

View File

@ -0,0 +1,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.

11
_constraints Normal file
View File

@ -0,0 +1,11 @@
<constraints>
<hardware>
<disk>
<size unit="G">16</size>
</disk>
<physicalmemory>
<size unit="G">4</size>
</physicalmemory>
<processors>4</processors>
</hardware>
</constraints>

22
_multibuild Normal file
View File

@ -0,0 +1,22 @@
<multibuild>
<flavor>gcc7-testresults</flavor>
<flavor>cross-aarch64-gcc7</flavor>
<flavor>cross-arm-gcc7</flavor>
<flavor>cross-avr-gcc7-bootstrap</flavor>
<flavor>cross-avr-gcc7</flavor>
<flavor>cross-i386-gcc7</flavor>
<flavor>cross-x86_64-gcc7</flavor>
<flavor>cross-s390x-gcc7</flavor>
<flavor>cross-sparc-gcc7</flavor>
<flavor>cross-sparc64-gcc7</flavor>
<flavor>cross-ppc64-gcc7</flavor>
<flavor>cross-ppc64le-gcc7</flavor>
<flavor>cross-m68k-gcc7</flavor>
<flavor>cross-mips-gcc7</flavor>
<flavor>cross-hppa-gcc7</flavor>
<flavor>cross-arm-none-gcc7-bootstrap</flavor>
<flavor>cross-arm-none-gcc7</flavor>
<flavor>cross-rx-gcc7-bootstrap</flavor>
<flavor>cross-rx-gcc7</flavor>
<flavor>cross-nvptx-gcc7</flavor>
</multibuild>

125
change_spec Normal file
View File

@ -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>' > _multibuild
echo '<flavor>'gcc$base_ver-testresults'</flavor>' >> _multibuild
add_cross() {
local pkgname="$1"; shift
local rpmtarget="$1"; shift
local triplet="$1"; shift
echo "%define pkgname $pkgname" > $pkgname.spec
echo "%define cross_arch $rpmtarget" >> $pkgname.spec
echo "%define gcc_target_arch $triplet" >> $pkgname.spec
echo "$@" >> $pkgname.spec
{ sed -n -e '1,/SRC-COMMON-BEGIN/p' cross.spec.in
sed -n -e '/SRC-COMMON-BEGIN/,/SRC-COMMON-END/p' $outfile
sed -n -e '/SRC-COMMON-END/,/BUILD-COMMON-BEGIN/p' cross.spec.in
sed -n -e '/BUILD-COMMON-BEGIN/,/BUILD-COMMON-END/p' $outfile
sed -n -e '/BUILD-COMMON-END/,$p' cross.spec.in; } |
sed -e "s#@base_ver@#$base_ver#" \
-e "s/^\(ExclusiveArch.*\) $rpmtarget[^ \r]*/\1 /" \
>> $pkgname.spec
echo '<flavor>'$pkgname'</flavor>' >> _multibuild
}
add_newlib_cross() {
add_cross $1-bootstrap $2 $3 "%define gcc_target_newlib 1
%define gcc_libc_bootstrap 1"
add_cross $1 $2 $3 "%define gcc_target_newlib 1"
}
# 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>' >> _multibuild
osc service localrun format_spec_file

38
check-build.sh Normal file
View File

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

928
cross-aarch64-gcc7.spec Normal file
View File

@ -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

928
cross-arm-gcc7.spec Normal file
View File

@ -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

View File

@ -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

928
cross-arm-none-gcc7.spec Normal file
View File

@ -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

View File

@ -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

928
cross-avr-gcc7.spec Normal file
View File

@ -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

View File

@ -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

928
cross-epiphany-gcc7.spec Normal file
View File

@ -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

928
cross-hppa-gcc7.spec Normal file
View File

@ -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

928
cross-i386-gcc7.spec Normal file
View File

@ -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

928
cross-m68k-gcc7.spec Normal file
View File

@ -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

928
cross-mips-gcc7.spec Normal file
View File

@ -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

928
cross-nvptx-gcc7.spec Normal file
View File

@ -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

928
cross-ppc64-gcc7.spec Normal file
View File

@ -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

928
cross-ppc64le-gcc7.spec Normal file
View File

@ -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

View File

@ -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

928
cross-rx-gcc7.spec Normal file
View File

@ -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

928
cross-s390x-gcc7.spec Normal file
View File

@ -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

928
cross-sparc-gcc7.spec Normal file
View File

@ -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

928
cross-sparc64-gcc7.spec Normal file
View File

@ -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

928
cross-x86_64-gcc7.spec Normal file
View File

@ -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

405
cross.spec.in Normal file
View File

@ -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@

3
gcc-7.5.0+r278197.tar.xz Normal file
View File

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

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

@ -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. */

2619
gcc.spec.in Normal file

File diff suppressed because it is too large Load Diff

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

@ -0,0 +1,91 @@
2005-11-28 Jakub Jelinek <jakub@redhat.com>
* config/rs6000/rs6000.c (rs6000_return_addr): If COUNT == 0,
read word RETURN_ADDRESS_OFFSET bytes above arg_pointer_rtx
instead of doing an extran indirection from frame_pointer_rtx.
* gcc.dg/20051128-1.c: New test.
#Index: gcc/config/rs6000/rs6000.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;
+}

View File

@ -0,0 +1,13 @@
Index: libgcc/Makefile.in
===================================================================
--- libgcc/Makefile.in.orig 2015-12-14 11:33:03.225790694 +0100
+++ libgcc/Makefile.in 2015-12-17 15:09:45.415136693 +0100
@@ -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 =

View File

@ -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 <doko@debian.org>
* Makefile.in: Allow transformations on info file names.
Define MAKEINFODEFS, macros to pass transformated info file
names to makeinfo.
* doc/cpp.texi: Use macros defined in MAKEINFODEFS for references.
* doc/cppinternals.texi: Likewise.
* doc/extend.texi: Likewise.
* doc/gcc.texi: Likewise.
* doc/gccint.texi: Likewise.
* doc/invoke.texi: Likewise.
* doc/libgcc.texi: Likewise.
* doc/makefile.texi: Likewise.
* doc/passes.texi: Likewise.
* doc/sourcebuild.texi: Likewise.
* doc/standards.texi: Likewise.
* doc/trouble.texi: Likewise.
gcc/fortran/ChangeLog:
* Make-lang.in: Allow transformations on info file names.
Pass macros of transformated info file defined in MAKEINFODEFS
names to makeinfo.
* gfortran.texi: Use macros defined in MAKEINFODEFS for references.
gcc/java/ChangeLog:
* Make-lang.in: Allow transformations on info file names.
Pass macros of transformated info file defined in MAKEINFODEFS
names to makeinfo.
* gcj.texi: Use macros defined in MAKEINFODEFS for references.
---
gcc/Makefile.in | 74 ++++++++++++++++++++++++++++++++++++----------
gcc/ada/gnat-style.texi | 2 -
gcc/ada/gnat_rm.texi | 2 -
gcc/ada/gnat_ugn.texi | 2 -
gcc/doc/cpp.texi | 2 -
gcc/doc/cppinternals.texi | 2 -
gcc/doc/extend.texi | 2 -
gcc/doc/gcc.texi | 8 ++--
gcc/doc/gccint.texi | 4 +-
gcc/doc/install.texi | 2 -
gcc/doc/invoke.texi | 10 +++---
gcc/doc/libgcc.texi | 2 -
gcc/doc/makefile.texi | 2 -
gcc/doc/passes.texi | 2 -
gcc/doc/standards.texi | 4 +-
gcc/fortran/Make-lang.in | 11 +++---
gcc/fortran/gfortran.texi | 2 -
gcc/java/Make-lang.in | 19 +++++++++--
gcc/java/gcj.texi | 20 ++++++------
libgomp/Makefile.am | 13 ++++----
libgomp/Makefile.in | 14 ++++----
libgomp/libgomp.texi | 2 -
22 files changed, 131 insertions(+), 70 deletions(-)
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in.orig 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.

116
gcc44-textdomain.patch Normal file
View File

@ -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
}
}

78
gcc48-bsc1161913.patch Normal file
View File

@ -0,0 +1,78 @@
commit 5c8a1211b9873a1b69ef7b2fddae181535bc3b0a
Author: Vladimir N. Makarov <vmakarov@redhat.com>
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 <vmakarov@redhat.com>
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;

View File

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

View File

@ -0,0 +1,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 <gmp.h>
#include <mpfr.h>],[
- #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 <gmp.h>
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;
}

View File

@ -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,

View File

@ -0,0 +1,993 @@
From 04553281f42e5c4340d554a93d1a73006365d8fb Mon Sep 17 00:00:00 2001
From: Richard Sandiford <richard.sandiford@arm.com>
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 <richard.sandiford@arm.com>
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 <richard.sandiford@arm.com>
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 <richard.sandiford@arm.com>
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 <richard.sandiford@arm.com>
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 <richard.sandiford@arm.com>
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 <richard.sandiford@arm.com>
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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,193 @@
Backport to gcc7 of the below commit for bsc#1172798
commit 20da13e395bde597d8337167c712039c8f923c3b
Author: Matthew Malcomson <matthew.malcomson@arm.com>
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 <matthew.malcomson@arm.com>
* 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

View File

@ -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 <matthew.malcomson@arm.com>
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 "*cb<optab><mode>1"
@@ -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
+# <http://www.gnu.org/licenses/>. */
+
+# 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

View File

@ -0,0 +1,578 @@
Backport of below commit for bsc#1172798
commit 2155170525f93093b90a1a065e7ed71a925566e9
Author: Matthew Malcomson <matthew.malcomson@arm.com>
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<N>` for register x<N>.
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
<speculation barrier>
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]?} } } */

View File

@ -0,0 +1,63 @@
From 6787268a289bdbc32920b13b4697eaf756f9f7e0 Mon Sep 17 00:00:00 2001
From: Richard Sandiford <richard.sandiford@arm.com>
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

51
gcc7-ada-MINSTKSZ.patch Normal file
View File

@ -0,0 +1,51 @@
From 331763de7d4850702a0f67298f36017c73cdb103 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
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

View File

@ -0,0 +1,44 @@
From 9467e7331188705ec16c086b77e1809c5b0aab7d Mon Sep 17 00:00:00 2001
From: Richard Biener <rguenther@suse.de>
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 <rguenther@suse.de>
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 <types.h> 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

View File

@ -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}`; \

226
gcc7-bsc1146475.patch Normal file
View File

@ -0,0 +1,226 @@
2019-10-01 Alexandre Oliva <oliva@adacore.com>
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);

72
gcc7-bsc1160086.patch Normal file
View File

@ -0,0 +1,72 @@
2019-12-17 Andreas Krebbel <krebbel@linux.ibm.com>
Backport from mainline
2019-12-16 Andreas Krebbel <krebbel@linux.ibm.com>
PR target/92950
* config/s390/vector.md ("mov<mode>" 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<mode>"
- [(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<mode>"
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<mode>"
[(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")

13
gcc7-bsc1216488.patch Normal file
View File

@ -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);

View File

@ -0,0 +1,260 @@
Backport of the below
commit db489777bb0185e64cf4b9b8c7afed4dcc6669bd
Author: Thomas Preud'homme <thomas.preudhomme@arm.com>
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 <thomas.preudhomme@arm.com>
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"

662
gcc7-flive-patching.patch Normal file
View File

@ -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" } } */

View File

@ -0,0 +1,35 @@
From f35d65517a59565758107c5b1a51a5fa382f8d1a Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor <iant@golang.org>
Date: Tue, 12 Jul 2022 19:42:43 -0700
Subject: [PATCH] libgo: don't include <linux/fs.h> 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 <linux/ether.h>
#endif
-#if defined(HAVE_LINUX_FS_H)
-#include <linux/fs.h>
-#endif
#if defined(HAVE_LINUX_REBOOT_H)
#include <linux/reboot.h>
#endif
--
2.37.2

View File

@ -0,0 +1,39 @@
From 2701442d0cf6292f6624443c15813d6d1a3562fe Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Mon, 11 Jul 2022 22:03:14 +0200
Subject: [PATCH] libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> 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 <sys/vt.h>
#include <linux/cdrom.h>
#include <linux/fd.h>
+#if SANITIZER_ANDROID
#include <linux/fs.h>
+#endif
#include <linux/hdreg.h>
#include <linux/input.h>
#include <linux/ioctl.h>
@@ -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;

47
gcc7-lra-elim.patch Normal file
View File

@ -0,0 +1,47 @@
From 9cd11fd48509234e18122036bf504981f5a91b9a Mon Sep 17 00:00:00 2001
From: Richard Sandiford <richard.sandiford@arm.com>
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

View File

@ -0,0 +1,555 @@
From 1258c4f8a08681cce523c40352a37584f9ba63bd Mon Sep 17 00:00:00 2001
From: Torsten Duwe <duwe@suse.de>
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 <gbelinassi@suse.de>
Backport from mainline
2017-07-07 Torsten Duwe <duwe@suse.de>
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

View File

@ -0,0 +1,53 @@
From c375b71b3f7e6801a5e5a10275b1a0e405f0ab6a Mon Sep 17 00:00:00 2001
From: Tom de Vries <tom@codesourcery.com>
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 <gbelinassi@suse.de>
2017-08-03 Tom de Vries <tom@codesourcery.com>
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

View File

@ -0,0 +1,61 @@
From cbc0c2840906ad6fee93a7423a0212713949e90e Mon Sep 17 00:00:00 2001
From: Tom de Vries <tom@codesourcery.com>
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 <gbelinassi@suse.de>
Backport from mainline
2017-08-03 Tom de Vries <tom@codesourcery.com>
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

View File

@ -0,0 +1,63 @@
From 96c0b9515d054bdc339bc379610a9c6b383b5977 Mon Sep 17 00:00:00 2001
From: Uros Bizjak <ubizjak@gmail.com>
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 <gbelinassi@suse.de>
Backport from mainline
2017-08-16 Uros Bizjak <ubizjak@gmail.com>
* 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

View File

@ -0,0 +1,66 @@
From 73fddef0fed58c74a8d6bcd40c632f1b31a23108 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
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 <gbelinassi@suse.de>
Backport from mainline
2018-01-16 Eric Botcazou <ebotcazou@adacore.com>
* 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

View File

@ -0,0 +1,387 @@
From 93132e0ab8aacedc740513c8e3d4ffd3bb0b8db7 Mon Sep 17 00:00:00 2001
From: Andreas Krebbel <krebbel@linux.vnet.ibm.com>
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 <gbelinassi@suse.de>
Backport from mainline
gcc/ChangeLog:
2018-04-06 Andreas Krebbel <krebbel@linux.vnet.ibm.com>
* 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 <krebbel@linux.vnet.ibm.com>
* 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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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 <stdio.h>
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

View File

@ -0,0 +1,60 @@
From 74d2c825af4a197de0aecbaadb66f5ad6d65cbdb Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
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 <gbelinassi@suse.de>
Backport from mainline
2018-11-08 Jozef Lawrynowicz <jozef.l@mittosystems.com>
* 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

View File

@ -0,0 +1,205 @@
From c3982f5bddf56bbc96d838ea35540eae81504bb3 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
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 <gbelinassi@suse.de>
Backport from mainline
2018-11-16 Jozef Lawrynowicz <jozef.l@mittosystems.com>
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

View File

@ -0,0 +1,70 @@
From 7e12d4ef76f860574dd7a822522238bdec2687d3 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
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 <gbelinassi@suse.de>
Backport from mainline
2018-12-10 Eric Botcazou <ebotcazou@adacore.com>
* 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

View File

@ -0,0 +1,60 @@
From 7314f1ac164bde51f43dd1c96fe2f1e7be5dfe77 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
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 <gbelinassi@suse.de>
Backport from mainline
2019-02-15 Eric Botcazou <ebotcazou@adacore.com>
* 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

View File

@ -0,0 +1,57 @@
From 030d757e6f0f86b5f899737ab2fe73261a759dc7 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
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 <gbelinassi@suse.de>
Backport from mainline
2019-02-16 Eric Botcazou <ebotcazou@adacore.com>
* 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

View File

@ -0,0 +1,153 @@
From dd42709efc288ce501b52d95b8ef0d05713a07f6 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
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 <gbelinassi@suse.de>
Backport from mainline
2019-04-12 Jakub Jelinek <jakub@redhat.com>
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 <gbelinassi@suse.de>
Backport of mainline
2019-04-12 Jakub Jelinek <jakub@redhat.com>
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 <gbelinassi@suse.de>
Backport from mainline
2019-04-12 Jakub Jelinek <jakub@redhat.com>
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

View File

@ -0,0 +1,36 @@
From 2d35914acc611b8780c52c2e6df78d56da37a61d Mon Sep 17 00:00:00 2001
From: Joao Moreira <jmoreira@suse.de>
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 <gbelinassi@suse.de>
Backport from mainline
2019-04-10 Joao Moreira <jmoreira@suse.de>
* 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

View File

@ -0,0 +1,34 @@
From e469ad6db5edd55f07cbf1ba5b4a49e2e9c7c72b Mon Sep 17 00:00:00 2001
From: Fangrui Song <maskray@google.com>
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 <gbelinassi@suse.de>
Backport from mainline
2020-01-20 Fangrui Song <maskray@google.com>
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

View File

@ -0,0 +1,43 @@
From 770fcd0a31f3d557e5c79004161fa4c14fdaeced Mon Sep 17 00:00:00 2001
From: Andrew Pinski <apinski@marvell.com>
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 <gbelinassi@suse.de>
Backport from mainline
2020-01-20 Andrew Pinski <apinski@marvell.com>
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

View File

@ -0,0 +1,38 @@
From 3775c56f07ebfba1155721bdaa948a71e26df6b0 Mon Sep 17 00:00:00 2001
From: Andrew Pinski <apinski@marvell.com>
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 <gbelinassi@suse.de>
Backport from mainline
2020-01-22 Andrew Pinski <apinski@marvell.com>
* 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

View File

@ -0,0 +1,249 @@
From 961670bae0c7b37073dbc0bb58d730d1ed603d5d Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
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

View File

@ -0,0 +1,66 @@
From 269286fbce10ce33e07a11f9abab60c74ba84e33 Mon Sep 17 00:00:00 2001
From: Hans-Peter Nilsson <hp@bitrange.com>
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

View File

@ -0,0 +1,973 @@
From 8ef0203090dab33a177f0b45f6bf69246047e463 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
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 <stdlib.h>
+ #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

View File

@ -0,0 +1,88 @@
From 686af21802e691f3b08cc45a5cb2c961b9676675 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
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 <linux/init.h> 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 <jakub@redhat.com>
* 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

View File

@ -0,0 +1,198 @@
From 8e8d2277ff4a6d22467736de3acabaedd0a3a003 Mon Sep 17 00:00:00 2001
From: Jakub Jelinek <jakub@redhat.com>
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 <gbelinassi@suse.de>
Backport from mainline
2021-04-03 Jakub Jelinek <jakub@redhat.com>
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

View File

@ -0,0 +1,355 @@
From e534bd23ac8d259768d67db6f876f75687b109e7 Mon Sep 17 00:00:00 2001
From: Giuliano Belinassi <gbelinassi@suse.de>
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 <matz@suse.de>
* 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 <gbelinassi@suse.de>
Backport from mainline
2020-02-03 H.J. Lu <hjl.tools@gmail.com>
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 <matz@suse.de>
---
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 <matz@suse.de>
+
+ * 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

117
gcc7-pr55917.patch Normal file
View File

@ -0,0 +1,117 @@
From 754d67d5ba4a1f9994210d402893a4cf49ce6a71 Mon Sep 17 00:00:00 2001
From: Jonathan Wakely <jwakely@redhat.com>
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<thread::_State*>(__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
+// <http://www.gnu.org/licenses/>.
+
+// { 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 <thread>
+#include <exception>
+#include <cstdlib>
+
+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

109
gcc7-pr72764.patch Normal file
View File

@ -0,0 +1,109 @@
From cffc4a68d759fdca588cdf9ece998862b76141e6 Mon Sep 17 00:00:00 2001
From: Jason Merrill <jason@redhat.com>
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<tree_node>
static GTY (()) hash_table<typename_hasher> *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

155
gcc7-pr78263.patch Normal file
View File

@ -0,0 +1,155 @@
From e756e900e911fdbc57cd76d6c12d20a9b1892e55 Mon Sep 17 00:00:00 2001
From: Bill Schmidt <wschmidt@linux.ibm.com>
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 <wschmidt@linux.ibm.com>
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 <wschmidt@linux.ibm.com>
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 <wschmidt@linux.ibm.com>
#+
#+ PR target/78263
#+ * config/rs6000/altivec.h: Don't #define vector, pixel, bool for
#+ C++ with strict ANSI requirements.
#+
# 2019-06-04 Marc Glisse <marc.glisse@inria.fr>
#
# * 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 <wschmidt@linux.ibm.com>
#+
#+ 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 <jakub@redhat.com>
#
# * 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
+# <http://www.gnu.org/licenses/>. */
+
+# 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 <altivec.h>
+
+bool foo (int x)
+{
+ return x == 2;
+}
+
--
2.27.0

116
gcc7-pr81942.patch Normal file
View File

@ -0,0 +1,116 @@
From d49318d9bc3e63251aada27b322e7756eab19884 Mon Sep 17 00:00:00 2001
From: Paolo Carlini <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
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 <paolo.carlini@oracle.com>
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;

13
gcc7-pr82248.diff Normal file
View File

@ -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"

28
gcc7-pr85887.patch Normal file
View File

@ -0,0 +1,28 @@
2019-10-22 Jakub Jelinek <jakub@redhat.com>
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);

81
gcc7-pr87723.patch Normal file
View File

@ -0,0 +1,81 @@
From 8c21b0d164f33d9d47acc26f4f9b99b53e3b1945 Mon Sep 17 00:00:00 2001
From: Andreas Krebbel <krebbel@linux.ibm.com>
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 <krebbel@linux.ibm.com>
PR target/87723
* config/s390/s390.md ("*r<noxa>sbg_di_rotl"): Remove mode
attributes for operands 3 and 4.
gcc/testsuite/ChangeLog:
2018-11-06 Andreas Krebbel <krebbel@linux.ibm.com>
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"
- "r<noxa>sbg\t%0,%1,%<bfstart>2,%<bfend>2,%b3"
+ "r<noxa>sbg\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

View File

@ -0,0 +1,141 @@
From 874b0e7d0c16653beeed2ce8d92363cc0c1580cd Mon Sep 17 00:00:00 2001
From: Martin Jambor <mjambor@suse.cz>
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 <jh@suse.cz>
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 <jh@suse.cz>
Martin Jambor <mjambor@suse.cz>
* 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=<number> Limit diagnostics to <number> 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

149
gcc7-pr88522.patch Normal file
View File

@ -0,0 +1,149 @@
backport: re PR target/88522 (Error: operand size mismatch for `vpgatherqq')
Backported from mainline
2018-12-21 Jakub Jelinek <jakub@redhat.com>
PR target/88522
* config/i386/sse.md (*avx512pf_gatherpf<mode>sf_mask,
*avx512pf_gatherpf<mode>df_mask, *avx512pf_scatterpf<mode>sf_mask,
*avx512pf_scatterpf<mode>df_mask): Use %X5 instead of %5 for
-masm=intel.
(gatherq_mode): Remove mode iterator.
(*avx512f_gathersi<mode>, *avx512f_gathersi<mode>_2): Use X instead
of <xtg_mode>.
(*avx512f_gatherdi<mode>): Use X instead of <gatherq_mode>.
(*avx512f_gatherdi<mode>_2, *avx512f_scattersi<mode>,
*avx512f_scatterdi<mode>): 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 "%M2vgatherpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vgatherpf0<ssemodesuffix>ps\t{%5%{%0%}|%X5%{%0%}}";
case 2:
- return "%M2vgatherpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vgatherpf1<ssemodesuffix>ps\t{%5%{%0%}|%X5%{%0%}}";
default:
gcc_unreachable ();
}
@@ -16084,9 +16084,9 @@
switch (INTVAL (operands[4]))
{
case 3:
- return "%M2vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vgatherpf0<ssemodesuffix>pd\t{%5%{%0%}|%X5%{%0%}}";
case 2:
- return "%M2vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vgatherpf1<ssemodesuffix>pd\t{%5%{%0%}|%X5%{%0%}}";
default:
gcc_unreachable ();
}
@@ -16130,10 +16130,10 @@
{
case 3:
case 7:
- return "%M2vscatterpf0<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vscatterpf0<ssemodesuffix>ps\t{%5%{%0%}|%X5%{%0%}}";
case 2:
case 6:
- return "%M2vscatterpf1<ssemodesuffix>ps\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vscatterpf1<ssemodesuffix>ps\t{%5%{%0%}|%X5%{%0%}}";
default:
gcc_unreachable ();
}
@@ -16177,10 +16177,10 @@
{
case 3:
case 7:
- return "%M2vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vscatterpf0<ssemodesuffix>pd\t{%5%{%0%}|%X5%{%0%}}";
case 2:
case 6:
- return "%M2vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%5%{%0%}}";
+ return "%M2vscatterpf1<ssemodesuffix>pd\t{%5%{%0%}|%X5%{%0%}}";
default:
gcc_unreachable ();
}
@@ -19180,12 +19180,6 @@
(set_attr "prefix" "vex")
(set_attr "mode" "<sseinsnmode>")])
-;; 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 "<avx512>_gathersi<mode>"
[(parallel [(set (match_operand:VI48F 0 "register_operand")
(unspec:VI48F
@@ -19219,7 +19213,7 @@
UNSPEC_GATHER))
(clobber (match_scratch:<avx512fmaskmode> 2 "=&Yk"))]
"TARGET_AVX512F"
- "%M4v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %<xtg_mode>6}"
+ "%M4v<sseintprefix>gatherd<ssemodesuffix>\t{%6, %0%{%2%}|%0%{%2%}, %X6}"
[(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
(set_attr "mode" "<sseinsnmode>")])
@@ -19238,7 +19232,7 @@
UNSPEC_GATHER))
(clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
"TARGET_AVX512F"
- "%M3v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<xtg_mode>5}"
+ "%M3v<sseintprefix>gatherd<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %X5}"
[(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
(set_attr "mode" "<sseinsnmode>")])
@@ -19278,7 +19272,7 @@
(clobber (match_scratch:QI 2 "=&Yk"))]
"TARGET_AVX512F"
{
- return "%M4v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %<gatherq_mode>6}";
+ return "%M4v<sseintprefix>gatherq<ssemodesuffix>\t{%6, %1%{%2%}|%1%{%2%}, %X6}";
}
[(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
@@ -19302,11 +19296,11 @@
if (<MODE>mode != <VEC_GATHER_SRCDI>mode)
{
if (<MODE_SIZE> != 64)
- return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%x0%{%1%}, %<gatherq_mode>5}";
+ return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %x0%{%1%}|%x0%{%1%}, %X5}";
else
- return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %t5}";
+ return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %t0%{%1%}|%t0%{%1%}, %X5}";
}
- return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %<gatherq_mode>5}";
+ return "%M3v<sseintprefix>gatherq<ssemodesuffix>\t{%5, %0%{%1%}|%0%{%1%}, %X5}";
}
[(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
@@ -19343,7 +19337,7 @@
UNSPEC_SCATTER))
(clobber (match_scratch:<avx512fmaskmode> 1 "=&Yk"))]
"TARGET_AVX512F"
- "%M0v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}"
+ "%M0v<sseintprefix>scatterd<ssemodesuffix>\t{%3, %5%{%1%}|%X5%{%1%}, %3}"
[(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
(set_attr "mode" "<sseinsnmode>")])
@@ -19379,11 +19373,7 @@
UNSPEC_SCATTER))
(clobber (match_scratch:QI 1 "=&Yk"))]
"TARGET_AVX512F"
-{
- if (GET_MODE_SIZE (GET_MODE_INNER (<MODE>mode)) == 8)
- return "%M0v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%5%{%1%}, %3}";
- return "%M0v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%t5%{%1%}, %3}";
-}
+ "%M0v<sseintprefix>scatterq<ssemodesuffix>\t{%3, %5%{%1%}|%X5%{%1%}, %3}"
[(set_attr "type" "ssemov")
(set_attr "prefix" "evex")
(set_attr "mode" "<sseinsnmode>")])

68
gcc7-pr89124.patch Normal file
View File

@ -0,0 +1,68 @@
From 9d983fd1b9611631fdd5efd26b3b7bdc1ab6dc24 Mon Sep 17 00:00:00 2001
From: Martin Jambor <mjambor@suse.cz>
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 <jakub@redhat.com>
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 <jakub@redhat.com>
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

56
gcc7-pr92154.patch Normal file
View File

@ -0,0 +1,56 @@
2019-11-26 Jakub Jelinek <jakub@redhat.com>
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)

139
gcc7-pr92692.patch Normal file
View File

@ -0,0 +1,139 @@
Backported to gcc7 from:
From: Wilco Dijkstra <wdijkstr@arm.com>
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<mode>)
Use epilogue_completed rather than reload_completed.
(aarch64_atomic_exchange<mode>): Likewise.
(aarch64_atomic_<atomic_optab><mode>): Likewise.
(atomic_nand<mode>): Likewise.
(aarch64_atomic_fetch_<atomic_optab><mode>): Likewise.
(atomic_fetch_nand<mode>): Likewise.
(aarch64_atomic_<atomic_optab>_fetch<mode>): Likewise.
(atomic_nand_fetch<mode>): 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 (<CODE>, 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 (<CODE>, 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 (<CODE>, 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],

128
gcc7-pr93246.patch Normal file
View File

@ -0,0 +1,128 @@
commit 20e9d78543493f2f6aeef19af4cea54696247fc8
Author: Richard Biener <rguenther@suse.de>
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 <rguenther@suse.de>
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 <typename = void> 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 <typename WrappedType> 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<Optional<>> wo = {&buf};
+ wo->set_present();
+ auto x = wo->is_present();
+ if (!x)
+ __builtin_abort ();
+}

41
gcc7-pr93888.patch Normal file
View File

@ -0,0 +1,41 @@
commit 64ba6d17022eeb65f56f0b141c2640f9ab938f97
Author: Jakub Jelinek <jakub@redhat.com>
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 <jakub@redhat.com>
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);
}

44
gcc7-pr93965.patch Normal file
View File

@ -0,0 +1,44 @@
From 08bf7bde9f2987b1c623d272cc71fc14a1622442 Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
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

140
gcc7-pr94148.patch Normal file
View File

@ -0,0 +1,140 @@
commit 5c7e6d4bdf879b437b43037e10453275acabf521
Author: Segher Boessenkool <segher@kernel.crashing.org>
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<int> &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<int> &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<int> last_visit_age = vNULL;
+ vec<int> 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)

23
gcc7-pr97535.patch Normal file
View File

@ -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

View File

@ -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. */

19
gcc7-rpmlintrc Normal file
View File

@ -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")

View File

@ -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 <sys/procfs.h>
#endif
#include <sys/user.h>
-#include <linux/cyclades.h>
#include <linux/if_eql.h>
#include <linux/if_plip.h>
#include <linux/lp.h>
@@ -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;

111
gcc7-stack-probe.diff Normal file
View File

@ -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

Some files were not shown because too many files have changed in this diff Show More