summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc')
-rw-r--r--meta/recipes-devtools/gcc/gcc-10.2.inc120
-rw-r--r--meta/recipes-devtools/gcc/gcc-13.2.inc119
-rw-r--r--meta/recipes-devtools/gcc/gcc-common.inc23
-rw-r--r--meta/recipes-devtools/gcc/gcc-configure-common.inc24
-rw-r--r--meta/recipes-devtools/gcc/gcc-cross-canadian.inc34
-rw-r--r--meta/recipes-devtools/gcc/gcc-cross-canadian_13.2.bb (renamed from meta/recipes-devtools/gcc/gcc-cross-canadian_10.2.bb)0
-rw-r--r--meta/recipes-devtools/gcc/gcc-cross.inc21
-rw-r--r--meta/recipes-devtools/gcc/gcc-cross_13.2.bb (renamed from meta/recipes-devtools/gcc/gcc-cross_10.2.bb)0
-rw-r--r--meta/recipes-devtools/gcc/gcc-crosssdk.inc6
-rw-r--r--meta/recipes-devtools/gcc/gcc-crosssdk_13.2.bb (renamed from meta/recipes-devtools/gcc/gcc-crosssdk_10.2.bb)0
-rw-r--r--meta/recipes-devtools/gcc/gcc-multilib-config.inc34
-rw-r--r--meta/recipes-devtools/gcc/gcc-runtime.inc168
-rw-r--r--meta/recipes-devtools/gcc/gcc-runtime_13.2.bb (renamed from meta/recipes-devtools/gcc/gcc-runtime_10.2.bb)0
-rw-r--r--meta/recipes-devtools/gcc/gcc-sanitizers.inc66
-rw-r--r--meta/recipes-devtools/gcc/gcc-sanitizers_13.2.bb (renamed from meta/recipes-devtools/gcc/gcc-sanitizers_10.2.bb)4
-rw-r--r--meta/recipes-devtools/gcc/gcc-shared-source.inc10
-rw-r--r--meta/recipes-devtools/gcc/gcc-source.inc10
-rw-r--r--meta/recipes-devtools/gcc/gcc-source_13.2.bb (renamed from meta/recipes-devtools/gcc/gcc-source_10.2.bb)0
-rw-r--r--meta/recipes-devtools/gcc/gcc-target.inc68
-rw-r--r--meta/recipes-devtools/gcc/gcc-testsuite.inc9
-rw-r--r--meta/recipes-devtools/gcc/gcc/0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch66
-rw-r--r--meta/recipes-devtools/gcc/gcc/0001-aarch64-New-Straight-Line-Speculation-SLS-mitigation.patch202
-rw-r--r--meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch10
-rw-r--r--meta/recipes-devtools/gcc/gcc/0001-libatomic-libgomp-libitc-Fix-bootstrap-PR70454.patch208
-rw-r--r--meta/recipes-devtools/gcc/gcc/0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch607
-rw-r--r--meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch140
-rw-r--r--meta/recipes-devtools/gcc/gcc/0003-64-bit-multilib-hack.patch (renamed from meta/recipes-devtools/gcc/gcc/0004-64-bit-multilib-hack.patch)123
-rw-r--r--meta/recipes-devtools/gcc/gcc/0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch658
-rw-r--r--meta/recipes-devtools/gcc/gcc/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch70
-rw-r--r--meta/recipes-devtools/gcc/gcc/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch64
-rw-r--r--meta/recipes-devtools/gcc/gcc/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch (renamed from meta/recipes-devtools/gcc/gcc/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch)24
-rw-r--r--meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch122
-rw-r--r--meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch35
-rw-r--r--meta/recipes-devtools/gcc/gcc/0006-cpp-honor-sysroot.patch (renamed from meta/recipes-devtools/gcc/gcc/0009-cpp-honor-sysroot.patch)28
-rw-r--r--meta/recipes-devtools/gcc/gcc/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch (renamed from meta/recipes-devtools/gcc/gcc/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch)238
-rw-r--r--meta/recipes-devtools/gcc/gcc/0008-fortran-cross-compile-hack.patch43
-rw-r--r--meta/recipes-devtools/gcc/gcc/0008-libtool.patch (renamed from meta/recipes-devtools/gcc/gcc/0014-libtool.patch)5
-rw-r--r--meta/recipes-devtools/gcc/gcc/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch (renamed from meta/recipes-devtools/gcc/gcc/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch)11
-rw-r--r--meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch54
-rw-r--r--meta/recipes-devtools/gcc/gcc/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch (renamed from meta/recipes-devtools/gcc/gcc/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch)14
-rw-r--r--meta/recipes-devtools/gcc/gcc/0011-aarch64-Fix-include-paths-when-S-B.patch55
-rw-r--r--meta/recipes-devtools/gcc/gcc/0012-Avoid-using-libdir-from-.la-which-usually-points-to-.patch (renamed from meta/recipes-devtools/gcc/gcc/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch)2
-rw-r--r--meta/recipes-devtools/gcc/gcc/0012-gcc-Fix-argument-list-too-long-error.patch41
-rw-r--r--meta/recipes-devtools/gcc/gcc/0013-Disable-sdt.patch110
-rw-r--r--meta/recipes-devtools/gcc/gcc/0013-Ensure-target-gcc-headers-can-be-included.patch113
-rw-r--r--meta/recipes-devtools/gcc/gcc/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch (renamed from meta/recipes-devtools/gcc/gcc/0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch)2
-rw-r--r--meta/recipes-devtools/gcc/gcc/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch (renamed from meta/recipes-devtools/gcc/gcc/0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch)10
-rw-r--r--meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch (renamed from meta/recipes-devtools/gcc/gcc/0024-handle-sysroot-support-for-nativesdk-gcc.patch)263
-rw-r--r--meta/recipes-devtools/gcc/gcc/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch (renamed from meta/recipes-devtools/gcc/gcc/0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch)19
-rw-r--r--meta/recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch (renamed from meta/recipes-devtools/gcc/gcc/0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch)16
-rw-r--r--meta/recipes-devtools/gcc/gcc/0018-export-CPP.patch50
-rw-r--r--meta/recipes-devtools/gcc/gcc/0019-Ensure-target-gcc-headers-can-be-included.patch57
-rw-r--r--meta/recipes-devtools/gcc/gcc/0019-Re-introduce-spe-commandline-options.patch (renamed from meta/recipes-devtools/gcc/gcc/0033-Re-introduce-spe-commandline-options.patch)13
-rw-r--r--meta/recipes-devtools/gcc/gcc/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch (renamed from meta/recipes-devtools/gcc/gcc/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch)34
-rw-r--r--meta/recipes-devtools/gcc/gcc/0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch26
-rw-r--r--meta/recipes-devtools/gcc/gcc/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch (renamed from meta/recipes-devtools/gcc/gcc/0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch)72
-rw-r--r--meta/recipes-devtools/gcc/gcc/0022-aarch64-Add-support-for-musl-ldso.patch25
-rw-r--r--meta/recipes-devtools/gcc/gcc/0022-libatomic-Do-not-enforce-march-on-aarch64.patch (renamed from meta/recipes-devtools/gcc/gcc/0037-libatomic-Do-not-enforce-march-on-aarch64.patch)18
-rw-r--r--meta/recipes-devtools/gcc/gcc/0023-Fix-install-path-of-linux64.h.patch31
-rw-r--r--meta/recipes-devtools/gcc/gcc/0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch28
-rw-r--r--meta/recipes-devtools/gcc/gcc/0025-gcc-testsuite-tweaks-for-mips-OE.patch233
-rw-r--r--meta/recipes-devtools/gcc/gcc/0026-Fix-various-_FOR_BUILD-and-related-variables.patch134
-rw-r--r--meta/recipes-devtools/gcc/gcc/0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch117
-rw-r--r--meta/recipes-devtools/gcc/gcc/0027-Fix-gcc-vect-module-testcases.patch26
-rw-r--r--meta/recipes-devtools/gcc/gcc/0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch25
-rw-r--r--meta/recipes-devtools/gcc/gcc/0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch26
-rw-r--r--meta/recipes-devtools/gcc/gcc/0030-sync-gcc-stddef.h-with-musl.patch88
-rw-r--r--meta/recipes-devtools/gcc/gcc/0031-fix-segmentation-fault-in-precompiled-header-generat.patch57
-rw-r--r--meta/recipes-devtools/gcc/gcc/0032-Fix-for-testsuite-failure.patch255
-rw-r--r--meta/recipes-devtools/gcc/gcc/0036-mingw32-Enable-operation_not_supported.patch26
-rw-r--r--meta/recipes-devtools/gcc/gcc/CVE-2023-4039.patch3093
-rw-r--r--meta/recipes-devtools/gcc/gcc_13.2.bb (renamed from meta/recipes-devtools/gcc/gcc_10.2.bb)10
-rw-r--r--meta/recipes-devtools/gcc/libgcc-common.inc23
-rw-r--r--meta/recipes-devtools/gcc/libgcc-initial.inc6
-rw-r--r--meta/recipes-devtools/gcc/libgcc-initial_13.2.bb (renamed from meta/recipes-devtools/gcc/libgcc-initial_10.2.bb)2
-rw-r--r--meta/recipes-devtools/gcc/libgcc.inc12
-rw-r--r--meta/recipes-devtools/gcc/libgcc_13.2.bb (renamed from meta/recipes-devtools/gcc/libgcc_10.2.bb)4
-rw-r--r--meta/recipes-devtools/gcc/libgfortran.inc19
-rw-r--r--meta/recipes-devtools/gcc/libgfortran_13.2.bb (renamed from meta/recipes-devtools/gcc/libgfortran_10.2.bb)0
79 files changed, 4933 insertions, 3646 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-10.2.inc b/meta/recipes-devtools/gcc/gcc-10.2.inc
deleted file mode 100644
index c0cd8b31d5..0000000000
--- a/meta/recipes-devtools/gcc/gcc-10.2.inc
+++ /dev/null
@@ -1,120 +0,0 @@
1require gcc-common.inc
2
3# Third digit in PV should be incremented after a minor release
4
5PV = "10.2.0"
6
7# BINV should be incremented to a revision after a minor gcc release
8
9BINV = "10.2.0"
10
11FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc:${FILE_DIRNAME}/gcc/backport:"
12
13DEPENDS =+ "mpfr gmp libmpc zlib flex-native"
14NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native flex-native"
15
16LICENSE = "GPL-3.0-with-GCC-exception & GPLv3"
17
18LIC_FILES_CHKSUM = "\
19 file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \
20 file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \
21 file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \
22 file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \
23 file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \
24"
25
26BASEURI ?= "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.xz"
27#RELEASE ?= "93a49d2d2292893b9b7f38132df949c70942838c"
28#BASEURI ?= "https://github.com/gcc-mirror/gcc/archive/${RELEASE}.zip;downloadfilename=gcc-${PV}-${RELEASE}.zip"
29SRC_URI = "\
30 ${BASEURI} \
31 file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \
32 file://0002-gcc-poison-system-directories.patch \
33 file://0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch \
34 file://0004-64-bit-multilib-hack.patch \
35 file://0005-optional-libstdc.patch \
36 file://0006-COLLECT_GCC_OPTIONS.patch \
37 file://0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
38 file://0008-fortran-cross-compile-hack.patch \
39 file://0009-cpp-honor-sysroot.patch \
40 file://0010-MIPS64-Default-to-N64-ABI.patch \
41 file://0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
42 file://0012-gcc-Fix-argument-list-too-long-error.patch \
43 file://0013-Disable-sdt.patch \
44 file://0014-libtool.patch \
45 file://0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \
46 file://0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch \
47 file://0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \
48 file://0018-export-CPP.patch \
49 file://0019-Ensure-target-gcc-headers-can-be-included.patch \
50 file://0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch \
51 file://0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch \
52 file://0022-aarch64-Add-support-for-musl-ldso.patch \
53 file://0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch \
54 file://0024-handle-sysroot-support-for-nativesdk-gcc.patch \
55 file://0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch \
56 file://0026-Fix-various-_FOR_BUILD-and-related-variables.patch \
57 file://0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch \
58 file://0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \
59 file://0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch \
60 file://0030-sync-gcc-stddef.h-with-musl.patch \
61 file://0031-fix-segmentation-fault-in-precompiled-header-generat.patch \
62 file://0032-Fix-for-testsuite-failure.patch \
63 file://0033-Re-introduce-spe-commandline-options.patch \
64 file://0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \
65 file://0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \
66 file://0036-mingw32-Enable-operation_not_supported.patch \
67 file://0037-libatomic-Do-not-enforce-march-on-aarch64.patch \
68 file://0001-aarch64-New-Straight-Line-Speculation-SLS-mitigation.patch \
69 file://0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch \
70 file://0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch \
71 file://0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch \
72 file://0001-libatomic-libgomp-libitc-Fix-bootstrap-PR70454.patch \
73"
74SRC_URI[sha256sum] = "b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c"
75
76S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}"
77# For dev release snapshotting
78#S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${RELEASE}"
79#B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
80
81# Language Overrides
82FORTRAN = ""
83JAVA = ""
84
85SSP ?= "--disable-libssp"
86SSP_mingw32 = "--enable-libssp"
87
88EXTRA_OECONF_BASE = "\
89 ${SSP} \
90 --enable-libitm \
91 --enable-lto \
92 --disable-bootstrap \
93 --with-system-zlib \
94 ${@'--with-linker-hash-style=${LINKER_HASH_STYLE}' if '${LINKER_HASH_STYLE}' else ''} \
95 --enable-linker-build-id \
96 --with-ppl=no \
97 --with-cloog=no \
98 --enable-checking=release \
99 --enable-cheaders=c_global \
100 --without-isl \
101"
102
103EXTRA_OECONF_INITIAL = "\
104 --disable-libgomp \
105 --disable-libitm \
106 --disable-libquadmath \
107 --with-system-zlib \
108 --disable-lto \
109 --disable-plugin \
110 --enable-linker-build-id \
111 --enable-decimal-float=no \
112 --without-isl \
113 --disable-libssp \
114"
115
116EXTRA_OECONF_PATHS = "\
117 --with-gxx-include-dir=/not/exist{target_includedir}/c++/${BINV} \
118 --with-sysroot=/not/exist \
119 --with-build-sysroot=${STAGING_DIR_TARGET} \
120"
diff --git a/meta/recipes-devtools/gcc/gcc-13.2.inc b/meta/recipes-devtools/gcc/gcc-13.2.inc
new file mode 100644
index 0000000000..603377a49a
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc-13.2.inc
@@ -0,0 +1,119 @@
1require gcc-common.inc
2
3# Third digit in PV should be incremented after a minor release
4
5PV = "13.2.0"
6
7# BINV should be incremented to a revision after a minor gcc release
8
9BINV = "13.2.0"
10
11FILESEXTRAPATHS =. "${FILE_DIRNAME}/gcc:${FILE_DIRNAME}/gcc/backport:"
12
13DEPENDS =+ "mpfr gmp libmpc zlib zstd flex-native"
14NATIVEDEPS = "mpfr-native gmp-native libmpc-native zlib-native flex-native zstd-native"
15
16LICENSE = "GPL-3.0-with-GCC-exception & GPL-3.0-only"
17
18LIC_FILES_CHKSUM = "\
19 file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552 \
20 file://COPYING3;md5=d32239bcb673463ab874e80d47fae504 \
21 file://COPYING3.LIB;md5=6a6a8e020838b23406c81b19c1d46df6 \
22 file://COPYING.LIB;md5=2d5025d4aa3495befef8f17206a5b0a1 \
23 file://COPYING.RUNTIME;md5=fe60d87048567d4fe8c8a0ed2448bcc8 \
24"
25# snapshot from git
26#RELEASE ?= "9b6bf076c11cba0f9ccdace63e8b4044b1a858ea"
27#BASEURI ?= "https://git.linaro.org/toolchain/gcc.git/snapshot/gcc-${RELEASE}.tar.gz"
28#SOURCEDIR = "gcc-${RELEASE}"
29#BASEURI ?= "https://repo.or.cz/official-gcc.git/snapshot/${RELEASE}.tar.gz;downloadfilename=gcc-${PV}-${RELEASE}.tar.gz"
30#SOURCEDIR ?= "official-gcc-${@'${RELEASE}'[0:7]}"
31
32# from snapshot
33#RELEASE ?= "13-20230520"
34#SOURCEDIR ?= "gcc-${RELEASE}"
35#BASEURI ?= "https://gcc.gnu.org/pub/gcc/snapshots/${RELEASE}/gcc-${RELEASE}.tar.xz"
36
37# official release
38RELEASE ?= "${PV}"
39BASEURI ?= "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.xz"
40SOURCEDIR ?= "gcc-${PV}"
41
42SRC_URI = "${BASEURI} \
43 file://0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch \
44 file://0002-gcc-poison-system-directories.patch \
45 file://0003-64-bit-multilib-hack.patch \
46 file://0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch \
47 file://0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch \
48 file://0006-cpp-honor-sysroot.patch \
49 file://0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch \
50 file://0008-libtool.patch \
51 file://0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch \
52 file://0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch \
53 file://0011-aarch64-Fix-include-paths-when-S-B.patch \
54 file://0012-Avoid-using-libdir-from-.la-which-usually-points-to-.patch \
55 file://0013-Ensure-target-gcc-headers-can-be-included.patch \
56 file://0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch \
57 file://0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch \
58 file://0016-handle-sysroot-support-for-nativesdk-gcc.patch \
59 file://0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch \
60 file://0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch \
61 file://0019-Re-introduce-spe-commandline-options.patch \
62 file://0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch \
63 file://0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch \
64 file://0022-libatomic-Do-not-enforce-march-on-aarch64.patch \
65 file://0023-Fix-install-path-of-linux64.h.patch \
66 file://0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch \
67 file://0025-gcc-testsuite-tweaks-for-mips-OE.patch \
68 file://CVE-2023-4039.patch \
69 file://0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch \
70 file://0027-Fix-gcc-vect-module-testcases.patch \
71"
72SRC_URI[sha256sum] = "e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da"
73
74S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/${SOURCEDIR}"
75B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
76
77# Language Overrides
78FORTRAN = ""
79JAVA = ""
80
81SSP ?= "--disable-libssp"
82SSP:mingw32 = "--enable-libssp"
83
84EXTRA_OECONF_BASE = "\
85 ${SSP} \
86 --enable-libitm \
87 --enable-lto \
88 --disable-bootstrap \
89 --with-system-zlib \
90 ${@'--with-linker-hash-style=${LINKER_HASH_STYLE}' if '${LINKER_HASH_STYLE}' else ''} \
91 --enable-linker-build-id \
92 --with-ppl=no \
93 --with-cloog=no \
94 --enable-checking=release \
95 --enable-cheaders=c_global \
96 --without-isl \
97"
98
99EXTRA_OECONF_INITIAL = "\
100 --disable-libgomp \
101 --disable-libitm \
102 --disable-libquadmath \
103 --with-system-zlib \
104 --disable-lto \
105 --disable-plugin \
106 --enable-linker-build-id \
107 --enable-decimal-float=no \
108 --without-isl \
109 --disable-libssp \
110"
111
112EXTRA_OECONF_PATHS = "\
113 --with-gxx-include-dir=/not/exist{target_includedir}/c++/${BINV} \
114 --with-sysroot=/not/exist \
115 --with-build-sysroot=${STAGING_DIR_TARGET} \
116"
117
118CVE_STATUS[CVE-2021-37322] = "cpe-incorrect: Is a binutils 2.26 issue, not gcc"
119CVE_STATUS[CVE-2023-4039] = "fixed-version: Fixed via CVE-2023-4039.patch included here. Set the status explictly to deal with all recipes that share the gcc-source"
diff --git a/meta/recipes-devtools/gcc/gcc-common.inc b/meta/recipes-devtools/gcc/gcc-common.inc
index 629fa26dfe..5ac82b1b57 100644
--- a/meta/recipes-devtools/gcc/gcc-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-common.inc
@@ -11,8 +11,7 @@ CVE_PRODUCT = "gcc"
11inherit autotools gettext texinfo 11inherit autotools gettext texinfo
12 12
13BPN = "gcc" 13BPN = "gcc"
14COMPILERDEP = "virtual/${MLPREFIX}${TARGET_PREFIX}gcc:do_gcc_stash_builddir" 14COMPILERDEP = "virtual/${TARGET_PREFIX}gcc:do_gcc_stash_builddir"
15COMPILERDEP_class-nativesdk = "virtual/${TARGET_PREFIX}gcc-crosssdk:do_gcc_stash_builddir"
16 15
17python extract_stashed_builddir () { 16python extract_stashed_builddir () {
18 src = d.expand("${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir-${TARGET_SYS}") 17 src = d.expand("${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir-${TARGET_SYS}")
@@ -32,6 +31,16 @@ def get_gcc_float_setting(bb, d):
32 31
33get_gcc_float_setting[vardepvalue] = "${@get_gcc_float_setting(bb, d)}" 32get_gcc_float_setting[vardepvalue] = "${@get_gcc_float_setting(bb, d)}"
34 33
34def get_gcc_x86_64_arch_setting(bb, d):
35 import re
36 march = re.match(r'^.*-march=([^\s]*)', d.getVar('TUNE_CCARGS'))
37 if march:
38 return "--with-arch=%s " % march.group(1)
39 # The earliest supported x86-64 CPU
40 return "--with-arch=core2"
41
42get_gcc_x86_64_arch_setting[vardepvalue] = "${@get_gcc_x86_64_arch_setting(bb, d)}"
43
35def get_gcc_mips_plt_setting(bb, d): 44def get_gcc_mips_plt_setting(bb, d):
36 if d.getVar('TRANSLATED_TARGET_ARCH') in [ 'mips', 'mipsel' ] and bb.utils.contains('DISTRO_FEATURES', 'mplt', True, False, d): 45 if d.getVar('TRANSLATED_TARGET_ARCH') in [ 'mips', 'mipsel' ] and bb.utils.contains('DISTRO_FEATURES', 'mplt', True, False, d):
37 return "--with-mips-plt" 46 return "--with-mips-plt"
@@ -83,14 +92,10 @@ def get_tune_parameters(tune, d):
83 92
84get_tune_parameters[vardepsexclude] = "AVAILTUNES TUNE_CCARGS OVERRIDES TUNE_FEATURES BASE_LIB BASELIB TUNE_ARCH ABIEXTENSION TARGET_FPU TUNE_PKGARCH PACKAGE_EXTRA_ARCHS" 93get_tune_parameters[vardepsexclude] = "AVAILTUNES TUNE_CCARGS OVERRIDES TUNE_FEATURES BASE_LIB BASELIB TUNE_ARCH ABIEXTENSION TARGET_FPU TUNE_PKGARCH PACKAGE_EXTRA_ARCHS"
85 94
86DEBIANNAME_${MLPREFIX}libgcc = "libgcc1" 95DEBIANNAME:${MLPREFIX}libgcc = "libgcc1"
87 96
88MIRRORS =+ "\ 97MIRRORS =+ "\
89${GNU_MIRROR}/gcc ftp://gcc.gnu.org/pub/gcc/releases/ \n \ 98 ${GNU_MIRROR}/gcc https://gcc.gnu.org/pub/gcc/releases/ \
90${GNU_MIRROR}/gcc ftp://gd.tuwien.ac.at/gnu/gcc/ \n \
91${GNU_MIRROR}/gcc http://mirrors.rcn.net/pub/sourceware/gcc/releases/ \n \
92${GNU_MIRROR}/gcc http://gcc.get-software.com/releases/ \n \
93${GNU_MIRROR}/gcc http://gcc.get-software.com/releases/ \n \
94" 99"
95# 100#
96# Set some default values 101# Set some default values
@@ -100,7 +105,7 @@ BINV = "${PV}"
100#S = "${WORKDIR}/gcc-${PV}" 105#S = "${WORKDIR}/gcc-${PV}"
101S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}" 106S = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}"
102 107
103B = "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}" 108B ?= "${WORKDIR}/gcc-${PV}/build.${HOST_SYS}.${TARGET_SYS}"
104 109
105target_includedir ?= "${includedir}" 110target_includedir ?= "${includedir}"
106target_libdir ?= "${libdir}" 111target_libdir ?= "${libdir}"
diff --git a/meta/recipes-devtools/gcc/gcc-configure-common.inc b/meta/recipes-devtools/gcc/gcc-configure-common.inc
index a64c4caf00..dba25eb754 100644
--- a/meta/recipes-devtools/gcc/gcc-configure-common.inc
+++ b/meta/recipes-devtools/gcc/gcc-configure-common.inc
@@ -44,27 +44,27 @@ EXTRA_OECONF = "\
44 44
45# glibc version is a minimum controlling whether features are enabled. 45# glibc version is a minimum controlling whether features are enabled.
46# Doesn't need to track glibc exactly 46# Doesn't need to track glibc exactly
47EXTRA_OECONF_append_libc-glibc = " --with-glibc-version=2.28 " 47EXTRA_OECONF:append:libc-glibc = " --with-glibc-version=2.28 "
48 48
49# Set this here since GCC configure won't auto-detect and enable 49# Set this here since GCC configure won't auto-detect and enable
50# initfini-arry when cross compiling. 50# initfini-arry when cross compiling.
51EXTRA_OECONF_append = " --enable-initfini-array" 51EXTRA_OECONF:append = " --enable-initfini-array"
52 52
53export gcc_cv_collect2_libs = 'none required' 53export gcc_cv_collect2_libs = 'none required'
54# We need to set gcc_cv_collect2_libs else there is cross-compilation badness 54# We need to set gcc_cv_collect2_libs else there is cross-compilation badness
55# in the config.log files (which might not get generated until do_compile 55# in the config.log files (which might not get generated until do_compile
56# hence being missed by the insane do_configure check). 56# hence being missed by the insane do_configure check).
57 57
58EXTRA_OECONF_append_linux = " --enable-__cxa_atexit" 58EXTRA_OECONF:append:linux = " --enable-__cxa_atexit"
59 59
60EXTRA_OECONF_append_mips64 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 60EXTRA_OECONF:append:mips64 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
61EXTRA_OECONF_append_mips64el = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 61EXTRA_OECONF:append:mips64el = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
62EXTRA_OECONF_append_mips64n32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 62EXTRA_OECONF:append:mips64n32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
63EXTRA_OECONF_append_mips64eln32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64" 63EXTRA_OECONF:append:mips64eln32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
64EXTRA_OECONF_append_mipsisa32r6el = " --with-abi=32 --with-arch=mips32r6" 64EXTRA_OECONF:append:mipsisa32r6el = " --with-abi=32 --with-arch=mips32r6"
65EXTRA_OECONF_append_mipsisa32r6 = " --with-abi=32 --with-arch=mips32r6" 65EXTRA_OECONF:append:mipsisa32r6 = " --with-abi=32 --with-arch=mips32r6"
66EXTRA_OECONF_append_mipsisa64r6el = " --with-abi=64 --with-arch-64=mips64r6" 66EXTRA_OECONF:append:mipsisa64r6el = " --with-abi=64 --with-arch-64=mips64r6"
67EXTRA_OECONF_append_mipsisa64r6 = " --with-abi=64 --with-arch-64=mips64r6" 67EXTRA_OECONF:append:mipsisa64r6 = " --with-abi=64 --with-arch-64=mips64r6"
68 68
69EXTRA_OECONF_GCC_FLOAT ??= "" 69EXTRA_OECONF_GCC_FLOAT ??= ""
70CPPFLAGS = "" 70CPPFLAGS = ""
@@ -73,7 +73,7 @@ SYSTEMHEADERS = "${target_includedir}"
73SYSTEMLIBS = "${target_base_libdir}/" 73SYSTEMLIBS = "${target_base_libdir}/"
74SYSTEMLIBS1 = "${target_libdir}/" 74SYSTEMLIBS1 = "${target_libdir}/"
75 75
76do_configure_prepend () { 76do_configure:prepend () {
77 # teach gcc to find correct target includedir when checking libc ssp support 77 # teach gcc to find correct target includedir when checking libc ssp support
78 mkdir -p ${B}/gcc 78 mkdir -p ${B}/gcc
79 echo "NATIVE_SYSTEM_HEADER_DIR = ${SYSTEMHEADERS}" > ${B}/gcc/t-oe 79 echo "NATIVE_SYSTEM_HEADER_DIR = ${SYSTEMHEADERS}" > ${B}/gcc/t-oe
diff --git a/meta/recipes-devtools/gcc/gcc-cross-canadian.inc b/meta/recipes-devtools/gcc/gcc-cross-canadian.inc
index d3875c94d3..ec87b46219 100644
--- a/meta/recipes-devtools/gcc/gcc-cross-canadian.inc
+++ b/meta/recipes-devtools/gcc/gcc-cross-canadian.inc
@@ -3,12 +3,13 @@ inherit cross-canadian
3SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)" 3SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)"
4PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}" 4PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}"
5 5
6DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}gcc-crosssdk virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc nativesdk-gettext flex-native virtual/libc" 6DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}gcc virtual/${HOST_PREFIX}binutils virtual/nativesdk-libc nativesdk-gettext flex-native virtual/libc"
7 7
8GCCMULTILIB = "--enable-multilib" 8GCCMULTILIB = "--enable-multilib"
9 9
10require gcc-configure-common.inc 10require gcc-configure-common.inc
11 11
12EXTRA_OECONF += "--with-plugin-ld=ld"
12EXTRA_OECONF_PATHS = "\ 13EXTRA_OECONF_PATHS = "\
13 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \ 14 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
14 --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \ 15 --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
@@ -45,6 +46,9 @@ export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres"
45export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}" 46export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}"
46 47
47do_configure () { 48do_configure () {
49 if [ ! -d ${RECIPE_SYSROOT}/${target_includedir} ]; then
50 mkdir -p ${RECIPE_SYSROOT}/${target_includedir}
51 fi
48 export CC_FOR_BUILD="${BUILD_CC}" 52 export CC_FOR_BUILD="${BUILD_CC}"
49 export CXX_FOR_BUILD="${BUILD_CXX}" 53 export CXX_FOR_BUILD="${BUILD_CXX}"
50 export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}" 54 export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}"
@@ -65,7 +69,7 @@ do_compile () {
65 69
66PACKAGES = "${PN}-dbg ${PN} ${PN}-doc" 70PACKAGES = "${PN}-dbg ${PN} ${PN}-doc"
67 71
68FILES_${PN} = "\ 72FILES:${PN} = "\
69 ${exec_prefix}/bin/* \ 73 ${exec_prefix}/bin/* \
70 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \ 74 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \
71 ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \ 75 ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
@@ -75,14 +79,15 @@ FILES_${PN} = "\
75 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \ 79 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
76 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \ 80 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
77 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \ 81 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \
82 ${libdir}/bfd-plugins/*.so \
78 ${includedir}/c++/${BINV} \ 83 ${includedir}/c++/${BINV} \
79 ${prefix}/${TARGET_SYS}/bin/* \ 84 ${prefix}/${TARGET_SYS}/bin/* \
80 ${prefix}/${TARGET_SYS}/lib/* \ 85 ${prefix}/${TARGET_SYS}/lib/* \
81 ${prefix}/${TARGET_SYS}${target_includedir}/* \ 86 ${prefix}/${TARGET_SYS}${target_includedir}/* \
82" 87"
83INSANE_SKIP_${PN} += "dev-so" 88INSANE_SKIP:${PN} += "dev-so"
84 89
85FILES_${PN}-doc = "\ 90FILES:${PN}-doc = "\
86 ${infodir} \ 91 ${infodir} \
87 ${mandir} \ 92 ${mandir} \
88 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \ 93 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
@@ -92,6 +97,8 @@ EXEEXT = ""
92 97
93# Compute how to get from libexecdir to bindir in python (easier than shell) 98# Compute how to get from libexecdir to bindir in python (easier than shell)
94BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}" 99BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
100# linker plugin path
101LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${libdir}/bfd-plugins"))}"
95 102
96do_install () { 103do_install () {
97 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h ) 104 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
@@ -121,23 +128,25 @@ do_install () {
121 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/ 128 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
122 install -d $dest 129 install -d $dest
123 suffix=${EXEEXT} 130 suffix=${EXEEXT}
124 for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do 131 for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
125 if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then 132 if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then
126 continue 133 continue
127 fi 134 fi
128 135
129 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix 136 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix
130 done 137 done
131 t=real-ld
132 ln -sf ${BINRELPATH}/${TARGET_PREFIX}ld$suffix $dest$t$suffix
133 138
134 # libquadmath headers need to be available in the gcc libexec dir 139 # libquadmath headers need to be available in the gcc libexec dir
135 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ 140 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
136 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ 141 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
137 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ 142 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
138 143
144 # install LTO linker plugins where binutils tools can find it
145 install -d ${D}${libdir}/bfd-plugins
146 ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
147
139 chown -R root:root ${D} 148 chown -R root:root ${D}
140 149
141 cross_canadian_bindirlinks 150 cross_canadian_bindirlinks
142 151
143 for i in linux ${CANADIANEXTRAOS} 152 for i in linux ${CANADIANEXTRAOS}
@@ -165,17 +174,14 @@ do_install () {
165} 174}
166 175
167ELFUTILS = "nativesdk-elfutils" 176ELFUTILS = "nativesdk-elfutils"
168DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib" 177DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib nativesdk-zstd"
169RDEPENDS_${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}" 178RDEPENDS:${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}"
170 179
171SYSTEMHEADERS = "${target_includedir}/" 180SYSTEMHEADERS = "${target_includedir}/"
172SYSTEMLIBS = "${target_base_libdir}/" 181SYSTEMLIBS = "${target_base_libdir}/"
173SYSTEMLIBS1 = "${target_libdir}/" 182SYSTEMLIBS1 = "${target_libdir}/"
174 183
175EXTRA_OECONF += "--enable-poison-system-directories" 184EXTRA_OECONF += "--enable-poison-system-directories"
176EXTRA_OECONF_remove_elf = "--with-sysroot=/not/exist" 185
177EXTRA_OECONF_remove_eabi = "--with-sysroot=/not/exist"
178EXTRA_OECONF_append_elf = " --without-headers --with-newlib"
179EXTRA_OECONF_append_eabi = " --without-headers --with-newlib"
180# gcc 4.7 needs -isystem 186# gcc 4.7 needs -isystem
181export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}" 187export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}"
diff --git a/meta/recipes-devtools/gcc/gcc-cross-canadian_10.2.bb b/meta/recipes-devtools/gcc/gcc-cross-canadian_13.2.bb
index bf53c5cd78..bf53c5cd78 100644
--- a/meta/recipes-devtools/gcc/gcc-cross-canadian_10.2.bb
+++ b/meta/recipes-devtools/gcc/gcc-cross-canadian_13.2.bb
diff --git a/meta/recipes-devtools/gcc/gcc-cross.inc b/meta/recipes-devtools/gcc/gcc-cross.inc
index 6fa8c274cd..a540fb2434 100644
--- a/meta/recipes-devtools/gcc/gcc-cross.inc
+++ b/meta/recipes-devtools/gcc/gcc-cross.inc
@@ -21,8 +21,8 @@ require gcc-configure-common.inc
21# gnu) will hit a QA failure. 21# gnu) will hit a QA failure.
22LINKER_HASH_STYLE ?= "sysv" 22LINKER_HASH_STYLE ?= "sysv"
23 23
24EXTRA_OECONF += "--enable-poison-system-directories" 24EXTRA_OECONF += "--enable-poison-system-directories=error"
25EXTRA_OECONF_append_sh4 = " \ 25EXTRA_OECONF:append:sh4 = " \
26 --with-multilib-list= \ 26 --with-multilib-list= \
27 --enable-incomplete-targets \ 27 --enable-incomplete-targets \
28" 28"
@@ -31,9 +31,9 @@ EXTRA_OECONF += "\
31 --with-system-zlib \ 31 --with-system-zlib \
32" 32"
33 33
34EXTRA_OECONF_append_libc-baremetal = " --without-headers" 34EXTRA_OECONF:append:libc-baremetal = " --without-headers"
35EXTRA_OECONF_remove_libc-baremetal = "--enable-threads=posix" 35EXTRA_OECONF:remove:libc-baremetal = "--enable-threads=posix"
36EXTRA_OECONF_remove_libc-newlib = "--enable-threads=posix" 36EXTRA_OECONF:remove:libc-newlib = "--enable-threads=posix"
37 37
38EXTRA_OECONF_PATHS = "\ 38EXTRA_OECONF_PATHS = "\
39 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \ 39 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
@@ -44,7 +44,7 @@ EXTRA_OECONF_PATHS = "\
44ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}" 44ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
45 45
46 46
47do_configure_prepend () { 47do_configure:prepend () {
48 install -d ${RECIPE_SYSROOT}${target_includedir} 48 install -d ${RECIPE_SYSROOT}${target_includedir}
49 touch ${RECIPE_SYSROOT}${target_includedir}/limits.h 49 touch ${RECIPE_SYSROOT}${target_includedir}/limits.h
50} 50}
@@ -83,6 +83,8 @@ INHIBIT_PACKAGE_STRIP = "1"
83 83
84# Compute how to get from libexecdir to bindir in python (easier than shell) 84# Compute how to get from libexecdir to bindir in python (easier than shell)
85BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}" 85BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
86# linker plugin path
87LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/bfd-plugins"))}"
86 88
87do_install () { 89do_install () {
88 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h ) 90 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
@@ -92,7 +94,7 @@ do_install () {
92 install -d ${D}${target_libdir} 94 install -d ${D}${target_libdir}
93 95
94 # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77 96 # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
95 # gfortran is fully backwards compatible. This is a safe and practical solution. 97 # gfortran is fully backwards compatible. This is a safe and practical solution.
96 if [ -n "${@d.getVar('FORTRAN')}" ]; then 98 if [ -n "${@d.getVar('FORTRAN')}" ]; then
97 ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true 99 ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
98 fortsymlinks="g77 gfortran" 100 fortsymlinks="g77 gfortran"
@@ -118,6 +120,10 @@ do_install () {
118 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ 120 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
119 121
120 find ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed -type f -not -name "README" -not -name limits.h -not -name syslimits.h | xargs rm -f 122 find ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed -type f -not -name "README" -not -name limits.h -not -name syslimits.h | xargs rm -f
123
124 # install LTO linker plugins where binutils tools can find it
125 install -d ${D}${libdir}/bfd-plugins
126 ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
121} 127}
122 128
123do_package[noexec] = "1" 129do_package[noexec] = "1"
@@ -143,6 +149,7 @@ do_gcc_stash_builddir () {
143 # Makefile does move-if-change which can end up with 'timestamp' as file contents so break links to those files 149 # Makefile does move-if-change which can end up with 'timestamp' as file contents so break links to those files
144 rm $dest/gcc/include/*.h 150 rm $dest/gcc/include/*.h
145 cp gcc/include/*.h $dest/gcc/include/ 151 cp gcc/include/*.h $dest/gcc/include/
152 sysroot-relativelinks.py $dest
146} 153}
147addtask do_gcc_stash_builddir after do_compile before do_install 154addtask do_gcc_stash_builddir after do_compile before do_install
148SSTATETASKS += "do_gcc_stash_builddir" 155SSTATETASKS += "do_gcc_stash_builddir"
diff --git a/meta/recipes-devtools/gcc/gcc-cross_10.2.bb b/meta/recipes-devtools/gcc/gcc-cross_13.2.bb
index b43cca0c52..b43cca0c52 100644
--- a/meta/recipes-devtools/gcc/gcc-cross_10.2.bb
+++ b/meta/recipes-devtools/gcc/gcc-cross_13.2.bb
diff --git a/meta/recipes-devtools/gcc/gcc-crosssdk.inc b/meta/recipes-devtools/gcc/gcc-crosssdk.inc
index bd2e71d63f..7eaad2314c 100644
--- a/meta/recipes-devtools/gcc/gcc-crosssdk.inc
+++ b/meta/recipes-devtools/gcc/gcc-crosssdk.inc
@@ -8,5 +8,7 @@ SYSTEMLIBS1 = "${SDKPATHNATIVE}${libdir_nativesdk}/"
8 8
9GCCMULTILIB = "--disable-multilib" 9GCCMULTILIB = "--disable-multilib"
10 10
11DEPENDS = "virtual/${TARGET_PREFIX}binutils-crosssdk gettext-native ${NATIVEDEPS}" 11DEPENDS = "virtual/${TARGET_PREFIX}binutils gettext-native ${NATIVEDEPS}"
12PROVIDES = "virtual/${TARGET_PREFIX}gcc-crosssdk virtual/${TARGET_PREFIX}g++-crosssdk" 12PROVIDES = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++"
13
14gcc_multilib_setup[vardepsexclude] = "MULTILIB_VARIANTS"
diff --git a/meta/recipes-devtools/gcc/gcc-crosssdk_10.2.bb b/meta/recipes-devtools/gcc/gcc-crosssdk_13.2.bb
index 40a6c4feff..40a6c4feff 100644
--- a/meta/recipes-devtools/gcc/gcc-crosssdk_10.2.bb
+++ b/meta/recipes-devtools/gcc/gcc-crosssdk_13.2.bb
diff --git a/meta/recipes-devtools/gcc/gcc-multilib-config.inc b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
index 31b8619be3..2dbbc23c94 100644
--- a/meta/recipes-devtools/gcc/gcc-multilib-config.inc
+++ b/meta/recipes-devtools/gcc/gcc-multilib-config.inc
@@ -31,7 +31,9 @@ python gcc_multilib_setup() {
31 '%s/*/linux64.h' % src_conf_dir, 31 '%s/*/linux64.h' % src_conf_dir,
32 '%s/aarch64/t-aarch64' % src_conf_dir, 32 '%s/aarch64/t-aarch64' % src_conf_dir,
33 '%s/aarch64/aarch64.h' % src_conf_dir, 33 '%s/aarch64/aarch64.h' % src_conf_dir,
34 '%s/aarch64/aarch64-linux.h' % src_conf_dir,
34 '%s/aarch64/aarch64-cores.def' % src_conf_dir, 35 '%s/aarch64/aarch64-cores.def' % src_conf_dir,
36 '%s/arm/linux-eabi.h' % src_conf_dir,
35 '%s/*/linux.h' % src_conf_dir, 37 '%s/*/linux.h' % src_conf_dir,
36 '%s/linux.h' % src_conf_dir) 38 '%s/linux.h' % src_conf_dir)
37 39
@@ -102,6 +104,8 @@ python gcc_multilib_setup() {
102 r'\1' + wrap_libdir(libdir64) + r'\3'), 104 r'\1' + wrap_libdir(libdir64) + r'\3'),
103 (r'^(#define\s*GLIBC_DYNAMIC_LINKER64\s*\"\S+\"\s*)(\S+)(\s*\"\S+\"\s*)(\S+)(\s*\".*\")$', 105 (r'^(#define\s*GLIBC_DYNAMIC_LINKER64\s*\"\S+\"\s*)(\S+)(\s*\"\S+\"\s*)(\S+)(\s*\".*\")$',
104 r'\1' + wrap_libdir(libdir64) + r'\3' + wrap_libdir(libdir64) + r'\5'), 106 r'\1' + wrap_libdir(libdir64) + r'\3' + wrap_libdir(libdir64) + r'\5'),
107 (r'^(#define\s*GLIBC_DYNAMIC_LINKER\b\s*)(\S+)(\s*\".*\")$',
108 r'\1' + wrap_libdir(libdir32) + r'\3'),
105 (r'^(#define\s*GLIBC_DYNAMIC_LINKERX32\s*)(\S+)(\s*\".*\")$', 109 (r'^(#define\s*GLIBC_DYNAMIC_LINKERX32\s*)(\S+)(\s*\".*\")$',
106 r'\1' + wrap_libdir(libdirx32) + r'\3'), 110 r'\1' + wrap_libdir(libdirx32) + r'\3'),
107 (r'^(#define\s*GLIBC_DYNAMIC_LINKERN32\s*)(\S+)(\s*\".*\")$', 111 (r'^(#define\s*GLIBC_DYNAMIC_LINKERN32\s*)(\S+)(\s*\".*\")$',
@@ -112,8 +116,18 @@ python gcc_multilib_setup() {
112 r'\1' + wrap_libdir(libdir64) + r'\3'), 116 r'\1' + wrap_libdir(libdir64) + r'\3'),
113 (r'^(#define\s*UCLIBC_DYNAMIC_LINKERN32\s*)(\S+)(\s*\".*\")$', 117 (r'^(#define\s*UCLIBC_DYNAMIC_LINKERN32\s*)(\S+)(\s*\".*\")$',
114 r'\1' + wrap_libdir(libdirn32) + r'\3'), 118 r'\1' + wrap_libdir(libdirn32) + r'\3'),
119 (r'^(#define\s*UCLIBC_DYNAMIC_LINKERX32\s*)(\S+)(\s*\".*\")$',
120 r'\1' + wrap_libdir(libdirx32) + r'\3'),
115 (r'^(#define\s*UCLIBC_DYNAMIC_LINKER\b\s*)(\S+)(\s*\".*\")$', 121 (r'^(#define\s*UCLIBC_DYNAMIC_LINKER\b\s*)(\S+)(\s*\".*\")$',
116 r'\1' + wrap_libdir(libdir32) + r'\3'), 122 r'\1' + wrap_libdir(libdir32) + r'\3'),
123 (r'^(#define\s*MUSL_DYNAMIC_LINKER32\s*)(\S+)(\s*\".*\")$',
124 r'\1' + wrap_libdir(libdir32) + r'\3'),
125 (r'^(#define\s*MUSL_DYNAMIC_LINKER64\s*)(\S+)(\s*\".*\")$',
126 r'\1' + wrap_libdir(libdir64) + r'\3'),
127 (r'^(#define\s*MUSL_DYNAMIC_LINKERX32\s*)(\S+)(\s*\".*\")$',
128 r'\1' + wrap_libdir(libdirx32) + r'\3'),
129 (r'^(#define\s*MUSL_DYNAMIC_LINKER\b\s*)(\S+)(\s*\".*\")$',
130 r'\1' + wrap_libdir(libdir32) + r'\3'),
117 ] 131 ]
118 132
119 for (i, line) in enumerate(filelines): 133 for (i, line) in enumerate(filelines):
@@ -138,15 +152,15 @@ python gcc_multilib_setup() {
138 } 152 }
139 153
140 gcc_header_config_files = { 154 gcc_header_config_files = {
141 'x86_64' : ['gcc/config/i386/linux64.h'], 155 'x86_64' : ['gcc/config/linux.h', 'gcc/config/i386/linux.h', 'gcc/config/i386/linux64.h'],
142 'i586' : ['gcc/config/i386/linux64.h'], 156 'i586' : ['gcc/config/linux.h', 'gcc/config/i386/linux.h', 'gcc/config/i386/linux64.h'],
143 'i686' : ['gcc/config/i386/linux64.h'], 157 'i686' : ['gcc/config/linux.h', 'gcc/config/i386/linux.h', 'gcc/config/i386/linux64.h'],
144 'mips' : ['gcc/config/mips/linux.h', 'gcc/config/mips/linux64.h'], 158 'mips' : ['gcc/config/linux.h', 'gcc/config/mips/linux.h', 'gcc/config/mips/linux64.h'],
145 'mips64' : ['gcc/config/mips/linux.h', 'gcc/config/mips/linux64.h'], 159 'mips64' : ['gcc/config/linux.h', 'gcc/config/mips/linux.h', 'gcc/config/mips/linux64.h'],
146 'powerpc' : ['gcc/config/rs6000/linux64.h'], 160 'powerpc' : ['gcc/config/linux.h', 'gcc/config/rs6000/linux64.h'],
147 'powerpc64' : ['gcc/config/rs6000/linux64.h'], 161 'powerpc64' : ['gcc/config/linux.h', 'gcc/config/rs6000/linux64.h'],
148 'aarch64' : ['gcc/config/aarch64/aarch64.h'], 162 'aarch64' : ['gcc/config/linux.h', 'gcc/config/aarch64/aarch64-linux.h', 'gcc/config/arm/linux-eabi.h'],
149 'arm' : ['gcc/config/aarch64/aarch64.h'], 163 'arm' : ['gcc/config/linux.h', 'gcc/config/aarch64/aarch64-linux.h', 'gcc/config/arm/linux-eabi.h'],
150 } 164 }
151 165
152 libdir32 = 'SYSTEMLIBS_DIR' 166 libdir32 = 'SYSTEMLIBS_DIR'
@@ -170,7 +184,7 @@ python gcc_multilib_setup() {
170 header_config_files = gcc_header_config_files[target_arch] 184 header_config_files = gcc_header_config_files[target_arch]
171 185
172 ml_list = ['DEFAULTTUNE_MULTILIB_ORIGINAL' if mlprefix else 'DEFAULTTUNE'] 186 ml_list = ['DEFAULTTUNE_MULTILIB_ORIGINAL' if mlprefix else 'DEFAULTTUNE']
173 mltunes = [('DEFAULTTUNE_virtclass-multilib-%s' % ml) for ml in multilibs] 187 mltunes = [('DEFAULTTUNE:virtclass-multilib-%s' % ml) for ml in multilibs]
174 if mlprefix: 188 if mlprefix:
175 mlindex = 0 189 mlindex = 0
176 for ml in multilibs: 190 for ml in multilibs:
diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc b/meta/recipes-devtools/gcc/gcc-runtime.inc
index 9dcce26536..dbc9141000 100644
--- a/meta/recipes-devtools/gcc/gcc-runtime.inc
+++ b/meta/recipes-devtools/gcc/gcc-runtime.inc
@@ -6,7 +6,7 @@ SUMMARY = "Runtime libraries from GCC"
6# All gcc-runtime packages are now covered by the runtime exception. 6# All gcc-runtime packages are now covered by the runtime exception.
7LICENSE = "GPL-3.0-with-GCC-exception" 7LICENSE = "GPL-3.0-with-GCC-exception"
8 8
9CXXFLAGS_remove = "-fvisibility-inlines-hidden" 9CXXFLAGS:remove = "-fvisibility-inlines-hidden"
10 10
11EXTRA_OECONF_PATHS = "\ 11EXTRA_OECONF_PATHS = "\
12 --with-gxx-include-dir=${includedir}/c++/${BINV} \ 12 --with-gxx-include-dir=${includedir}/c++/${BINV} \
@@ -14,63 +14,57 @@ EXTRA_OECONF_PATHS = "\
14 --with-build-sysroot=${STAGING_DIR_TARGET} \ 14 --with-build-sysroot=${STAGING_DIR_TARGET} \
15" 15"
16 16
17EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu" 17EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu"
18EXTRA_OECONF_append = " --cache-file=${B}/config.cache" 18EXTRA_OECONF:append = " --cache-file=${B}/config.cache"
19EXTRA_OECONF_append_libc-newlib = " --with-newlib" 19EXTRA_OECONF:append:libc-newlib = " --with-newlib --with-target-subdir"
20EXTRA_OECONF:append:libc-baremetal = " --with-target-subdir"
20 21
21# Disable ifuncs for libatomic on arm conflicts -march/-mcpu 22# Disable ifuncs for libatomic on arm conflicts -march/-mcpu
22EXTRA_OECONF_append_arm = " libat_cv_have_ifunc=no " 23EXTRA_OECONF:append:arm = " libat_cv_have_ifunc=no "
23EXTRA_OECONF_append_armeb = " libat_cv_have_ifunc=no " 24EXTRA_OECONF:append:armeb = " libat_cv_have_ifunc=no "
24 25
25DISABLE_STATIC_class-nativesdk ?= "" 26DISABLE_STATIC:class-nativesdk ?= ""
26 27
27# Newlib does not support symbol versioning on libsdtcc++ 28# Newlib does not support symbol versioning on libsdtcc++
28SYMVERS_CONF_libc-newlib = "" 29SYMVERS_CONF:libc-newlib = ""
29 30
30# Building with thumb enabled on armv6t fails 31# Building with thumb enabled on armv6t fails
31ARM_INSTRUCTION_SET_armv6 = "arm" 32ARM_INSTRUCTION_SET:armv6 = "arm"
32 33
33RUNTIMELIBITM = "libitm" 34RUNTIMELIBITM = "libitm"
34RUNTIMELIBITM_arc = "" 35RUNTIMELIBITM:arc = ""
35RUNTIMELIBITM_mipsarch = "" 36RUNTIMELIBITM:mipsarch = ""
36RUNTIMELIBITM_nios2 = "" 37RUNTIMELIBITM:nios2 = ""
37RUNTIMELIBITM_microblaze = "" 38RUNTIMELIBITM:microblaze = ""
38RUNTIMELIBITM_riscv32 = "" 39RUNTIMELIBITM:riscv32 = ""
39RUNTIMELIBITM_riscv64 = "" 40RUNTIMELIBITM:riscv64 = ""
41RUNTIMELIBITM:loongarch64 = ""
40RUNTIMELIBSSP ?= "" 42RUNTIMELIBSSP ?= ""
41RUNTIMELIBSSP_mingw32 ?= "libssp" 43RUNTIMELIBSSP:mingw32 ?= "libssp"
42 44
43RUNTIMETARGET = "${RUNTIMELIBSSP} libstdc++-v3 libgomp libatomic ${RUNTIMELIBITM} \ 45RUNTIMETARGET = "${RUNTIMELIBSSP} libstdc++-v3 libgomp libatomic ${RUNTIMELIBITM} \
44 ${@bb.utils.contains_any('FORTRAN', [',fortran',',f77'], 'libquadmath', '', d)} \ 46 ${@bb.utils.contains_any('FORTRAN', [',fortran',',f77'], 'libquadmath', '', d)} \
45" 47"
46# Only build libstdc++ for newlib 48# Only build libstdc++ for newlib
47RUNTIMETARGET_libc-newlib = "libstdc++-v3" 49RUNTIMETARGET:libc-newlib = "libstdc++-v3"
48 50
49# libiberty 51# libiberty
50# libgfortran needs separate recipe due to libquadmath dependency 52# libgfortran needs separate recipe due to libquadmath dependency
51 53
52SLIB = "${TMPDIR}/work-shared/gcc-${PV}-${PR}/gcc-${PV}"
53SLIB_NEW = "/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}"
54
55DEBUG_PREFIX_MAP_class-target = " \
56 -fdebug-prefix-map=${WORKDIR}/recipe-sysroot= \
57 -fdebug-prefix-map=${WORKDIR}/recipe-sysroot-native= \
58 -fdebug-prefix-map=${SLIB}=${SLIB_NEW} \
59 -fdebug-prefix-map=${SLIB}/include=${SLIB_NEW}/libstdc++-v3/../include \
60 -fdebug-prefix-map=${SLIB}/libiberty=${SLIB_NEW}/libstdc++-v3/../libiberty \
61 -fdebug-prefix-map=${B}=${SLIB_NEW} \
62 "
63
64do_configure () { 54do_configure () {
65 export CXX="${CXX} -nostdinc++ -nostdlib++" 55 export CXX="${CXX} -nostdinc++ -L${WORKDIR}/dummylib"
56 # libstdc++ isn't built yet so CXX would error not able to find it which breaks stdc++'s configure
57 # tests. Create a dummy empty lib for the purposes of configure.
58 mkdir -p ${WORKDIR}/dummylib
59 ${CC} -x c /dev/null -c -o ${WORKDIR}/dummylib/dummylib.o
60 ${AR} rcs ${WORKDIR}/dummylib/libstdc++.a ${WORKDIR}/dummylib/dummylib.o
66 for d in libgcc ${RUNTIMETARGET}; do 61 for d in libgcc ${RUNTIMETARGET}; do
67 echo "Configuring $d" 62 echo "Configuring $d"
68 rm -rf ${B}/${TARGET_SYS}/$d/ 63 rm -rf ${B}/${TARGET_SYS}/$d/
69 mkdir -p ${B}/${TARGET_SYS}/$d/ 64 mkdir -p ${B}/${TARGET_SYS}/$d/
70 cd ${B}/${TARGET_SYS}/$d/ 65 cd ${B}/${TARGET_SYS}/$d/
71 chmod a+x ${S}/$d/configure 66 chmod a+x ${S}/$d/configure
72 relpath=${@os.path.relpath("${S}/$d", "${B}/${TARGET_SYS}/$d")} 67 ${S}/$d/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
73 $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
74 if [ "$d" = "libgcc" ]; then 68 if [ "$d" = "libgcc" ]; then
75 (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h) 69 (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h)
76 fi 70 fi
@@ -91,6 +85,8 @@ do_install () {
91 cd ${B}/${TARGET_SYS}/$d/ 85 cd ${B}/${TARGET_SYS}/$d/
92 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/$d/ install 86 oe_runmake 'DESTDIR=${D}' MULTIBUILDTOP=${B}/${TARGET_SYS}/$d/ install
93 done 87 done
88 install -d ${D}${datadir}/gdb/auto-load/${libdir}
89 mv ${D}${libdir}/libstdc++*-gdb.py ${D}${datadir}/gdb/auto-load/${libdir}
94 if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include ]; then 90 if [ -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include ]; then
95 install -d ${D}${libdir}/${TARGET_SYS}/${BINV}/include 91 install -d ${D}${libdir}/${TARGET_SYS}/${BINV}/include
96 mv ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/* ${D}${libdir}/${TARGET_SYS}/${BINV}/include 92 mv ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/* ${D}${libdir}/${TARGET_SYS}/${BINV}/include
@@ -105,9 +101,12 @@ do_install () {
105 if [ -d ${D}${infodir} ]; then 101 if [ -d ${D}${infodir} ]; then
106 rmdir --ignore-fail-on-non-empty -p ${D}${infodir} 102 rmdir --ignore-fail-on-non-empty -p ${D}${infodir}
107 fi 103 fi
104 if [ -d ${D}${libdir} ]; then
105 rmdir --ignore-fail-on-non-empty -p ${D}${libdir}
106 fi
108} 107}
109 108
110do_install_append_class-target () { 109do_install:append:class-target () {
111 if [ "${TARGET_OS}" = "linux-gnuspe" ]; then 110 if [ "${TARGET_OS}" = "linux-gnuspe" ]; then
112 ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux 111 ln -s ${TARGET_SYS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-linux
113 fi 112 fi
@@ -138,7 +137,7 @@ do_install_append_class-target () {
138 ln -s ../${TARGET_SYS}/ext ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS}/ext 137 ln -s ../${TARGET_SYS}/ext ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR_MULTILIB_ORIGINAL}-${TARGET_OS}/ext
139 fi 138 fi
140 139
141 if [ "${TARGET_ARCH}" == "x86_64" -a "${MULTILIB_VARIANTS}" != "" ];then 140 if [ "${TARGET_ARCH}" = "x86_64" -a "${MULTILIB_VARIANTS}" != "" ];then
142 ln -sf ../${X86ARCH32}${TARGET_VENDOR}-${TARGET_OS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}/32 141 ln -sf ../${X86ARCH32}${TARGET_VENDOR}-${TARGET_OS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}/32
143 fi 142 fi
144 143
@@ -184,67 +183,72 @@ PACKAGES = "\
184 libitm-staticdev \ 183 libitm-staticdev \
185" 184"
186# The base package doesn't exist, so we clear the recommends. 185# The base package doesn't exist, so we clear the recommends.
187RRECOMMENDS_${PN}-dbg = "" 186RRECOMMENDS:${PN}-dbg = ""
188 187
189# include python debugging scripts 188# include python debugging scripts
190FILES_${PN}-dbg += "\ 189FILES:${PN}-dbg += "\
191 ${libdir}/libstdc++.*-gdb.py \
192 ${datadir}/gcc-${BINV}/python/libstdcxx \ 190 ${datadir}/gcc-${BINV}/python/libstdcxx \
191 ${datadir}/gdb/auto-load \
193" 192"
194 193# Needed by libstdcxx pretty printer, however it is disabled intentionally
195FILES_libg2c = "${target_libdir}/libg2c.so.*" 194# as it adds build time dependency on bash and some cases e.g. no GPL3 cases
196SUMMARY_libg2c = "Companion runtime library for g77" 195# bash is not availbale and builds fails
197FILES_libg2c-dev = "\ 196# So it needs to be added manually to images sadly.
197# RDEPENDS:${PN}-dbg += "python3-datetime"
198
199FILES:libg2c = "${target_libdir}/libg2c.so.*"
200SUMMARY:libg2c = "Companion runtime library for g77"
201FILES:libg2c-dev = "\
198 ${libdir}/libg2c.so \ 202 ${libdir}/libg2c.so \
199 ${libdir}/libg2c.a \ 203 ${libdir}/libg2c.a \
200 ${libdir}/libfrtbegin.a \ 204 ${libdir}/libfrtbegin.a \
201" 205"
202SUMMARY_libg2c-dev = "Companion runtime library for g77 - development files" 206SUMMARY:libg2c-dev = "Companion runtime library for g77 - development files"
203 207
204FILES_libstdc++ = "${libdir}/libstdc++.so.*" 208FILES:libstdc++ = "${libdir}/libstdc++.so.*"
205SUMMARY_libstdc++ = "GNU standard C++ library" 209SUMMARY:libstdc++ = "GNU standard C++ library"
206FILES_libstdc++-dev = "\ 210FILES:libstdc++-dev = "\
207 ${includedir}/c++/ \ 211 ${includedir}/c++/ \
208 ${libdir}/libstdc++.so \ 212 ${libdir}/libstdc++.so \
209 ${libdir}/libstdc++*.la \ 213 ${libdir}/libstdc++*.la \
210 ${libdir}/libsupc++.la \ 214 ${libdir}/libsupc++.la \
211" 215"
212SUMMARY_libstdc++-dev = "GNU standard C++ library - development files" 216SUMMARY:libstdc++-dev = "GNU standard C++ library - development files"
213FILES_libstdc++-staticdev = "\ 217FILES:libstdc++-staticdev = "\
214 ${libdir}/libstdc++*.a \ 218 ${libdir}/libstdc++*.a \
215 ${libdir}/libsupc++.a \ 219 ${libdir}/libsupc++.a \
216" 220"
217SUMMARY_libstdc++-staticdev = "GNU standard C++ library - static development files" 221SUMMARY:libstdc++-staticdev = "GNU standard C++ library - static development files"
218 222
219FILES_libstdc++-precompile-dev = "${includedir}/c++/${TARGET_SYS}/bits/*.gch" 223FILES:libstdc++-precompile-dev = "${includedir}/c++/${TARGET_SYS}/bits/*.gch"
220SUMMARY_libstdc++-precompile-dev = "GNU standard C++ library - precompiled header files" 224SUMMARY:libstdc++-precompile-dev = "GNU standard C++ library - precompiled header files"
221 225
222FILES_libssp = "${libdir}/libssp.so.*" 226FILES:libssp = "${libdir}/libssp.so.*"
223SUMMARY_libssp = "GNU stack smashing protection library" 227SUMMARY:libssp = "GNU stack smashing protection library"
224FILES_libssp-dev = "\ 228FILES:libssp-dev = "\
225 ${libdir}/libssp*.so \ 229 ${libdir}/libssp*.so \
226 ${libdir}/libssp*_nonshared.a \ 230 ${libdir}/libssp*_nonshared.a \
227 ${libdir}/libssp*.la \ 231 ${libdir}/libssp*.la \
228 ${libdir}/${TARGET_SYS}/${BINV}/include/ssp \ 232 ${libdir}/${TARGET_SYS}/${BINV}/include/ssp \
229" 233"
230SUMMARY_libssp-dev = "GNU stack smashing protection library - development files" 234SUMMARY:libssp-dev = "GNU stack smashing protection library - development files"
231FILES_libssp-staticdev = "${libdir}/libssp*.a" 235FILES:libssp-staticdev = "${libdir}/libssp*.a"
232SUMMARY_libssp-staticdev = "GNU stack smashing protection library - static development files" 236SUMMARY:libssp-staticdev = "GNU stack smashing protection library - static development files"
233 237
234FILES_libquadmath = "${libdir}/libquadmath*.so.*" 238FILES:libquadmath = "${libdir}/libquadmath*.so.*"
235SUMMARY_libquadmath = "GNU quad-precision math library" 239SUMMARY:libquadmath = "GNU quad-precision math library"
236FILES_libquadmath-dev = "\ 240FILES:libquadmath-dev = "\
237 ${libdir}/${TARGET_SYS}/${BINV}/include/quadmath* \ 241 ${libdir}/${TARGET_SYS}/${BINV}/include/quadmath* \
238 ${libdir}/libquadmath*.so \ 242 ${libdir}/libquadmath*.so \
239 ${libdir}/libquadmath.la \ 243 ${libdir}/libquadmath.la \
240" 244"
241SUMMARY_libquadmath-dev = "GNU quad-precision math library - development files" 245SUMMARY:libquadmath-dev = "GNU quad-precision math library - development files"
242FILES_libquadmath-staticdev = "${libdir}/libquadmath.a" 246FILES:libquadmath-staticdev = "${libdir}/libquadmath.a"
243SUMMARY_libquadmath-staticdev = "GNU quad-precision math library - static development files" 247SUMMARY:libquadmath-staticdev = "GNU quad-precision math library - static development files"
244 248
245FILES_libgomp = "${libdir}/libgomp*${SOLIBS}" 249FILES:libgomp = "${libdir}/libgomp*${SOLIBS}"
246SUMMARY_libgomp = "GNU OpenMP parallel programming library" 250SUMMARY:libgomp = "GNU OpenMP parallel programming library"
247FILES_libgomp-dev = "\ 251FILES:libgomp-dev = "\
248 ${libdir}/libgomp*${SOLIBSDEV} \ 252 ${libdir}/libgomp*${SOLIBSDEV} \
249 ${libdir}/libgomp*.la \ 253 ${libdir}/libgomp*.la \
250 ${libdir}/libgomp.spec \ 254 ${libdir}/libgomp.spec \
@@ -252,34 +256,34 @@ FILES_libgomp-dev = "\
252 ${libdir}/${TARGET_SYS}/${BINV}/include/omp.h \ 256 ${libdir}/${TARGET_SYS}/${BINV}/include/omp.h \
253 ${libdir}/${TARGET_SYS}/${BINV}/include/openacc.h \ 257 ${libdir}/${TARGET_SYS}/${BINV}/include/openacc.h \
254" 258"
255SUMMARY_libgomp-dev = "GNU OpenMP parallel programming library - development files" 259SUMMARY:libgomp-dev = "GNU OpenMP parallel programming library - development files"
256FILES_libgomp-staticdev = "${libdir}/libgomp*.a" 260FILES:libgomp-staticdev = "${libdir}/libgomp*.a"
257SUMMARY_libgomp-staticdev = "GNU OpenMP parallel programming library - static development files" 261SUMMARY:libgomp-staticdev = "GNU OpenMP parallel programming library - static development files"
258 262
259FILES_libatomic = "${libdir}/libatomic.so.*" 263FILES:libatomic = "${libdir}/libatomic.so.*"
260SUMMARY_libatomic = "GNU C++11 atomics support library" 264SUMMARY:libatomic = "GNU C++11 atomics support library"
261FILES_libatomic-dev = "\ 265FILES:libatomic-dev = "\
262 ${libdir}/libatomic.so \ 266 ${libdir}/libatomic.so \
263 ${libdir}/libatomic.la \ 267 ${libdir}/libatomic.la \
264" 268"
265SUMMARY_libatomic-dev = "GNU C++11 atomics support library - development files" 269SUMMARY:libatomic-dev = "GNU C++11 atomics support library - development files"
266FILES_libatomic-staticdev = "${libdir}/libatomic.a" 270FILES:libatomic-staticdev = "${libdir}/libatomic.a"
267SUMMARY_libatomic-staticdev = "GNU C++11 atomics support library - static development files" 271SUMMARY:libatomic-staticdev = "GNU C++11 atomics support library - static development files"
268 272
269FILES_libitm = "${libdir}/libitm.so.*" 273FILES:libitm = "${libdir}/libitm.so.*"
270SUMMARY_libitm = "GNU transactional memory support library" 274SUMMARY:libitm = "GNU transactional memory support library"
271FILES_libitm-dev = "\ 275FILES:libitm-dev = "\
272 ${libdir}/libitm.so \ 276 ${libdir}/libitm.so \
273 ${libdir}/libitm.la \ 277 ${libdir}/libitm.la \
274 ${libdir}/libitm.spec \ 278 ${libdir}/libitm.spec \
275" 279"
276SUMMARY_libitm-dev = "GNU transactional memory support library - development files" 280SUMMARY:libitm-dev = "GNU transactional memory support library - development files"
277FILES_libitm-staticdev = "${libdir}/libitm.a" 281FILES:libitm-staticdev = "${libdir}/libitm.a"
278SUMMARY_libitm-staticdev = "GNU transactional memory support library - static development files" 282SUMMARY:libitm-staticdev = "GNU transactional memory support library - static development files"
279 283
280require gcc-testsuite.inc 284require gcc-testsuite.inc
281 285
282EXTRA_OEMAKE_prepend_task-check = "${PARALLEL_MAKE} " 286EXTRA_OEMAKE:prepend:task-check = "${PARALLEL_MAKE} "
283 287
284MAKE_CHECK_TARGETS ??= "check-gcc ${@" ".join("check-target-" + i for i in d.getVar("RUNTIMETARGET").split())}" 288MAKE_CHECK_TARGETS ??= "check-gcc ${@" ".join("check-target-" + i for i in d.getVar("RUNTIMETARGET").split())}"
285# prettyprinters and xmethods require gdb tooling 289# prettyprinters and xmethods require gdb tooling
@@ -300,7 +304,7 @@ do_check() {
300 export DEJAGNU="${WORKDIR}/dejagnu/site.exp" 304 export DEJAGNU="${WORKDIR}/dejagnu/site.exp"
301 305
302 # HACK: this works around the configure setting CXX with -nostd* args 306 # HACK: this works around the configure setting CXX with -nostd* args
303 sed -i 's/-nostdinc++ -nostdlib++//g' $(find ${B} -name testsuite_flags | head -1) 307 sed -i 's#-nostdinc++ -L${WORKDIR}/dummylib##g' $(find ${B} -name testsuite_flags | head -1)
304 308
305 if [ "${TOOLCHAIN_TEST_TARGET}" = "user" ]; then 309 if [ "${TOOLCHAIN_TEST_TARGET}" = "user" ]; then
306 # qemu user has issues allocating large amounts of memory 310 # qemu user has issues allocating large amounts of memory
diff --git a/meta/recipes-devtools/gcc/gcc-runtime_10.2.bb b/meta/recipes-devtools/gcc/gcc-runtime_13.2.bb
index dd430b57eb..dd430b57eb 100644
--- a/meta/recipes-devtools/gcc/gcc-runtime_10.2.bb
+++ b/meta/recipes-devtools/gcc/gcc-runtime_13.2.bb
diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers.inc b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
index 9e643ee277..524ebd4ba4 100644
--- a/meta/recipes-devtools/gcc/gcc-sanitizers.inc
+++ b/meta/recipes-devtools/gcc/gcc-sanitizers.inc
@@ -47,11 +47,11 @@ do_install () {
47} 47}
48 48
49INHIBIT_DEFAULT_DEPS = "1" 49INHIBIT_DEFAULT_DEPS = "1"
50ALLOW_EMPTY_${PN} = "1" 50ALLOW_EMPTY:${PN} = "1"
51DEPENDS = "virtual/crypt gcc-runtime virtual/${TARGET_PREFIX}gcc" 51DEPENDS = "virtual/crypt gcc-runtime virtual/${TARGET_PREFIX}gcc"
52 52
53# used to fix ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized] 53# used to fix ../../../../../../../../../work-shared/gcc-8.3.0-r0/gcc-8.3.0/libsanitizer/libbacktrace/../../libbacktrace/elf.c:772:21: error: 'st.st_mode' may be used uninitialized in this function [-Werror=maybe-uninitialized]
54DEBUG_OPTIMIZATION_append = " -Wno-error" 54DEBUG_OPTIMIZATION:append = " -Wno-error"
55 55
56BBCLASSEXTEND = "nativesdk" 56BBCLASSEXTEND = "nativesdk"
57 57
@@ -60,58 +60,62 @@ PACKAGES += "libasan libubsan liblsan libtsan"
60PACKAGES += "libasan-dev libubsan-dev liblsan-dev libtsan-dev" 60PACKAGES += "libasan-dev libubsan-dev liblsan-dev libtsan-dev"
61PACKAGES += "libasan-staticdev libubsan-staticdev liblsan-staticdev libtsan-staticdev" 61PACKAGES += "libasan-staticdev libubsan-staticdev liblsan-staticdev libtsan-staticdev"
62 62
63RDEPENDS_libasan += "libstdc++" 63RDEPENDS:libasan += "libstdc++"
64RDEPENDS_libubsan += "libstdc++" 64RDEPENDS:libubsan += "libstdc++"
65RDEPENDS_liblsan += "libstdc++" 65RDEPENDS:liblsan += "libstdc++"
66RDEPENDS_libtsan += "libstdc++" 66RDEPENDS:libtsan += "libstdc++"
67RDEPENDS_libasan-dev += "${PN}" 67RDEPENDS:libasan-dev += "${PN}"
68RDEPENDS_libubsan-dev += "${PN}" 68RDEPENDS:libubsan-dev += "${PN}"
69RDEPENDS_liblsan-dev += "${PN}" 69RDEPENDS:liblsan-dev += "${PN}"
70RDEPENDS_libtsan-dev += "${PN}" 70RDEPENDS:libtsan-dev += "${PN}"
71RRECOMMENDS_${PN} += "libasan libubsan" 71RRECOMMENDS:${PN} += "libasan libubsan"
72RRECOMMENDS_${PN}_append_x86 = " liblsan" 72RRECOMMENDS:${PN}:append:x86 = " liblsan"
73RRECOMMENDS_${PN}_append_x86-64 = " liblsan libtsan" 73RRECOMMENDS:${PN}:append:x86-64 = " liblsan libtsan"
74RRECOMMENDS_${PN}_append_powerpc64 = " liblsan libtsan" 74RRECOMMENDS:${PN}:append:powerpc64 = " liblsan libtsan"
75RRECOMMENDS_${PN}_append_aarch64 = " liblsan libtsan" 75RRECOMMENDS:${PN}:append:aarch64 = " liblsan libtsan"
76 76
77do_package_write_ipk[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata" 77do_package_write_ipk[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
78do_package_write_deb[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata" 78do_package_write_deb[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
79do_package_write_rpm[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata" 79do_package_write_rpm[depends] += "virtual/${MLPREFIX}${TARGET_PREFIX}compilerlibs:do_packagedata"
80 80
81# Only x86, powerpc, sparc, s390, arm, and aarch64 are supported 81# Only x86, powerpc, sparc, s390, arm, aarch64 and loongarch64 are supported
82COMPATIBLE_HOST = '(x86_64|i.86|powerpc|sparc|s390|arm|aarch64).*-linux' 82COMPATIBLE_HOST = '(x86_64|i.86|powerpc|sparc|s390|arm|aarch64|loongarch64).*-linux'
83# musl is currently broken entirely 83# musl is currently broken entirely
84COMPATIBLE_HOST_libc-musl = 'null' 84COMPATIBLE_HOST:libc-musl = 'null'
85 85
86FILES_libasan += "${libdir}/libasan.so.*" 86FILES:libasan += "${libdir}/libasan.so.* ${libdir}/libhwasan.so.*"
87FILES_libasan-dev += "\ 87FILES:libasan-dev += "\
88 ${libdir}/libasan_preinit.o \ 88 ${libdir}/libasan_preinit.o \
89 ${libdir}/libhwasan_preinit.o \
89 ${libdir}/libasan.so \ 90 ${libdir}/libasan.so \
91 ${libdir}/libhwasan.so \
90 ${libdir}/libasan.la \ 92 ${libdir}/libasan.la \
91" 93"
92FILES_libasan-staticdev += "${libdir}/libasan.a" 94FILES:libasan-staticdev += "${libdir}/libasan.a \
95 ${libdir}/libhwasan.a \
96"
93 97
94FILES_libubsan += "${libdir}/libubsan.so.*" 98FILES:libubsan += "${libdir}/libubsan.so.*"
95FILES_libubsan-dev += "\ 99FILES:libubsan-dev += "\
96 ${libdir}/libubsan.so \ 100 ${libdir}/libubsan.so \
97 ${libdir}/libubsan.la \ 101 ${libdir}/libubsan.la \
98" 102"
99FILES_libubsan-staticdev += "${libdir}/libubsan.a" 103FILES:libubsan-staticdev += "${libdir}/libubsan.a"
100 104
101FILES_liblsan += "${libdir}/liblsan.so.*" 105FILES:liblsan += "${libdir}/liblsan.so.*"
102FILES_liblsan-dev += "\ 106FILES:liblsan-dev += "\
103 ${libdir}/liblsan.so \ 107 ${libdir}/liblsan.so \
104 ${libdir}/liblsan.la \ 108 ${libdir}/liblsan.la \
105 ${libdir}/liblsan_preinit.o \ 109 ${libdir}/liblsan_preinit.o \
106" 110"
107FILES_liblsan-staticdev += "${libdir}/liblsan.a" 111FILES:liblsan-staticdev += "${libdir}/liblsan.a"
108 112
109FILES_libtsan += "${libdir}/libtsan.so.*" 113FILES:libtsan += "${libdir}/libtsan.so.*"
110FILES_libtsan-dev += "\ 114FILES:libtsan-dev += "\
111 ${libdir}/libtsan.so \ 115 ${libdir}/libtsan.so \
112 ${libdir}/libtsan.la \ 116 ${libdir}/libtsan.la \
113 ${libdir}/libtsan_*.o \ 117 ${libdir}/libtsan_*.o \
114" 118"
115FILES_libtsan-staticdev += "${libdir}/libtsan.a" 119FILES:libtsan-staticdev += "${libdir}/libtsan.a"
116 120
117FILES_${PN} = "${libdir}/*.spec ${libdir}/${TARGET_SYS}/${BINV}/include/sanitizer/*.h" 121FILES:${PN} = "${libdir}/*.spec ${libdir}/${TARGET_SYS}/${BINV}/include/sanitizer/*.h"
diff --git a/meta/recipes-devtools/gcc/gcc-sanitizers_10.2.bb b/meta/recipes-devtools/gcc/gcc-sanitizers_13.2.bb
index f3c7058114..8bda2ccad6 100644
--- a/meta/recipes-devtools/gcc/gcc-sanitizers_10.2.bb
+++ b/meta/recipes-devtools/gcc/gcc-sanitizers_13.2.bb
@@ -3,5 +3,5 @@ require gcc-sanitizers.inc
3 3
4# Building with thumb enabled on armv4t armv5t fails with 4# Building with thumb enabled on armv4t armv5t fails with
5# sanitizer_linux.s:5749: Error: lo register required -- `ldr ip,[sp],#8' 5# sanitizer_linux.s:5749: Error: lo register required -- `ldr ip,[sp],#8'
6ARM_INSTRUCTION_SET_armv4 = "arm" 6ARM_INSTRUCTION_SET:armv4 = "arm"
7ARM_INSTRUCTION_SET_armv5 = "arm" 7ARM_INSTRUCTION_SET:armv5 = "arm"
diff --git a/meta/recipes-devtools/gcc/gcc-shared-source.inc b/meta/recipes-devtools/gcc/gcc-shared-source.inc
index aac4b49313..03f520b093 100644
--- a/meta/recipes-devtools/gcc/gcc-shared-source.inc
+++ b/meta/recipes-devtools/gcc/gcc-shared-source.inc
@@ -9,3 +9,13 @@ SRC_URI = ""
9 9
10do_configure[depends] += "gcc-source-${PV}:do_preconfigure" 10do_configure[depends] += "gcc-source-${PV}:do_preconfigure"
11do_populate_lic[depends] += "gcc-source-${PV}:do_unpack" 11do_populate_lic[depends] += "gcc-source-${PV}:do_unpack"
12do_deploy_source_date_epoch[depends] += "gcc-source-${PV}:do_deploy_source_date_epoch"
13
14# Copy the SDE from the shared workdir to the recipe workdir
15do_deploy_source_date_epoch () {
16 sde_file=${SDE_FILE}
17 sde_file=${sde_file#${WORKDIR}/}
18 mkdir -p ${SDE_DEPLOYDIR} $(dirname ${SDE_FILE})
19 cp -p $(dirname ${S})/$sde_file ${SDE_DEPLOYDIR}
20 cp -p $(dirname ${S})/$sde_file ${SDE_FILE}
21}
diff --git a/meta/recipes-devtools/gcc/gcc-source.inc b/meta/recipes-devtools/gcc/gcc-source.inc
index 03bab97815..265bcf4bef 100644
--- a/meta/recipes-devtools/gcc/gcc-source.inc
+++ b/meta/recipes-devtools/gcc/gcc-source.inc
@@ -17,15 +17,21 @@ STAMPCLEAN = "${STAMPS_DIR}/work-shared/gcc-${PV}-*"
17INHIBIT_DEFAULT_DEPS = "1" 17INHIBIT_DEFAULT_DEPS = "1"
18DEPENDS = "" 18DEPENDS = ""
19PACKAGES = "" 19PACKAGES = ""
20TARGET_ARCH = "allarch"
21TARGET_AS_ARCH = "none"
22TARGET_CC_ARCH = "none"
23TARGET_LD_ARCH = "none"
24TARGET_OS = "linux"
25baselib = "lib"
26PACKAGE_ARCH = "all"
20 27
28B = "${WORKDIR}/build"
21 29
22# This needs to be Python to avoid lots of shell variables becoming dependencies. 30# This needs to be Python to avoid lots of shell variables becoming dependencies.
23python do_preconfigure () { 31python do_preconfigure () {
24 import subprocess 32 import subprocess
25 cmd = d.expand('cd ${S} && PATH=${PATH} gnu-configize') 33 cmd = d.expand('cd ${S} && PATH=${PATH} gnu-configize')
26 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 34 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
27 # See 0044-gengtypes.patch, we need to regenerate this file
28 bb.utils.remove(d.expand("${S}/gcc/gengtype-lex.c"))
29 cmd = d.expand("sed -i 's/BUILD_INFO=info/BUILD_INFO=/' ${S}/gcc/configure") 35 cmd = d.expand("sed -i 's/BUILD_INFO=info/BUILD_INFO=/' ${S}/gcc/configure")
30 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True) 36 subprocess.check_output(cmd, stderr=subprocess.STDOUT, shell=True)
31 37
diff --git a/meta/recipes-devtools/gcc/gcc-source_10.2.bb b/meta/recipes-devtools/gcc/gcc-source_13.2.bb
index b890fa33ea..b890fa33ea 100644
--- a/meta/recipes-devtools/gcc/gcc-source_10.2.bb
+++ b/meta/recipes-devtools/gcc/gcc-source_13.2.bb
diff --git a/meta/recipes-devtools/gcc/gcc-target.inc b/meta/recipes-devtools/gcc/gcc-target.inc
index 1e25dad86b..7dac3ef422 100644
--- a/meta/recipes-devtools/gcc/gcc-target.inc
+++ b/meta/recipes-devtools/gcc/gcc-target.inc
@@ -5,7 +5,7 @@ EXTRA_OECONF_PATHS = "\
5 --with-build-sysroot=${STAGING_DIR_TARGET} \ 5 --with-build-sysroot=${STAGING_DIR_TARGET} \
6" 6"
7 7
8EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu" 8EXTRA_OECONF:append:linuxstdbase = " --enable-clocale=gnu"
9 9
10# Configure gcc running on the target to default to an architecture which will 10# Configure gcc running on the target to default to an architecture which will
11# be compatible with that of gcc-runtime (which is cross compiled to be target 11# be compatible with that of gcc-runtime (which is cross compiled to be target
@@ -15,11 +15,11 @@ EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu"
15 15
16ARMFPARCHEXT ?= "" 16ARMFPARCHEXT ?= ""
17 17
18EXTRA_OECONF_append_armv6_class-target = " --with-arch=armv6${ARMFPARCHEXT}" 18EXTRA_OECONF:append:armv6:class-target = " --with-arch=armv6${ARMFPARCHEXT}"
19EXTRA_OECONF_append_armv7a_class-target = " --with-arch=armv7-a${ARMFPARCHEXT}" 19EXTRA_OECONF:append:armv7a:class-target = " --with-arch=armv7-a${ARMFPARCHEXT}"
20EXTRA_OECONF_append_armv7ve_class-target = " --with-arch=armv7ve${ARMFPARCHEXT}" 20EXTRA_OECONF:append:armv7ve:class-target = " --with-arch=armv7ve${ARMFPARCHEXT}"
21EXTRA_OECONF_append_arc_class-target = " --with-cpu=${TUNE_PKGARCH}" 21EXTRA_OECONF:append:arc:class-target = " --with-cpu=${TUNE_PKGARCH}"
22EXTRA_OECONF_append_x86-64_class-target = " --with-arch=native" 22EXTRA_OECONF:append:x86-64:class-target = " ${@get_gcc_x86_64_arch_setting(bb, d)}"
23 23
24# libcc1 requres gcc_cv_objdump when cross build, but gcc_cv_objdump is 24# libcc1 requres gcc_cv_objdump when cross build, but gcc_cv_objdump is
25# set in subdir gcc, so subdir libcc1 can't use it, export it here to 25# set in subdir gcc, so subdir libcc1 can't use it, export it here to
@@ -40,11 +40,11 @@ PACKAGES = "\
40 ${PN}-dbg \ 40 ${PN}-dbg \
41" 41"
42 42
43FILES_${PN} = "\ 43FILES:${PN} = "\
44 ${bindir}/${TARGET_PREFIX}gcc* \ 44 ${bindir}/${TARGET_PREFIX}gcc* \
45 ${bindir}/${TARGET_PREFIX}lto* \ 45 ${bindir}/${TARGET_PREFIX}lto* \
46 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/collect2* \ 46 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/collect2* \
47 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \ 47 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/g++-mapper-server \
48 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lto* \ 48 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lto* \
49 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \ 49 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
50 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto*${SOLIBSDEV} \ 50 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto*${SOLIBSDEV} \
@@ -53,86 +53,87 @@ FILES_${PN} = "\
53 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \ 53 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
54 ${gcclibdir}/${TARGET_SYS}/${BINV}/include \ 54 ${gcclibdir}/${TARGET_SYS}/${BINV}/include \
55 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \ 55 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
56 ${libdir}/bfd-plugins/*.so \
56" 57"
57INSANE_SKIP_${PN} += "dev-so" 58INSANE_SKIP:${PN} += "dev-so"
58RRECOMMENDS_${PN} += "\ 59RRECOMMENDS:${PN} += "\
59 libssp \ 60 libssp \
60 libssp-dev \ 61 libssp-dev \
61" 62"
62RDEPENDS_${PN} += "cpp" 63RDEPENDS:${PN} += "cpp"
63 64
64FILES_${PN}-dev = "\ 65FILES:${PN}-dev = "\
65 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \ 66 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
66 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \ 67 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
67 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \ 68 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
68 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/gengtype \ 69 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/gengtype \
69 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.state \ 70 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.state \
70" 71"
71FILES_${PN}-symlinks = "\ 72FILES:${PN}-symlinks = "\
72 ${bindir}/cc \ 73 ${bindir}/cc \
73 ${bindir}/gcc \ 74 ${bindir}/gcc \
74 ${bindir}/gccbug \ 75 ${bindir}/gccbug \
75" 76"
76 77
77FILES_${PN}-plugins = "\ 78FILES:${PN}-plugins = "\
78 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \ 79 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \
79" 80"
80ALLOW_EMPTY_${PN}-plugins = "1" 81ALLOW_EMPTY:${PN}-plugins = "1"
81 82
82FILES_g77 = "\ 83FILES:g77 = "\
83 ${bindir}/${TARGET_PREFIX}g77 \ 84 ${bindir}/${TARGET_PREFIX}g77 \
84 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \ 85 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \
85" 86"
86FILES_g77-symlinks = "\ 87FILES:g77-symlinks = "\
87 ${bindir}/g77 \ 88 ${bindir}/g77 \
88 ${bindir}/f77 \ 89 ${bindir}/f77 \
89" 90"
90RRECOMMENDS_g77 = "\ 91RRECOMMENDS:g77 = "\
91 libg2c \ 92 libg2c \
92 libg2c-dev \ 93 libg2c-dev \
93" 94"
94 95
95FILES_gfortran = "\ 96FILES:gfortran = "\
96 ${bindir}/${TARGET_PREFIX}gfortran \ 97 ${bindir}/${TARGET_PREFIX}gfortran \
97 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \ 98 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \
98" 99"
99RRECOMMENDS_gfortran = "\ 100RRECOMMENDS:gfortran = "\
100 libquadmath \ 101 libquadmath \
101 libquadmath-dev \ 102 libquadmath-dev \
102" 103"
103FILES_gfortran-symlinks = "\ 104FILES:gfortran-symlinks = "\
104 ${bindir}/gfortran \ 105 ${bindir}/gfortran \
105 ${bindir}/f95" 106 ${bindir}/f95"
106 107
107FILES_cpp = "\ 108FILES:cpp = "\
108 ${bindir}/${TARGET_PREFIX}cpp* \ 109 ${bindir}/${TARGET_PREFIX}cpp* \
109 ${base_libdir}/cpp \ 110 ${base_libdir}/cpp \
110 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1" 111 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1"
111FILES_cpp-symlinks = "${bindir}/cpp" 112FILES:cpp-symlinks = "${bindir}/cpp"
112 113
113FILES_gcov = "${bindir}/${TARGET_PREFIX}gcov* \ 114FILES:gcov = "${bindir}/${TARGET_PREFIX}gcov* \
114 ${bindir}/${TARGET_PREFIX}gcov-tool* \ 115 ${bindir}/${TARGET_PREFIX}gcov-tool* \
115" 116"
116FILES_gcov-symlinks = "${bindir}/gcov \ 117FILES:gcov-symlinks = "${bindir}/gcov \
117 ${bindir}/gcov-tool \ 118 ${bindir}/gcov-tool \
118" 119"
119 120
120FILES_g++ = "\ 121FILES:g++ = "\
121 ${bindir}/${TARGET_PREFIX}g++* \ 122 ${bindir}/${TARGET_PREFIX}g++* \
122 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \ 123 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \
123" 124"
124FILES_g++-symlinks = "\ 125FILES:g++-symlinks = "\
125 ${bindir}/c++ \ 126 ${bindir}/c++ \
126 ${bindir}/g++ \ 127 ${bindir}/g++ \
127" 128"
128RRECOMMENDS_g++ = "\ 129RRECOMMENDS:g++ = "\
129 libstdc++ \ 130 libstdc++ \
130 libstdc++-dev \ 131 libstdc++-dev \
131 libatomic \ 132 libatomic \
132 libatomic-dev \ 133 libatomic-dev \
133" 134"
134 135
135FILES_${PN}-doc = "\ 136FILES:${PN}-doc = "\
136 ${infodir} \ 137 ${infodir} \
137 ${mandir} \ 138 ${mandir} \
138 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \ 139 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
@@ -191,7 +192,7 @@ do_install () {
191 rm -f *c++* 192 rm -f *c++*
192 193
193 # We don't care about the gcc-<version> ones for this 194 # We don't care about the gcc-<version> ones for this
194 rm -f *gcc-?.?* 195 rm -f *gcc-?*.?*
195 196
196 # Not sure why we end up with these but we don't want them... 197 # Not sure why we end up with these but we don't want them...
197 rm -f ${TARGET_PREFIX}${TARGET_PREFIX}* 198 rm -f ${TARGET_PREFIX}${TARGET_PREFIX}*
@@ -214,11 +215,12 @@ do_install () {
214 ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp 215 ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp
215 ln -sf g++ c++ 216 ln -sf g++ c++
216 ln -sf gcc cc 217 ln -sf gcc cc
217 218 install -d ${D}${libdir}/bfd-plugins
219 ln -sf ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
218 chown -R root:root ${D} 220 chown -R root:root ${D}
219} 221}
220 222
221do_install_append () { 223do_install:append () {
222 # 224 #
223 # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header 225 # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header
224 # files and places the modified files into 226 # files and places the modified files into
@@ -254,4 +256,4 @@ do_install_append () {
254# and builds track file dependencies (e.g. perl and its makedepends code). 256# and builds track file dependencies (e.g. perl and its makedepends code).
255# For determinism we don't install this ever and rely on the copy from gcc-cross. 257# For determinism we don't install this ever and rely on the copy from gcc-cross.
256# [YOCTO #7287] 258# [YOCTO #7287]
257SYSROOT_DIRS_BLACKLIST += "${libdir}/gcc" 259SYSROOT_DIRS_IGNORE += "${libdir}/gcc"
diff --git a/meta/recipes-devtools/gcc/gcc-testsuite.inc b/meta/recipes-devtools/gcc/gcc-testsuite.inc
index f68fec58ed..f16d471478 100644
--- a/meta/recipes-devtools/gcc/gcc-testsuite.inc
+++ b/meta/recipes-devtools/gcc/gcc-testsuite.inc
@@ -51,9 +51,14 @@ python check_prepare() {
51 # enable all valid instructions, since the test suite itself does not 51 # enable all valid instructions, since the test suite itself does not
52 # limit itself to the target cpu options. 52 # limit itself to the target cpu options.
53 # - valid for x86*, powerpc, arm, arm64 53 # - valid for x86*, powerpc, arm, arm64
54 if qemu_binary.lstrip("qemu-") in ["x86_64", "i386", "ppc", "arm", "aarch64"]: 54 if qemu_binary.endswith(("x86_64", "i386", "arm", "aarch64")):
55 args += ["-cpu", "max"] 55 args += ["-cpu", "max"]
56 56 elif qemu_binary.endswith(("ppc", "mips", "mips64")):
57 extra = d.getVar("QEMU_EXTRAOPTIONS_%s" % d.getVar('PACKAGE_ARCH'))
58 if extra:
59 args += extra.split()
60 # For mips64 we could set a maximal CPU (e.g. Loongson-3A4000) however they either have MSA
61 # or Loongson-MMI vector extensions, not both and qemu lacks complete support for MMI
57 sysroot = d.getVar("RECIPE_SYSROOT") 62 sysroot = d.getVar("RECIPE_SYSROOT")
58 args += ["-L", sysroot] 63 args += ["-L", sysroot]
59 # lib paths are static here instead of using $libdir since this is used by a -cross recipe 64 # lib paths are static here instead of using $libdir since this is used by a -cross recipe
diff --git a/meta/recipes-devtools/gcc/gcc/0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch b/meta/recipes-devtools/gcc/gcc/0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch
deleted file mode 100644
index c060accd99..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0001-aarch64-Fix-up-__aarch64_cas16_acq_rel-fallback.patch
+++ /dev/null
@@ -1,66 +0,0 @@
1Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@arm.com>
3
4From fd2ec4542fd2975e6d3f2f1c1a2639945a84f9e1 Mon Sep 17 00:00:00 2001
5From: Jakub Jelinek <jakub@redhat.com>
6Date: Mon, 3 Aug 2020 22:55:28 +0200
7Subject: [PATCH] aarch64: Fix up __aarch64_cas16_acq_rel fallback
8
9As mentioned in the PR, the fallback path when LSE is unavailable writes
10incorrect registers to the memory if the previous content compares equal
11to x0, x1 - it writes copy of x0, x1 from the start of function, but it
12should write x2, x3.
13
142020-08-03 Jakub Jelinek <jakub@redhat.com>
15
16 PR target/96402
17 * config/aarch64/lse.S (__aarch64_cas16_acq_rel): Use x2, x3 instead
18 of x(tmp0), x(tmp1) in STXP arguments.
19
20 * gcc.target/aarch64/pr96402.c: New test.
21
22(cherry picked from commit 90b43856fdff7d96d93d22970eca8a86c56e0ddc)
23---
24 gcc/testsuite/gcc.target/aarch64/pr96402.c | 16 ++++++++++++++++
25 libgcc/config/aarch64/lse.S | 2 +-
26 2 files changed, 17 insertions(+), 1 deletion(-)
27 create mode 100644 gcc/testsuite/gcc.target/aarch64/pr96402.c
28
29diff --git a/gcc/testsuite/gcc.target/aarch64/pr96402.c b/gcc/testsuite/gcc.target/aarch64/pr96402.c
30new file mode 100644
31index 00000000000..fa2dddfac15
32--- /dev/null
33+++ b/gcc/testsuite/gcc.target/aarch64/pr96402.c
34@@ -0,0 +1,16 @@
35+/* PR target/96402 */
36+/* { dg-do run { target int128 } } */
37+/* { dg-options "-moutline-atomics" } */
38+
39+int
40+main ()
41+{
42+ __int128 a = 0;
43+ __sync_val_compare_and_swap (&a, (__int128) 0, (__int128) 1);
44+ if (a != 1)
45+ __builtin_abort ();
46+ __sync_val_compare_and_swap (&a, (__int128) 1, (((__int128) 0xdeadbeeffeedbac1ULL) << 64) | 0xabadcafe00c0ffeeULL);
47+ if (a != ((((__int128) 0xdeadbeeffeedbac1ULL) << 64) | 0xabadcafe00c0ffeeULL))
48+ __builtin_abort ();
49+ return 0;
50+}
51diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
52index 64691c601c1..c8fbfbce4fd 100644
53--- a/libgcc/config/aarch64/lse.S
54+++ b/libgcc/config/aarch64/lse.S
55@@ -203,7 +203,7 @@ STARTFN NAME(cas)
56 cmp x0, x(tmp0)
57 ccmp x1, x(tmp1), #0, eq
58 bne 1f
59- STXP w(tmp2), x(tmp0), x(tmp1), [x4]
60+ STXP w(tmp2), x2, x3, [x4]
61 cbnz w(tmp2), 0b
62 1: ret
63
64--
652.26.2
66
diff --git a/meta/recipes-devtools/gcc/gcc/0001-aarch64-New-Straight-Line-Speculation-SLS-mitigation.patch b/meta/recipes-devtools/gcc/gcc/0001-aarch64-New-Straight-Line-Speculation-SLS-mitigation.patch
deleted file mode 100644
index 73de4c7590..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0001-aarch64-New-Straight-Line-Speculation-SLS-mitigation.patch
+++ /dev/null
@@ -1,202 +0,0 @@
1CVE: CVE-2020-13844
2Upstream-Status: Backport
3Signed-off-by: Ross Burton <ross.burton@arm.com>
4
5From 1ff243934ac443b5f58cd02a5012ce58ecc31fb2 Mon Sep 17 00:00:00 2001
6From: Matthew Malcomson <matthew.malcomson@arm.com>
7Date: Thu, 9 Jul 2020 09:11:58 +0100
8Subject: [PATCH 1/3] aarch64: New Straight Line Speculation (SLS) mitigation
9 flags
10
11Here we introduce the flags that will be used for straight line speculation.
12
13The new flag introduced is `-mharden-sls=`.
14This flag can take arguments of `none`, `all`, or a comma seperated list of one
15or more of `retbr` or `blr`.
16`none` indicates no special mitigation of the straight line speculation
17vulnerability.
18`all` requests all mitigations currently implemented.
19`retbr` requests that the RET and BR instructions have a speculation barrier
20inserted after them.
21`blr` requests that BLR instructions are replaced by a BL to a function stub
22using a BR with a speculation barrier after it.
23
24Setting this on a per-function basis using attributes or the like is not
25enabled, but may be in the future.
26
27gcc/ChangeLog:
28
292020-06-02 Matthew Malcomson <matthew.malcomson@arm.com>
30
31 * config/aarch64/aarch64-protos.h (aarch64_harden_sls_retbr_p):
32 New.
33 (aarch64_harden_sls_blr_p): New.
34 * config/aarch64/aarch64.c (enum aarch64_sls_hardening_type):
35 New.
36 (aarch64_harden_sls_retbr_p): New.
37 (aarch64_harden_sls_blr_p): New.
38 (aarch64_validate_sls_mitigation): New.
39 (aarch64_override_options): Parse options for SLS mitigation.
40 * config/aarch64/aarch64.opt (-mharden-sls): New option.
41 * doc/invoke.texi: Document new option.
42---
43 gcc/config/aarch64/aarch64-protos.h | 3 ++
44 gcc/config/aarch64/aarch64.c | 76 +++++++++++++++++++++++++++++++++++++
45 gcc/config/aarch64/aarch64.opt | 4 ++
46 gcc/doc/invoke.texi | 12 ++++++
47 4 files changed, 95 insertions(+)
48
49diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
50index 723d9ba..eb5f4b4 100644
51--- a/gcc/config/aarch64/aarch64-protos.h
52+++ b/gcc/config/aarch64/aarch64-protos.h
53@@ -781,4 +781,7 @@ extern const atomic_ool_names aarch64_ool_ldeor_names;
54
55 tree aarch64_resolve_overloaded_builtin_general (location_t, tree, void *);
56
57+extern bool aarch64_harden_sls_retbr_p (void);
58+extern bool aarch64_harden_sls_blr_p (void);
59+
60 #endif /* GCC_AARCH64_PROTOS_H */
61diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
62index b86434a..437a9cf 100644
63--- a/gcc/config/aarch64/aarch64.c
64+++ b/gcc/config/aarch64/aarch64.c
65@@ -14494,6 +14494,79 @@ aarch64_validate_mcpu (const char *str, const struct processor **res,
66 return false;
67 }
68
69+/* Straight line speculation indicators. */
70+enum aarch64_sls_hardening_type
71+{
72+ SLS_NONE = 0,
73+ SLS_RETBR = 1,
74+ SLS_BLR = 2,
75+ SLS_ALL = 3,
76+};
77+static enum aarch64_sls_hardening_type aarch64_sls_hardening;
78+
79+/* Return whether we should mitigatate Straight Line Speculation for the RET
80+ and BR instructions. */
81+bool
82+aarch64_harden_sls_retbr_p (void)
83+{
84+ return aarch64_sls_hardening & SLS_RETBR;
85+}
86+
87+/* Return whether we should mitigatate Straight Line Speculation for the BLR
88+ instruction. */
89+bool
90+aarch64_harden_sls_blr_p (void)
91+{
92+ return aarch64_sls_hardening & SLS_BLR;
93+}
94+
95+/* As of yet we only allow setting these options globally, in the future we may
96+ allow setting them per function. */
97+static void
98+aarch64_validate_sls_mitigation (const char *const_str)
99+{
100+ char *token_save = NULL;
101+ char *str = NULL;
102+
103+ if (strcmp (const_str, "none") == 0)
104+ {
105+ aarch64_sls_hardening = SLS_NONE;
106+ return;
107+ }
108+ if (strcmp (const_str, "all") == 0)
109+ {
110+ aarch64_sls_hardening = SLS_ALL;
111+ return;
112+ }
113+
114+ char *str_root = xstrdup (const_str);
115+ str = strtok_r (str_root, ",", &token_save);
116+ if (!str)
117+ error ("invalid argument given to %<-mharden-sls=%>");
118+
119+ int temp = SLS_NONE;
120+ while (str)
121+ {
122+ if (strcmp (str, "blr") == 0)
123+ temp |= SLS_BLR;
124+ else if (strcmp (str, "retbr") == 0)
125+ temp |= SLS_RETBR;
126+ else if (strcmp (str, "none") == 0 || strcmp (str, "all") == 0)
127+ {
128+ error ("%<%s%> must be by itself for %<-mharden-sls=%>", str);
129+ break;
130+ }
131+ else
132+ {
133+ error ("invalid argument %<%s%> for %<-mharden-sls=%>", str);
134+ break;
135+ }
136+ str = strtok_r (NULL, ",", &token_save);
137+ }
138+ aarch64_sls_hardening = (aarch64_sls_hardening_type) temp;
139+ free (str_root);
140+}
141+
142 /* Parses CONST_STR for branch protection features specified in
143 aarch64_branch_protect_types, and set any global variables required. Returns
144 the parsing result and assigns LAST_STR to the last processed token from
145@@ -14738,6 +14811,9 @@ aarch64_override_options (void)
146 selected_arch = NULL;
147 selected_tune = NULL;
148
149+ if (aarch64_harden_sls_string)
150+ aarch64_validate_sls_mitigation (aarch64_harden_sls_string);
151+
152 if (aarch64_branch_protection_string)
153 aarch64_validate_mbranch_protection (aarch64_branch_protection_string);
154
155diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
156index d99d14c..5170361 100644
157--- a/gcc/config/aarch64/aarch64.opt
158+++ b/gcc/config/aarch64/aarch64.opt
159@@ -71,6 +71,10 @@ mgeneral-regs-only
160 Target Report RejectNegative Mask(GENERAL_REGS_ONLY) Save
161 Generate code which uses only the general registers.
162
163+mharden-sls=
164+Target RejectNegative Joined Var(aarch64_harden_sls_string)
165+Generate code to mitigate against straight line speculation.
166+
167 mfix-cortex-a53-835769
168 Target Report Var(aarch64_fix_a53_err835769) Init(2) Save
169 Workaround for ARM Cortex-A53 Erratum number 835769.
170diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
171index a2794a6..bd5b77a 100644
172--- a/gcc/doc/invoke.texi
173+++ b/gcc/doc/invoke.texi
174@@ -696,6 +696,7 @@ Objective-C and Objective-C++ Dialects}.
175 -msign-return-address=@var{scope} @gol
176 -mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}
177 +@var{b-key}]|@var{bti} @gol
178+-mharden-sls=@var{opts} @gol
179 -march=@var{name} -mcpu=@var{name} -mtune=@var{name} @gol
180 -moverride=@var{string} -mverbose-cost-dump @gol
181 -mstack-protector-guard=@var{guard} -mstack-protector-guard-reg=@var{sysreg} @gol
182@@ -17065,6 +17066,17 @@ functions. The optional argument @samp{b-key} can be used to sign the functions
183 with the B-key instead of the A-key.
184 @samp{bti} turns on branch target identification mechanism.
185
186+@item -mharden-sls=@var{opts}
187+@opindex mharden-sls
188+Enable compiler hardening against straight line speculation (SLS).
189+@var{opts} is a comma-separated list of the following options:
190+@table @samp
191+@item retbr
192+@item blr
193+@end table
194+In addition, @samp{-mharden-sls=all} enables all SLS hardening while
195+@samp{-mharden-sls=none} disables all SLS hardening.
196+
197 @item -msve-vector-bits=@var{bits}
198 @opindex msve-vector-bits
199 Specify the number of bits in an SVE vector register. This option only has
200--
2012.7.4
202
diff --git a/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch b/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
index 82ae9f8d14..5c75698eda 100644
--- a/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
+++ b/meta/recipes-devtools/gcc/gcc/0001-gcc-4.3.1-ARCH_FLAGS_FOR_TARGET.patch
@@ -1,4 +1,4 @@
1From f2a5dc3bc7e5727d6bf77e1c6e8a31a6f000883d Mon Sep 17 00:00:00 2001 1From 553564bdcabdcc5d4cc4de73c7eb94c505ef51f5 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 08:37:11 +0400 3Date: Fri, 29 Mar 2013 08:37:11 +0400
4Subject: [PATCH] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET 4Subject: [PATCH] gcc-4.3.1: ARCH_FLAGS_FOR_TARGET
@@ -12,10 +12,10 @@ Upstream-Status: Inappropriate [embedded specific]
12 2 files changed, 2 insertions(+), 2 deletions(-) 12 2 files changed, 2 insertions(+), 2 deletions(-)
13 13
14diff --git a/configure b/configure 14diff --git a/configure b/configure
15index 4cc938ebb7d..226a64939d1 100755 15index 117a7ef23f2..535265253fd 100755
16--- a/configure 16--- a/configure
17+++ b/configure 17+++ b/configure
18@@ -7722,7 +7722,7 @@ fi 18@@ -10195,7 +10195,7 @@ fi
19 # for target_alias and gcc doesn't manage it consistently. 19 # for target_alias and gcc doesn't manage it consistently.
20 target_configargs="--cache-file=./config.cache ${target_configargs}" 20 target_configargs="--cache-file=./config.cache ${target_configargs}"
21 21
@@ -25,10 +25,10 @@ index 4cc938ebb7d..226a64939d1 100755
25 *" newlib "*) 25 *" newlib "*)
26 case " $target_configargs " in 26 case " $target_configargs " in
27diff --git a/configure.ac b/configure.ac 27diff --git a/configure.ac b/configure.ac
28index c78d9cbea62..f024f4bac9b 100644 28index b3e9bbd2aa5..5ac8d6490f6 100644
29--- a/configure.ac 29--- a/configure.ac
30+++ b/configure.ac 30+++ b/configure.ac
31@@ -3227,7 +3227,7 @@ fi 31@@ -3351,7 +3351,7 @@ fi
32 # for target_alias and gcc doesn't manage it consistently. 32 # for target_alias and gcc doesn't manage it consistently.
33 target_configargs="--cache-file=./config.cache ${target_configargs}" 33 target_configargs="--cache-file=./config.cache ${target_configargs}"
34 34
diff --git a/meta/recipes-devtools/gcc/gcc/0001-libatomic-libgomp-libitc-Fix-bootstrap-PR70454.patch b/meta/recipes-devtools/gcc/gcc/0001-libatomic-libgomp-libitc-Fix-bootstrap-PR70454.patch
deleted file mode 100644
index addecb4bd8..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0001-libatomic-libgomp-libitc-Fix-bootstrap-PR70454.patch
+++ /dev/null
@@ -1,208 +0,0 @@
1From 2824d2418605e092899117e77bc8ebf332321807 Mon Sep 17 00:00:00 2001
2From: Jakub Jelinek <jakub@redhat.com>
3Date: Fri, 15 Jan 2021 13:12:59 +0100
4Subject: [PATCH] libatomic, libgomp, libitc: Fix bootstrap [PR70454]
5
6The recent changes to error on mixing -march=i386 and -fcf-protection broke
7bootstrap. This patch changes lib{atomic,gomp,itm} configury, so that it
8only adds -march=i486 to flags if really needed (i.e. when 486 or later isn't
9on by default already). Similarly, it will not use ifuncs if -mcx16
10(or -march=i686 for 32-bit) is on by default.
11
122021-01-15 Jakub Jelinek <jakub@redhat.com>
13
14 PR target/70454
15libatomic/
16 * configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
17 be added through preprocessor check on
18 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4. Determine if try_ifunc is needed
19 based on preprocessor check on __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
20 or __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8.
21libgomp/
22 * configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
23 be added through preprocessor check on
24 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.
25libitm/
26 * configure.tgt: For i?86 and x86_64 determine if -march=i486 needs to
27 be added through preprocessor check on
28 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4.
29
30Upstream-Status: Backport [master post 10.x release]
31---
32 libatomic/configure.tgt | 56 +++++++++++++++++++++++------------------
33 libgomp/configure.tgt | 35 +++++++++++---------------
34 libitm/configure.tgt | 37 +++++++++++++--------------
35 3 files changed, 64 insertions(+), 64 deletions(-)
36
37diff --git a/libatomic/configure.tgt b/libatomic/configure.tgt
38index 5dd0926d20..6ea082a29b 100644
39--- a/libatomic/configure.tgt
40+++ b/libatomic/configure.tgt
41@@ -81,32 +81,40 @@ case "${target_cpu}" in
42 ARCH=sparc
43 ;;
44
45- i[3456]86)
46- case " ${CC} ${CFLAGS} " in
47- *" -m64 "*|*" -mx32 "*)
48- ;;
49- *)
50- if test -z "$with_arch"; then
51- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
52- XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
53- fi
54- esac
55- ARCH=x86
56- # ??? Detect when -march=i686 is already enabled.
57- try_ifunc=yes
58- ;;
59- x86_64)
60- case " ${CC} ${CFLAGS} " in
61- *" -m32 "*)
62+ i[3456]86 | x86_64)
63+ cat > conftestx.c <<EOF
64+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
65+#error need -march=i486
66+#endif
67+EOF
68+ if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
69+ :
70+ else
71+ if test "${target_cpu}" = x86_64; then
72 XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
73- XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
74- ;;
75- *)
76- ;;
77- esac
78+ else
79+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
80+ fi
81+ XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
82+ fi
83+ cat > conftestx.c <<EOF
84+#ifdef __x86_64__
85+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_16
86+#error need -mcx16
87+#endif
88+#else
89+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
90+#error need -march=i686
91+#endif
92+#endif
93+EOF
94+ if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
95+ try_ifunc=no
96+ else
97+ try_ifunc=yes
98+ fi
99+ rm -f conftestx.c
100 ARCH=x86
101- # ??? Detect when -mcx16 is already enabled.
102- try_ifunc=yes
103 ;;
104
105 *) ARCH="${target_cpu}" ;;
106diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt
107index 4790a31e39..761ef2a7db 100644
108--- a/libgomp/configure.tgt
109+++ b/libgomp/configure.tgt
110@@ -70,28 +70,23 @@ if test x$enable_linux_futex = xyes; then
111 ;;
112
113 # Note that bare i386 is not included here. We need cmpxchg.
114- i[456]86-*-linux*)
115+ i[456]86-*-linux* | x86_64-*-linux*)
116 config_path="linux/x86 linux posix"
117- case " ${CC} ${CFLAGS} " in
118- *" -m64 "*|*" -mx32 "*)
119- ;;
120- *)
121- if test -z "$with_arch"; then
122- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
123- fi
124- esac
125- ;;
126-
127- # Similar jiggery-pokery for x86_64 multilibs, except here we
128- # can't rely on the --with-arch configure option, since that
129- # applies to the 64-bit side.
130- x86_64-*-linux*)
131- config_path="linux/x86 linux posix"
132- case " ${CC} ${CFLAGS} " in
133- *" -m32 "*)
134+ cat > conftestx.c <<EOF
135+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
136+#error need -march=i486
137+#endif
138+EOF
139+ if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
140+ :
141+ else
142+ if test "${target_cpu}" = x86_64; then
143 XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
144- ;;
145- esac
146+ else
147+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
148+ fi
149+ fi
150+ rm -f conftestx.c
151 ;;
152
153 # Note that sparcv7 and sparcv8 is not included here. We need cas.
154diff --git a/libitm/configure.tgt b/libitm/configure.tgt
155index 04109160e9..ca62bac627 100644
156--- a/libitm/configure.tgt
157+++ b/libitm/configure.tgt
158@@ -58,16 +58,23 @@ case "${target_cpu}" in
159
160 arm*) ARCH=arm ;;
161
162- i[3456]86)
163- case " ${CC} ${CFLAGS} " in
164- *" -m64 "*|*" -mx32 "*)
165- ;;
166- *)
167- if test -z "$with_arch"; then
168- XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
169- XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
170- fi
171- esac
172+ i[3456]86 | x86_64)
173+ cat > conftestx.c <<EOF
174+#ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
175+#error need -march=i486
176+#endif
177+EOF
178+ if ${CC} ${CFLAGS} -E conftestx.c > /dev/null 2>&1; then
179+ :
180+ else
181+ if test "${target_cpu}" = x86_64; then
182+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
183+ else
184+ XCFLAGS="${XCFLAGS} -march=i486 -mtune=${target_cpu}"
185+ fi
186+ XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
187+ fi
188+ rm -f conftestx.c
189 XCFLAGS="${XCFLAGS} -mrtm"
190 ARCH=x86
191 ;;
192@@ -102,16 +109,6 @@ case "${target_cpu}" in
193 ARCH=sparc
194 ;;
195
196- x86_64)
197- case " ${CC} ${CFLAGS} " in
198- *" -m32 "*)
199- XCFLAGS="${XCFLAGS} -march=i486 -mtune=generic"
200- XCFLAGS="${XCFLAGS} -fomit-frame-pointer"
201- ;;
202- esac
203- XCFLAGS="${XCFLAGS} -mrtm"
204- ARCH=x86
205- ;;
206 s390|s390x)
207 XCFLAGS="${XCFLAGS} -mzarch -mhtm"
208 ARCH=s390
diff --git a/meta/recipes-devtools/gcc/gcc/0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch b/meta/recipes-devtools/gcc/gcc/0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch
deleted file mode 100644
index 823cc8b668..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0002-aarch64-Introduce-SLS-mitigation-for-RET-and-BR-inst.patch
+++ /dev/null
@@ -1,607 +0,0 @@
1Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@arm.com>
3
4From b1204d16e1ec96a4aa89e44de8990e2499ffdb22 Mon Sep 17 00:00:00 2001
5From: Matthew Malcomson <matthew.malcomson@arm.com>
6Date: Thu, 9 Jul 2020 09:11:59 +0100
7Subject: [PATCH 2/3] aarch64: Introduce SLS mitigation for RET and BR
8 instructions
9
10Instructions following RET or BR are not necessarily executed. In order
11to avoid speculation past RET and BR we can simply append a speculation
12barrier.
13
14Since these speculation barriers will not be architecturally executed,
15they are not expected to add a high performance penalty.
16
17The speculation barrier is to be SB when targeting architectures which
18have this enabled, and DSB SY + ISB otherwise.
19
20We add tests for each of the cases where such an instruction was seen.
21
22This is implemented by modifying each machine description pattern that
23emits either a RET or a BR instruction. We choose not to use something
24like `TARGET_ASM_FUNCTION_EPILOGUE` since it does not affect the
25`indirect_jump`, `jump`, `sibcall_insn` and `sibcall_value_insn`
26patterns and we find it preferable to implement the functionality in the
27same way for every pattern.
28
29There is one particular case which is slightly tricky. The
30implementation of TARGET_ASM_TRAMPOLINE_TEMPLATE uses a BR which needs
31to be mitigated against. The trampoline template is used *once* per
32compilation unit, and the TRAMPOLINE_SIZE is exposed to the user via the
33builtin macro __LIBGCC_TRAMPOLINE_SIZE__.
34In the future we may implement function specific attributes to turn on
35and off hardening on a per-function basis.
36The fixed nature of the trampoline described above implies it will be
37safer to ensure this speculation barrier is always used.
38
39Testing:
40 Bootstrap and regtest done on aarch64-none-linux
41 Used a temporary hack(1) to use these options on every test in the
42 testsuite and a script to check that the output never emitted an
43 unmitigated RET or BR.
44
451) Temporary hack was a change to the testsuite to always use
46`-save-temps` and run a script on the assembly output of those
47compilations which produced one to ensure every RET or BR is immediately
48followed by a speculation barrier.
49
50gcc/ChangeLog:
51
52 * config/aarch64/aarch64-protos.h (aarch64_sls_barrier): New.
53 * config/aarch64/aarch64.c (aarch64_output_casesi): Emit
54 speculation barrier after BR instruction if needs be.
55 (aarch64_trampoline_init): Handle ptr_mode value & adjust size
56 of code copied.
57 (aarch64_sls_barrier): New.
58 (aarch64_asm_trampoline_template): Add needed barriers.
59 * config/aarch64/aarch64.h (AARCH64_ISA_SB): New.
60 (TARGET_SB): New.
61 (TRAMPOLINE_SIZE): Account for barrier.
62 * config/aarch64/aarch64.md (indirect_jump, *casesi_dispatch,
63 simple_return, *do_return, *sibcall_insn, *sibcall_value_insn):
64 Emit barrier if needs be, also account for possible barrier using
65 "sls_length" attribute.
66 (sls_length): New attribute.
67 (length): Determine default using any non-default sls_length
68 value.
69
70gcc/testsuite/ChangeLog:
71
72 * gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c: New test.
73 * gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c:
74 New test.
75 * gcc.target/aarch64/sls-mitigation/sls-mitigation.exp: New file.
76 * lib/target-supports.exp (check_effective_target_aarch64_asm_sb_ok):
77 New proc.
78---
79 gcc/config/aarch64/aarch64-protos.h | 1 +
80 gcc/config/aarch64/aarch64.c | 41 ++++++-
81 gcc/config/aarch64/aarch64.h | 10 +-
82 gcc/config/aarch64/aarch64.md | 76 +++++++++----
83 .../aarch64/sls-mitigation/sls-miti-retbr-pacret.c | 21 ++++
84 .../aarch64/sls-mitigation/sls-miti-retbr.c | 119 +++++++++++++++++++++
85 .../aarch64/sls-mitigation/sls-mitigation.exp | 73 +++++++++++++
86 gcc/testsuite/lib/target-supports.exp | 2 +-
87 8 files changed, 318 insertions(+), 25 deletions(-)
88 create mode 100644 gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c
89 create mode 100644 gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c
90 create mode 100644 gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-mitigation.exp
91
92diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
93index eb5f4b4..ee0ffde 100644
94--- a/gcc/config/aarch64/aarch64-protos.h
95+++ b/gcc/config/aarch64/aarch64-protos.h
96@@ -781,6 +781,7 @@ extern const atomic_ool_names aarch64_ool_ldeor_names;
97
98 tree aarch64_resolve_overloaded_builtin_general (location_t, tree, void *);
99
100+const char *aarch64_sls_barrier (int);
101 extern bool aarch64_harden_sls_retbr_p (void);
102 extern bool aarch64_harden_sls_blr_p (void);
103
104diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
105index 437a9cf..44e3d1f 100644
106--- a/gcc/config/aarch64/aarch64.c
107+++ b/gcc/config/aarch64/aarch64.c
108@@ -10852,8 +10852,8 @@ aarch64_return_addr (int count, rtx frame ATTRIBUTE_UNUSED)
109 static void
110 aarch64_asm_trampoline_template (FILE *f)
111 {
112- int offset1 = 16;
113- int offset2 = 20;
114+ int offset1 = 24;
115+ int offset2 = 28;
116
117 if (aarch64_bti_enabled ())
118 {
119@@ -10876,6 +10876,17 @@ aarch64_asm_trampoline_template (FILE *f)
120 }
121 asm_fprintf (f, "\tbr\t%s\n", reg_names [IP1_REGNUM]);
122
123+ /* We always emit a speculation barrier.
124+ This is because the same trampoline template is used for every nested
125+ function. Since nested functions are not particularly common or
126+ performant we don't worry too much about the extra instructions to copy
127+ around.
128+ This is not yet a problem, since we have not yet implemented function
129+ specific attributes to choose between hardening against straight line
130+ speculation or not, but such function specific attributes are likely to
131+ happen in the future. */
132+ asm_fprintf (f, "\tdsb\tsy\n\tisb\n");
133+
134 /* The trampoline needs an extra padding instruction. In case if BTI is
135 enabled the padding instruction is replaced by the BTI instruction at
136 the beginning. */
137@@ -10890,10 +10901,14 @@ static void
138 aarch64_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value)
139 {
140 rtx fnaddr, mem, a_tramp;
141- const int tramp_code_sz = 16;
142+ const int tramp_code_sz = 24;
143
144 /* Don't need to copy the trailing D-words, we fill those in below. */
145- emit_block_move (m_tramp, assemble_trampoline_template (),
146+ /* We create our own memory address in Pmode so that `emit_block_move` can
147+ use parts of the backend which expect Pmode addresses. */
148+ rtx temp = convert_memory_address (Pmode, XEXP (m_tramp, 0));
149+ emit_block_move (gen_rtx_MEM (BLKmode, temp),
150+ assemble_trampoline_template (),
151 GEN_INT (tramp_code_sz), BLOCK_OP_NORMAL);
152 mem = adjust_address (m_tramp, ptr_mode, tramp_code_sz);
153 fnaddr = XEXP (DECL_RTL (fndecl), 0);
154@@ -11084,6 +11099,8 @@ aarch64_output_casesi (rtx *operands)
155 output_asm_insn (buf, operands);
156 output_asm_insn (patterns[index][1], operands);
157 output_asm_insn ("br\t%3", operands);
158+ output_asm_insn (aarch64_sls_barrier (aarch64_harden_sls_retbr_p ()),
159+ operands);
160 assemble_label (asm_out_file, label);
161 return "";
162 }
163@@ -22924,6 +22941,22 @@ aarch64_file_end_indicate_exec_stack ()
164 #undef GNU_PROPERTY_AARCH64_FEATURE_1_BTI
165 #undef GNU_PROPERTY_AARCH64_FEATURE_1_AND
166
167+/* Helper function for straight line speculation.
168+ Return what barrier should be emitted for straight line speculation
169+ mitigation.
170+ When not mitigating against straight line speculation this function returns
171+ an empty string.
172+ When mitigating against straight line speculation, use:
173+ * SB when the v8.5-A SB extension is enabled.
174+ * DSB+ISB otherwise. */
175+const char *
176+aarch64_sls_barrier (int mitigation_required)
177+{
178+ return mitigation_required
179+ ? (TARGET_SB ? "sb" : "dsb\tsy\n\tisb")
180+ : "";
181+}
182+
183 /* Target-specific selftests. */
184
185 #if CHECKING_P
186diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
187index 1ce23c6..c21015f 100644
188--- a/gcc/config/aarch64/aarch64.h
189+++ b/gcc/config/aarch64/aarch64.h
190@@ -281,6 +281,7 @@ extern unsigned aarch64_architecture_version;
191 #define AARCH64_ISA_F32MM (aarch64_isa_flags & AARCH64_FL_F32MM)
192 #define AARCH64_ISA_F64MM (aarch64_isa_flags & AARCH64_FL_F64MM)
193 #define AARCH64_ISA_BF16 (aarch64_isa_flags & AARCH64_FL_BF16)
194+#define AARCH64_ISA_SB (aarch64_isa_flags & AARCH64_FL_SB)
195
196 /* Crypto is an optional extension to AdvSIMD. */
197 #define TARGET_CRYPTO (TARGET_SIMD && AARCH64_ISA_CRYPTO)
198@@ -378,6 +379,9 @@ extern unsigned aarch64_architecture_version;
199 #define TARGET_FIX_ERR_A53_835769_DEFAULT 1
200 #endif
201
202+/* SB instruction is enabled through +sb. */
203+#define TARGET_SB (AARCH64_ISA_SB)
204+
205 /* Apply the workaround for Cortex-A53 erratum 835769. */
206 #define TARGET_FIX_ERR_A53_835769 \
207 ((aarch64_fix_a53_err835769 == 2) \
208@@ -1058,8 +1062,10 @@ typedef struct
209
210 #define RETURN_ADDR_RTX aarch64_return_addr
211
212-/* BTI c + 3 insns + 2 pointer-sized entries. */
213-#define TRAMPOLINE_SIZE (TARGET_ILP32 ? 24 : 32)
214+/* BTI c + 3 insns
215+ + sls barrier of DSB + ISB.
216+ + 2 pointer-sized entries. */
217+#define TRAMPOLINE_SIZE (24 + (TARGET_ILP32 ? 8 : 16))
218
219 /* Trampolines contain dwords, so must be dword aligned. */
220 #define TRAMPOLINE_ALIGNMENT 64
221diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
222index 8c8be3c..dda04ee 100644
223--- a/gcc/config/aarch64/aarch64.md
224+++ b/gcc/config/aarch64/aarch64.md
225@@ -407,10 +407,25 @@
226 ;; Attribute that specifies whether the alternative uses MOVPRFX.
227 (define_attr "movprfx" "no,yes" (const_string "no"))
228
229+;; Attribute to specify that an alternative has the length of a single
230+;; instruction plus a speculation barrier.
231+(define_attr "sls_length" "none,retbr,casesi" (const_string "none"))
232+
233 (define_attr "length" ""
234 (cond [(eq_attr "movprfx" "yes")
235 (const_int 8)
236- ] (const_int 4)))
237+
238+ (eq_attr "sls_length" "retbr")
239+ (cond [(match_test "!aarch64_harden_sls_retbr_p ()") (const_int 4)
240+ (match_test "TARGET_SB") (const_int 8)]
241+ (const_int 12))
242+
243+ (eq_attr "sls_length" "casesi")
244+ (cond [(match_test "!aarch64_harden_sls_retbr_p ()") (const_int 16)
245+ (match_test "TARGET_SB") (const_int 20)]
246+ (const_int 24))
247+ ]
248+ (const_int 4)))
249
250 ;; Strictly for compatibility with AArch32 in pipeline models, since AArch64 has
251 ;; no predicated insns.
252@@ -447,8 +462,12 @@
253 (define_insn "indirect_jump"
254 [(set (pc) (match_operand:DI 0 "register_operand" "r"))]
255 ""
256- "br\\t%0"
257- [(set_attr "type" "branch")]
258+ {
259+ output_asm_insn ("br\\t%0", operands);
260+ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ());
261+ }
262+ [(set_attr "type" "branch")
263+ (set_attr "sls_length" "retbr")]
264 )
265
266 (define_insn "jump"
267@@ -765,7 +784,7 @@
268 "*
269 return aarch64_output_casesi (operands);
270 "
271- [(set_attr "length" "16")
272+ [(set_attr "sls_length" "casesi")
273 (set_attr "type" "branch")]
274 )
275
276@@ -844,18 +863,23 @@
277 [(return)]
278 ""
279 {
280+ const char *ret = NULL;
281 if (aarch64_return_address_signing_enabled ()
282 && TARGET_ARMV8_3
283 && !crtl->calls_eh_return)
284 {
285 if (aarch64_ra_sign_key == AARCH64_KEY_B)
286- return "retab";
287+ ret = "retab";
288 else
289- return "retaa";
290+ ret = "retaa";
291 }
292- return "ret";
293+ else
294+ ret = "ret";
295+ output_asm_insn (ret, operands);
296+ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ());
297 }
298- [(set_attr "type" "branch")]
299+ [(set_attr "type" "branch")
300+ (set_attr "sls_length" "retbr")]
301 )
302
303 (define_expand "return"
304@@ -867,8 +891,12 @@
305 (define_insn "simple_return"
306 [(simple_return)]
307 ""
308- "ret"
309- [(set_attr "type" "branch")]
310+ {
311+ output_asm_insn ("ret", operands);
312+ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ());
313+ }
314+ [(set_attr "type" "branch")
315+ (set_attr "sls_length" "retbr")]
316 )
317
318 (define_insn "*cb<optab><mode>1"
319@@ -1066,10 +1094,16 @@
320 (unspec:DI [(match_operand:DI 2 "const_int_operand")] UNSPEC_CALLEE_ABI)
321 (return)]
322 "SIBLING_CALL_P (insn)"
323- "@
324- br\\t%0
325- b\\t%c0"
326- [(set_attr "type" "branch, branch")]
327+ {
328+ if (which_alternative == 0)
329+ {
330+ output_asm_insn ("br\\t%0", operands);
331+ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ());
332+ }
333+ return "b\\t%c0";
334+ }
335+ [(set_attr "type" "branch, branch")
336+ (set_attr "sls_length" "retbr,none")]
337 )
338
339 (define_insn "*sibcall_value_insn"
340@@ -1080,10 +1114,16 @@
341 (unspec:DI [(match_operand:DI 3 "const_int_operand")] UNSPEC_CALLEE_ABI)
342 (return)]
343 "SIBLING_CALL_P (insn)"
344- "@
345- br\\t%1
346- b\\t%c1"
347- [(set_attr "type" "branch, branch")]
348+ {
349+ if (which_alternative == 0)
350+ {
351+ output_asm_insn ("br\\t%1", operands);
352+ return aarch64_sls_barrier (aarch64_harden_sls_retbr_p ());
353+ }
354+ return "b\\t%c1";
355+ }
356+ [(set_attr "type" "branch, branch")
357+ (set_attr "sls_length" "retbr,none")]
358 )
359
360 ;; Call subroutine returning any type.
361diff --git a/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c
362new file mode 100644
363index 0000000..fa1887a
364--- /dev/null
365+++ b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr-pacret.c
366@@ -0,0 +1,21 @@
367+/* Avoid ILP32 since pacret is only available for LP64 */
368+/* { dg-do compile { target { ! ilp32 } } } */
369+/* { dg-additional-options "-mharden-sls=retbr -mbranch-protection=pac-ret -march=armv8.3-a" } */
370+
371+/* Testing the do_return pattern for retaa and retab. */
372+long retbr_subcall(void);
373+long retbr_do_return_retaa(void)
374+{
375+ return retbr_subcall()+1;
376+}
377+
378+__attribute__((target("branch-protection=pac-ret+b-key")))
379+long retbr_do_return_retab(void)
380+{
381+ return retbr_subcall()+1;
382+}
383+
384+/* Ensure there are no BR or RET instructions which are not directly followed
385+ by a speculation barrier. */
386+/* { dg-final { scan-assembler-not {\t(br|ret|retaa|retab)\tx[0-9][0-9]?\n\t(?!dsb\tsy\n\tisb)} } } */
387+/* { dg-final { scan-assembler-not {ret\t} } } */
388diff --git a/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c
389new file mode 100644
390index 0000000..76b8d03
391--- /dev/null
392+++ b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-retbr.c
393@@ -0,0 +1,119 @@
394+/* We ensure that -Wpedantic is off since it complains about the trampolines
395+ we explicitly want to test. */
396+/* { dg-additional-options "-mharden-sls=retbr -Wno-pedantic " } */
397+/*
398+ Ensure that the SLS hardening of RET and BR leaves no unprotected RET/BR
399+ instructions.
400+ */
401+typedef int (foo) (int, int);
402+typedef void (bar) (int, int);
403+struct sls_testclass {
404+ foo *x;
405+ bar *y;
406+ int left;
407+ int right;
408+};
409+
410+int
411+retbr_sibcall_value_insn (struct sls_testclass x)
412+{
413+ return x.x(x.left, x.right);
414+}
415+
416+void
417+retbr_sibcall_insn (struct sls_testclass x)
418+{
419+ x.y(x.left, x.right);
420+}
421+
422+/* Aim to test two different returns.
423+ One that introduces a tail call in the middle of the function, and one that
424+ has a normal return. */
425+int
426+retbr_multiple_returns (struct sls_testclass x)
427+{
428+ int temp;
429+ if (x.left % 10)
430+ return x.x(x.left, 100);
431+ else if (x.right % 20)
432+ {
433+ return x.x(x.left * x.right, 100);
434+ }
435+ temp = x.left % x.right;
436+ temp *= 100;
437+ temp /= 2;
438+ return temp % 3;
439+}
440+
441+void
442+retbr_multiple_returns_void (struct sls_testclass x)
443+{
444+ if (x.left % 10)
445+ {
446+ x.y(x.left, 100);
447+ }
448+ else if (x.right % 20)
449+ {
450+ x.y(x.left * x.right, 100);
451+ }
452+ return;
453+}
454+
455+/* Testing the casesi jump via register. */
456+__attribute__ ((optimize ("Os")))
457+int
458+retbr_casesi_dispatch (struct sls_testclass x)
459+{
460+ switch (x.left)
461+ {
462+ case -5:
463+ return -2;
464+ case -3:
465+ return -1;
466+ case 0:
467+ return 0;
468+ case 3:
469+ return 1;
470+ case 5:
471+ break;
472+ default:
473+ __builtin_unreachable ();
474+ }
475+ return x.right;
476+}
477+
478+/* Testing the BR in trampolines is mitigated against. */
479+void f1 (void *);
480+void f3 (void *, void (*)(void *));
481+void f2 (void *);
482+
483+int
484+retbr_trampolines (void *a, int b)
485+{
486+ if (!b)
487+ {
488+ f1 (a);
489+ return 1;
490+ }
491+ if (b)
492+ {
493+ void retbr_tramp_internal (void *c)
494+ {
495+ if (c == a)
496+ f2 (c);
497+ }
498+ f3 (a, retbr_tramp_internal);
499+ }
500+ return 0;
501+}
502+
503+/* Testing the indirect_jump pattern. */
504+void
505+retbr_indirect_jump (int *buf)
506+{
507+ __builtin_longjmp(buf, 1);
508+}
509+
510+/* Ensure there are no BR or RET instructions which are not directly followed
511+ by a speculation barrier. */
512+/* { dg-final { scan-assembler-not {\t(br|ret|retaa|retab)\tx[0-9][0-9]?\n\t(?!dsb\tsy\n\tisb|sb)} } } */
513diff --git a/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-mitigation.exp b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-mitigation.exp
514new file mode 100644
515index 0000000..8122503
516--- /dev/null
517+++ b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-mitigation.exp
518@@ -0,0 +1,73 @@
519+# Regression driver for SLS mitigation on AArch64.
520+# Copyright (C) 2020 Free Software Foundation, Inc.
521+# Contributed by ARM Ltd.
522+#
523+# This file is part of GCC.
524+#
525+# GCC is free software; you can redistribute it and/or modify it
526+# under the terms of the GNU General Public License as published by
527+# the Free Software Foundation; either version 3, or (at your option)
528+# any later version.
529+#
530+# GCC is distributed in the hope that it will be useful, but
531+# WITHOUT ANY WARRANTY; without even the implied warranty of
532+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
533+# General Public License for more details.
534+#
535+# You should have received a copy of the GNU General Public License
536+# along with GCC; see the file COPYING3. If not see
537+# <http://www.gnu.org/licenses/>. */
538+
539+# Exit immediately if this isn't an AArch64 target.
540+if {![istarget aarch64*-*-*] } then {
541+ return
542+}
543+
544+# Load support procs.
545+load_lib gcc-dg.exp
546+load_lib torture-options.exp
547+
548+# If a testcase doesn't have special options, use these.
549+global DEFAULT_CFLAGS
550+if ![info exists DEFAULT_CFLAGS] then {
551+ set DEFAULT_CFLAGS " "
552+}
553+
554+# Initialize `dg'.
555+dg-init
556+torture-init
557+
558+# Use different architectures as well as the normal optimisation options.
559+# (i.e. use both SB and DSB+ISB barriers).
560+
561+set save-dg-do-what-default ${dg-do-what-default}
562+# Main loop.
563+# Run with torture tests (i.e. a bunch of different optimisation levels) just
564+# to increase test coverage.
565+set dg-do-what-default assemble
566+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
567+ "-save-temps" $DEFAULT_CFLAGS
568+
569+# Run the same tests but this time with SB extension.
570+# Since not all supported assemblers will support that extension we decide
571+# whether to assemble or just compile based on whether the extension is
572+# supported for the available assembler.
573+
574+set templist {}
575+foreach x $DG_TORTURE_OPTIONS {
576+ lappend templist "$x -march=armv8.3-a+sb "
577+ lappend templist "$x -march=armv8-a+sb "
578+}
579+set-torture-options $templist
580+if { [check_effective_target_aarch64_asm_sb_ok] } {
581+ set dg-do-what-default assemble
582+} else {
583+ set dg-do-what-default compile
584+}
585+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
586+ "-save-temps" $DEFAULT_CFLAGS
587+set dg-do-what-default ${save-dg-do-what-default}
588+
589+# All done.
590+torture-finish
591+dg-finish
592diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
593index 8a186dd..9d2e093 100644
594--- a/gcc/testsuite/lib/target-supports.exp
595+++ b/gcc/testsuite/lib/target-supports.exp
596@@ -9432,7 +9432,7 @@ proc check_effective_target_aarch64_tiny { } {
597 # various architecture extensions via the .arch_extension pseudo-op.
598
599 foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse" "dotprod" "sve"
600- "i8mm" "f32mm" "f64mm" "bf16" } {
601+ "i8mm" "f32mm" "f64mm" "bf16" "sb" } {
602 eval [string map [list FUNC $aarch64_ext] {
603 proc check_effective_target_aarch64_asm_FUNC_ok { } {
604 if { [istarget aarch64*-*-*] } {
605--
6062.7.4
607
diff --git a/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch b/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch
index 30a8486016..492300047d 100644
--- a/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch
+++ b/meta/recipes-devtools/gcc/gcc/0002-gcc-poison-system-directories.patch
@@ -1,6 +1,6 @@
1From 74cc21f474402cf3578e37e1d7a1a22bbd070f6a Mon Sep 17 00:00:00 2001 1From 52676b5934ba127c3af39fc484c8236c8fa60b96 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 08:59:00 +0400 3Date: Mon, 8 Mar 2021 16:04:20 -0800
4Subject: [PATCH] gcc: poison-system-directories 4Subject: [PATCH] gcc: poison-system-directories
5 5
6Add /sw/include and /opt/include based on the original 6Add /sw/include and /opt/include based on the original
@@ -11,25 +11,24 @@ aborted.
11Instead, we add the two missing items to the current scan. If the user 11Instead, we add the two missing items to the current scan. If the user
12wants this to be a failure, they can add "-Werror=poison-system-directories". 12wants this to be a failure, they can add "-Werror=poison-system-directories".
13 13
14Upstream-Status: Inappropriate [OE configuration]
14Signed-off-by: Mark Hatle <mark.hatle@windriver.com> 15Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
15Signed-off-by: Khem Raj <raj.khem@gmail.com> 16Signed-off-by: Khem Raj <raj.khem@gmail.com>
16
17Upstream-Status: Pending
18--- 17---
19 gcc/common.opt | 4 ++++ 18 gcc/common.opt | 4 ++++
20 gcc/config.in | 6 ++++++ 19 gcc/config.in | 10 ++++++++++
21 gcc/configure | 16 ++++++++++++++++ 20 gcc/configure | 19 +++++++++++++++++++
22 gcc/configure.ac | 10 ++++++++++ 21 gcc/configure.ac | 16 ++++++++++++++++
23 gcc/doc/invoke.texi | 9 +++++++++ 22 gcc/doc/invoke.texi | 9 +++++++++
24 gcc/gcc.c | 2 ++ 23 gcc/gcc.cc | 9 +++++++--
25 gcc/incpath.c | 21 +++++++++++++++++++++ 24 gcc/incpath.cc | 21 +++++++++++++++++++++
26 7 files changed, 68 insertions(+) 25 7 files changed, 86 insertions(+), 2 deletions(-)
27 26
28diff --git a/gcc/common.opt b/gcc/common.opt 27diff --git a/gcc/common.opt b/gcc/common.opt
29index 65a82410abc..415f38fa1f4 100644 28index 862c474d3c8..64c4277c991 100644
30--- a/gcc/common.opt 29--- a/gcc/common.opt
31+++ b/gcc/common.opt 30+++ b/gcc/common.opt
32@@ -682,6 +682,10 @@ Wreturn-local-addr 31@@ -711,6 +711,10 @@ Wreturn-local-addr
33 Common Var(warn_return_local_addr) Init(1) Warning 32 Common Var(warn_return_local_addr) Init(1) Warning
34 Warn about returning a pointer/reference to a local or temporary variable. 33 Warn about returning a pointer/reference to a local or temporary variable.
35 34
@@ -41,10 +40,10 @@ index 65a82410abc..415f38fa1f4 100644
41 Common Var(warn_shadow) Warning 40 Common Var(warn_shadow) Warning
42 Warn when one variable shadows another. Same as -Wshadow=global. 41 Warn when one variable shadows another. Same as -Wshadow=global.
43diff --git a/gcc/config.in b/gcc/config.in 42diff --git a/gcc/config.in b/gcc/config.in
44index 809e7b26823..5adeaeed36b 100644 43index 4cad077bfbe..80e832fdb84 100644
45--- a/gcc/config.in 44--- a/gcc/config.in
46+++ b/gcc/config.in 45+++ b/gcc/config.in
47@@ -224,6 +224,12 @@ 46@@ -236,6 +236,16 @@
48 #endif 47 #endif
49 48
50 49
@@ -52,24 +51,28 @@ index 809e7b26823..5adeaeed36b 100644
52+#ifndef USED_FOR_TARGET 51+#ifndef USED_FOR_TARGET
53+#undef ENABLE_POISON_SYSTEM_DIRECTORIES 52+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
54+#endif 53+#endif
54+/* Define to warn for use of native system header directories */
55+#ifndef USED_FOR_TARGET
56+#undef POISON_BY_DEFAULT
57+#endif
55+ 58+
56+ 59+
57 /* Define if you want all operations on RTL (the basic data structure of the 60 /* Define if you want all operations on RTL (the basic data structure of the
58 optimizer and back end) to be checked for dynamic type safety at runtime. 61 optimizer and back end) to be checked for dynamic type safety at runtime.
59 This is quite expensive. */ 62 This is quite expensive. */
60diff --git a/gcc/configure b/gcc/configure 63diff --git a/gcc/configure b/gcc/configure
61index cd3d9516fce..8de766a942c 100755 64index c7b26d1927d..3508be7b439 100755
62--- a/gcc/configure 65--- a/gcc/configure
63+++ b/gcc/configure 66+++ b/gcc/configure
64@@ -1010,6 +1010,7 @@ with_system_zlib 67@@ -1026,6 +1026,7 @@ enable_maintainer_mode
65 enable_maintainer_mode
66 enable_link_mutex 68 enable_link_mutex
69 enable_link_serialization
67 enable_version_specific_runtime_libs 70 enable_version_specific_runtime_libs
68+enable_poison_system_directories 71+enable_poison_system_directories
69 enable_plugin 72 enable_plugin
70 enable_host_shared 73 enable_host_shared
71 enable_libquadmath_support 74 enable_libquadmath_support
72@@ -1766,6 +1767,8 @@ Optional Features: 75@@ -1788,6 +1789,8 @@ Optional Features:
73 --enable-version-specific-runtime-libs 76 --enable-version-specific-runtime-libs
74 specify that runtime libraries should be installed 77 specify that runtime libraries should be installed
75 in a compiler-specific directory 78 in a compiler-specific directory
@@ -78,7 +81,7 @@ index cd3d9516fce..8de766a942c 100755
78 --enable-plugin enable plugin support 81 --enable-plugin enable plugin support
79 --enable-host-shared build host code as shared libraries 82 --enable-host-shared build host code as shared libraries
80 --disable-libquadmath-support 83 --disable-libquadmath-support
81@@ -30235,6 +30238,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : 84@@ -31753,6 +31756,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
82 fi 85 fi
83 86
84 87
@@ -89,9 +92,12 @@ index cd3d9516fce..8de766a942c 100755
89+ enable_poison_system_directories=no 92+ enable_poison_system_directories=no
90+fi 93+fi
91+ 94+
92+if test "x${enable_poison_system_directories}" = "xyes"; then 95+if test "x${enable_poison_system_directories}" != "xno"; then
93+ 96+
94+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h 97+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
98+if test "$enable_poison_system_directories" = "error"; then
99+$as_echo "#define POISON_BY_DEFAULT 1" >>confdefs.h
100+fi
95+ 101+
96+fi 102+fi
97+ 103+
@@ -99,58 +105,64 @@ index cd3d9516fce..8de766a942c 100755
99 105
100 106
101diff --git a/gcc/configure.ac b/gcc/configure.ac 107diff --git a/gcc/configure.ac b/gcc/configure.ac
102index 0de3b4bf97b..8bfd6feb780 100644 108index 09082e8ccae..6cd01a8966b 100644
103--- a/gcc/configure.ac 109--- a/gcc/configure.ac
104+++ b/gcc/configure.ac 110+++ b/gcc/configure.ac
105@@ -6595,6 +6595,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, 111@@ -7292,6 +7292,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
106 [specify that runtime libraries should be 112 [specify that runtime libraries should be
107 installed in a compiler-specific directory])]) 113 installed in a compiler-specific directory])])
108 114
109+AC_ARG_ENABLE([poison-system-directories], 115+AC_ARG_ENABLE([poison-system-directories],
110+ AS_HELP_STRING([--enable-poison-system-directories], 116+ AS_HELP_STRING([--enable-poison-system-directories],
111+ [warn for use of native system header directories]),, 117+ [warn for use of native system header directories (no/yes/error)]),,
112+ [enable_poison_system_directories=no]) 118+ [enable_poison_system_directories=no])
113+if test "x${enable_poison_system_directories}" = "xyes"; then 119+AC_MSG_NOTICE([poisoned directories $enable_poison_system_directories])
120+if test "x${enable_poison_system_directories}" != "xno"; then
121+ AC_MSG_NOTICE([poisoned directories enabled])
114+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], 122+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
115+ [1], 123+ [1],
116+ [Define to warn for use of native system header directories]) 124+ [Define to warn for use of native system header directories])
125+ if test $enable_poison_system_directories = "error"; then
126+ AC_MSG_NOTICE([poisoned directories are fatal])
127+ AC_DEFINE([POISON_BY_DEFAULT], [1], [Define to make poison warnings errors])
128+ fi
117+fi 129+fi
118+ 130+
119 # Substitute configuration variables 131 # Substitute configuration variables
120 AC_SUBST(subdirs) 132 AC_SUBST(subdirs)
121 AC_SUBST(srcdir) 133 AC_SUBST(srcdir)
122diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi 134diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
123index f98161391a0..f12d8d12150 100644 135index de40f62e219..d6f203c8b71 100644
124--- a/gcc/doc/invoke.texi 136--- a/gcc/doc/invoke.texi
125+++ b/gcc/doc/invoke.texi 137+++ b/gcc/doc/invoke.texi
126@@ -348,6 +348,7 @@ Objective-C and Objective-C++ Dialects}. 138@@ -384,6 +384,7 @@ Objective-C and Objective-C++ Dialects}.
127 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol 139 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
128 -Wparentheses -Wno-pedantic-ms-format @gol 140 -Wparentheses -Wno-pedantic-ms-format
129 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol 141 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
130+-Wno-poison-system-directories @gol 142+-Wno-poison-system-directories
131 -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol 143 -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls
132 -Wrestrict -Wno-return-local-addr -Wreturn-type @gol 144 -Wrestrict -Wno-return-local-addr -Wreturn-type
133 -Wno-scalar-storage-order -Wsequence-point @gol 145 -Wno-scalar-storage-order -Wsequence-point
134@@ -6924,6 +6925,14 @@ made up of data only and thus requires no special treatment. But, for 146@@ -8426,6 +8427,14 @@ made up of data only and thus requires no special treatment. But, for
135 most targets, it is made up of code and thus requires the stack to be 147 most targets, it is made up of code and thus requires the stack to be
136 made executable in order for the program to work properly. 148 made executable in order for the program to work properly.
137 149
138+@item -Wno-poison-system-directories
139+@opindex Wno-poison-system-directories 150+@opindex Wno-poison-system-directories
151+@item -Wno-poison-system-directories
140+Do not warn for @option{-I} or @option{-L} options using system 152+Do not warn for @option{-I} or @option{-L} options using system
141+directories such as @file{/usr/include} when cross compiling. This 153+directories such as @file{/usr/include} when cross compiling. This
142+option is intended for use in chroot environments when such 154+option is intended for use in chroot environments when such
143+directories contain the correct headers and libraries for the target 155+directories contain the correct headers and libraries for the target
144+system rather than the host. 156+system rather than the host.
145+ 157+
146 @item -Wfloat-equal
147 @opindex Wfloat-equal 158 @opindex Wfloat-equal
148 @opindex Wno-float-equal 159 @opindex Wno-float-equal
149diff --git a/gcc/gcc.c b/gcc/gcc.c 160 @item -Wfloat-equal
150index 9f790db0daf..b2200c5185a 100644 161diff --git a/gcc/gcc.cc b/gcc/gcc.cc
151--- a/gcc/gcc.c 162index 16bb07f2cdc..5feae021545 100644
152+++ b/gcc/gcc.c 163--- a/gcc/gcc.cc
153@@ -1041,6 +1041,8 @@ proper position among the other output files. */ 164+++ b/gcc/gcc.cc
165@@ -1146,6 +1146,8 @@ proper position among the other output files. */
154 "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ 166 "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
155 "%X %{o*} %{e*} %{N} %{n} %{r}\ 167 "%X %{o*} %{e*} %{N} %{n} %{r}\
156 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ 168 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
@@ -159,10 +171,24 @@ index 9f790db0daf..b2200c5185a 100644
159 %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ 171 %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \
160 VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ 172 VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
161 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ 173 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
162diff --git a/gcc/incpath.c b/gcc/incpath.c 174@@ -1241,8 +1243,11 @@ static const char *cpp_unique_options =
163index 8a2bda00f80..9098ab044ab 100644 175 static const char *cpp_options =
164--- a/gcc/incpath.c 176 "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
165+++ b/gcc/incpath.c 177 %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\
178- %{!fno-working-directory:-fworking-directory}}} %{O*}\
179- %{undef} %{save-temps*:-fpch-preprocess}";
180+ %{!fno-working-directory:-fworking-directory}}} %{O*}"
181+#ifdef POISON_BY_DEFAULT
182+ " -Werror=poison-system-directories"
183+#endif
184+ " %{undef} %{save-temps*:-fpch-preprocess}";
185
186 /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al.
187
188diff --git a/gcc/incpath.cc b/gcc/incpath.cc
189index 4d44321183f..46c0d543205 100644
190--- a/gcc/incpath.cc
191+++ b/gcc/incpath.cc
166@@ -26,6 +26,7 @@ 192@@ -26,6 +26,7 @@
167 #include "intl.h" 193 #include "intl.h"
168 #include "incpath.h" 194 #include "incpath.h"
@@ -171,7 +197,7 @@ index 8a2bda00f80..9098ab044ab 100644
171 197
172 /* Microsoft Windows does not natively support inodes. 198 /* Microsoft Windows does not natively support inodes.
173 VMS has non-numeric inodes. */ 199 VMS has non-numeric inodes. */
174@@ -393,6 +394,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) 200@@ -399,6 +400,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
175 } 201 }
176 fprintf (stderr, _("End of search list.\n")); 202 fprintf (stderr, _("End of search list.\n"));
177 } 203 }
@@ -182,17 +208,17 @@ index 8a2bda00f80..9098ab044ab 100644
182+ struct cpp_dir *p; 208+ struct cpp_dir *p;
183+ 209+
184+ for (p = heads[INC_QUOTE]; p; p = p->next) 210+ for (p = heads[INC_QUOTE]; p; p = p->next)
185+ { 211+ {
186+ if ((!strncmp (p->name, "/usr/include", 12)) 212+ if ((!strncmp (p->name, "/usr/include", 12))
187+ || (!strncmp (p->name, "/usr/local/include", 18)) 213+ || (!strncmp (p->name, "/usr/local/include", 18))
188+ || (!strncmp (p->name, "/usr/X11R6/include", 18)) 214+ || (!strncmp (p->name, "/usr/X11R6/include", 18))
189+ || (!strncmp (p->name, "/sw/include", 11)) 215+ || (!strncmp (p->name, "/sw/include", 11))
190+ || (!strncmp (p->name, "/opt/include", 12))) 216+ || (!strncmp (p->name, "/opt/include", 12)))
191+ warning (OPT_Wpoison_system_directories, 217+ warning (OPT_Wpoison_system_directories,
192+ "include location \"%s\" is unsafe for " 218+ "include location \"%s\" is unsafe for "
193+ "cross-compilation", 219+ "cross-compilation",
194+ p->name); 220+ p->name);
195+ } 221+ }
196+ } 222+ }
197+#endif 223+#endif
198 } 224 }
diff --git a/meta/recipes-devtools/gcc/gcc/0004-64-bit-multilib-hack.patch b/meta/recipes-devtools/gcc/gcc/0003-64-bit-multilib-hack.patch
index 7c751bef65..69e7fa0ba9 100644
--- a/meta/recipes-devtools/gcc/gcc/0004-64-bit-multilib-hack.patch
+++ b/meta/recipes-devtools/gcc/gcc/0003-64-bit-multilib-hack.patch
@@ -1,7 +1,7 @@
1From 85a7c5aeb82ed61e6ef6d8e061b9da9e6a4a652c Mon Sep 17 00:00:00 2001 1From febfac59d0e8a864370d0b4018b4e497ceec156d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:10:06 +0400 3Date: Fri, 29 Mar 2013 09:10:06 +0400
4Subject: [PATCH] 64-bit multilib hack. 4Subject: [PATCH] 64-bit multilib hack
5 5
6GCC has internal multilib handling code but it assumes a very specific rigid directory 6GCC has internal multilib handling code but it assumes a very specific rigid directory
7layout. The build system implementation of multilib layout is very generic and allows 7layout. The build system implementation of multilib layout is very generic and allows
@@ -19,25 +19,28 @@ and be able to patch these entries with a complete set of correct paths but this
19don't have such code at this point. This is something the target gcc recipe should do 19don't have such code at this point. This is something the target gcc recipe should do
20and override these platform defaults in its build config. 20and override these platform defaults in its build config.
21 21
22Do same for riscv64 and aarch64 22Do same for riscv64, aarch64 & arc
23 23
24RP 15/8/11 24RP 15/8/11
25 25
26Upstream-Status: Inappropriate[OE-Specific] 26Upstream-Status: Inappropriate [OE-Specific]
27 27
28Signed-off-by: Khem Raj <raj.khem@gmail.com> 28Signed-off-by: Khem Raj <raj.khem@gmail.com>
29Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com> 29Signed-off-by: Elvis Dowson <elvis.dowson@gmail.com>
30Signed-off-by: Mark Hatle <mark.hatle@windriver.com> 30Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
31Signed-off-by: Zang Ruochen <zangruochen@loongson.cn>
31--- 32---
32 gcc/config/aarch64/t-aarch64-linux | 8 ++++---- 33 gcc/config/aarch64/t-aarch64-linux | 8 ++++----
34 gcc/config/arc/t-multilib-linux | 4 ++--
33 gcc/config/i386/t-linux64 | 6 ++---- 35 gcc/config/i386/t-linux64 | 6 ++----
34 gcc/config/mips/t-linux64 | 10 +++------- 36 gcc/config/mips/t-linux64 | 28 ++--------------------------
35 gcc/config/riscv/t-linux | 6 ++++-- 37 gcc/config/riscv/t-linux | 4 ++--
36 gcc/config/rs6000/t-linux64 | 5 ++--- 38 gcc/config/rs6000/t-linux64 | 5 ++---
37 5 files changed, 15 insertions(+), 20 deletions(-) 39 gcc/config/loongarch/t-linux | 34 ++++++++++++++++++----------------
40 7 files changed, 32 insertions(+), 57 deletions(-)
38 41
39diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux 42diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux
40index 83e59e33b85..b1356be1fb4 100644 43index 57bf4100fcd..aaef5da8059 100644
41--- a/gcc/config/aarch64/t-aarch64-linux 44--- a/gcc/config/aarch64/t-aarch64-linux
42+++ b/gcc/config/aarch64/t-aarch64-linux 45+++ b/gcc/config/aarch64/t-aarch64-linux
43@@ -21,8 +21,8 @@ 46@@ -21,8 +21,8 @@
@@ -53,8 +56,24 @@ index 83e59e33b85..b1356be1fb4 100644
53 56
54-MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) 57-MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
55+#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) 58+#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
59diff --git a/gcc/config/arc/t-multilib-linux b/gcc/config/arc/t-multilib-linux
60index a839e4ea67c..f92664573a9 100644
61--- a/gcc/config/arc/t-multilib-linux
62+++ b/gcc/config/arc/t-multilib-linux
63@@ -16,9 +16,9 @@
64 # along with GCC; see the file COPYING3. If not see
65 # <http://www.gnu.org/licenses/>.
66
67-MULTILIB_OPTIONS = mcpu=hs/mcpu=archs/mcpu=hs38/mcpu=hs38_linux/mcpu=arc700/mcpu=nps400
68+#MULTILIB_OPTIONS = mcpu=hs/mcpu=archs/mcpu=hs38/mcpu=hs38_linux/mcpu=arc700/mcpu=nps400
69
70-MULTILIB_DIRNAMES = hs archs hs38 hs38_linux arc700 nps400
71+#MULTILIB_DIRNAMES = hs archs hs38 hs38_linux arc700 nps400
72
73 # Aliases:
74 MULTILIB_MATCHES += mcpu?arc700=mA7
56diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 75diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64
57index 1171e218578..5e057b7e5db 100644 76index 138956b0962..d6e0cdc4342 100644
58--- a/gcc/config/i386/t-linux64 77--- a/gcc/config/i386/t-linux64
59+++ b/gcc/config/i386/t-linux64 78+++ b/gcc/config/i386/t-linux64
60@@ -32,7 +32,5 @@ 79@@ -32,7 +32,5 @@
@@ -68,37 +87,53 @@ index 1171e218578..5e057b7e5db 100644
68+MULTILIB_DIRNAMES = . . 87+MULTILIB_DIRNAMES = . .
69+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) 88+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
70diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 89diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64
71index ceb58d3b5f3..43fe2bf28ab 100644 90index 176091cabb6..8258ef40559 100644
72--- a/gcc/config/mips/t-linux64 91--- a/gcc/config/mips/t-linux64
73+++ b/gcc/config/mips/t-linux64 92+++ b/gcc/config/mips/t-linux64
74@@ -17,10 +17,6 @@ 93@@ -17,29 +17,5 @@
75 # <http://www.gnu.org/licenses/>. 94 # <http://www.gnu.org/licenses/>.
76 95
77 MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64 96 MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
78-MULTILIB_DIRNAMES = n32 32 64 97-MULTILIB_DIRNAMES = n32 32 64
79-MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el) 98-MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
80-MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft) 99-MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
81-MULTILIB_OSDIRNAMES = \ 100-ifeq (yes,$(enable_multiarch))
101- ifneq (,$(findstring gnuabi64,$(target)))
102- MULTILIB_OSDIRNAMES = \
103- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
104- ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
105- ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
106- else ifneq (,$(findstring gnuabin32,$(target)))
107- MULTILIB_OSDIRNAMES = \
108- ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
109- ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
110- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
111- else
112- MULTILIB_OSDIRNAMES = \
113- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
114- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
115- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
116- endif
117-else
118- MULTILIB_OSDIRNAMES = \
82- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \ 119- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
83- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \ 120- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
84- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT)) 121- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
122-endif
85+MULTILIB_DIRNAMES = . . . 123+MULTILIB_DIRNAMES = . . .
86+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) 124+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
87+
88diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux 125diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux
89index 216d2776a18..e4d817621fc 100644 126index 216d2776a18..e3c520f4bf6 100644
90--- a/gcc/config/riscv/t-linux 127--- a/gcc/config/riscv/t-linux
91+++ b/gcc/config/riscv/t-linux 128+++ b/gcc/config/riscv/t-linux
92@@ -1,3 +1,5 @@ 129@@ -1,3 +1,3 @@
93 # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ 130 # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
94-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) 131-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
95-MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) 132-MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
96+#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) 133+#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
97+MULTILIB_DIRNAMES := . .
98+#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) 134+#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
99+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
100diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 135diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64
101index 264a7e27524..dc9d440f66b 100644 136index 01a94242308..1429eceaebf 100644
102--- a/gcc/config/rs6000/t-linux64 137--- a/gcc/config/rs6000/t-linux64
103+++ b/gcc/config/rs6000/t-linux64 138+++ b/gcc/config/rs6000/t-linux64
104@@ -26,10 +26,9 @@ 139@@ -26,10 +26,9 @@
@@ -112,5 +147,55 @@ index 264a7e27524..dc9d440f66b 100644
112-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu) 147-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
113+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) 148+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
114 149
115 rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c 150 rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc
116 $(COMPILE) $< 151 $(COMPILE) $<
152diff --git a/gcc/config/loongarch/t-linux b/gcc/config/loongarch/t-linux
153index e40da1792..0c7ec9f8a 100644
154--- a/gcc/config/loongarch/t-linux
155+++ b/gcc/config/loongarch/t-linux
156@@ -18,7 +18,9 @@
157
158 # Multilib
159 MULTILIB_OPTIONS = mabi=lp64d/mabi=lp64f/mabi=lp64s
160-MULTILIB_DIRNAMES = base/lp64d base/lp64f base/lp64s
161+#MULTILIB_DIRNAMES = base/lp64d base/lp64f base/lp64s
162+MULTILIB_DIRNAMES = . . .
163+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
164
165 # The GCC driver always gets all abi-related options on the command line.
166 # (see loongarch-driver.c:driver_get_normalized_m_opts)
167@@ -36,18 +38,18 @@ else
168 endif
169
170 # Don't define MULTILIB_OSDIRNAMES if multilib is disabled.
171-ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),)
172-
173- MULTILIB_OSDIRNAMES = \
174- mabi.lp64d=../lib64$\
175- $(call if_multiarch,:loongarch64-linux-gnu)
176-
177- MULTILIB_OSDIRNAMES += \
178- mabi.lp64f=../lib64/f32$\
179- $(call if_multiarch,:loongarch64-linux-gnuf32)
180-
181- MULTILIB_OSDIRNAMES += \
182- mabi.lp64s=../lib64/sf$\
183- $(call if_multiarch,:loongarch64-linux-gnusf)
184-
185-endif
186+#ifeq ($(filter LA_DISABLE_MULTILIB,$(tm_defines)),)
187+#
188+# MULTILIB_OSDIRNAMES = \
189+# mabi.lp64d=../lib64$\
190+# $(call if_multiarch,:loongarch64-linux-gnu)
191+#
192+# MULTILIB_OSDIRNAMES += \
193+# mabi.lp64f=../lib64/f32$\
194+# $(call if_multiarch,:loongarch64-linux-gnuf32)
195+#
196+# MULTILIB_OSDIRNAMES += \
197+# mabi.lp64s=../lib64/sf$\
198+# $(call if_multiarch,:loongarch64-linux-gnusf)
199+#
200+#endif
201
diff --git a/meta/recipes-devtools/gcc/gcc/0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch b/meta/recipes-devtools/gcc/gcc/0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch
deleted file mode 100644
index 716a367172..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0003-aarch64-Mitigate-SLS-for-BLR-instruction.patch
+++ /dev/null
@@ -1,658 +0,0 @@
1Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@arm.com>
3
4From a5e7efc40ed841934c1d913f39476afa17d8e5f7 Mon Sep 17 00:00:00 2001
5From: Matthew Malcomson <matthew.malcomson@arm.com>
6Date: Thu, 9 Jul 2020 09:11:59 +0100
7Subject: [PATCH 3/3] aarch64: Mitigate SLS for BLR instruction
8
9This patch introduces the mitigation for Straight Line Speculation past
10the BLR instruction.
11
12This mitigation replaces BLR instructions with a BL to a stub which uses
13a BR to jump to the original value. These function stubs are then
14appended with a speculation barrier to ensure no straight line
15speculation happens after these jumps.
16
17When optimising for speed we use a set of stubs for each function since
18this should help the branch predictor make more accurate predictions
19about where a stub should branch.
20
21When optimising for size we use one set of stubs for all functions.
22This set of stubs can have human readable names, and we are using
23`__call_indirect_x<N>` for register x<N>.
24
25When BTI branch protection is enabled the BLR instruction can jump to a
26`BTI c` instruction using any register, while the BR instruction can
27only jump to a `BTI c` instruction using the x16 or x17 registers.
28Hence, in order to ensure this transformation is safe we mov the value
29of the original register into x16 and use x16 for the BR.
30
31As an example when optimising for size:
32a
33 BLR x0
34instruction would get transformed to something like
35 BL __call_indirect_x0
36where __call_indirect_x0 labels a thunk that contains
37__call_indirect_x0:
38 MOV X16, X0
39 BR X16
40 <speculation barrier>
41
42The first version of this patch used local symbols specific to a
43compilation unit to try and avoid relocations.
44This was mistaken since functions coming from the same compilation unit
45can still be in different sections, and the assembler will insert
46relocations at jumps between sections.
47
48On any relocation the linker is permitted to emit a veneer to handle
49jumps between symbols that are very far apart. The registers x16 and
50x17 may be clobbered by these veneers.
51Hence the function stubs cannot rely on the values of x16 and x17 being
52the same as just before the function stub is called.
53
54Similar can be said for the hot/cold partitioning of single functions,
55so function-local stubs have the same restriction.
56
57This updated version of the patch never emits function stubs for x16 and
58x17, and instead forces other registers to be used.
59
60Given the above, there is now no benefit to local symbols (since they
61are not enough to avoid dealing with linker intricacies). This patch
62now uses global symbols with hidden visibility each stored in their own
63COMDAT section. This means stubs can be shared between compilation
64units while still avoiding the PLT indirection.
65
66This patch also removes the `__call_indirect_x30` stub (and
67function-local equivalent) which would simply jump back to the original
68location.
69
70The function-local stubs are emitted to the assembly output file in one
71chunk, which means we need not add the speculation barrier directly
72after each one.
73This is because we know for certain that the instructions directly after
74the BR in all but the last function stub will be from another one of
75these stubs and hence will not contain a speculation gadget.
76Instead we add a speculation barrier at the end of the sequence of
77stubs.
78
79The global stubs are emitted in COMDAT/.linkonce sections by
80themselves so that the linker can remove duplicates from multiple object
81files. This means they are not emitted in one chunk, and each one must
82include the speculation barrier.
83
84Another difference is that since the global stubs are shared across
85compilation units we do not know that all functions will be targeting an
86architecture supporting the SB instruction.
87Rather than provide multiple stubs for each architecture, we provide a
88stub that will work for all architectures -- using the DSB+ISB barrier.
89
90This mitigation does not apply for BLR instructions in the following
91places:
92- Some accesses to thread-local variables use a code sequence with a BLR
93 instruction. This code sequence is part of the binary interface between
94 compiler and linker. If this BLR instruction needs to be mitigated, it'd
95 probably be best to do so in the linker. It seems that the code sequence
96 for thread-local variable access is unlikely to lead to a Spectre Revalation
97 Gadget.
98- PLT stubs are produced by the linker and each contain a BLR instruction.
99 It seems that at most only after the last PLT stub a Spectre Revalation
100 Gadget might appear.
101
102Testing:
103 Bootstrap and regtest on AArch64
104 (with BOOT_CFLAGS="-mharden-sls=retbr,blr")
105 Used a temporary hack(1) in gcc-dg.exp to use these options on every
106 test in the testsuite, a slight modification to emit the speculation
107 barrier after every function stub, and a script to check that the
108 output never emitted a BLR, or unmitigated BR or RET instruction.
109 Similar on an aarch64-none-elf cross-compiler.
110
1111) Temporary hack emitted a speculation barrier at the end of every stub
112function, and used a script to ensure that:
113 a) Every RET or BR is immediately followed by a speculation barrier.
114 b) No BLR instruction is emitted by compiler.
115
116gcc/ChangeLog:
117
118 * config/aarch64/aarch64-protos.h (aarch64_indirect_call_asm):
119 New declaration.
120 * config/aarch64/aarch64.c (aarch64_regno_regclass): Handle new
121 stub registers class.
122 (aarch64_class_max_nregs): Likewise.
123 (aarch64_register_move_cost): Likewise.
124 (aarch64_sls_shared_thunks): Global array to store stub labels.
125 (aarch64_sls_emit_function_stub): New.
126 (aarch64_create_blr_label): New.
127 (aarch64_sls_emit_blr_function_thunks): New.
128 (aarch64_sls_emit_shared_blr_thunks): New.
129 (aarch64_asm_file_end): New.
130 (aarch64_indirect_call_asm): New.
131 (TARGET_ASM_FILE_END): Use aarch64_asm_file_end.
132 (TARGET_ASM_FUNCTION_EPILOGUE): Use
133 aarch64_sls_emit_blr_function_thunks.
134 * config/aarch64/aarch64.h (STB_REGNUM_P): New.
135 (enum reg_class): Add STUB_REGS class.
136 (machine_function): Introduce `call_via` array for
137 function-local stub labels.
138 * config/aarch64/aarch64.md (*call_insn, *call_value_insn): Use
139 aarch64_indirect_call_asm to emit code when hardening BLR
140 instructions.
141 * config/aarch64/constraints.md (Ucr): New constraint
142 representing registers for indirect calls. Is GENERAL_REGS
143 usually, and STUB_REGS when hardening BLR instruction against
144 SLS.
145 * config/aarch64/predicates.md (aarch64_general_reg): STUB_REGS class
146 is also a general register.
147
148gcc/testsuite/ChangeLog:
149
150 * gcc.target/aarch64/sls-mitigation/sls-miti-blr-bti.c: New test.
151 * gcc.target/aarch64/sls-mitigation/sls-miti-blr.c: New test.
152---
153 gcc/config/aarch64/aarch64-protos.h | 1 +
154 gcc/config/aarch64/aarch64.c | 225 ++++++++++++++++++++-
155 gcc/config/aarch64/aarch64.h | 15 ++
156 gcc/config/aarch64/aarch64.md | 11 +-
157 gcc/config/aarch64/constraints.md | 9 +
158 gcc/config/aarch64/predicates.md | 3 +-
159 .../aarch64/sls-mitigation/sls-miti-blr-bti.c | 40 ++++
160 .../aarch64/sls-mitigation/sls-miti-blr.c | 33 +++
161 8 files changed, 328 insertions(+), 9 deletions(-)
162 create mode 100644 gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr-bti.c
163 create mode 100644 gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr.c
164
165diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
166index ee0ffde..839f801 100644
167--- a/gcc/config/aarch64/aarch64-protos.h
168+++ b/gcc/config/aarch64/aarch64-protos.h
169@@ -782,6 +782,7 @@ extern const atomic_ool_names aarch64_ool_ldeor_names;
170 tree aarch64_resolve_overloaded_builtin_general (location_t, tree, void *);
171
172 const char *aarch64_sls_barrier (int);
173+const char *aarch64_indirect_call_asm (rtx);
174 extern bool aarch64_harden_sls_retbr_p (void);
175 extern bool aarch64_harden_sls_blr_p (void);
176
177diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
178index 2389d49..0f7bba3 100644
179--- a/gcc/config/aarch64/aarch64.c
180+++ b/gcc/config/aarch64/aarch64.c
181@@ -10605,6 +10605,9 @@ aarch64_label_mentioned_p (rtx x)
182 enum reg_class
183 aarch64_regno_regclass (unsigned regno)
184 {
185+ if (STUB_REGNUM_P (regno))
186+ return STUB_REGS;
187+
188 if (GP_REGNUM_P (regno))
189 return GENERAL_REGS;
190
191@@ -10939,6 +10942,7 @@ aarch64_class_max_nregs (reg_class_t regclass, machine_mode mode)
192 unsigned int nregs, vec_flags;
193 switch (regclass)
194 {
195+ case STUB_REGS:
196 case TAILCALL_ADDR_REGS:
197 case POINTER_REGS:
198 case GENERAL_REGS:
199@@ -13155,10 +13159,12 @@ aarch64_register_move_cost (machine_mode mode,
200 = aarch64_tune_params.regmove_cost;
201
202 /* Caller save and pointer regs are equivalent to GENERAL_REGS. */
203- if (to == TAILCALL_ADDR_REGS || to == POINTER_REGS)
204+ if (to == TAILCALL_ADDR_REGS || to == POINTER_REGS
205+ || to == STUB_REGS)
206 to = GENERAL_REGS;
207
208- if (from == TAILCALL_ADDR_REGS || from == POINTER_REGS)
209+ if (from == TAILCALL_ADDR_REGS || from == POINTER_REGS
210+ || from == STUB_REGS)
211 from = GENERAL_REGS;
212
213 /* Make RDFFR very expensive. In particular, if we know that the FFR
214@@ -22957,6 +22963,215 @@ aarch64_sls_barrier (int mitigation_required)
215 : "";
216 }
217
218+static GTY (()) tree aarch64_sls_shared_thunks[30];
219+static GTY (()) bool aarch64_sls_shared_thunks_needed = false;
220+const char *indirect_symbol_names[30] = {
221+ "__call_indirect_x0",
222+ "__call_indirect_x1",
223+ "__call_indirect_x2",
224+ "__call_indirect_x3",
225+ "__call_indirect_x4",
226+ "__call_indirect_x5",
227+ "__call_indirect_x6",
228+ "__call_indirect_x7",
229+ "__call_indirect_x8",
230+ "__call_indirect_x9",
231+ "__call_indirect_x10",
232+ "__call_indirect_x11",
233+ "__call_indirect_x12",
234+ "__call_indirect_x13",
235+ "__call_indirect_x14",
236+ "__call_indirect_x15",
237+ "", /* "__call_indirect_x16", */
238+ "", /* "__call_indirect_x17", */
239+ "__call_indirect_x18",
240+ "__call_indirect_x19",
241+ "__call_indirect_x20",
242+ "__call_indirect_x21",
243+ "__call_indirect_x22",
244+ "__call_indirect_x23",
245+ "__call_indirect_x24",
246+ "__call_indirect_x25",
247+ "__call_indirect_x26",
248+ "__call_indirect_x27",
249+ "__call_indirect_x28",
250+ "__call_indirect_x29",
251+};
252+
253+/* Function to create a BLR thunk. This thunk is used to mitigate straight
254+ line speculation. Instead of a simple BLR that can be speculated past,
255+ we emit a BL to this thunk, and this thunk contains a BR to the relevant
256+ register. These thunks have the relevant speculation barries put after
257+ their indirect branch so that speculation is blocked.
258+
259+ We use such a thunk so the speculation barriers are kept off the
260+ architecturally executed path in order to reduce the performance overhead.
261+
262+ When optimizing for size we use stubs shared by the linked object.
263+ When optimizing for performance we emit stubs for each function in the hope
264+ that the branch predictor can better train on jumps specific for a given
265+ function. */
266+rtx
267+aarch64_sls_create_blr_label (int regnum)
268+{
269+ gcc_assert (STUB_REGNUM_P (regnum));
270+ if (optimize_function_for_size_p (cfun))
271+ {
272+ /* For the thunks shared between different functions in this compilation
273+ unit we use a named symbol -- this is just for users to more easily
274+ understand the generated assembly. */
275+ aarch64_sls_shared_thunks_needed = true;
276+ const char *thunk_name = indirect_symbol_names[regnum];
277+ if (aarch64_sls_shared_thunks[regnum] == NULL)
278+ {
279+ /* Build a decl representing this function stub and record it for
280+ later. We build a decl here so we can use the GCC machinery for
281+ handling sections automatically (through `get_named_section` and
282+ `make_decl_one_only`). That saves us a lot of trouble handling
283+ the specifics of different output file formats. */
284+ tree decl = build_decl (BUILTINS_LOCATION, FUNCTION_DECL,
285+ get_identifier (thunk_name),
286+ build_function_type_list (void_type_node,
287+ NULL_TREE));
288+ DECL_RESULT (decl) = build_decl (BUILTINS_LOCATION, RESULT_DECL,
289+ NULL_TREE, void_type_node);
290+ TREE_PUBLIC (decl) = 1;
291+ TREE_STATIC (decl) = 1;
292+ DECL_IGNORED_P (decl) = 1;
293+ DECL_ARTIFICIAL (decl) = 1;
294+ make_decl_one_only (decl, DECL_ASSEMBLER_NAME (decl));
295+ resolve_unique_section (decl, 0, false);
296+ aarch64_sls_shared_thunks[regnum] = decl;
297+ }
298+
299+ return gen_rtx_SYMBOL_REF (Pmode, thunk_name);
300+ }
301+
302+ if (cfun->machine->call_via[regnum] == NULL)
303+ cfun->machine->call_via[regnum]
304+ = gen_rtx_LABEL_REF (Pmode, gen_label_rtx ());
305+ return cfun->machine->call_via[regnum];
306+}
307+
308+/* Helper function for aarch64_sls_emit_blr_function_thunks and
309+ aarch64_sls_emit_shared_blr_thunks below. */
310+static void
311+aarch64_sls_emit_function_stub (FILE *out_file, int regnum)
312+{
313+ /* Save in x16 and branch to that function so this transformation does
314+ not prevent jumping to `BTI c` instructions. */
315+ asm_fprintf (out_file, "\tmov\tx16, x%d\n", regnum);
316+ asm_fprintf (out_file, "\tbr\tx16\n");
317+}
318+
319+/* Emit all BLR stubs for this particular function.
320+ Here we emit all the BLR stubs needed for the current function. Since we
321+ emit these stubs in a consecutive block we know there will be no speculation
322+ gadgets between each stub, and hence we only emit a speculation barrier at
323+ the end of the stub sequences.
324+
325+ This is called in the TARGET_ASM_FUNCTION_EPILOGUE hook. */
326+void
327+aarch64_sls_emit_blr_function_thunks (FILE *out_file)
328+{
329+ if (! aarch64_harden_sls_blr_p ())
330+ return;
331+
332+ bool any_functions_emitted = false;
333+ /* We must save and restore the current function section since this assembly
334+ is emitted at the end of the function. This means it can be emitted *just
335+ after* the cold section of a function. That cold part would be emitted in
336+ a different section. That switch would trigger a `.cfi_endproc` directive
337+ to be emitted in the original section and a `.cfi_startproc` directive to
338+ be emitted in the new section. Switching to the original section without
339+ restoring would mean that the `.cfi_endproc` emitted as a function ends
340+ would happen in a different section -- leaving an unmatched
341+ `.cfi_startproc` in the cold text section and an unmatched `.cfi_endproc`
342+ in the standard text section. */
343+ section *save_text_section = in_section;
344+ switch_to_section (function_section (current_function_decl));
345+ for (int regnum = 0; regnum < 30; ++regnum)
346+ {
347+ rtx specu_label = cfun->machine->call_via[regnum];
348+ if (specu_label == NULL)
349+ continue;
350+
351+ targetm.asm_out.print_operand (out_file, specu_label, 0);
352+ asm_fprintf (out_file, ":\n");
353+ aarch64_sls_emit_function_stub (out_file, regnum);
354+ any_functions_emitted = true;
355+ }
356+ if (any_functions_emitted)
357+ /* Can use the SB if needs be here, since this stub will only be used
358+ by the current function, and hence for the current target. */
359+ asm_fprintf (out_file, "\t%s\n", aarch64_sls_barrier (true));
360+ switch_to_section (save_text_section);
361+}
362+
363+/* Emit shared BLR stubs for the current compilation unit.
364+ Over the course of compiling this unit we may have converted some BLR
365+ instructions to a BL to a shared stub function. This is where we emit those
366+ stub functions.
367+ This function is for the stubs shared between different functions in this
368+ compilation unit. We share when optimizing for size instead of speed.
369+
370+ This function is called through the TARGET_ASM_FILE_END hook. */
371+void
372+aarch64_sls_emit_shared_blr_thunks (FILE *out_file)
373+{
374+ if (! aarch64_sls_shared_thunks_needed)
375+ return;
376+
377+ for (int regnum = 0; regnum < 30; ++regnum)
378+ {
379+ tree decl = aarch64_sls_shared_thunks[regnum];
380+ if (!decl)
381+ continue;
382+
383+ const char *name = indirect_symbol_names[regnum];
384+ switch_to_section (get_named_section (decl, NULL, 0));
385+ ASM_OUTPUT_ALIGN (out_file, 2);
386+ targetm.asm_out.globalize_label (out_file, name);
387+ /* Only emits if the compiler is configured for an assembler that can
388+ handle visibility directives. */
389+ targetm.asm_out.assemble_visibility (decl, VISIBILITY_HIDDEN);
390+ ASM_OUTPUT_TYPE_DIRECTIVE (out_file, name, "function");
391+ ASM_OUTPUT_LABEL (out_file, name);
392+ aarch64_sls_emit_function_stub (out_file, regnum);
393+ /* Use the most conservative target to ensure it can always be used by any
394+ function in the translation unit. */
395+ asm_fprintf (out_file, "\tdsb\tsy\n\tisb\n");
396+ ASM_DECLARE_FUNCTION_SIZE (out_file, name, decl);
397+ }
398+}
399+
400+/* Implement TARGET_ASM_FILE_END. */
401+void
402+aarch64_asm_file_end ()
403+{
404+ aarch64_sls_emit_shared_blr_thunks (asm_out_file);
405+ /* Since this function will be called for the ASM_FILE_END hook, we ensure
406+ that what would be called otherwise (e.g. `file_end_indicate_exec_stack`
407+ for FreeBSD) still gets called. */
408+#ifdef TARGET_ASM_FILE_END
409+ TARGET_ASM_FILE_END ();
410+#endif
411+}
412+
413+const char *
414+aarch64_indirect_call_asm (rtx addr)
415+{
416+ gcc_assert (REG_P (addr));
417+ if (aarch64_harden_sls_blr_p ())
418+ {
419+ rtx stub_label = aarch64_sls_create_blr_label (REGNO (addr));
420+ output_asm_insn ("bl\t%0", &stub_label);
421+ }
422+ else
423+ output_asm_insn ("blr\t%0", &addr);
424+ return "";
425+}
426+
427 /* Target-specific selftests. */
428
429 #if CHECKING_P
430@@ -23507,6 +23722,12 @@ aarch64_libgcc_floating_mode_supported_p
431 #undef TARGET_MD_ASM_ADJUST
432 #define TARGET_MD_ASM_ADJUST arm_md_asm_adjust
433
434+#undef TARGET_ASM_FILE_END
435+#define TARGET_ASM_FILE_END aarch64_asm_file_end
436+
437+#undef TARGET_ASM_FUNCTION_EPILOGUE
438+#define TARGET_ASM_FUNCTION_EPILOGUE aarch64_sls_emit_blr_function_thunks
439+
440 struct gcc_target targetm = TARGET_INITIALIZER;
441
442 #include "gt-aarch64.h"
443diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
444index 8e0fc37..7331450 100644
445--- a/gcc/config/aarch64/aarch64.h
446+++ b/gcc/config/aarch64/aarch64.h
447@@ -643,6 +643,16 @@ extern unsigned aarch64_architecture_version;
448 #define GP_REGNUM_P(REGNO) \
449 (((unsigned) (REGNO - R0_REGNUM)) <= (R30_REGNUM - R0_REGNUM))
450
451+/* Registers known to be preserved over a BL instruction. This consists of the
452+ GENERAL_REGS without x16, x17, and x30. The x30 register is changed by the
453+ BL instruction itself, while the x16 and x17 registers may be used by
454+ veneers which can be inserted by the linker. */
455+#define STUB_REGNUM_P(REGNO) \
456+ (GP_REGNUM_P (REGNO) \
457+ && (REGNO) != R16_REGNUM \
458+ && (REGNO) != R17_REGNUM \
459+ && (REGNO) != R30_REGNUM) \
460+
461 #define FP_REGNUM_P(REGNO) \
462 (((unsigned) (REGNO - V0_REGNUM)) <= (V31_REGNUM - V0_REGNUM))
463
464@@ -667,6 +677,7 @@ enum reg_class
465 {
466 NO_REGS,
467 TAILCALL_ADDR_REGS,
468+ STUB_REGS,
469 GENERAL_REGS,
470 STACK_REG,
471 POINTER_REGS,
472@@ -689,6 +700,7 @@ enum reg_class
473 { \
474 "NO_REGS", \
475 "TAILCALL_ADDR_REGS", \
476+ "STUB_REGS", \
477 "GENERAL_REGS", \
478 "STACK_REG", \
479 "POINTER_REGS", \
480@@ -708,6 +720,7 @@ enum reg_class
481 { \
482 { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \
483 { 0x00030000, 0x00000000, 0x00000000 }, /* TAILCALL_ADDR_REGS */\
484+ { 0x3ffcffff, 0x00000000, 0x00000000 }, /* STUB_REGS */ \
485 { 0x7fffffff, 0x00000000, 0x00000003 }, /* GENERAL_REGS */ \
486 { 0x80000000, 0x00000000, 0x00000000 }, /* STACK_REG */ \
487 { 0xffffffff, 0x00000000, 0x00000003 }, /* POINTER_REGS */ \
488@@ -862,6 +875,8 @@ typedef struct GTY (()) machine_function
489 struct aarch64_frame frame;
490 /* One entry for each hard register. */
491 bool reg_is_wrapped_separately[LAST_SAVED_REGNUM];
492+ /* One entry for each general purpose register. */
493+ rtx call_via[SP_REGNUM];
494 bool label_is_assembled;
495 } machine_function;
496 #endif
497diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
498index dda04ee..43da754 100644
499--- a/gcc/config/aarch64/aarch64.md
500+++ b/gcc/config/aarch64/aarch64.md
501@@ -1022,16 +1022,15 @@
502 )
503
504 (define_insn "*call_insn"
505- [(call (mem:DI (match_operand:DI 0 "aarch64_call_insn_operand" "r, Usf"))
506+ [(call (mem:DI (match_operand:DI 0 "aarch64_call_insn_operand" "Ucr, Usf"))
507 (match_operand 1 "" ""))
508 (unspec:DI [(match_operand:DI 2 "const_int_operand")] UNSPEC_CALLEE_ABI)
509 (clobber (reg:DI LR_REGNUM))]
510 ""
511 "@
512- blr\\t%0
513+ * return aarch64_indirect_call_asm (operands[0]);
514 bl\\t%c0"
515- [(set_attr "type" "call, call")]
516-)
517+ [(set_attr "type" "call, call")])
518
519 (define_expand "call_value"
520 [(parallel
521@@ -1050,13 +1049,13 @@
522
523 (define_insn "*call_value_insn"
524 [(set (match_operand 0 "" "")
525- (call (mem:DI (match_operand:DI 1 "aarch64_call_insn_operand" "r, Usf"))
526+ (call (mem:DI (match_operand:DI 1 "aarch64_call_insn_operand" "Ucr, Usf"))
527 (match_operand 2 "" "")))
528 (unspec:DI [(match_operand:DI 3 "const_int_operand")] UNSPEC_CALLEE_ABI)
529 (clobber (reg:DI LR_REGNUM))]
530 ""
531 "@
532- blr\\t%1
533+ * return aarch64_indirect_call_asm (operands[1]);
534 bl\\t%c1"
535 [(set_attr "type" "call, call")]
536 )
537diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md
538index d993268..8cc6f50 100644
539--- a/gcc/config/aarch64/constraints.md
540+++ b/gcc/config/aarch64/constraints.md
541@@ -24,6 +24,15 @@
542 (define_register_constraint "Ucs" "TAILCALL_ADDR_REGS"
543 "@internal Registers suitable for an indirect tail call")
544
545+(define_register_constraint "Ucr"
546+ "aarch64_harden_sls_blr_p () ? STUB_REGS : GENERAL_REGS"
547+ "@internal Registers to be used for an indirect call.
548+ This is usually the general registers, but when we are hardening against
549+ Straight Line Speculation we disallow x16, x17, and x30 so we can use
550+ indirection stubs. These indirection stubs cannot use the above registers
551+ since they will be reached by a BL that may have to go through a linker
552+ veneer.")
553+
554 (define_register_constraint "w" "FP_REGS"
555 "Floating point and SIMD vector registers.")
556
557diff --git a/gcc/config/aarch64/predicates.md b/gcc/config/aarch64/predicates.md
558index 215fcec..1754b1e 100644
559--- a/gcc/config/aarch64/predicates.md
560+++ b/gcc/config/aarch64/predicates.md
561@@ -32,7 +32,8 @@
562
563 (define_predicate "aarch64_general_reg"
564 (and (match_operand 0 "register_operand")
565- (match_test "REGNO_REG_CLASS (REGNO (op)) == GENERAL_REGS")))
566+ (match_test "REGNO_REG_CLASS (REGNO (op)) == STUB_REGS
567+ || REGNO_REG_CLASS (REGNO (op)) == GENERAL_REGS")))
568
569 ;; Return true if OP a (const_int 0) operand.
570 (define_predicate "const0_operand"
571diff --git a/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr-bti.c b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr-bti.c
572new file mode 100644
573index 0000000..b1fb754
574--- /dev/null
575+++ b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr-bti.c
576@@ -0,0 +1,40 @@
577+/* { dg-do compile } */
578+/* { dg-additional-options "-mharden-sls=blr -mbranch-protection=bti" } */
579+/*
580+ Ensure that the SLS hardening of BLR leaves no BLR instructions.
581+ Here we also check that there are no BR instructions with anything except an
582+ x16 or x17 register. This is because a `BTI c` instruction can be branched
583+ to using a BLR instruction using any register, but can only be branched to
584+ with a BR using an x16 or x17 register.
585+ */
586+typedef int (foo) (int, int);
587+typedef void (bar) (int, int);
588+struct sls_testclass {
589+ foo *x;
590+ bar *y;
591+ int left;
592+ int right;
593+};
594+
595+/* We test both RTL patterns for a call which returns a value and a call which
596+ does not. */
597+int blr_call_value (struct sls_testclass x)
598+{
599+ int retval = x.x(x.left, x.right);
600+ if (retval % 10)
601+ return 100;
602+ return 9;
603+}
604+
605+int blr_call (struct sls_testclass x)
606+{
607+ x.y(x.left, x.right);
608+ if (x.left % 10)
609+ return 100;
610+ return 9;
611+}
612+
613+/* { dg-final { scan-assembler-not {\tblr\t} } } */
614+/* { dg-final { scan-assembler-not {\tbr\tx(?!16|17)} } } */
615+/* { dg-final { scan-assembler {\tbr\tx(16|17)} } } */
616+
617diff --git a/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr.c b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr.c
618new file mode 100644
619index 0000000..88bafff
620--- /dev/null
621+++ b/gcc/testsuite/gcc.target/aarch64/sls-mitigation/sls-miti-blr.c
622@@ -0,0 +1,33 @@
623+/* { dg-additional-options "-mharden-sls=blr -save-temps" } */
624+/* Ensure that the SLS hardening of BLR leaves no BLR instructions.
625+ We only test that all BLR instructions have been removed, not that the
626+ resulting code makes sense. */
627+typedef int (foo) (int, int);
628+typedef void (bar) (int, int);
629+struct sls_testclass {
630+ foo *x;
631+ bar *y;
632+ int left;
633+ int right;
634+};
635+
636+/* We test both RTL patterns for a call which returns a value and a call which
637+ does not. */
638+int blr_call_value (struct sls_testclass x)
639+{
640+ int retval = x.x(x.left, x.right);
641+ if (retval % 10)
642+ return 100;
643+ return 9;
644+}
645+
646+int blr_call (struct sls_testclass x)
647+{
648+ x.y(x.left, x.right);
649+ if (x.left % 10)
650+ return 100;
651+ return 9;
652+}
653+
654+/* { dg-final { scan-assembler-not {\tblr\t} } } */
655+/* { dg-final { scan-assembler {\tbr\tx[0-9][0-9]?} } } */
656--
6572.7.4
658
diff --git a/meta/recipes-devtools/gcc/gcc/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch b/meta/recipes-devtools/gcc/gcc/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch
deleted file mode 100644
index 27237feb5a..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0003-gcc-4.3.3-SYSROOT_CFLAGS_FOR_TARGET.patch
+++ /dev/null
@@ -1,70 +0,0 @@
1From 6e3395c0bc933bdc3242d1dead4896d0aa4e11a8 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:08:31 +0400
4Subject: [PATCH] gcc-4.3.3: SYSROOT_CFLAGS_FOR_TARGET
5
6Before committing, I noticed that PR/32161 was marked as a dup of PR/32009, but my previous patch did not fix it.
7
8This alternative patch is better because it lets you just use CFLAGS_FOR_TARGET to set the compilation flags for libgcc. Since bootstrapped target libraries are never compiled with the native compiler, it makes little sense to use different flags for stage1 and later stages. And it also makes little sense to use a different variable than CFLAGS_FOR_TARGET.
9
10Other changes I had to do include:
11
12- moving the creation of default CFLAGS_FOR_TARGET from Makefile.am to configure.ac, because otherwise the BOOT_CFLAGS are substituted into CFLAGS_FOR_TARGET (which is "-O2 -g $(CFLAGS)") via $(CFLAGS). It is also cleaner this way though.
13
14- passing the right CFLAGS to configure scripts as exported environment variables
15
16I also stopped passing LIBCFLAGS to configure scripts since they are unused in the whole src tree. And I updated the documentation as H-P reminded me to do.
17
18Bootstrapped/regtested i686-pc-linux-gnu, will commit to 4.4 shortly. Ok for 4.3?
19
20Signed-off-by: Paolo Bonzini <bonzini@gnu.org>
21Signed-off-by: Khem Raj <raj.khem@gmail.com>
22
23Upstream-Status: Pending
24---
25 configure | 32 ++++++++++++++++++++++++++++++++
26 1 file changed, 32 insertions(+)
27
28diff --git a/configure b/configure
29index 226a64939d1..b31dc137fc9 100755
30--- a/configure
31+++ b/configure
32@@ -6971,6 +6971,38 @@ fi
33
34
35
36+# During gcc bootstrap, if we use some random cc for stage1 then CFLAGS
37+# might be empty or "-g". We don't require a C++ compiler, so CXXFLAGS
38+# might also be empty (or "-g", if a non-GCC C++ compiler is in the path).
39+# We want to ensure that TARGET libraries (which we know are built with
40+# gcc) are built with "-O2 -g", so include those options when setting
41+# CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET.
42+if test "x$CFLAGS_FOR_TARGET" = x; then
43+ CFLAGS_FOR_TARGET=$CFLAGS
44+ case " $CFLAGS " in
45+ *" -O2 "*) ;;
46+ *) CFLAGS_FOR_TARGET="-O2 $CFLAGS" ;;
47+ esac
48+ case " $CFLAGS " in
49+ *" -g "* | *" -g3 "*) ;;
50+ *) CFLAGS_FOR_TARGET="-g $CFLAGS" ;;
51+ esac
52+fi
53+
54+
55+if test "x$CXXFLAGS_FOR_TARGET" = x; then
56+ CXXFLAGS_FOR_TARGET=$CXXFLAGS
57+ case " $CXXFLAGS " in
58+ *" -O2 "*) ;;
59+ *) CXXFLAGS_FOR_TARGET="-O2 $CXXFLAGS" ;;
60+ esac
61+ case " $CXXFLAGS " in
62+ *" -g "* | *" -g3 "*) ;;
63+ *) CXXFLAGS_FOR_TARGET="-g $CXXFLAGS" ;;
64+ esac
65+fi
66+
67+
68 # Handle --with-headers=XXX. If the value is not "yes", the contents of
69 # the named directory are copied to $(tooldir)/sys-include.
70 if test x"${with_headers}" != x && test x"${with_headers}" != xno ; then
diff --git a/meta/recipes-devtools/gcc/gcc/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch b/meta/recipes-devtools/gcc/gcc/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch
new file mode 100644
index 0000000000..7e33bf17b0
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0004-Pass-CXXFLAGS_FOR_BUILD-in-a-couple-of-places-to-avo.patch
@@ -0,0 +1,64 @@
1From 6fbf920ccde6efc2d0caafde996d9e5738a1ba37 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Thu, 28 Oct 2021 11:33:40 +0100
4Subject: [PATCH] Pass CXXFLAGS_FOR_BUILD in a couple of places to avoid these
5 errors.
6
7If CXXFLAGS contains something unsupported by the build CXX, we see build failures (e.g. using -fmacro-prefix-map for the target).
8
92021-10-28 Richard Purdie <richard.purdie@linuxfoundation.org>
10
11ChangeLog:
12
13 * Makefile.in: Regenerate.
14 * Makefile.tpl: Add missing CXXFLAGS_FOR_BUILD overrides
15
16Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612560.html]
17
18Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
19Signed-off-by: Khem Raj <raj.khem@gmail.com>
20---
21 Makefile.in | 2 ++
22 Makefile.tpl | 2 ++
23 2 files changed, 4 insertions(+)
24
25diff --git a/Makefile.in b/Makefile.in
26index 06a9398e172..4b0069b257c 100644
27--- a/Makefile.in
28+++ b/Makefile.in
29@@ -178,6 +178,7 @@ BUILD_EXPORTS = \
30 # built for the build system to override those in BASE_FLAGS_TO_PASS.
31 EXTRA_BUILD_FLAGS = \
32 CFLAGS="$(CFLAGS_FOR_BUILD)" \
33+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
34 LDFLAGS="$(LDFLAGS_FOR_BUILD)"
35
36 # This is the list of directories to built for the host system.
37@@ -210,6 +211,7 @@ HOST_EXPORTS = \
38 CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \
39 CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \
40 CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \
41+ CXXFLAGS_FOR_BUILD="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS_FOR_BUILD; \
42 DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
43 DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \
44 LD="$(LD)"; export LD; \
45diff --git a/Makefile.tpl b/Makefile.tpl
46index dfbd74b68f8..419b332953b 100644
47--- a/Makefile.tpl
48+++ b/Makefile.tpl
49@@ -181,6 +181,7 @@ BUILD_EXPORTS = \
50 # built for the build system to override those in BASE_FLAGS_TO_PASS.
51 EXTRA_BUILD_FLAGS = \
52 CFLAGS="$(CFLAGS_FOR_BUILD)" \
53+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
54 LDFLAGS="$(LDFLAGS_FOR_BUILD)"
55
56 # This is the list of directories to built for the host system.
57@@ -213,6 +214,7 @@ HOST_EXPORTS = \
58 CPP_FOR_BUILD="$(CPP_FOR_BUILD)"; export CPP_FOR_BUILD; \
59 CPPFLAGS_FOR_BUILD="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS_FOR_BUILD; \
60 CXX_FOR_BUILD="$(CXX_FOR_BUILD)"; export CXX_FOR_BUILD; \
61+ CXXFLAGS_FOR_BUILD="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS_FOR_BUILD; \
62 DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \
63 DSYMUTIL="$(DSYMUTIL)"; export DSYMUTIL; \
64 LD="$(LD)"; export LD; \
diff --git a/meta/recipes-devtools/gcc/gcc/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch b/meta/recipes-devtools/gcc/gcc/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
index a764bdd0f4..db2fea3d16 100644
--- a/meta/recipes-devtools/gcc/gcc/0007-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
+++ b/meta/recipes-devtools/gcc/gcc/0005-Use-the-defaults.h-in-B-instead-of-S-and-t-oe-in-B.patch
@@ -1,4 +1,4 @@
1From 5670d4489f119d2da661734895ac0be99b606d1b Mon Sep 17 00:00:00 2001 1From 2cedf13819c0cc929660072d8a972f5e422f9701 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:17:25 +0400 3Date: Fri, 29 Mar 2013 09:17:25 +0400
4Subject: [PATCH] Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B} 4Subject: [PATCH] Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B}
@@ -7,16 +7,16 @@ Use the defaults.h in ${B} instead of ${S}, and t-oe in ${B}, so that
7the source can be shared between gcc-cross-initial, 7the source can be shared between gcc-cross-initial,
8gcc-cross-intermediate, gcc-cross, gcc-runtime, and also the sdk build. 8gcc-cross-intermediate, gcc-cross, gcc-runtime, and also the sdk build.
9 9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11
12Upstream-Status: Pending
13
14While compiling gcc-crosssdk-initial-x86_64 on some host, there is 10While compiling gcc-crosssdk-initial-x86_64 on some host, there is
15occasionally failure that test the existance of default.h doesn't 11occasionally failure that test the existance of default.h doesn't
16work, the reason is tm_include_list='** defaults.h' rather than 12work, the reason is tm_include_list='** defaults.h' rather than
17tm_include_list='** ./defaults.h' 13tm_include_list='** ./defaults.h'
18 14
19So we add the test condition for this situation. 15So we add the test condition for this situation.
16
17Upstream-Status: Inappropriate [embedded specific]
18
19Signed-off-by: Khem Raj <raj.khem@gmail.com>
20Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> 20Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
21--- 21---
22 gcc/Makefile.in | 2 +- 22 gcc/Makefile.in | 2 +-
@@ -26,10 +26,10 @@ Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
26 4 files changed, 7 insertions(+), 7 deletions(-) 26 4 files changed, 7 insertions(+), 7 deletions(-)
27 27
28diff --git a/gcc/Makefile.in b/gcc/Makefile.in 28diff --git a/gcc/Makefile.in b/gcc/Makefile.in
29index 543b477ff18..a67d2cc18d6 100644 29index 775aaa1b3c4..04f28984b34 100644
30--- a/gcc/Makefile.in 30--- a/gcc/Makefile.in
31+++ b/gcc/Makefile.in 31+++ b/gcc/Makefile.in
32@@ -540,7 +540,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@ 32@@ -561,7 +561,7 @@ TARGET_SYSTEM_ROOT = @TARGET_SYSTEM_ROOT@
33 TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@ 33 TARGET_SYSTEM_ROOT_DEFINE = @TARGET_SYSTEM_ROOT_DEFINE@
34 34
35 xmake_file=@xmake_file@ 35 xmake_file=@xmake_file@
@@ -39,10 +39,10 @@ index 543b477ff18..a67d2cc18d6 100644
39 TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@ 39 TM_MULTILIB_CONFIG=@TM_MULTILIB_CONFIG@
40 TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@ 40 TM_MULTILIB_EXCEPTIONS_CONFIG=@TM_MULTILIB_EXCEPTIONS_CONFIG@
41diff --git a/gcc/configure b/gcc/configure 41diff --git a/gcc/configure b/gcc/configure
42index 8de766a942c..b26e8fc7fee 100755 42index 3508be7b439..cf773a8b854 100755
43--- a/gcc/configure 43--- a/gcc/configure
44+++ b/gcc/configure 44+++ b/gcc/configure
45@@ -12705,8 +12705,8 @@ for f in $tm_file; do 45@@ -13507,8 +13507,8 @@ for f in $tm_file; do
46 tm_include_list="${tm_include_list} $f" 46 tm_include_list="${tm_include_list} $f"
47 ;; 47 ;;
48 defaults.h ) 48 defaults.h )
@@ -54,10 +54,10 @@ index 8de766a942c..b26e8fc7fee 100755
54 * ) 54 * )
55 tm_file_list="${tm_file_list} \$(srcdir)/config/$f" 55 tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
56diff --git a/gcc/configure.ac b/gcc/configure.ac 56diff --git a/gcc/configure.ac b/gcc/configure.ac
57index 8bfd6feb780..26fa46802c7 100644 57index 6cd01a8966b..22591478b72 100644
58--- a/gcc/configure.ac 58--- a/gcc/configure.ac
59+++ b/gcc/configure.ac 59+++ b/gcc/configure.ac
60@@ -2138,8 +2138,8 @@ for f in $tm_file; do 60@@ -2357,8 +2357,8 @@ for f in $tm_file; do
61 tm_include_list="${tm_include_list} $f" 61 tm_include_list="${tm_include_list} $f"
62 ;; 62 ;;
63 defaults.h ) 63 defaults.h )
@@ -69,7 +69,7 @@ index 8bfd6feb780..26fa46802c7 100644
69 * ) 69 * )
70 tm_file_list="${tm_file_list} \$(srcdir)/config/$f" 70 tm_file_list="${tm_file_list} \$(srcdir)/config/$f"
71diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh 71diff --git a/gcc/mkconfig.sh b/gcc/mkconfig.sh
72index d2c677a4a42..d03852481cb 100644 72index 054ede89647..3b2c2b9df37 100644
73--- a/gcc/mkconfig.sh 73--- a/gcc/mkconfig.sh
74+++ b/gcc/mkconfig.sh 74+++ b/gcc/mkconfig.sh
75@@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then 75@@ -77,7 +77,7 @@ if [ -n "$HEADERS" ]; then
diff --git a/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch b/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch
deleted file mode 100644
index 4020c9e3cf..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0005-optional-libstdc.patch
+++ /dev/null
@@ -1,122 +0,0 @@
1From 6ddfb0bfcd1eea71acd37ab06f7a4510b9f1d12b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:12:56 +0400
4Subject: [PATCH] optional libstdc
5
6gcc-runtime builds libstdc++ separately from gcc-cross-*. Its configure tests using g++
7will not run correctly since by default the linker will try to link against libstdc++
8which shouldn't exist yet. We need an option to disable -lstdc++
9option whilst leaving -lc, -lgcc and other automatic library dependencies added by gcc
10driver. This patch adds such an option which only disables the -lstdc++.
11
12A "standard" gcc build uses xgcc and hence avoids this. We should ask upstream how to
13do this officially, the likely answer is don't build libstdc++ separately.
14
15RP 29/6/10
16
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18
19Upstream-Status: Inappropriate [embedded specific]
20---
21 gcc/c-family/c.opt | 4 ++++
22 gcc/cp/g++spec.c | 1 +
23 gcc/doc/invoke.texi | 32 +++++++++++++++++++++++++++++++-
24 gcc/gcc.c | 1 +
25 4 files changed, 37 insertions(+), 1 deletion(-)
26
27diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
28index c49da99d395..35f712e2c84 100644
29--- a/gcc/c-family/c.opt
30+++ b/gcc/c-family/c.opt
31@@ -2025,6 +2025,10 @@ nostdinc++
32 C++ ObjC++
33 Do not search standard system include directories for C++.
34
35+nostdlib++
36+Driver
37+Do not link standard C++ runtime library
38+
39 o
40 C ObjC C++ ObjC++ Joined Separate
41 ; Documented in common.opt
42diff --git a/gcc/cp/g++spec.c b/gcc/cp/g++spec.c
43index 0ab63bcd211..7b081e9e4f0 100644
44--- a/gcc/cp/g++spec.c
45+++ b/gcc/cp/g++spec.c
46@@ -137,6 +137,7 @@ lang_specific_driver (struct cl_decoded_option **in_decoded_options,
47 switch (decoded_options[i].opt_index)
48 {
49 case OPT_nostdlib:
50+ case OPT_nostdlib__:
51 case OPT_nodefaultlibs:
52 library = -1;
53 break;
54diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
55index f12d8d12150..cf6cb428e7d 100644
56--- a/gcc/doc/invoke.texi
57+++ b/gcc/doc/invoke.texi
58@@ -230,6 +230,9 @@ in the following sections.
59 -fno-weak -nostdinc++ @gol
60 -fvisibility-inlines-hidden @gol
61 -fvisibility-ms-compat @gol
62+-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
63+-fvtv-counts -fvtv-debug @gol
64+-nostdlib++ @gol
65 -fext-numeric-literals @gol
66 -Wabi-tag -Wcatch-value -Wcatch-value=@var{n} @gol
67 -Wno-class-conversion -Wclass-memaccess @gol
68@@ -599,7 +602,7 @@ Objective-C and Objective-C++ Dialects}.
69 -pie -pthread -r -rdynamic @gol
70 -s -static -static-pie -static-libgcc -static-libstdc++ @gol
71 -static-libasan -static-libtsan -static-liblsan -static-libubsan @gol
72--shared -shared-libgcc -symbolic @gol
73+-shared -shared-libgcc -symbolic -nostdlib++ @gol
74 -T @var{script} -Wl,@var{option} -Xlinker @var{option} @gol
75 -u @var{symbol} -z @var{keyword}}
76
77@@ -14407,6 +14410,33 @@ Specify that the program entry point is @var{entry}. The argument is
78 interpreted by the linker; the GNU linker accepts either a symbol name
79 or an address.
80
81+@item -nostdlib++
82+@opindex nostdlib++
83+Do not use the standard system C++ runtime libraries when linking.
84+Only the libraries you specify will be passed to the linker.
85+
86+@cindex @option{-lgcc}, use with @option{-nostdlib}
87+@cindex @option{-nostdlib} and unresolved references
88+@cindex unresolved references and @option{-nostdlib}
89+@cindex @option{-lgcc}, use with @option{-nodefaultlibs}
90+@cindex @option{-nodefaultlibs} and unresolved references
91+@cindex unresolved references and @option{-nodefaultlibs}
92+One of the standard libraries bypassed by @option{-nostdlib} and
93+@option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
94+which GCC uses to overcome shortcomings of particular machines, or special
95+needs for some languages.
96+(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
97+Collection (GCC) Internals},
98+for more discussion of @file{libgcc.a}.)
99+In most cases, you need @file{libgcc.a} even when you want to avoid
100+other standard libraries. In other words, when you specify @option{-nostdlib}
101+or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well.
102+This ensures that you have no unresolved references to internal GCC
103+library subroutines.
104+(An example of such an internal subroutine is @code{__main}, used to ensure C++
105+constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
106+GNU Compiler Collection (GCC) Internals}.)
107+
108 @item -pie
109 @opindex pie
110 Produce a dynamically linked position independent executable on targets
111diff --git a/gcc/gcc.c b/gcc/gcc.c
112index b2200c5185a..f8be58ce0a6 100644
113--- a/gcc/gcc.c
114+++ b/gcc/gcc.c
115@@ -1051,6 +1051,7 @@ proper position among the other output files. */
116 %(mflib) " STACK_SPLIT_SPEC "\
117 %{fprofile-arcs|fprofile-generate*|coverage:-lgcov} " SANITIZER_SPEC " \
118 %{!nostdlib:%{!r:%{!nodefaultlibs:%(link_ssp) %(link_gcc_c_sequence)}}}\
119+ %{!nostdlib++:}\
120 %{!nostdlib:%{!r:%{!nostartfiles:%E}}} %{T*} \n%(post_link) }}}}}}"
121 #endif
122
diff --git a/meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch b/meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch
deleted file mode 100644
index 9fbbe80703..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0006-COLLECT_GCC_OPTIONS.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From a6c90d3a9c5010b4aa7cc30467cf81ca7e0f430e Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:16:28 +0400
4Subject: [PATCH] COLLECT_GCC_OPTIONS
5
6This patch adds --sysroot into COLLECT_GCC_OPTIONS which is used to
7invoke collect2.
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10
11Upstream-Status: Pending
12---
13 gcc/gcc.c | 9 +++++++++
14 1 file changed, 9 insertions(+)
15
16diff --git a/gcc/gcc.c b/gcc/gcc.c
17index f8be58ce0a6..48b0f9dde81 100644
18--- a/gcc/gcc.c
19+++ b/gcc/gcc.c
20@@ -4806,6 +4806,15 @@ set_collect_gcc_options (void)
21 sizeof ("COLLECT_GCC_OPTIONS=") - 1);
22
23 first_time = TRUE;
24+#ifdef HAVE_LD_SYSROOT
25+ if (target_system_root_changed && target_system_root)
26+ {
27+ obstack_grow (&collect_obstack, "'--sysroot=", sizeof("'--sysroot=")-1);
28+ obstack_grow (&collect_obstack, target_system_root,strlen(target_system_root));
29+ obstack_grow (&collect_obstack, "'", 1);
30+ first_time = FALSE;
31+ }
32+#endif
33 for (i = 0; (int) i < n_switches; i++)
34 {
35 const char *const *args;
diff --git a/meta/recipes-devtools/gcc/gcc/0009-cpp-honor-sysroot.patch b/meta/recipes-devtools/gcc/gcc/0006-cpp-honor-sysroot.patch
index 8ad6853d81..704c44cb72 100644
--- a/meta/recipes-devtools/gcc/gcc/0009-cpp-honor-sysroot.patch
+++ b/meta/recipes-devtools/gcc/gcc/0006-cpp-honor-sysroot.patch
@@ -1,4 +1,4 @@
1From 1d76de7f1f5c99f1fa1a4b14aedad3d702e4e136 Mon Sep 17 00:00:00 2001 1From f0b4d02a3a3dca1d67fd7add15ed63c2cd572bb9 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:22:00 +0400 3Date: Fri, 29 Mar 2013 09:22:00 +0400
4Subject: [PATCH] cpp: honor sysroot. 4Subject: [PATCH] cpp: honor sysroot.
@@ -17,31 +17,33 @@ The fix below adds %I to the cpp-output spec macro so the default substitutions
17 17
18RP 2012/04/13 18RP 2012/04/13
19 19
20Signed-off-by: Khem Raj <raj.khem@gmail.com> 20Upstream-Status: Inappropriate [embedded specific]
21 21
22Upstream-Status: Pending 22Signed-off-by: Khem Raj <raj.khem@gmail.com>
23--- 23---
24 gcc/cp/lang-specs.h | 2 +- 24 gcc/cp/lang-specs.h | 2 +-
25 gcc/gcc.c | 2 +- 25 gcc/gcc.cc | 2 +-
26 2 files changed, 2 insertions(+), 2 deletions(-) 26 2 files changed, 2 insertions(+), 2 deletions(-)
27 27
28diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h 28diff --git a/gcc/cp/lang-specs.h b/gcc/cp/lang-specs.h
29index 0ad4a33b93e..16c744f4f90 100644 29index c591d155cc1..61927869fe1 100644
30--- a/gcc/cp/lang-specs.h 30--- a/gcc/cp/lang-specs.h
31+++ b/gcc/cp/lang-specs.h 31+++ b/gcc/cp/lang-specs.h
32@@ -66,5 +66,5 @@ along with GCC; see the file COPYING3. If not see 32@@ -116,7 +116,7 @@ along with GCC; see the file COPYING3. If not see
33 {".ii", "@c++-cpp-output", 0, 0, 0}, 33 {".ii", "@c++-cpp-output", 0, 0, 0},
34 {"@c++-cpp-output", 34 {"@c++-cpp-output",
35 "%{!E:%{!M:%{!MM:" 35 "%{!E:%{!M:%{!MM:"
36- " cc1plus -fpreprocessed %i %(cc1_options) %2" 36- " cc1plus -fpreprocessed %i %(cc1_options) %2"
37+ " cc1plus -fpreprocessed %i %I %(cc1_options) %2" 37+ " cc1plus -fpreprocessed %i %I %(cc1_options) %2"
38 " %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, 38 " %{!fsyntax-only:"
39diff --git a/gcc/gcc.c b/gcc/gcc.c 39 " %{fmodule-only:%{!S:-o %g.s%V}}"
40index 48b0f9dde81..c87f603955f 100644 40 " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}"
41--- a/gcc/gcc.c 41diff --git a/gcc/gcc.cc b/gcc/gcc.cc
42+++ b/gcc/gcc.c 42index 5feae021545..8af0c814c33 100644
43@@ -1348,7 +1348,7 @@ static const struct compiler default_compilers[] = 43--- a/gcc/gcc.cc
44 %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0}, 44+++ b/gcc/gcc.cc
45@@ -1468,7 +1468,7 @@ static const struct compiler default_compilers[] =
46 %W{o*:--output-pch %*}}%V}}}}}}}", 0, 0, 0},
45 {".i", "@cpp-output", 0, 0, 0}, 47 {".i", "@cpp-output", 0, 0, 0},
46 {"@cpp-output", 48 {"@cpp-output",
47- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0}, 49- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
diff --git a/meta/recipes-devtools/gcc/gcc/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch b/meta/recipes-devtools/gcc/gcc/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
index e357976330..079142c540 100644
--- a/meta/recipes-devtools/gcc/gcc/0011-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
+++ b/meta/recipes-devtools/gcc/gcc/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch
@@ -1,4 +1,4 @@
1From 8fc016a53c22c19feccbfa13ebdf19090dc67058 Mon Sep 17 00:00:00 2001 1From aacfd6e14dd583b1fdc65691def61c5e1bc89708 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:24:50 +0400 3Date: Fri, 29 Mar 2013 09:24:50 +0400
4Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER 4Subject: [PATCH] Define GLIBC_DYNAMIC_LINKER and UCLIBC_DYNAMIC_LINKER
@@ -12,26 +12,48 @@ SH, sparc, alpha for possible future support (if any)
12 12
13Removes the do_headerfix task in metadata 13Removes the do_headerfix task in metadata
14 14
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16
17Upstream-Status: Inappropriate [OE configuration] 15Upstream-Status: Inappropriate [OE configuration]
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
18--- 17---
19 gcc/config/alpha/linux-elf.h | 4 ++-- 18 gcc/config/aarch64/aarch64-linux.h | 4 ++--
20 gcc/config/arm/linux-eabi.h | 4 ++-- 19 gcc/config/alpha/linux-elf.h | 4 ++--
21 gcc/config/arm/linux-elf.h | 2 +- 20 gcc/config/arm/linux-eabi.h | 6 +++---
22 gcc/config/i386/linux.h | 2 +- 21 gcc/config/arm/linux-elf.h | 2 +-
23 gcc/config/i386/linux64.h | 6 +++--- 22 gcc/config/i386/linux.h | 4 ++--
24 gcc/config/linux.h | 8 ++++---- 23 gcc/config/i386/linux64.h | 12 ++++++------
25 gcc/config/mips/linux.h | 12 ++++++------ 24 gcc/config/linux.h | 8 ++++----
26 gcc/config/riscv/linux.h | 2 +- 25 gcc/config/loongarch/gnu-user.h | 4 ++--
27 gcc/config/rs6000/linux64.h | 15 +++++---------- 26 gcc/config/microblaze/linux.h | 4 ++--
28 gcc/config/sh/linux.h | 2 +- 27 gcc/config/mips/linux.h | 18 +++++++++---------
29 gcc/config/sparc/linux.h | 2 +- 28 gcc/config/nios2/linux.h | 4 ++--
30 gcc/config/sparc/linux64.h | 4 ++-- 29 gcc/config/riscv/linux.h | 4 ++--
31 12 files changed, 29 insertions(+), 34 deletions(-) 30 gcc/config/rs6000/linux64.h | 15 +++++----------
31 gcc/config/rs6000/sysv4.h | 4 ++--
32 gcc/config/s390/linux.h | 8 ++++----
33 gcc/config/sh/linux.h | 4 ++--
34 gcc/config/sparc/linux.h | 2 +-
35 gcc/config/sparc/linux64.h | 4 ++--
36 18 files changed, 53 insertions(+), 58 deletions(-)
32 37
38diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
39index 4277f03da2a..e4c92c03291 100644
40--- a/gcc/config/aarch64/aarch64-linux.h
41+++ b/gcc/config/aarch64/aarch64-linux.h
42@@ -21,10 +21,10 @@
43 #ifndef GCC_AARCH64_LINUX_H
44 #define GCC_AARCH64_LINUX_H
45
46-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
47+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
48
49 #undef MUSL_DYNAMIC_LINKER
50-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
51+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
52
53 #undef ASAN_CC1_SPEC
54 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
33diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h 55diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
34index e25fcac3c59..01aca0c6542 100644 56index 03f783f2ad1..4fa02668aa7 100644
35--- a/gcc/config/alpha/linux-elf.h 57--- a/gcc/config/alpha/linux-elf.h
36+++ b/gcc/config/alpha/linux-elf.h 58+++ b/gcc/config/alpha/linux-elf.h
37@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see 59@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see
@@ -46,10 +68,10 @@ index e25fcac3c59..01aca0c6542 100644
46 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" 68 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
47 #elif DEFAULT_LIBC == LIBC_GLIBC 69 #elif DEFAULT_LIBC == LIBC_GLIBC
48diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h 70diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
49index 5bdcfa0c5d3..0c0332f317f 100644 71index a119875599d..dce7f59eeea 100644
50--- a/gcc/config/arm/linux-eabi.h 72--- a/gcc/config/arm/linux-eabi.h
51+++ b/gcc/config/arm/linux-eabi.h 73+++ b/gcc/config/arm/linux-eabi.h
52@@ -65,8 +65,8 @@ 74@@ -62,8 +62,8 @@
53 GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */ 75 GLIBC_DYNAMIC_LINKER_DEFAULT and TARGET_DEFAULT_FLOAT_ABI. */
54 76
55 #undef GLIBC_DYNAMIC_LINKER 77 #undef GLIBC_DYNAMIC_LINKER
@@ -60,8 +82,17 @@ index 5bdcfa0c5d3..0c0332f317f 100644
60 #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT 82 #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
61 83
62 #define GLIBC_DYNAMIC_LINKER \ 84 #define GLIBC_DYNAMIC_LINKER \
85@@ -86,7 +86,7 @@
86 #define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
87 #endif
88 #define MUSL_DYNAMIC_LINKER \
89- "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
90+ SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
91
92 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
93 use the GNU/Linux version, not the generic BPABI version. */
63diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h 94diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
64index 0ec3aa53189..abfa9566d74 100644 95index 7b7b7cbbe14..98ef2267117 100644
65--- a/gcc/config/arm/linux-elf.h 96--- a/gcc/config/arm/linux-elf.h
66+++ b/gcc/config/arm/linux-elf.h 97+++ b/gcc/config/arm/linux-elf.h
67@@ -60,7 +60,7 @@ 98@@ -60,7 +60,7 @@
@@ -74,7 +105,7 @@ index 0ec3aa53189..abfa9566d74 100644
74 #define LINUX_TARGET_LINK_SPEC "%{h*} \ 105 #define LINUX_TARGET_LINK_SPEC "%{h*} \
75 %{static:-Bstatic} \ 106 %{static:-Bstatic} \
76diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h 107diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
77index 9f823f125ed..e0390b7d5e3 100644 108index bbb7cc7115e..7d9272040ee 100644
78--- a/gcc/config/i386/linux.h 109--- a/gcc/config/i386/linux.h
79+++ b/gcc/config/i386/linux.h 110+++ b/gcc/config/i386/linux.h
80@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see 111@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
@@ -85,12 +116,13 @@ index 9f823f125ed..e0390b7d5e3 100644
85+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" 116+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
86 117
87 #undef MUSL_DYNAMIC_LINKER 118 #undef MUSL_DYNAMIC_LINKER
88 #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" 119-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
120+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-i386.so.1"
89diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h 121diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
90index 6cb68d1ccfa..7de09ec857c 100644 122index 2bd9f48e271..dbbe7ca5440 100644
91--- a/gcc/config/i386/linux64.h 123--- a/gcc/config/i386/linux64.h
92+++ b/gcc/config/i386/linux64.h 124+++ b/gcc/config/i386/linux64.h
93@@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 125@@ -27,13 +27,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
94 #define GNU_USER_LINK_EMULATION64 "elf_x86_64" 126 #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
95 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" 127 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
96 128
@@ -102,12 +134,19 @@ index 6cb68d1ccfa..7de09ec857c 100644
102+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2" 134+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
103 135
104 #undef MUSL_DYNAMIC_LINKER32 136 #undef MUSL_DYNAMIC_LINKER32
105 #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" 137-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
138+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1"
139 #undef MUSL_DYNAMIC_LINKER64
140-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
141+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1"
142 #undef MUSL_DYNAMIC_LINKERX32
143-#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
144+#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1"
106diff --git a/gcc/config/linux.h b/gcc/config/linux.h 145diff --git a/gcc/config/linux.h b/gcc/config/linux.h
107index 95654bcdb5a..0c1a8118a26 100644 146index e3aca79cccc..6491c6b84f5 100644
108--- a/gcc/config/linux.h 147--- a/gcc/config/linux.h
109+++ b/gcc/config/linux.h 148+++ b/gcc/config/linux.h
110@@ -94,10 +94,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 149@@ -86,10 +86,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
111 GLIBC_DYNAMIC_LINKER must be defined for each target using them, or 150 GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
112 GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets 151 GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
113 supporting both 32-bit and 64-bit compilation. */ 152 supporting both 32-bit and 64-bit compilation. */
@@ -122,11 +161,51 @@ index 95654bcdb5a..0c1a8118a26 100644
122 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" 161 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
123 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" 162 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
124 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" 163 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
164diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h
165index aecaa02a199..62f88f7f9a2 100644
166--- a/gcc/config/loongarch/gnu-user.h
167+++ b/gcc/config/loongarch/gnu-user.h
168@@ -31,11 +31,11 @@ along with GCC; see the file COPYING3. If not see
169
170 #undef GLIBC_DYNAMIC_LINKER
171 #define GLIBC_DYNAMIC_LINKER \
172- "/lib" ABI_GRLEN_SPEC "/ld-linux-loongarch-" ABI_SPEC ".so.1"
173+ SYSTEMLIBS_DIR "ld-linux-loongarch-" ABI_SPEC ".so.1"
174
175 #undef MUSL_DYNAMIC_LINKER
176 #define MUSL_DYNAMIC_LINKER \
177- "/lib" ABI_GRLEN_SPEC "/ld-musl-loongarch-" ABI_SPEC ".so.1"
178+ SYSTEMLIBS_DIR "ld-musl-loongarch-" ABI_SPEC ".so.1"
179
180 #undef GNU_USER_TARGET_LINK_SPEC
181 #define GNU_USER_TARGET_LINK_SPEC \
182diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
183index e2e2c421c52..6f26480e3b5 100644
184--- a/gcc/config/microblaze/linux.h
185+++ b/gcc/config/microblaze/linux.h
186@@ -28,7 +28,7 @@
187 #undef TLS_NEEDS_GOT
188 #define TLS_NEEDS_GOT 1
189
190-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
191+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "/ld.so.1"
192 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
193
194 #if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
195@@ -38,7 +38,7 @@
196 #endif
197
198 #undef MUSL_DYNAMIC_LINKER
199-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
200+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
201
202 #undef SUBTARGET_EXTRA_SPECS
203 #define SUBTARGET_EXTRA_SPECS \
125diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h 204diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
126index 54446e58e5f..4786ee304c1 100644 205index 5add34ea134..34692b433b8 100644
127--- a/gcc/config/mips/linux.h 206--- a/gcc/config/mips/linux.h
128+++ b/gcc/config/mips/linux.h 207+++ b/gcc/config/mips/linux.h
129@@ -22,20 +22,20 @@ along with GCC; see the file COPYING3. If not see 208@@ -22,29 +22,29 @@ along with GCC; see the file COPYING3. If not see
130 #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32" 209 #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
131 210
132 #define GLIBC_DYNAMIC_LINKER32 \ 211 #define GLIBC_DYNAMIC_LINKER32 \
@@ -153,8 +232,37 @@ index 54446e58e5f..4786ee304c1 100644
153 232
154 #undef MUSL_DYNAMIC_LINKER32 233 #undef MUSL_DYNAMIC_LINKER32
155 #define MUSL_DYNAMIC_LINKER32 \ 234 #define MUSL_DYNAMIC_LINKER32 \
235- "/lib/ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
236+ SYSTEMLIBS_DIR "ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
237 #undef MUSL_DYNAMIC_LINKER64
238 #define MUSL_DYNAMIC_LINKER64 \
239- "/lib/ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
240+ SYSTEMLIBS_DIR "ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
241 #define MUSL_DYNAMIC_LINKERN32 \
242- "/lib/ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
243+ SYSTEMLIBS_DIR "ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
244
245 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
246 #define GNU_USER_DYNAMIC_LINKERN32 \
247diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
248index 2ce097ebbce..1d45d7b4962 100644
249--- a/gcc/config/nios2/linux.h
250+++ b/gcc/config/nios2/linux.h
251@@ -29,10 +29,10 @@
252 #undef CPP_SPEC
253 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
254
255-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1"
256+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-nios2.so.1"
257
258 #undef MUSL_DYNAMIC_LINKER
259-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-nios2.so.1"
260+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-nios2.so.1"
261
262 #undef LINK_SPEC
263 #define LINK_SPEC LINK_SPEC_ENDIAN \
156diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h 264diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
157index 4afef7c228c..01997330741 100644 265index 3e625e0f867..dc3afc97e27 100644
158--- a/gcc/config/riscv/linux.h 266--- a/gcc/config/riscv/linux.h
159+++ b/gcc/config/riscv/linux.h 267+++ b/gcc/config/riscv/linux.h
160@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see 268@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see
@@ -166,11 +274,20 @@ index 4afef7c228c..01997330741 100644
166 274
167 #define MUSL_ABI_SUFFIX \ 275 #define MUSL_ABI_SUFFIX \
168 "%{mabi=ilp32:-sf}" \ 276 "%{mabi=ilp32:-sf}" \
277@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3. If not see
278 "%{mabi=lp64d:}"
279
280 #undef MUSL_DYNAMIC_LINKER
281-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
282+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
283
284 #define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
285
169diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h 286diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
170index 34776c8421e..967c1c43c63 100644 287index 9e457033d11..2ddab7c99c1 100644
171--- a/gcc/config/rs6000/linux64.h 288--- a/gcc/config/rs6000/linux64.h
172+++ b/gcc/config/rs6000/linux64.h 289+++ b/gcc/config/rs6000/linux64.h
173@@ -419,24 +419,19 @@ extern int dot_symbols; 290@@ -339,24 +339,19 @@ extern int dot_symbols;
174 #undef LINK_OS_DEFAULT_SPEC 291 #undef LINK_OS_DEFAULT_SPEC
175 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" 292 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
176 293
@@ -200,12 +317,55 @@ index 34776c8421e..967c1c43c63 100644
200 317
201 #undef DEFAULT_ASM_ENDIAN 318 #undef DEFAULT_ASM_ENDIAN
202 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) 319 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
320diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
321index ae932fc22f0..26db003cb3a 100644
322--- a/gcc/config/rs6000/sysv4.h
323+++ b/gcc/config/rs6000/sysv4.h
324@@ -771,10 +771,10 @@ GNU_USER_TARGET_CC1_SPEC
325
326 #define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
327
328-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
329+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld.so.1"
330 #undef MUSL_DYNAMIC_LINKER
331 #define MUSL_DYNAMIC_LINKER \
332- "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
333+ SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
334
335 #ifndef GNU_USER_DYNAMIC_LINKER
336 #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
337diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
338index 02aa1edaff8..fab268d61f4 100644
339--- a/gcc/config/s390/linux.h
340+++ b/gcc/config/s390/linux.h
341@@ -72,13 +72,13 @@ along with GCC; see the file COPYING3. If not see
342 #define MULTILIB_DEFAULTS { "m31" }
343 #endif
344
345-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
346-#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1"
347+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
348+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64.so.1"
349
350 #undef MUSL_DYNAMIC_LINKER32
351-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1"
352+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-s390.so.1"
353 #undef MUSL_DYNAMIC_LINKER64
354-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1"
355+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-s390x.so.1"
356
357 #undef LINK_SPEC
358 #define LINK_SPEC \
203diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h 359diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
204index c1d0441d488..81373eb8336 100644 360index 29f5902b98b..83d1e53e6e2 100644
205--- a/gcc/config/sh/linux.h 361--- a/gcc/config/sh/linux.h
206+++ b/gcc/config/sh/linux.h 362+++ b/gcc/config/sh/linux.h
207@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see 363@@ -61,10 +61,10 @@ along with GCC; see the file COPYING3. If not see
208 "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \ 364
365 #undef MUSL_DYNAMIC_LINKER
366 #define MUSL_DYNAMIC_LINKER \
367- "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
368+ SYSTEMLIBS_DIR "ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
209 "%{mfdpic:-fdpic}.so.1" 369 "%{mfdpic:-fdpic}.so.1"
210 370
211-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" 371-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
@@ -214,10 +374,10 @@ index c1d0441d488..81373eb8336 100644
214 #undef SUBTARGET_LINK_EMUL_SUFFIX 374 #undef SUBTARGET_LINK_EMUL_SUFFIX
215 #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}" 375 #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}"
216diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h 376diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
217index 81201e67a2f..8b6fc577594 100644 377index 0e33b3cac2c..84f29adbb35 100644
218--- a/gcc/config/sparc/linux.h 378--- a/gcc/config/sparc/linux.h
219+++ b/gcc/config/sparc/linux.h 379+++ b/gcc/config/sparc/linux.h
220@@ -84,7 +84,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); 380@@ -78,7 +78,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
221 When the -shared link option is used a final link is not being 381 When the -shared link option is used a final link is not being
222 done. */ 382 done. */
223 383
@@ -227,10 +387,10 @@ index 81201e67a2f..8b6fc577594 100644
227 #undef LINK_SPEC 387 #undef LINK_SPEC
228 #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ 388 #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
229diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h 389diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
230index a1a0efd8f28..85d1084afc2 100644 390index f1cc0a19e49..94bc2032803 100644
231--- a/gcc/config/sparc/linux64.h 391--- a/gcc/config/sparc/linux64.h
232+++ b/gcc/config/sparc/linux64.h 392+++ b/gcc/config/sparc/linux64.h
233@@ -84,8 +84,8 @@ along with GCC; see the file COPYING3. If not see 393@@ -78,8 +78,8 @@ along with GCC; see the file COPYING3. If not see
234 When the -shared link option is used a final link is not being 394 When the -shared link option is used a final link is not being
235 done. */ 395 done. */
236 396
diff --git a/meta/recipes-devtools/gcc/gcc/0008-fortran-cross-compile-hack.patch b/meta/recipes-devtools/gcc/gcc/0008-fortran-cross-compile-hack.patch
deleted file mode 100644
index 714db3bef5..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0008-fortran-cross-compile-hack.patch
+++ /dev/null
@@ -1,43 +0,0 @@
1From f05062625e7a4751be723595a2f7a4b7fbeff311 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:20:01 +0400
4Subject: [PATCH] fortran cross-compile hack.
5
6* Fortran would have searched for arm-angstrom-gnueabi-gfortran but would have used
7used gfortan. For gcc_4.2.2.bb we want to use the gfortran compiler from our cross
8directory.
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11
12Upstream-Status: Inappropriate [embedded specific]
13---
14 libgfortran/configure | 2 +-
15 libgfortran/configure.ac | 2 +-
16 2 files changed, 2 insertions(+), 2 deletions(-)
17
18diff --git a/libgfortran/configure b/libgfortran/configure
19index b4cf854ddb3..e8e0ac3b1cf 100755
20--- a/libgfortran/configure
21+++ b/libgfortran/configure
22@@ -13090,7 +13090,7 @@ esac
23
24 # We need gfortran to compile parts of the library
25 #AC_PROG_FC(gfortran)
26-FC="$GFORTRAN"
27+#FC="$GFORTRAN"
28 ac_ext=${ac_fc_srcext-f}
29 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
30 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
31diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
32index 711dc60ff78..3c9bbfbf47d 100644
33--- a/libgfortran/configure.ac
34+++ b/libgfortran/configure.ac
35@@ -258,7 +258,7 @@ AC_SUBST(enable_static)
36
37 # We need gfortran to compile parts of the library
38 #AC_PROG_FC(gfortran)
39-FC="$GFORTRAN"
40+#FC="$GFORTRAN"
41 AC_PROG_FC(gfortran)
42
43 # extra LD Flags which are required for targets
diff --git a/meta/recipes-devtools/gcc/gcc/0014-libtool.patch b/meta/recipes-devtools/gcc/gcc/0008-libtool.patch
index f4e70c3b18..5b44dc809e 100644
--- a/meta/recipes-devtools/gcc/gcc/0014-libtool.patch
+++ b/meta/recipes-devtools/gcc/gcc/0008-libtool.patch
@@ -1,4 +1,4 @@
1From 6ecd478881468934444ff85611fd43f7033b1e81 Mon Sep 17 00:00:00 2001 1From 7608e93ab97e8c33e3b14323d0cabc651926e403 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:29:11 +0400 3Date: Fri, 29 Mar 2013 09:29:11 +0400
4Subject: [PATCH] libtool 4Subject: [PATCH] libtool
@@ -15,9 +15,8 @@ to filter the zero case.
15 15
16RP 2012/8/24 16RP 2012/8/24
17 17
18Upstream-Status: Submitted [https://lists.gnu.org/archive/html/libtool-patches/2023-04/msg00000.html]
18Signed-off-by: Khem Raj <raj.khem@gmail.com> 19Signed-off-by: Khem Raj <raj.khem@gmail.com>
19
20Upstream-Status: Pending
21--- 20---
22 ltmain.sh | 4 ++++ 21 ltmain.sh | 4 ++++
23 1 file changed, 4 insertions(+) 22 1 file changed, 4 insertions(+)
diff --git a/meta/recipes-devtools/gcc/gcc/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch b/meta/recipes-devtools/gcc/gcc/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
index bc2674abcc..86542bd146 100644
--- a/meta/recipes-devtools/gcc/gcc/0015-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
+++ b/meta/recipes-devtools/gcc/gcc/0009-gcc-armv4-pass-fix-v4bx-to-linker-to-support-EABI.patch
@@ -1,4 +1,4 @@
1From de4427fa49c07dc651ee6ceaf5c5078700ca3b08 Mon Sep 17 00:00:00 2001 1From 4b0efc18e0d91967a3db11d9ef0595a5a76ad67a Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:30:32 +0400 3Date: Fri, 29 Mar 2013 09:30:32 +0400
4Subject: [PATCH] gcc: armv4: pass fix-v4bx to linker to support EABI. 4Subject: [PATCH] gcc: armv4: pass fix-v4bx to linker to support EABI.
@@ -11,20 +11,19 @@ for eabi defaulting toolchains.
11 11
12We might want to send it upstream. 12We might want to send it upstream.
13 13
14Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615319.html]
14Signed-off-by: Khem Raj <raj.khem@gmail.com> 15Signed-off-by: Khem Raj <raj.khem@gmail.com>
15
16Upstream-Status: Pending
17--- 16---
18 gcc/config/arm/linux-eabi.h | 6 +++++- 17 gcc/config/arm/linux-eabi.h | 6 +++++-
19 1 file changed, 5 insertions(+), 1 deletion(-) 18 1 file changed, 5 insertions(+), 1 deletion(-)
20 19
21diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h 20diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
22index 0c0332f317f..7b3769e8459 100644 21index dce7f59eeea..27402c629c6 100644
23--- a/gcc/config/arm/linux-eabi.h 22--- a/gcc/config/arm/linux-eabi.h
24+++ b/gcc/config/arm/linux-eabi.h 23+++ b/gcc/config/arm/linux-eabi.h
25@@ -91,10 +91,14 @@ 24@@ -88,10 +88,14 @@
26 #define MUSL_DYNAMIC_LINKER \ 25 #define MUSL_DYNAMIC_LINKER \
27 "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1" 26 SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
28 27
29+/* For armv4 we pass --fix-v4bx to linker to support EABI */ 28+/* For armv4 we pass --fix-v4bx to linker to support EABI */
30+#undef TARGET_FIX_V4BX_SPEC 29+#undef TARGET_FIX_V4BX_SPEC
diff --git a/meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch b/meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch
deleted file mode 100644
index 625e2d8709..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0010-MIPS64-Default-to-N64-ABI.patch
+++ /dev/null
@@ -1,54 +0,0 @@
1From 4fad4433c96bc9d0d9d124f9674fb3389f6f426e Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:23:08 +0400
4Subject: [PATCH] MIPS64: Default to N64 ABI
5
6MIPS64 defaults to n32 ABI, this patch makes it
7so that it defaults to N64 ABI
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10
11Upstream-Status: Inappropriate [OE config specific]
12---
13 gcc/config.gcc | 10 +++++-----
14 1 file changed, 5 insertions(+), 5 deletions(-)
15
16diff --git a/gcc/config.gcc b/gcc/config.gcc
17index cf1a87e2efd..37c4221a39f 100644
18--- a/gcc/config.gcc
19+++ b/gcc/config.gcc
20@@ -2511,29 +2511,29 @@ mips*-*-linux*) # Linux MIPS, either endian.
21 default_mips_arch=mips32
22 ;;
23 mips64el-st-linux-gnu)
24- default_mips_abi=n32
25+ default_mips_abi=64
26 tm_file="${tm_file} mips/st.h"
27 tmake_file="${tmake_file} mips/t-st"
28 enable_mips_multilibs="yes"
29 ;;
30 mips64octeon*-*-linux*)
31- default_mips_abi=n32
32+ default_mips_abi=64
33 tm_defines="${tm_defines} MIPS_CPU_STRING_DEFAULT=\\\"octeon\\\""
34 target_cpu_default=MASK_SOFT_FLOAT_ABI
35 enable_mips_multilibs="yes"
36 ;;
37 mipsisa64r6*-*-linux*)
38- default_mips_abi=n32
39+ default_mips_abi=64
40 default_mips_arch=mips64r6
41 enable_mips_multilibs="yes"
42 ;;
43 mipsisa64r2*-*-linux*)
44- default_mips_abi=n32
45+ default_mips_abi=64
46 default_mips_arch=mips64r2
47 enable_mips_multilibs="yes"
48 ;;
49 mips64*-*-linux* | mipsisa64*-*-linux*)
50- default_mips_abi=n32
51+ default_mips_abi=64
52 enable_mips_multilibs="yes"
53 ;;
54 esac
diff --git a/meta/recipes-devtools/gcc/gcc/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch b/meta/recipes-devtools/gcc/gcc/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch
index 1dc4bb859a..bc3943087c 100644
--- a/meta/recipes-devtools/gcc/gcc/0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch
+++ b/meta/recipes-devtools/gcc/gcc/0010-Use-the-multilib-config-files-from-B-instead-of-usin.patch
@@ -1,4 +1,4 @@
1From 6b363c2c1c089ee900efa6013aefba1003840a37 Mon Sep 17 00:00:00 2001 1From b015460586e2ea8a35a11d1a607728707bdf6509 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:33:04 +0400 3Date: Fri, 29 Mar 2013 09:33:04 +0400
4Subject: [PATCH] Use the multilib config files from ${B} instead of using the 4Subject: [PATCH] Use the multilib config files from ${B} instead of using the
@@ -18,10 +18,10 @@ Upstream-Status: Inappropriate [configuration]
18 2 files changed, 36 insertions(+), 8 deletions(-) 18 2 files changed, 36 insertions(+), 8 deletions(-)
19 19
20diff --git a/gcc/configure b/gcc/configure 20diff --git a/gcc/configure b/gcc/configure
21index 6080f86145e..825a9652329 100755 21index cf773a8b854..448a1ec093e 100755
22--- a/gcc/configure 22--- a/gcc/configure
23+++ b/gcc/configure 23+++ b/gcc/configure
24@@ -12685,10 +12685,20 @@ done 24@@ -13487,10 +13487,20 @@ done
25 tmake_file_= 25 tmake_file_=
26 for f in ${tmake_file} 26 for f in ${tmake_file}
27 do 27 do
@@ -46,7 +46,7 @@ index 6080f86145e..825a9652329 100755
46 done 46 done
47 tmake_file="${tmake_file_}${omp_device_property_tmake_file}" 47 tmake_file="${tmake_file_}${omp_device_property_tmake_file}"
48 48
49@@ -12699,6 +12709,10 @@ tm_file_list="options.h" 49@@ -13501,6 +13511,10 @@ tm_file_list="options.h"
50 tm_include_list="options.h insn-constants.h" 50 tm_include_list="options.h insn-constants.h"
51 for f in $tm_file; do 51 for f in $tm_file; do
52 case $f in 52 case $f in
@@ -58,10 +58,10 @@ index 6080f86145e..825a9652329 100755
58 f=`echo $f | sed 's/^..//'` 58 f=`echo $f | sed 's/^..//'`
59 tm_file_list="${tm_file_list} $f" 59 tm_file_list="${tm_file_list} $f"
60diff --git a/gcc/configure.ac b/gcc/configure.ac 60diff --git a/gcc/configure.ac b/gcc/configure.ac
61index 42be5252778..6099eb3251f 100644 61index 22591478b72..b6e7f5149a7 100644
62--- a/gcc/configure.ac 62--- a/gcc/configure.ac
63+++ b/gcc/configure.ac 63+++ b/gcc/configure.ac
64@@ -2118,10 +2118,20 @@ done 64@@ -2337,10 +2337,20 @@ done
65 tmake_file_= 65 tmake_file_=
66 for f in ${tmake_file} 66 for f in ${tmake_file}
67 do 67 do
@@ -86,7 +86,7 @@ index 42be5252778..6099eb3251f 100644
86 done 86 done
87 tmake_file="${tmake_file_}${omp_device_property_tmake_file}" 87 tmake_file="${tmake_file_}${omp_device_property_tmake_file}"
88 88
89@@ -2132,6 +2142,10 @@ tm_file_list="options.h" 89@@ -2351,6 +2361,10 @@ tm_file_list="options.h"
90 tm_include_list="options.h insn-constants.h" 90 tm_include_list="options.h insn-constants.h"
91 for f in $tm_file; do 91 for f in $tm_file; do
92 case $f in 92 case $f in
diff --git a/meta/recipes-devtools/gcc/gcc/0011-aarch64-Fix-include-paths-when-S-B.patch b/meta/recipes-devtools/gcc/gcc/0011-aarch64-Fix-include-paths-when-S-B.patch
new file mode 100644
index 0000000000..974aca5ee4
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0011-aarch64-Fix-include-paths-when-S-B.patch
@@ -0,0 +1,55 @@
1From b7ce05b2d969b311c6061bda32c3117c76bf7e0c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 31 Jan 2023 22:03:38 -0800
4Subject: [PATCH] aarch64: Fix include paths when S != B
5
6aarch64.h gets copied into build directory when built out of tree, in
7this case build uses this file but does not find the includes inside it
8since they are not found in any of include paths specified in compiler
9cmdline.
10
11Fixes build errors like
12
13% g++ -c -isystem/mnt/b/yoe/master/build/tmp/work/x86_64-linux/gcc-cross-aarch64/13.0.1-r0/recipe-sysroot-native/usr/include -O2 -pipe -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -DGENERATOR_FILE -I. -Ibuild -I../../../../../../../work-shared/gcc-13.0.1-r0/gcc-b2ec2504af77b35e748067eeb846821d12a6b6b4/gcc -I../../../../../../../work-shared/gcc-13.0.1-r0/gcc-b2ec2504af77b35e748067eeb846821d12a6b6b4/gcc/build -I../../../../../../../work-shared/gcc-13.0.1-r0/gcc-b2ec2504af77b35e748067eeb846821d12a6b6b4/gcc/../include -I../../../../../../../work-shared/gcc-13.0.1-r0/gcc-b2ec2504af77b35e748067eeb846821d12a6b6b4/gcc/../libcpp/include -o build/gencheck.o ../../../../../../../work-shared/gcc-13.0.1-r0/gcc-b2ec2504af77b35e748067eeb846821d12a6b6b4/gcc/gencheck.cc
14In file included from ./tm.h:34,
15 from ../../../../../../../work-shared/gcc-13.0.1-r0/gcc-b2ec2504af77b35e748067eeb846821d12a6b6b4/gcc/gencheck.cc:23:
16./config/aarch64/aarch64.h:164:10: fatal error: aarch64-option-extensions.def: No such file or directory
17 164 | #include "aarch64-option-extensions.def"
18 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19compilation terminated.
20
21See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105144
22
23Upstream-Status: Pending
24
25Signed-off-by: Khem Raj <raj.khem@gmail.com>
26---
27 gcc/config/aarch64/aarch64.h | 8 ++++----
28 1 file changed, 4 insertions(+), 4 deletions(-)
29
30diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
31index 73b09e20508..10ea3672f20 100644
32--- a/gcc/config/aarch64/aarch64.h
33+++ b/gcc/config/aarch64/aarch64.h
34@@ -161,8 +161,8 @@
35 enum class aarch64_feature : unsigned char {
36 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) IDENT,
37 #define AARCH64_ARCH(A, B, IDENT, D, E) IDENT,
38-#include "aarch64-option-extensions.def"
39-#include "aarch64-arches.def"
40+#include "config/aarch64/aarch64-option-extensions.def"
41+#include "config/aarch64/aarch64-arches.def"
42 };
43
44 /* Define unique flags for each of the above. */
45@@ -171,8 +171,8 @@ enum class aarch64_feature : unsigned char {
46 = aarch64_feature_flags (1) << int (aarch64_feature::IDENT);
47 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) HANDLE (IDENT)
48 #define AARCH64_ARCH(A, B, IDENT, D, E) HANDLE (IDENT)
49-#include "aarch64-option-extensions.def"
50-#include "aarch64-arches.def"
51+#include "config/aarch64/aarch64-option-extensions.def"
52+#include "config/aarch64/aarch64-arches.def"
53 #undef HANDLE
54
55 #endif
diff --git a/meta/recipes-devtools/gcc/gcc/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch b/meta/recipes-devtools/gcc/gcc/0012-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
index 05f12847e9..cf5efcd32d 100644
--- a/meta/recipes-devtools/gcc/gcc/0017-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
+++ b/meta/recipes-devtools/gcc/gcc/0012-Avoid-using-libdir-from-.la-which-usually-points-to-.patch
@@ -1,4 +1,4 @@
1From 08752c2f1d21553301bee5757c453c6a36cbe03c Mon Sep 17 00:00:00 2001 1From 39ab6fe76f2788b2c989d29c9016f1fe53cb736e Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 09:39:38 +0000 3Date: Fri, 20 Feb 2015 09:39:38 +0000
4Subject: [PATCH] Avoid using libdir from .la which usually points to a host 4Subject: [PATCH] Avoid using libdir from .la which usually points to a host
diff --git a/meta/recipes-devtools/gcc/gcc/0012-gcc-Fix-argument-list-too-long-error.patch b/meta/recipes-devtools/gcc/gcc/0012-gcc-Fix-argument-list-too-long-error.patch
deleted file mode 100644
index 88e1715b5c..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0012-gcc-Fix-argument-list-too-long-error.patch
+++ /dev/null
@@ -1,41 +0,0 @@
1From a22d1264049d29b90663cf5667049ae6f9b7a5ce Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:26:37 +0400
4Subject: [PATCH] gcc: Fix argument list too long error.
5
6There would be an "Argument list too long" error when the
7build directory is longer than 200, this is caused by:
8
9headers=`echo $(PLUGIN_HEADERS) | tr ' ' '\012' | sort -u`
10
11The PLUGIN_HEADERS is too long before sort, so the "echo" can't handle
12it, use the $(sort list) of GNU make which can handle the too long list
13would fix the problem, the header would be short enough after sorted.
14The "tr ' ' '\012'" was used for translating the space to "\n", the
15$(sort list) doesn't need this.
16
17Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19
20RP: gcc then added *.h and *.def additions to this list, breaking the original
21fix. Add the sort to the original gcc code, leaving the tr+sort to fix the original
22issue but include the new files too as reported by Zhuang <qiuguang.zqg@alibaba-inc.com>
23
24Upstream-Status: Pending
25---
26 gcc/Makefile.in | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29diff --git a/gcc/Makefile.in b/gcc/Makefile.in
30index a67d2cc18d6..480c9366418 100644
31--- a/gcc/Makefile.in
32+++ b/gcc/Makefile.in
33@@ -3606,7 +3606,7 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
34 # We keep the directory structure for files in config or c-family and .def
35 # files. All other files are flattened to a single directory.
36 $(mkinstalldirs) $(DESTDIR)$(plugin_includedir)
37- headers=`echo $(PLUGIN_HEADERS) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \
38+ headers=`echo $(sort $(PLUGIN_HEADERS)) $$(cd $(srcdir); echo *.h *.def) | tr ' ' '\012' | sort -u`; \
39 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`; \
40 for file in $$headers; do \
41 if [ -f $$file ] ; then \
diff --git a/meta/recipes-devtools/gcc/gcc/0013-Disable-sdt.patch b/meta/recipes-devtools/gcc/gcc/0013-Disable-sdt.patch
deleted file mode 100644
index 207cdb57af..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0013-Disable-sdt.patch
+++ /dev/null
@@ -1,110 +0,0 @@
1From fa47586935a18ecfc2ad5586802e326e21741b7b Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 29 Mar 2013 09:28:10 +0400
4Subject: [PATCH] Disable sdt.
5
6We don't list dtrace in DEPENDS so we shouldn't be depending on this header.
7It may or may not exist from preivous builds though. To be determinstic, disable
8sdt.h usage always. This avoids build failures if the header is removed after configure
9but before libgcc is compiled for example.
10
11RP 2012/8/7
12
13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14
15Disable sdt for libstdc++-v3.
16
17Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
18
19Upstream-Status: Inappropriate [hack]
20---
21 gcc/configure | 12 ++++++------
22 gcc/configure.ac | 18 +++++++++---------
23 libstdc++-v3/configure | 6 +++---
24 libstdc++-v3/configure.ac | 2 +-
25 4 files changed, 19 insertions(+), 19 deletions(-)
26
27diff --git a/gcc/configure b/gcc/configure
28index b26e8fc7fee..6080f86145e 100755
29--- a/gcc/configure
30+++ b/gcc/configure
31@@ -29789,12 +29789,12 @@ fi
32 { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sdt.h in the target C library" >&5
33 $as_echo_n "checking sys/sdt.h in the target C library... " >&6; }
34 have_sys_sdt_h=no
35-if test -f $target_header_dir/sys/sdt.h; then
36- have_sys_sdt_h=yes
37-
38-$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
39-
40-fi
41+#if test -f $target_header_dir/sys/sdt.h; then
42+# have_sys_sdt_h=yes
43+#
44+#$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
45+#
46+#fi
47 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_sys_sdt_h" >&5
48 $as_echo "$have_sys_sdt_h" >&6; }
49
50diff --git a/gcc/configure.ac b/gcc/configure.ac
51index 26fa46802c7..42be5252778 100644
52--- a/gcc/configure.ac
53+++ b/gcc/configure.ac
54@@ -6190,15 +6190,15 @@ fi
55 AC_SUBST([enable_default_ssp])
56
57 # Test for <sys/sdt.h> on the target.
58-GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
59-AC_MSG_CHECKING(sys/sdt.h in the target C library)
60-have_sys_sdt_h=no
61-if test -f $target_header_dir/sys/sdt.h; then
62- have_sys_sdt_h=yes
63- AC_DEFINE(HAVE_SYS_SDT_H, 1,
64- [Define if your target C library provides sys/sdt.h])
65-fi
66-AC_MSG_RESULT($have_sys_sdt_h)
67+#GCC_TARGET_TEMPLATE([HAVE_SYS_SDT_H])
68+#AC_MSG_CHECKING(sys/sdt.h in the target C library)
69+#have_sys_sdt_h=no
70+#if test -f $target_header_dir/sys/sdt.h; then
71+# have_sys_sdt_h=yes
72+# AC_DEFINE(HAVE_SYS_SDT_H, 1,
73+# [Define if your target C library provides sys/sdt.h])
74+#fi
75+#AC_MSG_RESULT($have_sys_sdt_h)
76
77 # Check if TFmode long double should be used by default or not.
78 # Some glibc targets used DFmode long double, but with glibc 2.4
79diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
80index 9f9c5a2419a..71ed13b815b 100755
81--- a/libstdc++-v3/configure
82+++ b/libstdc++-v3/configure
83@@ -22615,11 +22615,11 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
84 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
85 ac_compiler_gnu=$ac_cv_c_compiler_gnu
86
87- if test $glibcxx_cv_sys_sdt_h = yes; then
88+# if test $glibcxx_cv_sys_sdt_h = yes; then
89
90-$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
91+#$as_echo "#define HAVE_SYS_SDT_H 1" >>confdefs.h
92
93- fi
94+# fi
95 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_sys_sdt_h" >&5
96 $as_echo "$glibcxx_cv_sys_sdt_h" >&6; }
97
98diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
99index 699e55fd829..5c7a7bda439 100644
100--- a/libstdc++-v3/configure.ac
101+++ b/libstdc++-v3/configure.ac
102@@ -241,7 +241,7 @@ GLIBCXX_CHECK_SC_NPROCESSORS_ONLN
103 GLIBCXX_CHECK_SC_NPROC_ONLN
104 GLIBCXX_CHECK_PTHREADS_NUM_PROCESSORS_NP
105 GLIBCXX_CHECK_SYSCTL_HW_NCPU
106-GLIBCXX_CHECK_SDT_H
107+#GLIBCXX_CHECK_SDT_H
108
109 # Check for available headers.
110 AC_CHECK_HEADERS([endian.h execinfo.h float.h fp.h ieeefp.h inttypes.h \
diff --git a/meta/recipes-devtools/gcc/gcc/0013-Ensure-target-gcc-headers-can-be-included.patch b/meta/recipes-devtools/gcc/gcc/0013-Ensure-target-gcc-headers-can-be-included.patch
new file mode 100644
index 0000000000..e2343a3c17
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0013-Ensure-target-gcc-headers-can-be-included.patch
@@ -0,0 +1,113 @@
1From 531b9df680c4380797e8e7705a8e7f8ed17ebe68 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 10:25:11 +0000
4Subject: [PATCH] Ensure target gcc headers can be included
5
6There are a few headers installed as part of the OpenEmbedded
7gcc-runtime target (omp.h, ssp/*.h). Being installed from a recipe
8built for the target architecture, these are within the target
9sysroot and not cross/nativesdk; thus they weren't able to be
10found by gcc with the existing search paths. Add support for
11picking up these headers under the sysroot supplied on the gcc
12command line in order to resolve this.
13
14Extend target gcc headers search to musl too
15
16Upstream-Status: Inappropriate [embedded specific]
17
18Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
19Signed-off-by: Khem Raj <raj.khem@gmail.com>
20---
21 gcc/Makefile.in | 2 ++
22 gcc/config/linux.h | 8 ++++++++
23 gcc/config/rs6000/sysv4.h | 8 ++++++++
24 gcc/cppdefault.cc | 4 ++++
25 4 files changed, 22 insertions(+)
26
27diff --git a/gcc/Makefile.in b/gcc/Makefile.in
28index 04f28984b34..8ef996c0f4d 100644
29--- a/gcc/Makefile.in
30+++ b/gcc/Makefile.in
31@@ -640,6 +640,7 @@ libexecdir = @libexecdir@
32
33 # Directory in which the compiler finds libraries etc.
34 libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
35+libsubdir_target = $(target_noncanonical)/$(version)
36 # Directory in which the compiler finds executables
37 libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
38 # Directory in which all plugin resources are installed
39@@ -3059,6 +3060,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\"
40
41 PREPROCESSOR_DEFINES = \
42 -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
43+ -DGCC_INCLUDE_SUBDIR_TARGET=\"$(libsubdir_target)/include\" \
44 -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
45 -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
46 -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
47diff --git a/gcc/config/linux.h b/gcc/config/linux.h
48index 6491c6b84f5..57496ff1f2f 100644
49--- a/gcc/config/linux.h
50+++ b/gcc/config/linux.h
51@@ -157,6 +157,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
52 #define INCLUDE_DEFAULTS_MUSL_TOOL
53 #endif
54
55+#ifdef GCC_INCLUDE_SUBDIR_TARGET
56+#define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
57+ { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0},
58+#else
59+#define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET
60+#endif
61+
62 #ifdef NATIVE_SYSTEM_HEADER_DIR
63 #define INCLUDE_DEFAULTS_MUSL_NATIVE \
64 { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
65@@ -183,6 +190,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
66 INCLUDE_DEFAULTS_MUSL_PREFIX \
67 INCLUDE_DEFAULTS_MUSL_CROSS \
68 INCLUDE_DEFAULTS_MUSL_TOOL \
69+ INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
70 INCLUDE_DEFAULTS_MUSL_NATIVE \
71 { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
72 { 0, 0, 0, 0, 0, 0 } \
73diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
74index 26db003cb3a..3a443abcf6b 100644
75--- a/gcc/config/rs6000/sysv4.h
76+++ b/gcc/config/rs6000/sysv4.h
77@@ -986,6 +986,13 @@ ncrtn.o%s"
78 #define INCLUDE_DEFAULTS_MUSL_TOOL
79 #endif
80
81+#ifdef GCC_INCLUDE_SUBDIR_TARGET
82+#define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
83+ { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0},
84+#else
85+#define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET
86+#endif
87+
88 #ifdef NATIVE_SYSTEM_HEADER_DIR
89 #define INCLUDE_DEFAULTS_MUSL_NATIVE \
90 { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
91@@ -1012,6 +1019,7 @@ ncrtn.o%s"
92 INCLUDE_DEFAULTS_MUSL_PREFIX \
93 INCLUDE_DEFAULTS_MUSL_CROSS \
94 INCLUDE_DEFAULTS_MUSL_TOOL \
95+ INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
96 INCLUDE_DEFAULTS_MUSL_NATIVE \
97 { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
98 { 0, 0, 0, 0, 0, 0 } \
99diff --git a/gcc/cppdefault.cc b/gcc/cppdefault.cc
100index 141bb4d25f6..734590a7059 100644
101--- a/gcc/cppdefault.cc
102+++ b/gcc/cppdefault.cc
103@@ -64,6 +64,10 @@ const struct default_include cpp_include_defaults[]
104 /* This is the dir for gcc's private headers. */
105 { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
106 #endif
107+#ifdef GCC_INCLUDE_SUBDIR_TARGET
108+ /* This is the dir for gcc's private headers under the specified sysroot. */
109+ { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 },
110+#endif
111 #ifdef LOCAL_INCLUDE_DIR
112 /* /usr/local/include comes before the fixincluded header files. */
113 { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
diff --git a/meta/recipes-devtools/gcc/gcc/0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch b/meta/recipes-devtools/gcc/gcc/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch
index c3baf8b451..30224d7485 100644
--- a/meta/recipes-devtools/gcc/gcc/0020-Don-t-search-host-directory-during-relink-if-inst_pr.patch
+++ b/meta/recipes-devtools/gcc/gcc/0014-Don-t-search-host-directory-during-relink-if-inst_pr.patch
@@ -1,4 +1,4 @@
1From 870e805d705d99d9b9d7dbd09727f9c1d2ad9c1d Mon Sep 17 00:00:00 2001 1From 793201cebfeb129f6f263e64310b30a0ffa48895 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 3 Mar 2015 08:21:19 +0000 3Date: Tue, 3 Mar 2015 08:21:19 +0000
4Subject: [PATCH] Don't search host directory during "relink" if $inst_prefix 4Subject: [PATCH] Don't search host directory during "relink" if $inst_prefix
diff --git a/meta/recipes-devtools/gcc/gcc/0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch b/meta/recipes-devtools/gcc/gcc/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch
index 80c4d2292c..33c601ac97 100644
--- a/meta/recipes-devtools/gcc/gcc/0023-libcc1-fix-libcc1-s-install-path-and-rpath.patch
+++ b/meta/recipes-devtools/gcc/gcc/0015-libcc1-fix-libcc1-s-install-path-and-rpath.patch
@@ -1,4 +1,4 @@
1From 3474e16ad4ea8cf4e0e330568e3bc9039e723dce Mon Sep 17 00:00:00 2001 1From 5de63874335c1c673dd132f6aca00dc13f1eac51 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com> 2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Sun, 5 Jul 2015 20:25:18 -0700 3Date: Sun, 5 Jul 2015 20:25:18 -0700
4Subject: [PATCH] libcc1: fix libcc1's install path and rpath 4Subject: [PATCH] libcc1: fix libcc1's install path and rpath
@@ -20,10 +20,10 @@ Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
20 2 files changed, 4 insertions(+), 4 deletions(-) 20 2 files changed, 4 insertions(+), 4 deletions(-)
21 21
22diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am 22diff --git a/libcc1/Makefile.am b/libcc1/Makefile.am
23index c005b0dad4a..ec31d35b7b9 100644 23index 921a33fe236..938e6f964cd 100644
24--- a/libcc1/Makefile.am 24--- a/libcc1/Makefile.am
25+++ b/libcc1/Makefile.am 25+++ b/libcc1/Makefile.am
26@@ -37,8 +37,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ 26@@ -40,8 +40,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
27 $(Wc)$(libiberty_normal))) 27 $(Wc)$(libiberty_normal)))
28 libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) 28 libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
29 29
@@ -35,10 +35,10 @@ index c005b0dad4a..ec31d35b7b9 100644
35 if ENABLE_PLUGIN 35 if ENABLE_PLUGIN
36 plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la 36 plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la
37diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in 37diff --git a/libcc1/Makefile.in b/libcc1/Makefile.in
38index 7104b649026..2103c477468 100644 38index f8f590d71e9..56462492045 100644
39--- a/libcc1/Makefile.in 39--- a/libcc1/Makefile.in
40+++ b/libcc1/Makefile.in 40+++ b/libcc1/Makefile.in
41@@ -393,8 +393,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \ 41@@ -396,8 +396,8 @@ libiberty = $(if $(wildcard $(libiberty_noasan)),$(Wc)$(libiberty_noasan), \
42 $(Wc)$(libiberty_normal))) 42 $(Wc)$(libiberty_normal)))
43 43
44 libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty)) 44 libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
diff --git a/meta/recipes-devtools/gcc/gcc/0024-handle-sysroot-support-for-nativesdk-gcc.patch b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
index dc3e6da65a..bdffcae7dc 100644
--- a/meta/recipes-devtools/gcc/gcc/0024-handle-sysroot-support-for-nativesdk-gcc.patch
+++ b/meta/recipes-devtools/gcc/gcc/0016-handle-sysroot-support-for-nativesdk-gcc.patch
@@ -1,4 +1,4 @@
1From 702daf2e9cb97337e0e594fcd435b1b61a917d14 Mon Sep 17 00:00:00 2001 1From bbc75b93bff66891fa7ffb3af5c6ad53df1fff68 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 7 Dec 2015 23:39:54 +0000 3Date: Mon, 7 Dec 2015 23:39:54 +0000
4Subject: [PATCH] handle sysroot support for nativesdk-gcc 4Subject: [PATCH] handle sysroot support for nativesdk-gcc
@@ -23,6 +23,9 @@ b) Add other paths which need relocation into a .gccrelocprefix section
23Upstream-Status: Inappropriate 23Upstream-Status: Inappropriate
24RP 2015/7/28 24RP 2015/7/28
25 25
26Extend the gccrelocprefix support to musl config too, this ensures
27that gcc will get right bits in SDK installations
28
26Signed-off-by: Khem Raj <raj.khem@gmail.com> 29Signed-off-by: Khem Raj <raj.khem@gmail.com>
27 30
28Added PREFIXVAR and EXEC_PREFIXVAR to support runtime relocation. Without 31Added PREFIXVAR and EXEC_PREFIXVAR to support runtime relocation. Without
@@ -32,19 +35,21 @@ implementation.)
32 35
33Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org> 36Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
34--- 37---
35 gcc/c-family/c-opts.c | 4 +-- 38 gcc/c-family/c-opts.cc | 4 +--
36 gcc/cppdefault.c | 63 ++++++++++++++++++++++++++----------------- 39 gcc/config/linux.h | 24 +++++++--------
37 gcc/cppdefault.h | 13 ++++----- 40 gcc/config/rs6000/sysv4.h | 24 +++++++--------
38 gcc/gcc.c | 20 +++++++++----- 41 gcc/cppdefault.cc | 65 ++++++++++++++++++++++++---------------
39 gcc/incpath.c | 12 ++++----- 42 gcc/cppdefault.h | 13 +++-----
40 gcc/prefix.c | 6 +++-- 43 gcc/gcc.cc | 20 ++++++++----
41 6 files changed, 70 insertions(+), 48 deletions(-) 44 gcc/incpath.cc | 12 ++++----
45 gcc/prefix.cc | 6 ++--
46 8 files changed, 95 insertions(+), 73 deletions(-)
42 47
43diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c 48diff --git a/gcc/c-family/c-opts.cc b/gcc/c-family/c-opts.cc
44index 58ba0948e79..806bbcfb7a5 100644 49index c68a2a27469..77e9b5eceaa 100644
45--- a/gcc/c-family/c-opts.c 50--- a/gcc/c-family/c-opts.cc
46+++ b/gcc/c-family/c-opts.c 51+++ b/gcc/c-family/c-opts.cc
47@@ -1409,8 +1409,8 @@ add_prefixed_path (const char *suffix, incpath_kind chain) 52@@ -1458,8 +1458,8 @@ add_prefixed_path (const char *suffix, incpath_kind chain)
48 size_t prefix_len, suffix_len; 53 size_t prefix_len, suffix_len;
49 54
50 suffix_len = strlen (suffix); 55 suffix_len = strlen (suffix);
@@ -55,10 +60,166 @@ index 58ba0948e79..806bbcfb7a5 100644
55 60
56 path = (char *) xmalloc (prefix_len + suffix_len + 1); 61 path = (char *) xmalloc (prefix_len + suffix_len + 1);
57 memcpy (path, prefix, prefix_len); 62 memcpy (path, prefix, prefix_len);
58diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c 63diff --git a/gcc/config/linux.h b/gcc/config/linux.h
59index 2f43b88a0c3..6b6be04686c 100644 64index 57496ff1f2f..c921cf6ef63 100644
60--- a/gcc/cppdefault.c 65--- a/gcc/config/linux.h
61+++ b/gcc/cppdefault.c 66+++ b/gcc/config/linux.h
67@@ -121,53 +121,53 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
68 * Unfortunately, this is mostly duplicated from cppdefault.cc */
69 #if DEFAULT_LIBC == LIBC_MUSL
70 #define INCLUDE_DEFAULTS_MUSL_GPP \
71- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
72+ { GPLUSPLUS_INCLUDE_DIRVAR, "G++", 1, 1, \
73 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
74- { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
75+ { GPLUSPLUS_TOOL_INCLUDE_DIRVAR, "G++", 1, 1, \
76 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
77- { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
78+ { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1, \
79 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
80
81 #ifdef LOCAL_INCLUDE_DIR
82 #define INCLUDE_DEFAULTS_MUSL_LOCAL \
83- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
84- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
85+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 2 }, \
86+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 0 },
87 #else
88 #define INCLUDE_DEFAULTS_MUSL_LOCAL
89 #endif
90
91 #ifdef PREFIX_INCLUDE_DIR
92 #define INCLUDE_DEFAULTS_MUSL_PREFIX \
93- { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
94+ { PREFIX_INCLUDE_DIRVAR, 0, 0, 1, 0, 0},
95 #else
96 #define INCLUDE_DEFAULTS_MUSL_PREFIX
97 #endif
98
99 #ifdef CROSS_INCLUDE_DIR
100 #define INCLUDE_DEFAULTS_MUSL_CROSS \
101- { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
102+ { CROSS_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0},
103 #else
104 #define INCLUDE_DEFAULTS_MUSL_CROSS
105 #endif
106
107 #ifdef TOOL_INCLUDE_DIR
108 #define INCLUDE_DEFAULTS_MUSL_TOOL \
109- { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
110+ { TOOL_INCLUDE_DIRVAR, "BINUTILS", 0, 1, 0, 0},
111 #else
112 #define INCLUDE_DEFAULTS_MUSL_TOOL
113 #endif
114
115 #ifdef GCC_INCLUDE_SUBDIR_TARGET
116 #define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
117- { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0},
118+ { STANDARD_STARTFILE_PREFIX_2VAR, "GCC", 0, 0, 1, 0},
119 #else
120 #define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET
121 #endif
122
123 #ifdef NATIVE_SYSTEM_HEADER_DIR
124 #define INCLUDE_DEFAULTS_MUSL_NATIVE \
125- { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
126- { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
127+ { NATIVE_SYSTEM_HEADER_DIRVAR, 0, 0, 0, 1, 2 }, \
128+ { NATIVE_SYSTEM_HEADER_DIRVAR, 0, 0, 0, 1, 0 },
129 #else
130 #define INCLUDE_DEFAULTS_MUSL_NATIVE
131 #endif
132@@ -192,7 +192,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
133 INCLUDE_DEFAULTS_MUSL_TOOL \
134 INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
135 INCLUDE_DEFAULTS_MUSL_NATIVE \
136- { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
137+ { GCC_INCLUDE_DIRVAR, "GCC", 0, 1, 0, 0 }, \
138 { 0, 0, 0, 0, 0, 0 } \
139 }
140 #endif
141diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
142index 3a443abcf6b..ef83a5a432e 100644
143--- a/gcc/config/rs6000/sysv4.h
144+++ b/gcc/config/rs6000/sysv4.h
145@@ -950,53 +950,53 @@ ncrtn.o%s"
146 /* Include order changes for musl, same as in generic linux.h. */
147 #if DEFAULT_LIBC == LIBC_MUSL
148 #define INCLUDE_DEFAULTS_MUSL_GPP \
149- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, \
150+ { GPLUSPLUS_INCLUDE_DIRVAR, "G++", 1, 1, \
151 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, \
152- { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, \
153+ { GPLUSPLUS_TOOL_INCLUDE_DIRVAR, "G++", 1, 1, \
154 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, \
155- { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, \
156+ { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1, \
157 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
158
159 #ifdef LOCAL_INCLUDE_DIR
160 #define INCLUDE_DEFAULTS_MUSL_LOCAL \
161- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 }, \
162- { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
163+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 2 }, \
164+ { LOCAL_INCLUDE_DIRVAR, 0, 0, 1, 1, 0 },
165 #else
166 #define INCLUDE_DEFAULTS_MUSL_LOCAL
167 #endif
168
169 #ifdef PREFIX_INCLUDE_DIR
170 #define INCLUDE_DEFAULTS_MUSL_PREFIX \
171- { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0},
172+ { PREFIX_INCLUDE_DIRVAR, 0, 0, 1, 0, 0},
173 #else
174 #define INCLUDE_DEFAULTS_MUSL_PREFIX
175 #endif
176
177 #ifdef CROSS_INCLUDE_DIR
178 #define INCLUDE_DEFAULTS_MUSL_CROSS \
179- { CROSS_INCLUDE_DIR, "GCC", 0, 0, 0, 0},
180+ { CROSS_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 0},
181 #else
182 #define INCLUDE_DEFAULTS_MUSL_CROSS
183 #endif
184
185 #ifdef TOOL_INCLUDE_DIR
186 #define INCLUDE_DEFAULTS_MUSL_TOOL \
187- { TOOL_INCLUDE_DIR, "BINUTILS", 0, 1, 0, 0},
188+ { TOOL_INCLUDE_DIRVAR, "BINUTILS", 0, 1, 0, 0},
189 #else
190 #define INCLUDE_DEFAULTS_MUSL_TOOL
191 #endif
192
193 #ifdef GCC_INCLUDE_SUBDIR_TARGET
194 #define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
195- { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0},
196+ { STANDARD_STARTFILE_PREFIX_2VAR, "GCC", 0, 0, 1, 0},
197 #else
198 #define INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET
199 #endif
200
201 #ifdef NATIVE_SYSTEM_HEADER_DIR
202 #define INCLUDE_DEFAULTS_MUSL_NATIVE \
203- { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 2 }, \
204- { NATIVE_SYSTEM_HEADER_DIR, 0, 0, 0, 1, 0 },
205+ { NATIVE_SYSTEM_HEADER_DIRVAR, 0, 0, 0, 1, 2 }, \
206+ { NATIVE_SYSTEM_HEADER_DIRVAR, 0, 0, 0, 1, 0 },
207 #else
208 #define INCLUDE_DEFAULTS_MUSL_NATIVE
209 #endif
210@@ -1021,7 +1021,7 @@ ncrtn.o%s"
211 INCLUDE_DEFAULTS_MUSL_TOOL \
212 INCLUDE_DEFAULTS_MUSL_SUBDIR_TARGET \
213 INCLUDE_DEFAULTS_MUSL_NATIVE \
214- { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \
215+ { GCC_INCLUDE_DIRVAR, "GCC", 0, 1, 0, 0 }, \
216 { 0, 0, 0, 0, 0, 0 } \
217 }
218 #endif
219diff --git a/gcc/cppdefault.cc b/gcc/cppdefault.cc
220index 734590a7059..b4a8fc29e4a 100644
221--- a/gcc/cppdefault.cc
222+++ b/gcc/cppdefault.cc
62@@ -35,6 +35,30 @@ 223@@ -35,6 +35,30 @@
63 # undef CROSS_INCLUDE_DIR 224 # undef CROSS_INCLUDE_DIR
64 #endif 225 #endif
@@ -90,7 +251,7 @@ index 2f43b88a0c3..6b6be04686c 100644
90 const struct default_include cpp_include_defaults[] 251 const struct default_include cpp_include_defaults[]
91 #ifdef INCLUDE_DEFAULTS 252 #ifdef INCLUDE_DEFAULTS
92 = INCLUDE_DEFAULTS; 253 = INCLUDE_DEFAULTS;
93@@ -42,38 +66,38 @@ const struct default_include cpp_include_defaults[] 254@@ -42,17 +66,17 @@ const struct default_include cpp_include_defaults[]
94 = { 255 = {
95 #ifdef GPLUSPLUS_INCLUDE_DIR 256 #ifdef GPLUSPLUS_INCLUDE_DIR
96 /* Pick up GNU C++ generic include files. */ 257 /* Pick up GNU C++ generic include files. */
@@ -110,6 +271,9 @@ index 2f43b88a0c3..6b6be04686c 100644
110+ { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1, 271+ { GPLUSPLUS_BACKWARD_INCLUDE_DIRVAR, "G++", 1, 1,
111 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, 272 GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 },
112 #endif 273 #endif
274 #ifdef GPLUSPLUS_LIBCXX_INCLUDE_DIR
275@@ -62,26 +86,26 @@ const struct default_include cpp_include_defaults[]
276 #endif
113 #ifdef GCC_INCLUDE_DIR 277 #ifdef GCC_INCLUDE_DIR
114 /* This is the dir for gcc's private headers. */ 278 /* This is the dir for gcc's private headers. */
115- { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, 279- { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
@@ -133,12 +297,16 @@ index 2f43b88a0c3..6b6be04686c 100644
133 #endif 297 #endif
134 #ifdef FIXED_INCLUDE_DIR 298 #ifdef FIXED_INCLUDE_DIR
135 /* This is the dir for fixincludes. */ 299 /* This is the dir for fixincludes. */
300 #ifndef SYSROOT_HEADERS_SUFFIX_SPEC
301- { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0, 2 },
302+ { FIXED_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 2 },
303 #endif
136- { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0, 304- { FIXED_INCLUDE_DIR, "GCC", 0, 0, 0,
137+ { FIXED_INCLUDE_DIRVAR, "GCC", 0, 0, 0, 305+ { FIXED_INCLUDE_DIRVAR, "GCC", 0, 0, 0,
138 /* A multilib suffix needs adding if different multilibs use 306 /* A multilib suffix needs adding if different multilibs use
139 different headers. */ 307 different headers. */
140 #ifdef SYSROOT_HEADERS_SUFFIX_SPEC 308 #ifdef SYSROOT_HEADERS_SUFFIX_SPEC
141@@ -85,33 +109,24 @@ const struct default_include cpp_include_defaults[] 309@@ -93,33 +117,24 @@ const struct default_include cpp_include_defaults[]
142 #endif 310 #endif
143 #ifdef CROSS_INCLUDE_DIR 311 #ifdef CROSS_INCLUDE_DIR
144 /* One place the target system's headers might be. */ 312 /* One place the target system's headers might be. */
@@ -179,7 +347,7 @@ index 2f43b88a0c3..6b6be04686c 100644
179 /* This value is set by cpp_relocated at runtime */ 347 /* This value is set by cpp_relocated at runtime */
180 const char *gcc_exec_prefix; 348 const char *gcc_exec_prefix;
181diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h 349diff --git a/gcc/cppdefault.h b/gcc/cppdefault.h
182index a681264f75e..5e10a2fa140 100644 350index e26b424e99c..c9abb090dcd 100644
183--- a/gcc/cppdefault.h 351--- a/gcc/cppdefault.h
184+++ b/gcc/cppdefault.h 352+++ b/gcc/cppdefault.h
185@@ -33,7 +33,8 @@ 353@@ -33,7 +33,8 @@
@@ -190,9 +358,9 @@ index a681264f75e..5e10a2fa140 100644
190+ const char *fname; /* The name of the directory. */ 358+ const char *fname; /* The name of the directory. */
191+ 359+
192 const char *const component; /* The component containing the directory 360 const char *const component; /* The component containing the directory
193 (see update_path in prefix.c) */ 361 (see update_path in prefix.cc) */
194 const char cplusplus; /* Only look here if we're compiling C++. */ 362 const char cplusplus; /* When this is non-zero, we should only
195@@ -50,17 +51,13 @@ struct default_include 363@@ -55,17 +56,13 @@ struct default_include
196 }; 364 };
197 365
198 extern const struct default_include cpp_include_defaults[]; 366 extern const struct default_include cpp_include_defaults[];
@@ -213,11 +381,11 @@ index a681264f75e..5e10a2fa140 100644
213 /* The run-time execution prefix. This is typically the lib/gcc 381 /* The run-time execution prefix. This is typically the lib/gcc
214 subdirectory of the actual installation. */ 382 subdirectory of the actual installation. */
215 extern const char *gcc_exec_prefix; 383 extern const char *gcc_exec_prefix;
216diff --git a/gcc/gcc.c b/gcc/gcc.c 384diff --git a/gcc/gcc.cc b/gcc/gcc.cc
217index c87f603955f..535d5c3bb65 100644 385index 8af0c814c33..605fe3b8c0d 100644
218--- a/gcc/gcc.c 386--- a/gcc/gcc.cc
219+++ b/gcc/gcc.c 387+++ b/gcc/gcc.cc
220@@ -252,6 +252,8 @@ FILE *report_times_to_file = NULL; 388@@ -255,6 +255,8 @@ FILE *report_times_to_file = NULL;
221 #endif 389 #endif
222 static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT; 390 static const char *target_system_root = DEFAULT_TARGET_SYSTEM_ROOT;
223 391
@@ -226,7 +394,7 @@ index c87f603955f..535d5c3bb65 100644
226 /* Nonzero means pass the updated target_system_root to the compiler. */ 394 /* Nonzero means pass the updated target_system_root to the compiler. */
227 395
228 static int target_system_root_changed; 396 static int target_system_root_changed;
229@@ -526,6 +528,7 @@ or with constant text in a single argument. 397@@ -578,6 +580,7 @@ or with constant text in a single argument.
230 %G process LIBGCC_SPEC as a spec. 398 %G process LIBGCC_SPEC as a spec.
231 %R Output the concatenation of target_system_root and 399 %R Output the concatenation of target_system_root and
232 target_sysroot_suffix. 400 target_sysroot_suffix.
@@ -234,7 +402,7 @@ index c87f603955f..535d5c3bb65 100644
234 %S process STARTFILE_SPEC as a spec. A capital S is actually used here. 402 %S process STARTFILE_SPEC as a spec. A capital S is actually used here.
235 %E process ENDFILE_SPEC as a spec. A capital E is actually used here. 403 %E process ENDFILE_SPEC as a spec. A capital E is actually used here.
236 %C process CPP_SPEC as a spec. 404 %C process CPP_SPEC as a spec.
237@@ -1499,10 +1502,10 @@ static const char *gcc_libexec_prefix; 405@@ -1619,10 +1622,10 @@ static const char *gcc_libexec_prefix;
238 gcc_exec_prefix is set because, in that case, we know where the 406 gcc_exec_prefix is set because, in that case, we know where the
239 compiler has been installed, and use paths relative to that 407 compiler has been installed, and use paths relative to that
240 location instead. */ 408 location instead. */
@@ -249,7 +417,7 @@ index c87f603955f..535d5c3bb65 100644
249 417
250 /* For native compilers, these are well-known paths containing 418 /* For native compilers, these are well-known paths containing
251 components that may be provided by the system. For cross 419 components that may be provided by the system. For cross
252@@ -1510,9 +1513,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX; 420@@ -1630,9 +1633,9 @@ static const char *const standard_startfile_prefix = STANDARD_STARTFILE_PREFIX;
253 static const char *md_exec_prefix = MD_EXEC_PREFIX; 421 static const char *md_exec_prefix = MD_EXEC_PREFIX;
254 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX; 422 static const char *md_startfile_prefix = MD_STARTFILE_PREFIX;
255 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1; 423 static const char *md_startfile_prefix_1 = MD_STARTFILE_PREFIX_1;
@@ -261,7 +429,7 @@ index c87f603955f..535d5c3bb65 100644
261 = STANDARD_STARTFILE_PREFIX_2; 429 = STANDARD_STARTFILE_PREFIX_2;
262 430
263 /* A relative path to be used in finding the location of tools 431 /* A relative path to be used in finding the location of tools
264@@ -5952,6 +5955,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part) 432@@ -6652,6 +6655,11 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
265 } 433 }
266 break; 434 break;
267 435
@@ -273,11 +441,11 @@ index c87f603955f..535d5c3bb65 100644
273 case 'S': 441 case 'S':
274 value = do_spec_1 (startfile_spec, 0, NULL); 442 value = do_spec_1 (startfile_spec, 0, NULL);
275 if (value != 0) 443 if (value != 0)
276diff --git a/gcc/incpath.c b/gcc/incpath.c 444diff --git a/gcc/incpath.cc b/gcc/incpath.cc
277index 9098ab044ab..bfad4ebe382 100644 445index 46c0d543205..d088dae7b04 100644
278--- a/gcc/incpath.c 446--- a/gcc/incpath.cc
279+++ b/gcc/incpath.c 447+++ b/gcc/incpath.cc
280@@ -131,7 +131,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, 448@@ -135,7 +135,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
281 int relocated = cpp_relocated (); 449 int relocated = cpp_relocated ();
282 size_t len; 450 size_t len;
283 451
@@ -286,7 +454,7 @@ index 9098ab044ab..bfad4ebe382 100644
286 { 454 {
287 /* Look for directories that start with the standard prefix. 455 /* Look for directories that start with the standard prefix.
288 "Translate" them, i.e. replace /usr/local/lib/gcc... with 456 "Translate" them, i.e. replace /usr/local/lib/gcc... with
289@@ -145,7 +145,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, 457@@ -150,7 +150,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
290 now. */ 458 now. */
291 if (sysroot && p->add_sysroot) 459 if (sysroot && p->add_sysroot)
292 continue; 460 continue;
@@ -295,7 +463,7 @@ index 9098ab044ab..bfad4ebe382 100644
295 { 463 {
296 char *str = concat (iprefix, p->fname + len, NULL); 464 char *str = concat (iprefix, p->fname + len, NULL);
297 if (p->multilib == 1 && imultilib) 465 if (p->multilib == 1 && imultilib)
298@@ -185,7 +185,7 @@ add_standard_paths (const char *sysroot, const char *iprefix, 466@@ -191,7 +191,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
299 free (sysroot_no_trailing_dir_separator); 467 free (sysroot_no_trailing_dir_separator);
300 } 468 }
301 else if (!p->add_sysroot && relocated 469 else if (!p->add_sysroot && relocated
@@ -304,7 +472,7 @@ index 9098ab044ab..bfad4ebe382 100644
304 { 472 {
305 static const char *relocated_prefix; 473 static const char *relocated_prefix;
306 char *ostr; 474 char *ostr;
307@@ -202,12 +202,12 @@ add_standard_paths (const char *sysroot, const char *iprefix, 475@@ -208,12 +208,12 @@ add_standard_paths (const char *sysroot, const char *iprefix,
308 dummy = concat (gcc_exec_prefix, "dummy", NULL); 476 dummy = concat (gcc_exec_prefix, "dummy", NULL);
309 relocated_prefix 477 relocated_prefix
310 = make_relative_prefix (dummy, 478 = make_relative_prefix (dummy,
@@ -320,11 +488,11 @@ index 9098ab044ab..bfad4ebe382 100644
320 NULL); 488 NULL);
321 str = update_path (ostr, p->component); 489 str = update_path (ostr, p->component);
322 free (ostr); 490 free (ostr);
323diff --git a/gcc/prefix.c b/gcc/prefix.c 491diff --git a/gcc/prefix.cc b/gcc/prefix.cc
324index 1a403e535bd..c26d07bde12 100644 492index c2a37bde5ea..33944701ced 100644
325--- a/gcc/prefix.c 493--- a/gcc/prefix.cc
326+++ b/gcc/prefix.c 494+++ b/gcc/prefix.cc
327@@ -72,7 +72,9 @@ License along with GCC; see the file COPYING3. If not see 495@@ -73,7 +73,9 @@ License along with GCC; see the file COPYING3. If not see
328 #include "prefix.h" 496 #include "prefix.h"
329 #include "common/common-target.h" 497 #include "common/common-target.h"
330 498
@@ -335,7 +503,7 @@ index 1a403e535bd..c26d07bde12 100644
335 503
336 static const char *get_key_value (char *); 504 static const char *get_key_value (char *);
337 static char *translate_name (char *); 505 static char *translate_name (char *);
338@@ -212,7 +214,7 @@ translate_name (char *name) 506@@ -213,7 +215,7 @@ translate_name (char *name)
339 prefix = getenv (key); 507 prefix = getenv (key);
340 508
341 if (prefix == 0) 509 if (prefix == 0)
@@ -344,6 +512,3 @@ index 1a403e535bd..c26d07bde12 100644
344 512
345 /* We used to strip trailing DIR_SEPARATORs here, but that can 513 /* We used to strip trailing DIR_SEPARATORs here, but that can
346 sometimes yield a result with no separator when one was coded 514 sometimes yield a result with no separator when one was coded
347--
3482.29.2
349
diff --git a/meta/recipes-devtools/gcc/gcc/0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch b/meta/recipes-devtools/gcc/gcc/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch
index abf1f8491f..8a11049ca3 100644
--- a/meta/recipes-devtools/gcc/gcc/0025-Search-target-sysroot-gcc-version-specific-dirs-with.patch
+++ b/meta/recipes-devtools/gcc/gcc/0017-Search-target-sysroot-gcc-version-specific-dirs-with.patch
@@ -1,4 +1,4 @@
1From 9c0c73ee48dbee2aad57f4dcdad1b7b74e77b944 Mon Sep 17 00:00:00 2001 1From 7e095089452b6e895ec40981752e9f902f0ad889 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 7 Dec 2015 23:41:45 +0000 3Date: Mon, 7 Dec 2015 23:41:45 +0000
4Subject: [PATCH] Search target sysroot gcc version specific dirs with 4Subject: [PATCH] Search target sysroot gcc version specific dirs with
@@ -42,19 +42,20 @@ binaries can be found first. With this change the search path becomes:
42<sysroot>/lib32/ 42<sysroot>/lib32/
43<sysroot>/usr/lib32/ 43<sysroot>/usr/lib32/
44 44
45Upstream-Status: Pending
46RP 2015/7/31 45RP 2015/7/31
47 46
47Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615320.html]
48
48Signed-off-by: Khem Raj <raj.khem@gmail.com> 49Signed-off-by: Khem Raj <raj.khem@gmail.com>
49--- 50---
50 gcc/gcc.c | 29 ++++++++++++++++++++++++++++- 51 gcc/gcc.cc | 29 ++++++++++++++++++++++++++++-
51 1 file changed, 28 insertions(+), 1 deletion(-) 52 1 file changed, 28 insertions(+), 1 deletion(-)
52 53
53diff --git a/gcc/gcc.c b/gcc/gcc.c 54diff --git a/gcc/gcc.cc b/gcc/gcc.cc
54index 535d5c3bb65..04647ae812d 100644 55index 605fe3b8c0d..c3a1dab38c4 100644
55--- a/gcc/gcc.c 56--- a/gcc/gcc.cc
56+++ b/gcc/gcc.c 57+++ b/gcc/gcc.cc
57@@ -2616,7 +2616,7 @@ for_each_path (const struct path_prefix *paths, 58@@ -2809,7 +2809,7 @@ for_each_path (const struct path_prefix *paths,
58 if (path == NULL) 59 if (path == NULL)
59 { 60 {
60 len = paths->max_len + extra_space + 1; 61 len = paths->max_len + extra_space + 1;
@@ -63,7 +64,7 @@ index 535d5c3bb65..04647ae812d 100644
63 path = XNEWVEC (char, len); 64 path = XNEWVEC (char, len);
64 } 65 }
65 66
66@@ -2628,6 +2628,33 @@ for_each_path (const struct path_prefix *paths, 67@@ -2821,6 +2821,33 @@ for_each_path (const struct path_prefix *paths,
67 /* Look first in MACHINE/VERSION subdirectory. */ 68 /* Look first in MACHINE/VERSION subdirectory. */
68 if (!skip_multi_dir) 69 if (!skip_multi_dir)
69 { 70 {
diff --git a/meta/recipes-devtools/gcc/gcc/0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch b/meta/recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
index 2a6769a82e..9bc77b485f 100644
--- a/meta/recipes-devtools/gcc/gcc/0028-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
+++ b/meta/recipes-devtools/gcc/gcc/0018-Add-ssp_nonshared-to-link-commandline-for-musl-targe.patch
@@ -1,4 +1,4 @@
1From 5db0404eb770ac477fd99d444226bcf021067584 Mon Sep 17 00:00:00 2001 1From bf92b290556b7050df0a001cc7ae43cf79990456 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 27 Jun 2017 18:10:54 -0700 3Date: Tue, 27 Jun 2017 18:10:54 -0700
4Subject: [PATCH] Add ssp_nonshared to link commandline for musl targets 4Subject: [PATCH] Add ssp_nonshared to link commandline for musl targets
@@ -13,7 +13,7 @@ are already present in libc_nonshared library therefore
13we do not need any library helper on glibc based systems 13we do not need any library helper on glibc based systems
14but musl needs the libssp_noshared from gcc 14but musl needs the libssp_noshared from gcc
15 15
16Upstream-Status: Pending 16Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2023-April/615317.html]
17 17
18Signed-off-by: Khem Raj <raj.khem@gmail.com> 18Signed-off-by: Khem Raj <raj.khem@gmail.com>
19--- 19---
@@ -23,11 +23,11 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
23 3 files changed, 27 insertions(+) 23 3 files changed, 27 insertions(+)
24 24
25diff --git a/gcc/config/linux.h b/gcc/config/linux.h 25diff --git a/gcc/config/linux.h b/gcc/config/linux.h
26index 0c1a8118a26..bdc2a2d0659 100644 26index c921cf6ef63..32e1bc1ae2d 100644
27--- a/gcc/config/linux.h 27--- a/gcc/config/linux.h
28+++ b/gcc/config/linux.h 28+++ b/gcc/config/linux.h
29@@ -195,6 +195,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 29@@ -195,6 +195,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
30 { GCC_INCLUDE_DIR, "GCC", 0, 1, 0, 0 }, \ 30 { GCC_INCLUDE_DIRVAR, "GCC", 0, 1, 0, 0 }, \
31 { 0, 0, 0, 0, 0, 0 } \ 31 { 0, 0, 0, 0, 0, 0 } \
32 } 32 }
33+#ifdef TARGET_LIBC_PROVIDES_SSP 33+#ifdef TARGET_LIBC_PROVIDES_SSP
@@ -41,10 +41,10 @@ index 0c1a8118a26..bdc2a2d0659 100644
41 41
42 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */ 42 #if (DEFAULT_LIBC == LIBC_UCLIBC) && defined (SINGLE_LIBC) /* uClinux */
43diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h 43diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
44index b7026fcbee7..dd54d6c393e 100644 44index 5d21befe8e4..1248a68e4ca 100644
45--- a/gcc/config/rs6000/linux.h 45--- a/gcc/config/rs6000/linux.h
46+++ b/gcc/config/rs6000/linux.h 46+++ b/gcc/config/rs6000/linux.h
47@@ -94,6 +94,16 @@ 47@@ -99,6 +99,16 @@
48 " -m elf32ppclinux") 48 " -m elf32ppclinux")
49 #endif 49 #endif
50 50
@@ -62,10 +62,10 @@ index b7026fcbee7..dd54d6c393e 100644
62 #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \ 62 #define LINK_OS_LINUX_SPEC LINK_OS_LINUX_EMUL " %{!shared: %{!static: \
63 %{!static-pie: \ 63 %{!static-pie: \
64diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h 64diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
65index 967c1c43c63..dc5e4d97975 100644 65index 2ddab7c99c1..9641580fc83 100644
66--- a/gcc/config/rs6000/linux64.h 66--- a/gcc/config/rs6000/linux64.h
67+++ b/gcc/config/rs6000/linux64.h 67+++ b/gcc/config/rs6000/linux64.h
68@@ -452,6 +452,16 @@ extern int dot_symbols; 68@@ -372,6 +372,16 @@ extern int dot_symbols;
69 " -m elf64ppc") 69 " -m elf64ppc")
70 #endif 70 #endif
71 71
diff --git a/meta/recipes-devtools/gcc/gcc/0018-export-CPP.patch b/meta/recipes-devtools/gcc/gcc/0018-export-CPP.patch
deleted file mode 100644
index 886a1221d3..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0018-export-CPP.patch
+++ /dev/null
@@ -1,50 +0,0 @@
1From 5c3d66378c7ff60ca11a875aa4aa6f8a8529d43a Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 09:40:59 +0000
4Subject: [PATCH] export CPP
5
6The OE environment sets and exports CPP as being the target gcc. When
7building gcc-cross-canadian for a mingw targetted sdk, the following can be found
8in build.x86_64-pokysdk-mingw32.i586-poky-linux/build-x86_64-linux/libiberty/config.log:
9
10configure:3641: checking for _FILE_OFFSET_BITS value needed for large files
11configure:3666: gcc -c -isystem/media/build1/poky/build/tmp/sysroots/x86_64-linux/usr/include -O2 -pipe conftest.c >&5
12configure:3666: $? = 0
13configure:3698: result: no
14configure:3786: checking how to run the C preprocessor
15configure:3856: result: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32
16configure:3876: x86_64-pokysdk-mingw32-gcc -E --sysroot=/media/build1/poky/build/tmp/sysroots/x86_64-nativesdk-mingw32-pokysdk-mingw32 conftest.c
17configure:3876: $? = 0
18
19Note this is a *build* target (in build-x86_64-linux) so it should be
20using the host "gcc", not x86_64-pokysdk-mingw32-gcc. Since the mingw32
21headers are very different, using the wrong cpp is a real problem. It is leaking
22into configure through the CPP variable. Ultimately this leads to build
23failures related to not being able to include a process.h file for pem-unix.c.
24
25The fix is to ensure we export a sane CPP value into the build
26environment when using build targets. We could define a CPP_FOR_BUILD value which may be
27the version which needs to be upstreamed but for now, this fix is good enough to
28avoid the problem.
29
30RP 22/08/2013
31
32Upstream-Status: Pending
33
34Signed-off-by: Khem Raj <raj.khem@gmail.com>
35---
36 Makefile.in | 1 +
37 1 file changed, 1 insertion(+)
38
39diff --git a/Makefile.in b/Makefile.in
40index 36e369df6e7..c717903bb13 100644
41--- a/Makefile.in
42+++ b/Makefile.in
43@@ -149,6 +149,7 @@ BUILD_EXPORTS = \
44 AR="$(AR_FOR_BUILD)"; export AR; \
45 AS="$(AS_FOR_BUILD)"; export AS; \
46 CC="$(CC_FOR_BUILD)"; export CC; \
47+ CPP="$(CC_FOR_BUILD) -E"; export CPP; \
48 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
49 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
50 CXX="$(CXX_FOR_BUILD)"; export CXX; \
diff --git a/meta/recipes-devtools/gcc/gcc/0019-Ensure-target-gcc-headers-can-be-included.patch b/meta/recipes-devtools/gcc/gcc/0019-Ensure-target-gcc-headers-can-be-included.patch
deleted file mode 100644
index 2797b2c22d..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0019-Ensure-target-gcc-headers-can-be-included.patch
+++ /dev/null
@@ -1,57 +0,0 @@
1From 378b752c5d9a3dba4e58cdadf8b4b4f34ea99a76 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 20 Feb 2015 10:25:11 +0000
4Subject: [PATCH] Ensure target gcc headers can be included
5
6There are a few headers installed as part of the OpenEmbedded
7gcc-runtime target (omp.h, ssp/*.h). Being installed from a recipe
8built for the target architecture, these are within the target
9sysroot and not cross/nativesdk; thus they weren't able to be
10found by gcc with the existing search paths. Add support for
11picking up these headers under the sysroot supplied on the gcc
12command line in order to resolve this.
13
14Upstream-Status: Pending
15
16Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
17Signed-off-by: Khem Raj <raj.khem@gmail.com>
18---
19 gcc/Makefile.in | 2 ++
20 gcc/cppdefault.c | 4 ++++
21 2 files changed, 6 insertions(+)
22
23diff --git a/gcc/Makefile.in b/gcc/Makefile.in
24index 480c9366418..011c7ac2db6 100644
25--- a/gcc/Makefile.in
26+++ b/gcc/Makefile.in
27@@ -618,6 +618,7 @@ libexecdir = @libexecdir@
28
29 # Directory in which the compiler finds libraries etc.
30 libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
31+libsubdir_target = $(target_noncanonical)/$(version)
32 # Directory in which the compiler finds executables
33 libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
34 # Directory in which all plugin resources are installed
35@@ -2946,6 +2947,7 @@ CFLAGS-intl.o += -DLOCALEDIR=\"$(localedir)\"
36
37 PREPROCESSOR_DEFINES = \
38 -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \
39+ -DGCC_INCLUDE_SUBDIR_TARGET=\"$(libsubdir_target)/include\" \
40 -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
41 -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
42 -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
43diff --git a/gcc/cppdefault.c b/gcc/cppdefault.c
44index af38cc494ea..2f43b88a0c3 100644
45--- a/gcc/cppdefault.c
46+++ b/gcc/cppdefault.c
47@@ -59,6 +59,10 @@ const struct default_include cpp_include_defaults[]
48 /* This is the dir for gcc's private headers. */
49 { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 },
50 #endif
51+#ifdef GCC_INCLUDE_SUBDIR_TARGET
52+ /* This is the dir for gcc's private headers under the specified sysroot. */
53+ { STANDARD_STARTFILE_PREFIX_2 GCC_INCLUDE_SUBDIR_TARGET, "GCC", 0, 0, 1, 0 },
54+#endif
55 #ifdef LOCAL_INCLUDE_DIR
56 /* /usr/local/include comes before the fixincluded header files. */
57 { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
diff --git a/meta/recipes-devtools/gcc/gcc/0033-Re-introduce-spe-commandline-options.patch b/meta/recipes-devtools/gcc/gcc/0019-Re-introduce-spe-commandline-options.patch
index ba7c2b8fd5..f785688661 100644
--- a/meta/recipes-devtools/gcc/gcc/0033-Re-introduce-spe-commandline-options.patch
+++ b/meta/recipes-devtools/gcc/gcc/0019-Re-introduce-spe-commandline-options.patch
@@ -1,4 +1,4 @@
1From 3fc06241ce37e2e4b3ed21ace28d347eb511448d Mon Sep 17 00:00:00 2001 1From 587ac4a59ea56da18a9989c31a75124e974cb37c Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 6 Jun 2018 12:10:22 -0700 3Date: Wed, 6 Jun 2018 12:10:22 -0700
4Subject: [PATCH] Re-introduce spe commandline options 4Subject: [PATCH] Re-introduce spe commandline options
@@ -10,17 +10,18 @@ Upstream-Status: Inappropriate [SPE port is removed from rs600 port]
10 10
11Signed-off-by: Khem Raj <raj.khem@gmail.com> 11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12--- 12---
13 gcc/config/rs6000/rs6000.opt | 12 ++++++++++++ 13 gcc/config/rs6000/rs6000.opt | 13 +++++++++++++
14 1 file changed, 12 insertions(+) 14 1 file changed, 13 insertions(+)
15 15
16diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt 16diff --git a/gcc/config/rs6000/rs6000.opt b/gcc/config/rs6000/rs6000.opt
17index f95b8279270..0e52d51409d 100644 17index bde6d3ff664..5af9640825c 100644
18--- a/gcc/config/rs6000/rs6000.opt 18--- a/gcc/config/rs6000/rs6000.opt
19+++ b/gcc/config/rs6000/rs6000.opt 19+++ b/gcc/config/rs6000/rs6000.opt
20@@ -344,6 +344,18 @@ mdebug= 20@@ -344,6 +344,19 @@ mdebug=
21 Target RejectNegative Joined 21 Target RejectNegative Joined
22 -mdebug= Enable debug output. 22 -mdebug= Enable debug output.
23 23
24+; PPC SPE ABI
24+mspe 25+mspe
25+Target Var(rs6000_spe) Save 26+Target Var(rs6000_spe) Save
26+Generate SPE SIMD instructions on E500. 27+Generate SPE SIMD instructions on E500.
@@ -33,6 +34,6 @@ index f95b8279270..0e52d51409d 100644
33+Target RejectNegative Var(rs6000_spe_abi, 0) 34+Target RejectNegative Var(rs6000_spe_abi, 0)
34+Do not use the SPE ABI extensions. 35+Do not use the SPE ABI extensions.
35+ 36+
37 ; Altivec ABI
36 mabi=altivec 38 mabi=altivec
37 Target RejectNegative Var(rs6000_altivec_abi) Save 39 Target RejectNegative Var(rs6000_altivec_abi) Save
38 Use the AltiVec ABI extensions.
diff --git a/meta/recipes-devtools/gcc/gcc/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch b/meta/recipes-devtools/gcc/gcc/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
index 4ce9dc6def..b86edab5d5 100644
--- a/meta/recipes-devtools/gcc/gcc/0034-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
+++ b/meta/recipes-devtools/gcc/gcc/0020-libgcc_s-Use-alias-for-__cpu_indicator_init-instead-.patch
@@ -1,4 +1,4 @@
1From b42ff59c3fe2967d37815c8db72a47b9b7f585b4 Mon Sep 17 00:00:00 2001 1From 8c4c59521720f8c1b1e38e38896b47fcb1bf00ac Mon Sep 17 00:00:00 2001
2From: Szabolcs Nagy <nsz@port70.net> 2From: Szabolcs Nagy <nsz@port70.net>
3Date: Sat, 24 Oct 2015 20:09:53 +0000 3Date: Sat, 24 Oct 2015 20:09:53 +0000
4Subject: [PATCH] libgcc_s: Use alias for __cpu_indicator_init instead of 4Subject: [PATCH] libgcc_s: Use alias for __cpu_indicator_init instead of
@@ -29,38 +29,38 @@ gcc/Changelog:
29 * config/i386/i386-expand.c (ix86_expand_builtin): Make __builtin_cpu_init 29 * config/i386/i386-expand.c (ix86_expand_builtin): Make __builtin_cpu_init
30 call __cpu_indicator_init_local instead of __cpu_indicator_init. 30 call __cpu_indicator_init_local instead of __cpu_indicator_init.
31 31
32Upstream-Status: Pending 32Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2023-February/612559.html]
33 33
34Signed-off-by: Khem Raj <raj.khem@gmail.com> 34Signed-off-by: Khem Raj <raj.khem@gmail.com>
35--- 35---
36 gcc/config/i386/i386-expand.c | 4 ++-- 36 gcc/config/i386/i386-expand.cc | 4 ++--
37 libgcc/config/i386/cpuinfo.c | 6 +++--- 37 libgcc/config/i386/cpuinfo.c | 6 +++---
38 libgcc/config/i386/t-linux | 2 +- 38 libgcc/config/i386/t-linux | 2 +-
39 3 files changed, 6 insertions(+), 6 deletions(-) 39 3 files changed, 6 insertions(+), 6 deletions(-)
40 40
41diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c 41diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
42index 48f00c5fcfc..468f5f71fac 100644 42index 0d817fc3f3b..8d34d19d3f9 100644
43--- a/gcc/config/i386/i386-expand.c 43--- a/gcc/config/i386/i386-expand.cc
44+++ b/gcc/config/i386/i386-expand.c 44+++ b/gcc/config/i386/i386-expand.cc
45@@ -10941,10 +10941,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget, 45@@ -12691,10 +12691,10 @@ ix86_expand_builtin (tree exp, rtx target, rtx subtarget,
46 { 46 {
47 case IX86_BUILTIN_CPU_INIT: 47 case IX86_BUILTIN_CPU_INIT:
48 { 48 {
49- /* Make it call __cpu_indicator_init in libgcc. */ 49- /* Make it call __cpu_indicator_init in libgcc. */
50+ /* Make it call __cpu_indicator_init_local in libgcc.a. */ 50+ /* Make it call __cpu_indicator_init_local in libgcc.a. */
51 tree call_expr, fndecl, type; 51 tree call_expr, fndecl, type;
52 type = build_function_type_list (integer_type_node, NULL_TREE); 52 type = build_function_type_list (integer_type_node, NULL_TREE);
53- fndecl = build_fn_decl ("__cpu_indicator_init", type); 53- fndecl = build_fn_decl ("__cpu_indicator_init", type);
54+ fndecl = build_fn_decl ("__cpu_indicator_init_local", type); 54+ fndecl = build_fn_decl ("__cpu_indicator_init_local", type);
55 call_expr = build_call_expr (fndecl, 0); 55 call_expr = build_call_expr (fndecl, 0);
56 return expand_expr (call_expr, target, mode, EXPAND_NORMAL); 56 return expand_expr (call_expr, target, mode, EXPAND_NORMAL);
57 } 57 }
58diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c 58diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
59index 00322c58622..f42bbb8af98 100644 59index 50b6d8248a2..724ced402a1 100644
60--- a/libgcc/config/i386/cpuinfo.c 60--- a/libgcc/config/i386/cpuinfo.c
61+++ b/libgcc/config/i386/cpuinfo.c 61+++ b/libgcc/config/i386/cpuinfo.c
62@@ -508,7 +508,7 @@ __cpu_indicator_init (void) 62@@ -63,7 +63,7 @@ __cpu_indicator_init (void)
63 return 0; 63 __cpu_features2);
64 } 64 }
65 65
66-#if defined SHARED && defined USE_ELF_SYMVER 66-#if defined SHARED && defined USE_ELF_SYMVER
diff --git a/meta/recipes-devtools/gcc/gcc/0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch b/meta/recipes-devtools/gcc/gcc/0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch
deleted file mode 100644
index abee48669d..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0021-Use-SYSTEMLIBS_DIR-replacement-instead-of-hardcoding.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From aba42de763a619355471efd1573561b0cbf51162 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 28 Apr 2015 23:15:27 -0700
4Subject: [PATCH] Use SYSTEMLIBS_DIR replacement instead of hardcoding
5 base_libdir
6
7Upstream-Status: Pending
8
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 gcc/config/aarch64/aarch64-linux.h | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
15index e587e2e9ad6..ddc62895693 100644
16--- a/gcc/config/aarch64/aarch64-linux.h
17+++ b/gcc/config/aarch64/aarch64-linux.h
18@@ -21,7 +21,7 @@
19 #ifndef GCC_AARCH64_LINUX_H
20 #define GCC_AARCH64_LINUX_H
21
22-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
23+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
24
25 #undef MUSL_DYNAMIC_LINKER
26 #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
diff --git a/meta/recipes-devtools/gcc/gcc/0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch b/meta/recipes-devtools/gcc/gcc/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
index dd1bf6dedc..b6707592dc 100644
--- a/meta/recipes-devtools/gcc/gcc/0035-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
+++ b/meta/recipes-devtools/gcc/gcc/0021-gentypes-genmodes-Do-not-use-__LINE__-for-maintainin.patch
@@ -1,4 +1,4 @@
1From 0395060a7dcf98c5f5a65103f6aaa71d6b862259 Mon Sep 17 00:00:00 2001 1From f15b19d8e058c983c49c4566c1879fdaf5b1ab54 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org> 2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Tue, 10 Mar 2020 08:26:53 -0700 3Date: Tue, 10 Mar 2020 08:26:53 -0700
4Subject: [PATCH] gentypes/genmodes: Do not use __LINE__ for maintaining 4Subject: [PATCH] gentypes/genmodes: Do not use __LINE__ for maintaining
@@ -12,15 +12,15 @@ Upstream-Status: Inappropriate [OE Reproducibility specific]
12Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> 12Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
13Signed-off-by: Khem Raj <raj.khem@gmail.com> 13Signed-off-by: Khem Raj <raj.khem@gmail.com>
14--- 14---
15 gcc/gengtype.c | 6 +++--- 15 gcc/gengtype.cc | 6 +++---
16 gcc/genmodes.c | 32 ++++++++++++++++---------------- 16 gcc/genmodes.cc | 32 ++++++++++++++++----------------
17 2 files changed, 19 insertions(+), 19 deletions(-) 17 2 files changed, 19 insertions(+), 19 deletions(-)
18 18
19diff --git a/gcc/gengtype.c b/gcc/gengtype.c 19diff --git a/gcc/gengtype.cc b/gcc/gengtype.cc
20index 981577481af..d5700fff401 100644 20index 7763f40e9ab..4f0c1eb1508 100644
21--- a/gcc/gengtype.c 21--- a/gcc/gengtype.cc
22+++ b/gcc/gengtype.c 22+++ b/gcc/gengtype.cc
23@@ -991,7 +991,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt, 23@@ -1005,7 +1005,7 @@ create_field_at (pair_p next, type_p type, const char *name, options_p opt,
24 /* Create a fake field with the given type and name. NEXT is the next 24 /* Create a fake field with the given type and name. NEXT is the next
25 field in the chain. */ 25 field in the chain. */
26 #define create_field(next,type,name) \ 26 #define create_field(next,type,name) \
@@ -29,7 +29,7 @@ index 981577481af..d5700fff401 100644
29 29
30 /* Like create_field, but the field is only valid when condition COND 30 /* Like create_field, but the field is only valid when condition COND
31 is true. */ 31 is true. */
32@@ -1024,7 +1024,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name, 32@@ -1038,7 +1038,7 @@ create_optional_field_ (pair_p next, type_p type, const char *name,
33 } 33 }
34 34
35 #define create_optional_field(next,type,name,cond) \ 35 #define create_optional_field(next,type,name,cond) \
@@ -38,7 +38,7 @@ index 981577481af..d5700fff401 100644
38 38
39 /* Reverse a linked list of 'struct pair's in place. */ 39 /* Reverse a linked list of 'struct pair's in place. */
40 pair_p 40 pair_p
41@@ -5187,7 +5187,7 @@ main (int argc, char **argv) 41@@ -5223,7 +5223,7 @@ main (int argc, char **argv)
42 /* These types are set up with #define or else outside of where 42 /* These types are set up with #define or else outside of where
43 we can see them. We should initialize them before calling 43 we can see them. We should initialize them before calling
44 read_input_list. */ 44 read_input_list. */
@@ -47,11 +47,11 @@ index 981577481af..d5700fff401 100644
47 Call;} while (0) 47 Call;} while (0)
48 POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos)); 48 POS_HERE (do_scalar_typedef ("CUMULATIVE_ARGS", &pos));
49 POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); 49 POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos));
50diff --git a/gcc/genmodes.c b/gcc/genmodes.c 50diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc
51index bd78310ea24..dbd02c51a4c 100644 51index 715787b8f48..302adff28d5 100644
52--- a/gcc/genmodes.c 52--- a/gcc/genmodes.cc
53+++ b/gcc/genmodes.c 53+++ b/gcc/genmodes.cc
54@@ -430,7 +430,7 @@ complete_all_modes (void) 54@@ -441,7 +441,7 @@ complete_all_modes (void)
55 } 55 }
56 56
57 /* For each mode in class CLASS, construct a corresponding complex mode. */ 57 /* For each mode in class CLASS, construct a corresponding complex mode. */
@@ -60,7 +60,7 @@ index bd78310ea24..dbd02c51a4c 100644
60 static void 60 static void
61 make_complex_modes (enum mode_class cl, 61 make_complex_modes (enum mode_class cl,
62 const char *file, unsigned int line) 62 const char *file, unsigned int line)
63@@ -489,7 +489,7 @@ make_complex_modes (enum mode_class cl, 63@@ -500,7 +500,7 @@ make_complex_modes (enum mode_class cl,
64 having as many components as necessary. ORDER is the sorting order 64 having as many components as necessary. ORDER is the sorting order
65 of the mode, with smaller numbers indicating a higher priority. */ 65 of the mode, with smaller numbers indicating a higher priority. */
66 #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W, ORDER) \ 66 #define VECTOR_MODES_WITH_PREFIX(PREFIX, C, W, ORDER) \
@@ -69,16 +69,16 @@ index bd78310ea24..dbd02c51a4c 100644
69 #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W, 0) 69 #define VECTOR_MODES(C, W) VECTOR_MODES_WITH_PREFIX (V, C, W, 0)
70 static void ATTRIBUTE_UNUSED 70 static void ATTRIBUTE_UNUSED
71 make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, 71 make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
72@@ -541,7 +541,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width, 72@@ -553,7 +553,7 @@ make_vector_modes (enum mode_class cl, const char *prefix, unsigned int width,
73 /* Create a vector of booleans called NAME with COUNT elements and
74 BYTESIZE bytes in total. */ 73 BYTESIZE bytes in total. */
75 #define VECTOR_BOOL_MODE(NAME, COUNT, BYTESIZE) \ 74 #define VECTOR_BOOL_MODE(NAME, COUNT, COMPONENT, BYTESIZE) \
76- make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, __LINE__) 75 make_vector_bool_mode (#NAME, COUNT, #COMPONENT, BYTESIZE, \
77+ make_vector_bool_mode (#NAME, COUNT, BYTESIZE, __FILE__, 0) 76- __FILE__, __LINE__)
77+ __FILE__, 0)
78 static void ATTRIBUTE_UNUSED 78 static void ATTRIBUTE_UNUSED
79 make_vector_bool_mode (const char *name, unsigned int count, 79 make_vector_bool_mode (const char *name, unsigned int count,
80 unsigned int bytesize, const char *file, 80 const char *component, unsigned int bytesize,
81@@ -563,7 +563,7 @@ make_vector_bool_mode (const char *name, unsigned int count, 81@@ -575,7 +575,7 @@ make_vector_bool_mode (const char *name, unsigned int count,
82 /* Input. */ 82 /* Input. */
83 83
84 #define _SPECIAL_MODE(C, N) \ 84 #define _SPECIAL_MODE(C, N) \
@@ -87,7 +87,7 @@ index bd78310ea24..dbd02c51a4c 100644
87 #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N) 87 #define RANDOM_MODE(N) _SPECIAL_MODE (RANDOM, N)
88 #define CC_MODE(N) _SPECIAL_MODE (CC, N) 88 #define CC_MODE(N) _SPECIAL_MODE (CC, N)
89 89
90@@ -576,7 +576,7 @@ make_special_mode (enum mode_class cl, const char *name, 90@@ -588,7 +588,7 @@ make_special_mode (enum mode_class cl, const char *name,
91 91
92 #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y) 92 #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
93 #define FRACTIONAL_INT_MODE(N, B, Y) \ 93 #define FRACTIONAL_INT_MODE(N, B, Y) \
@@ -96,7 +96,7 @@ index bd78310ea24..dbd02c51a4c 100644
96 96
97 static void 97 static void
98 make_int_mode (const char *name, 98 make_int_mode (const char *name,
99@@ -589,16 +589,16 @@ make_int_mode (const char *name, 99@@ -629,16 +629,16 @@ make_opaque_mode (const char *name,
100 } 100 }
101 101
102 #define FRACT_MODE(N, Y, F) \ 102 #define FRACT_MODE(N, Y, F) \
@@ -117,7 +117,7 @@ index bd78310ea24..dbd02c51a4c 100644
117 117
118 /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT, 118 /* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT,
119 FILE, and LINE. */ 119 FILE, and LINE. */
120@@ -619,7 +619,7 @@ make_fixed_point_mode (enum mode_class cl, 120@@ -659,7 +659,7 @@ make_fixed_point_mode (enum mode_class cl,
121 121
122 #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F) 122 #define FLOAT_MODE(N, Y, F) FRACTIONAL_FLOAT_MODE (N, -1U, Y, F)
123 #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \ 123 #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
@@ -126,7 +126,7 @@ index bd78310ea24..dbd02c51a4c 100644
126 126
127 static void 127 static void
128 make_float_mode (const char *name, 128 make_float_mode (const char *name,
129@@ -636,7 +636,7 @@ make_float_mode (const char *name, 129@@ -676,7 +676,7 @@ make_float_mode (const char *name,
130 #define DECIMAL_FLOAT_MODE(N, Y, F) \ 130 #define DECIMAL_FLOAT_MODE(N, Y, F) \
131 FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F) 131 FRACTIONAL_DECIMAL_FLOAT_MODE (N, -1U, Y, F)
132 #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \ 132 #define FRACTIONAL_DECIMAL_FLOAT_MODE(N, B, Y, F) \
@@ -135,7 +135,7 @@ index bd78310ea24..dbd02c51a4c 100644
135 135
136 static void 136 static void
137 make_decimal_float_mode (const char *name, 137 make_decimal_float_mode (const char *name,
138@@ -651,7 +651,7 @@ make_decimal_float_mode (const char *name, 138@@ -691,7 +691,7 @@ make_decimal_float_mode (const char *name,
139 } 139 }
140 140
141 #define RESET_FLOAT_FORMAT(N, F) \ 141 #define RESET_FLOAT_FORMAT(N, F) \
@@ -144,7 +144,7 @@ index bd78310ea24..dbd02c51a4c 100644
144 static void ATTRIBUTE_UNUSED 144 static void ATTRIBUTE_UNUSED
145 reset_float_format (const char *name, const char *format, 145 reset_float_format (const char *name, const char *format,
146 const char *file, unsigned int line) 146 const char *file, unsigned int line)
147@@ -672,7 +672,7 @@ reset_float_format (const char *name, const char *format, 147@@ -712,7 +712,7 @@ reset_float_format (const char *name, const char *format,
148 148
149 /* __intN support. */ 149 /* __intN support. */
150 #define INT_N(M,PREC) \ 150 #define INT_N(M,PREC) \
@@ -153,7 +153,7 @@ index bd78310ea24..dbd02c51a4c 100644
153 static void ATTRIBUTE_UNUSED 153 static void ATTRIBUTE_UNUSED
154 make_int_n (const char *m, int bitsize, 154 make_int_n (const char *m, int bitsize,
155 const char *file, unsigned int line) 155 const char *file, unsigned int line)
156@@ -701,7 +701,7 @@ make_int_n (const char *m, int bitsize, 156@@ -741,7 +741,7 @@ make_int_n (const char *m, int bitsize,
157 /* Partial integer modes are specified by relation to a full integer 157 /* Partial integer modes are specified by relation to a full integer
158 mode. */ 158 mode. */
159 #define PARTIAL_INT_MODE(M,PREC,NAME) \ 159 #define PARTIAL_INT_MODE(M,PREC,NAME) \
@@ -162,16 +162,16 @@ index bd78310ea24..dbd02c51a4c 100644
162 static void ATTRIBUTE_UNUSED 162 static void ATTRIBUTE_UNUSED
163 make_partial_integer_mode (const char *base, const char *name, 163 make_partial_integer_mode (const char *base, const char *name,
164 unsigned int precision, 164 unsigned int precision,
165@@ -728,7 +728,7 @@ make_partial_integer_mode (const char *base, const char *name, 165@@ -768,7 +768,7 @@ make_partial_integer_mode (const char *base, const char *name,
166 /* A single vector mode can be specified by naming its component 166 /* A single vector mode can be specified by naming its component
167 mode and the number of components. */ 167 mode and the number of components. */
168 #define VECTOR_MODE(C, M, N) \ 168 #define VECTOR_MODE_WITH_PREFIX(PREFIX, C, M, N, ORDER) \
169- make_vector_mode (MODE_##C, #M, N, __FILE__, __LINE__); 169- make_vector_mode (MODE_##C, #PREFIX, #M, N, ORDER, __FILE__, __LINE__);
170+ make_vector_mode (MODE_##C, #M, N, __FILE__, 0); 170+ make_vector_mode (MODE_##C, #PREFIX, #M, N, ORDER, __FILE__, 0);
171 #define VECTOR_MODE(C, M, N) VECTOR_MODE_WITH_PREFIX(V, C, M, N, 0);
171 static void ATTRIBUTE_UNUSED 172 static void ATTRIBUTE_UNUSED
172 make_vector_mode (enum mode_class bclass, 173 make_vector_mode (enum mode_class bclass,
173 const char *base, 174@@ -815,7 +815,7 @@ make_vector_mode (enum mode_class bclass,
174@@ -771,7 +771,7 @@ make_vector_mode (enum mode_class bclass,
175 175
176 /* Adjustability. */ 176 /* Adjustability. */
177 #define _ADD_ADJUST(A, M, X, C1, C2) \ 177 #define _ADD_ADJUST(A, M, X, C1, C2) \
diff --git a/meta/recipes-devtools/gcc/gcc/0022-aarch64-Add-support-for-musl-ldso.patch b/meta/recipes-devtools/gcc/gcc/0022-aarch64-Add-support-for-musl-ldso.patch
deleted file mode 100644
index c55b66d4ba..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0022-aarch64-Add-support-for-musl-ldso.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1From d63820a78d92f302410358293546f01c7ad17bd8 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 28 Apr 2015 23:18:39 -0700
4Subject: [PATCH] aarch64: Add support for musl ldso
5
6Upstream-Status: Pending
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10 gcc/config/aarch64/aarch64-linux.h | 2 +-
11 1 file changed, 1 insertion(+), 1 deletion(-)
12
13diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
14index ddc62895693..b301825313a 100644
15--- a/gcc/config/aarch64/aarch64-linux.h
16+++ b/gcc/config/aarch64/aarch64-linux.h
17@@ -24,7 +24,7 @@
18 #define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
19
20 #undef MUSL_DYNAMIC_LINKER
21-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
22+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
23
24 #undef ASAN_CC1_SPEC
25 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
diff --git a/meta/recipes-devtools/gcc/gcc/0037-libatomic-Do-not-enforce-march-on-aarch64.patch b/meta/recipes-devtools/gcc/gcc/0022-libatomic-Do-not-enforce-march-on-aarch64.patch
index 3946acea11..0ea8aac543 100644
--- a/meta/recipes-devtools/gcc/gcc/0037-libatomic-Do-not-enforce-march-on-aarch64.patch
+++ b/meta/recipes-devtools/gcc/gcc/0022-libatomic-Do-not-enforce-march-on-aarch64.patch
@@ -1,4 +1,4 @@
1From 38d262bfe7c0c894c364dc6e4dc7971e78a73974 Mon Sep 17 00:00:00 2001 1From 939a899b862f7a25e52b74d1587fc75fc65779c0 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com> 2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 13 May 2020 15:10:38 -0700 3Date: Wed, 13 May 2020 15:10:38 -0700
4Subject: [PATCH] libatomic: Do not enforce march on aarch64 4Subject: [PATCH] libatomic: Do not enforce march on aarch64
@@ -17,7 +17,7 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
17 2 files changed, 2 deletions(-) 17 2 files changed, 2 deletions(-)
18 18
19diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am 19diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
20index 133fbbca77e..ac1ca645876 100644 20index c6c8d81c56a..d959a5d040e 100644
21--- a/libatomic/Makefile.am 21--- a/libatomic/Makefile.am
22+++ b/libatomic/Makefile.am 22+++ b/libatomic/Makefile.am
23@@ -125,7 +125,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS))) 23@@ -125,7 +125,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS)))
@@ -26,17 +26,17 @@ index 133fbbca77e..ac1ca645876 100644
26 if ARCH_AARCH64_LINUX 26 if ARCH_AARCH64_LINUX
27-IFUNC_OPTIONS = -march=armv8-a+lse 27-IFUNC_OPTIONS = -march=armv8-a+lse
28 libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS))) 28 libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
29 endif 29 libatomic_la_SOURCES += atomic_16.S
30 if ARCH_ARM_LINUX 30
31diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in 31diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
32index a51807e95c9..97df2d7ff03 100644 32index a0fa3dfc8cc..e70d389874a 100644
33--- a/libatomic/Makefile.in 33--- a/libatomic/Makefile.in
34+++ b/libatomic/Makefile.in 34+++ b/libatomic/Makefile.in
35@@ -431,7 +431,6 @@ M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files))) 35@@ -447,7 +447,6 @@ M_SRC = $(firstword $(filter %/$(M_FILE), $(all_c_files)))
36 libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \ 36 libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix \
37 _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_2) \ 37 _$(s)_.lo,$(SIZEOBJS))) $(am__append_1) $(am__append_3) \
38 $(am__append_3) $(am__append_4) 38 $(am__append_4) $(am__append_5)
39-@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv8-a+lse 39-@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv8-a+lse
40 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64 40 @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
41 @ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586 41 @ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -march=i586
42 @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16 42 @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@IFUNC_OPTIONS = -mcx16 -mcx16
diff --git a/meta/recipes-devtools/gcc/gcc/0023-Fix-install-path-of-linux64.h.patch b/meta/recipes-devtools/gcc/gcc/0023-Fix-install-path-of-linux64.h.patch
new file mode 100644
index 0000000000..cd962d82bd
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0023-Fix-install-path-of-linux64.h.patch
@@ -0,0 +1,31 @@
1From 696d696381dd99ec2bddb1170f96f98da36eb418 Mon Sep 17 00:00:00 2001
2From: Andrei Gherzan <andrei.gherzan@huawei.com>
3Date: Wed, 22 Dec 2021 12:49:25 +0100
4Subject: [PATCH] Fix install path of linux64.h
5
6We add linux64.h to tm includes[1] as a relative path to B. This patch
7adapts the install path of linux64.h to match the include in tm.h.
8
9[1] 0016-Use-the-multilib-config-files-from-B-instead-of-usin.patch
10
11Signed-off-by: Andrei Gherzan <andrei.gherzan@huawei.com>
12
13Upstream-Status: Inappropriate [configuration]
14Signed-off-by: Khem Raj <raj.khem@gmail.com>
15---
16 gcc/Makefile.in | 2 ++
17 1 file changed, 2 insertions(+)
18
19diff --git a/gcc/Makefile.in b/gcc/Makefile.in
20index 8ef996c0f4d..21daf380e34 100644
21--- a/gcc/Makefile.in
22+++ b/gcc/Makefile.in
23@@ -3731,6 +3731,8 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
24 "$(srcdir)"/config/* | "$(srcdir)"/common/config/* \
25 | "$(srcdir)"/c-family/* | "$(srcdir)"/*.def ) \
26 base=`echo "$$path" | sed -e "s|$$srcdirstrip/||"`;; \
27+ */linux64.h ) \
28+ base=`dirname $$path`;;\
29 *) base=`basename $$path` ;; \
30 esac; \
31 dest=$(plugin_includedir)/$$base; \
diff --git a/meta/recipes-devtools/gcc/gcc/0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch b/meta/recipes-devtools/gcc/gcc/0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch
new file mode 100644
index 0000000000..04d940ae0b
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch
@@ -0,0 +1,28 @@
1From 9487b1d6136ea09cce4792d59d0170c712575550 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Sat, 20 Aug 2022 09:04:14 -0700
4Subject: [PATCH] Avoid hardcoded build paths into ppc libgcc
5
6Avoid encoding build paths into sources used for floating point on powerpc.
7(MACHINE=qemuppc bitbake libgcc).
8
9Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2022-August/599882.html]
10Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 libgcc/config/rs6000/t-float128 | 2 +-
14 1 file changed, 1 insertion(+), 1 deletion(-)
15
16diff --git a/libgcc/config/rs6000/t-float128 b/libgcc/config/rs6000/t-float128
17index b09b5664af0..513e63748f1 100644
18--- a/libgcc/config/rs6000/t-float128
19+++ b/libgcc/config/rs6000/t-float128
20@@ -103,7 +103,7 @@ $(ibm128_dec_objs) : INTERNAL_CFLAGS += $(IBM128_CFLAGS_DECIMAL)
21 $(fp128_softfp_src) : $(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@)) $(fp128_dep)
22 @src="$(srcdir)/soft-fp/$(subst -sw,,$(subst kf,tf,$@))"; \
23 echo "Create $@"; \
24- (echo "/* file created from $$src */"; \
25+ (echo "/* file created from `basename $$src` */"; \
26 echo; \
27 sed -f $(fp128_sed) < $$src) > $@
28
diff --git a/meta/recipes-devtools/gcc/gcc/0025-gcc-testsuite-tweaks-for-mips-OE.patch b/meta/recipes-devtools/gcc/gcc/0025-gcc-testsuite-tweaks-for-mips-OE.patch
new file mode 100644
index 0000000000..e4d57c27ef
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0025-gcc-testsuite-tweaks-for-mips-OE.patch
@@ -0,0 +1,233 @@
1From f12acc6a383546d48da3bdfb2f25ca2adb7976d7 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Sun, 13 Aug 2023 10:24:05 +0100
4Subject: [PATCH] gcc testsuite tweaks for mips/OE
5
6Disable loongson-mmi runtine, qemu doesn't appear to fully support them even if some
7of the instruction decoding is there.
8
9Also disable MSA mips runtime extensions. For some reason qemu appears to accept the test
10code when it shouldn't. Our selected MIPS cpu for QEMU doesn't support them.
11
12MIPS is unusual in the gcc testsuite as it uses EFFECTIVE_TARGETS and loops
13multiple times through the vector testsuite. In the case of the two above, we can
14compile/link them but not run them. Even with the runtime disabled, if the code
15marks it as a runtime test, it will elevate itself to that. Setting the default
16target to compile therefore isn't enough.
17
18Therefore add code to downgrade runtime tests to link tests if the hardware
19support isn't there to run them. This avoids thousands of test failures. To do
20this we have to hook downgrade code into the main test runner.
21
22Enable that downgrading for other cases where hardware to run vector extensions is
23unavailable to remove test failures on other architectures too.
24
25Also, for gcc.target tests, add checks on wheter loongson or msa code can
26be run before trying that, allowing downgrading of tests there to work too.
27
28Upstream-Status: Pending
29[Parts of the patch may be able to be split off and acceptable to upstream with
30discussion. Need to investigate why qemu-user passes the 'bad' instructions']
31
32Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
33---
34 gcc/testsuite/gcc.target/mips/mips.exp | 16 +++++++++
35 gcc/testsuite/lib/gcc-dg.exp | 11 +++++++
36 gcc/testsuite/lib/target-supports.exp | 45 ++++++++------------------
37 3 files changed, 41 insertions(+), 31 deletions(-)
38
39diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
40index 15d574202d3..2cef9709774 100644
41--- a/gcc/testsuite/gcc.target/mips/mips.exp
42+++ b/gcc/testsuite/gcc.target/mips/mips.exp
43@@ -709,7 +709,23 @@ proc mips_first_unsupported_option { upstatus } {
44 global mips_option_tests
45 upvar $upstatus status
46
47+ if { [mips_have_test_option_p status "-mmsa"] } {
48+ verbose -log "Found -mmsa"
49+ if { ![check_mips_msa_hw_available] } {
50+ verbose -log "No MSA avail"
51+ return "-mmsa"
52+ }
53+ }
54+ if { [mips_have_test_option_p status "-mloongson-mmi"] } {
55+ verbose -log "Found -mloonson-mmi"
56+ if { ![check_mips_loongson_mmi_hw_available] } {
57+ verbose -log "No MMI avail"
58+ return "-mloonson-mmi"
59+ }
60+ }
61+
62 foreach { option code } [array get mips_option_tests] {
63+
64 if { [mips_have_test_option_p status $option] } {
65 regsub -all "\n" $code "\\n\\\n" asm
66 # Use check_runtime from target-supports.exp, which caches
67diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
68index 9d79b9402e9..e0e5cbb1af8 100644
69--- a/gcc/testsuite/lib/gcc-dg.exp
70+++ b/gcc/testsuite/lib/gcc-dg.exp
71@@ -240,9 +240,20 @@ proc schedule-cleanups { opts } {
72
73 proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
74 # Set up the compiler flags, based on what we're going to do.
75+ global do-what-limit
76
77 set options [list]
78
79+ if [info exists do-what-limit] then {
80+ # Demote run tests to $do-what-limit if set
81+ switch $do_what {
82+ run {
83+ set do_what ${do-what-limit}
84+ set dg-do-what ${do-what-limit}
85+ }
86+ }
87+ }
88+
89 switch $do_what {
90 "preprocess" {
91 set compile_type "preprocess"
92diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
93index 40f71e9ed8b..10e267fa16d 100644
94--- a/gcc/testsuite/lib/target-supports.exp
95+++ b/gcc/testsuite/lib/target-supports.exp
96@@ -2155,14 +2155,7 @@ proc check_mips_loongson_mmi_hw_available { } {
97 if { !([istarget mips*-*-*]) } {
98 expr 0
99 } else {
100- check_runtime_nocache mips_loongson_mmi_hw_available {
101- #include <loongson-mmiintrin.h>
102- int main()
103- {
104- asm volatile ("paddw $f2,$f4,$f6");
105- return 0;
106- }
107- } "-mloongson-mmi"
108+ expr 0
109 }
110 }]
111 }
112@@ -2176,29 +2169,7 @@ proc check_mips_msa_hw_available { } {
113 if { !([istarget mips*-*-*]) } {
114 expr 0
115 } else {
116- check_runtime_nocache mips_msa_hw_available {
117- #if !defined(__mips_msa)
118- #error "MSA NOT AVAIL"
119- #else
120- #if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
121- #error "MSA NOT AVAIL FOR ISA REV < 2"
122- #endif
123- #if !defined(__mips_hard_float)
124- #error "MSA HARD_FLOAT REQUIRED"
125- #endif
126- #if __mips_fpr != 64
127- #error "MSA 64-bit FPR REQUIRED"
128- #endif
129- #include <msa.h>
130-
131- int main()
132- {
133- v8i16 v = __builtin_msa_ldi_h (0);
134- v[0] = 0;
135- return v[0];
136- }
137- #endif
138- } "-mmsa"
139+ expr 0
140 }
141 }]
142 }
143@@ -9187,6 +9158,7 @@ proc is-effective-target-keyword { arg } {
144
145 proc et-dg-runtest { runtest testcases flags default-extra-flags } {
146 global dg-do-what-default
147+ global do-what-limit
148 global EFFECTIVE_TARGETS
149 global et_index
150
151@@ -9194,6 +9166,7 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
152 foreach target $EFFECTIVE_TARGETS {
153 set target_flags $flags
154 set dg-do-what-default compile
155+ set do-what-limit link
156 set et_index [lsearch -exact $EFFECTIVE_TARGETS $target]
157 if { [info procs add_options_for_${target}] != [list] } {
158 set target_flags [add_options_for_${target} "$flags"]
159@@ -9201,8 +9174,10 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
160 if { [info procs check_effective_target_${target}_runtime]
161 != [list] && [check_effective_target_${target}_runtime] } {
162 set dg-do-what-default run
163+ set do-what-limit run
164 }
165 $runtest $testcases $target_flags ${default-extra-flags}
166+ unset do-what-limit
167 }
168 } else {
169 set et_index 0
170@@ -10789,6 +10764,7 @@ proc check_effective_target_sigsetjmp {} {
171 proc check_vect_support_and_set_flags { } {
172 global DEFAULT_VECTCFLAGS
173 global dg-do-what-default
174+ global do-what-limit
175 global EFFECTIVE_TARGETS
176
177 if [istarget powerpc-*paired*] {
178@@ -10797,6 +10773,7 @@ proc check_vect_support_and_set_flags { } {
179 set dg-do-what-default run
180 } else {
181 set dg-do-what-default compile
182+ set do-what-limit link
183 }
184 } elseif [istarget powerpc*-*-*] {
185 # Skip targets not supporting -maltivec.
186@@ -10821,6 +10798,7 @@ proc check_vect_support_and_set_flags { } {
187 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
188 }
189 set dg-do-what-default compile
190+ set do-what-limit link
191 }
192 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
193 lappend DEFAULT_VECTCFLAGS "-msse2"
194@@ -10828,6 +10806,7 @@ proc check_vect_support_and_set_flags { } {
195 set dg-do-what-default run
196 } else {
197 set dg-do-what-default compile
198+ set do-what-limit link
199 }
200 } elseif { [istarget mips*-*-*]
201 && [check_effective_target_nomips16] } {
202@@ -10847,6 +10826,7 @@ proc check_vect_support_and_set_flags { } {
203 set dg-do-what-default run
204 } else {
205 set dg-do-what-default compile
206+ set do-what-limit link
207 }
208 } elseif [istarget alpha*-*-*] {
209 # Alpha's vectorization capabilities are extremely limited.
210@@ -10860,6 +10840,7 @@ proc check_vect_support_and_set_flags { } {
211 set dg-do-what-default run
212 } else {
213 set dg-do-what-default compile
214+ set do-what-limit link
215 }
216 } elseif [istarget ia64-*-*] {
217 set dg-do-what-default run
218@@ -10873,6 +10854,7 @@ proc check_vect_support_and_set_flags { } {
219 set dg-do-what-default run
220 } else {
221 set dg-do-what-default compile
222+ set do-what-limit link
223 }
224 } elseif [istarget aarch64*-*-*] {
225 set dg-do-what-default run
226@@ -10897,6 +10879,7 @@ proc check_vect_support_and_set_flags { } {
227 } else {
228 lappend DEFAULT_VECTCFLAGS "-march=z14" "-mzarch"
229 set dg-do-what-default compile
230+ set do-what-limit link
231 }
232 } elseif [istarget amdgcn-*-*] {
233 set dg-do-what-default run
diff --git a/meta/recipes-devtools/gcc/gcc/0026-Fix-various-_FOR_BUILD-and-related-variables.patch b/meta/recipes-devtools/gcc/gcc/0026-Fix-various-_FOR_BUILD-and-related-variables.patch
deleted file mode 100644
index 97bf2f3a73..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0026-Fix-various-_FOR_BUILD-and-related-variables.patch
+++ /dev/null
@@ -1,134 +0,0 @@
1From 3a003af8804dda90fdf4862eca5f66cb12faaf02 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 7 Dec 2015 23:42:45 +0000
4Subject: [PATCH] Fix various _FOR_BUILD and related variables
5
6When doing a FOR_BUILD thing, you have to override CFLAGS with
7CFLAGS_FOR_BUILD. And if you use C++, you also have to override
8CXXFLAGS with CXXFLAGS_FOR_BUILD.
9Without this, when building for mingw, you end up trying to use
10the mingw headers for a host build.
11
12The same goes for other variables as well, such as CPPFLAGS,
13CPP, and GMPINC.
14
15Upstream-Status: Pending
16
17Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
18Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
19Signed-off-by: Khem Raj <raj.khem@gmail.com>
20---
21 Makefile.in | 6 ++++++
22 Makefile.tpl | 5 +++++
23 gcc/Makefile.in | 2 +-
24 gcc/configure | 2 +-
25 gcc/configure.ac | 2 +-
26 5 files changed, 14 insertions(+), 3 deletions(-)
27
28diff --git a/Makefile.in b/Makefile.in
29index c717903bb13..5abc649868d 100644
30--- a/Makefile.in
31+++ b/Makefile.in
32@@ -152,6 +152,7 @@ BUILD_EXPORTS = \
33 CPP="$(CC_FOR_BUILD) -E"; export CPP; \
34 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
35 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
36+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
37 CXX="$(CXX_FOR_BUILD)"; export CXX; \
38 CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
39 GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
40@@ -171,6 +172,9 @@ BUILD_EXPORTS = \
41 # built for the build system to override those in BASE_FLAGS_TO_PASS.
42 EXTRA_BUILD_FLAGS = \
43 CFLAGS="$(CFLAGS_FOR_BUILD)" \
44+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
45+ CPP="$(CC_FOR_BUILD) -E" \
46+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \
47 LDFLAGS="$(LDFLAGS_FOR_BUILD)"
48
49 # This is the list of directories to built for the host system.
50@@ -188,6 +192,7 @@ HOST_SUBDIR = @host_subdir@
51 HOST_EXPORTS = \
52 $(BASE_EXPORTS) \
53 CC="$(CC)"; export CC; \
54+ CPP="$(CC) -E"; export CPP; \
55 ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \
56 CFLAGS="$(CFLAGS)"; export CFLAGS; \
57 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
58@@ -776,6 +781,7 @@ BASE_FLAGS_TO_PASS = \
59 "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
60 "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
61 "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
62+ "CXXFLAGS_FOR_BUILD=$(CXXFLAGS_FOR_BUILD)" \
63 "EXPECT=$(EXPECT)" \
64 "FLEX=$(FLEX)" \
65 "INSTALL=$(INSTALL)" \
66diff --git a/Makefile.tpl b/Makefile.tpl
67index efed1511750..778beb705b4 100644
68--- a/Makefile.tpl
69+++ b/Makefile.tpl
70@@ -154,6 +154,7 @@ BUILD_EXPORTS = \
71 CC="$(CC_FOR_BUILD)"; export CC; \
72 CFLAGS="$(CFLAGS_FOR_BUILD)"; export CFLAGS; \
73 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
74+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)"; export CPPFLAGS; \
75 CXX="$(CXX_FOR_BUILD)"; export CXX; \
76 CXXFLAGS="$(CXXFLAGS_FOR_BUILD)"; export CXXFLAGS; \
77 GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \
78@@ -173,6 +174,9 @@ BUILD_EXPORTS = \
79 # built for the build system to override those in BASE_FLAGS_TO_PASS.
80 EXTRA_BUILD_FLAGS = \
81 CFLAGS="$(CFLAGS_FOR_BUILD)" \
82+ CXXFLAGS="$(CXXFLAGS_FOR_BUILD)" \
83+ CPP="$(CC_FOR_BUILD) -E" \
84+ CPPFLAGS="$(CPPFLAGS_FOR_BUILD)" \
85 LDFLAGS="$(LDFLAGS_FOR_BUILD)"
86
87 # This is the list of directories to built for the host system.
88@@ -190,6 +194,7 @@ HOST_SUBDIR = @host_subdir@
89 HOST_EXPORTS = \
90 $(BASE_EXPORTS) \
91 CC="$(CC)"; export CC; \
92+ CPP="$(CC) -E"; export CPP; \
93 ADA_CFLAGS="$(ADA_CFLAGS)"; export ADA_CFLAGS; \
94 CFLAGS="$(CFLAGS)"; export CFLAGS; \
95 CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \
96diff --git a/gcc/Makefile.in b/gcc/Makefile.in
97index 011c7ac2db6..2f1165f7b5e 100644
98--- a/gcc/Makefile.in
99+++ b/gcc/Makefile.in
100@@ -805,7 +805,7 @@ BUILD_LDFLAGS=@BUILD_LDFLAGS@
101 BUILD_NO_PIE_FLAG = @BUILD_NO_PIE_FLAG@
102 BUILD_LDFLAGS += $(BUILD_NO_PIE_FLAG)
103 BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
104- -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS)
105+ -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS_FOR_BUILD)
106
107 # Actual name to use when installing a native compiler.
108 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
109diff --git a/gcc/configure b/gcc/configure
110index 825a9652329..ff46cf58960 100755
111--- a/gcc/configure
112+++ b/gcc/configure
113@@ -12314,7 +12314,7 @@ else
114 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
115 CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
116 LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
117- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
118+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
119 ${realsrcdir}/configure \
120 --enable-languages=${enable_languages-all} \
121 ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \
122diff --git a/gcc/configure.ac b/gcc/configure.ac
123index 6099eb3251f..b3c345b61dc 100644
124--- a/gcc/configure.ac
125+++ b/gcc/configure.ac
126@@ -1898,7 +1898,7 @@ else
127 CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
128 CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
129 LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
130- GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
131+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
132 ${realsrcdir}/configure \
133 --enable-languages=${enable_languages-all} \
134 ${enable_obsolete+--enable-obsolete="$enable_obsolete"} \
diff --git a/meta/recipes-devtools/gcc/gcc/0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch b/meta/recipes-devtools/gcc/gcc/0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch
new file mode 100644
index 0000000000..a408a98698
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch
@@ -0,0 +1,117 @@
1From adb60dc78e0da4877747f32347cee339364775be Mon Sep 17 00:00:00 2001
2From: Richard Sandiford <richard.sandiford@arm.com>
3Date: Fri, 15 Sep 2023 09:19:14 +0100
4Subject: [PATCH] aarch64: Fix loose ldpstp check [PR111411]
5
6aarch64_operands_ok_for_ldpstp contained the code:
7
8 /* One of the memory accesses must be a mempair operand.
9 If it is not the first one, they need to be swapped by the
10 peephole. */
11 if (!aarch64_mem_pair_operand (mem_1, GET_MODE (mem_1))
12 && !aarch64_mem_pair_operand (mem_2, GET_MODE (mem_2)))
13 return false;
14
15But the requirement isn't just that one of the accesses must be a
16valid mempair operand. It's that the lower access must be, since
17that's the access that will be used for the instruction operand.
18
19gcc/
20 PR target/111411
21 * config/aarch64/aarch64.cc (aarch64_operands_ok_for_ldpstp): Require
22 the lower memory access to a mem-pair operand.
23
24gcc/testsuite/
25 PR target/111411
26 * gcc.dg/rtl/aarch64/pr111411.c: New test.
27
28Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=2d38f45bcca62ca0c7afef4b579f82c5c2a01610]
29Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
30---
31 gcc/config/aarch64/aarch64.cc | 8 ++-
32 gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c | 57 +++++++++++++++++++++
33 2 files changed, 60 insertions(+), 5 deletions(-)
34 create mode 100644 gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c
35
36diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
37index 6118a3354ac..9b1f791ca8b 100644
38--- a/gcc/config/aarch64/aarch64.cc
39+++ b/gcc/config/aarch64/aarch64.cc
40@@ -26154,11 +26154,9 @@ aarch64_operands_ok_for_ldpstp (rtx *operands, bool load,
41 gcc_assert (known_eq (GET_MODE_SIZE (GET_MODE (mem_1)),
42 GET_MODE_SIZE (GET_MODE (mem_2))));
43
44- /* One of the memory accesses must be a mempair operand.
45- If it is not the first one, they need to be swapped by the
46- peephole. */
47- if (!aarch64_mem_pair_operand (mem_1, GET_MODE (mem_1))
48- && !aarch64_mem_pair_operand (mem_2, GET_MODE (mem_2)))
49+ /* The lower memory access must be a mem-pair operand. */
50+ rtx lower_mem = reversed ? mem_2 : mem_1;
51+ if (!aarch64_mem_pair_operand (lower_mem, GET_MODE (lower_mem)))
52 return false;
53
54 if (REG_P (reg_1) && FP_REGNUM_P (REGNO (reg_1)))
55diff --git a/gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c b/gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c
56new file mode 100644
57index 00000000000..ad07e9c6c89
58--- /dev/null
59+++ b/gcc/testsuite/gcc.dg/rtl/aarch64/pr111411.c
60@@ -0,0 +1,57 @@
61+/* { dg-do compile { target aarch64*-*-* } } */
62+/* { dg-require-effective-target lp64 } */
63+/* { dg-options "-O -fdisable-rtl-postreload -fpeephole2 -fno-schedule-fusion" } */
64+
65+extern int data[];
66+
67+void __RTL (startwith ("ira")) foo (void *ptr)
68+{
69+ (function "foo"
70+ (param "ptr"
71+ (DECL_RTL (reg/v:DI <0> [ ptr ]))
72+ (DECL_RTL_INCOMING (reg/v:DI x0 [ ptr ]))
73+ ) ;; param "ptr"
74+ (insn-chain
75+ (block 2
76+ (edge-from entry (flags "FALLTHRU"))
77+ (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK)
78+ (insn 4 (set (reg:DI <0>) (reg:DI x0)))
79+ (insn 5 (set (reg:DI <1>)
80+ (plus:DI (reg:DI <0>) (const_int 768))))
81+ (insn 6 (set (mem:SI (plus:DI (reg:DI <0>)
82+ (const_int 508)) [1 &data+508 S4 A4])
83+ (const_int 0)))
84+ (insn 7 (set (mem:SI (plus:DI (reg:DI <1>)
85+ (const_int -256)) [1 &data+512 S4 A4])
86+ (const_int 0)))
87+ (edge-to exit (flags "FALLTHRU"))
88+ ) ;; block 2
89+ ) ;; insn-chain
90+ ) ;; function
91+}
92+
93+void __RTL (startwith ("ira")) bar (void *ptr)
94+{
95+ (function "bar"
96+ (param "ptr"
97+ (DECL_RTL (reg/v:DI <0> [ ptr ]))
98+ (DECL_RTL_INCOMING (reg/v:DI x0 [ ptr ]))
99+ ) ;; param "ptr"
100+ (insn-chain
101+ (block 2
102+ (edge-from entry (flags "FALLTHRU"))
103+ (cnote 3 [bb 2] NOTE_INSN_BASIC_BLOCK)
104+ (insn 4 (set (reg:DI <0>) (reg:DI x0)))
105+ (insn 5 (set (reg:DI <1>)
106+ (plus:DI (reg:DI <0>) (const_int 768))))
107+ (insn 6 (set (mem:SI (plus:DI (reg:DI <1>)
108+ (const_int -256)) [1 &data+512 S4 A4])
109+ (const_int 0)))
110+ (insn 7 (set (mem:SI (plus:DI (reg:DI <0>)
111+ (const_int 508)) [1 &data+508 S4 A4])
112+ (const_int 0)))
113+ (edge-to exit (flags "FALLTHRU"))
114+ ) ;; block 2
115+ ) ;; insn-chain
116+ ) ;; function
117+}
diff --git a/meta/recipes-devtools/gcc/gcc/0027-Fix-gcc-vect-module-testcases.patch b/meta/recipes-devtools/gcc/gcc/0027-Fix-gcc-vect-module-testcases.patch
new file mode 100644
index 0000000000..4b89036814
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0027-Fix-gcc-vect-module-testcases.patch
@@ -0,0 +1,26 @@
1Upstream-Status: Backport [https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=948dbc5ee45f9ffd5f41fd6782704081cc7c8c27]
2
3Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
4
5diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c
6index ed63ff59cc0..009c849b7e7 100644
7--- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c
8+++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-10.c
9@@ -1,3 +1,5 @@
10+/* Since this uses dg-additional-sources, need to specify `dg-do run` instead of the default. */
11+/* { dg-do run } */
12 /* { dg-require-effective-target vect_simd_clones } */
13 /* { dg-additional-options "-fopenmp-simd" } */
14 /* { dg-additional-options "-mavx" { target avx_runtime } } */
15diff --git a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c
16index c44471e35bc..4699a3f3c80 100644
17--- a/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c
18+++ b/gcc/testsuite/gcc.dg/vect/vect-simd-clone-12.c
19@@ -1,3 +1,5 @@
20+/* Since this uses dg-additional-sources, need to specify `dg-do run` instead of the default. */
21+/* { dg-do run } */
22 /* { dg-require-effective-target vect_simd_clones } */
23 /* { dg-additional-options "-fopenmp-simd" } */
24 /* { dg-additional-options "-mavx" { target avx_runtime } } */
25--
262.43.0
diff --git a/meta/recipes-devtools/gcc/gcc/0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch b/meta/recipes-devtools/gcc/gcc/0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch
deleted file mode 100644
index 3cd75b7183..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0027-nios2-Define-MUSL_DYNAMIC_LINKER.patch
+++ /dev/null
@@ -1,25 +0,0 @@
1From 4e53d0ae70af85af0e112a48a3e4dfe4c39f4a8d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 2 Feb 2016 10:26:10 -0800
4Subject: [PATCH] nios2: Define MUSL_DYNAMIC_LINKER
5
6Upstream-Status: Pending
7
8Signed-off-by: Marek Vasut <marex@denx.de>
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 gcc/config/nios2/linux.h | 1 +
12 1 file changed, 1 insertion(+)
13
14diff --git a/gcc/config/nios2/linux.h b/gcc/config/nios2/linux.h
15index 4bdcdcca1f0..e7943a9d640 100644
16--- a/gcc/config/nios2/linux.h
17+++ b/gcc/config/nios2/linux.h
18@@ -30,6 +30,7 @@
19 #define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}"
20
21 #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-nios2.so.1"
22+#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-nios2.so.1"
23
24 #undef LINK_SPEC
25 #define LINK_SPEC LINK_SPEC_ENDIAN \
diff --git a/meta/recipes-devtools/gcc/gcc/0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch b/meta/recipes-devtools/gcc/gcc/0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch
deleted file mode 100644
index 767cba0380..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0029-Link-libgcc-using-LDFLAGS-not-just-SHLIB_LDFLAGS.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From fbc926dbf6a47fa623b9c94cd9b09a0e90448fdc Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 4 May 2016 21:11:34 -0700
4Subject: [PATCH] Link libgcc using LDFLAGS, not just SHLIB_LDFLAGS
5
6Upstream-Status: Pending
7
8Signed-off-by: Christopher Larson <chris_larson@mentor.com>
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 libgcc/config/t-slibgcc | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/libgcc/config/t-slibgcc b/libgcc/config/t-slibgcc
15index c997553447c..330352c2c81 100644
16--- a/libgcc/config/t-slibgcc
17+++ b/libgcc/config/t-slibgcc
18@@ -32,7 +32,7 @@ SHLIB_INSTALL_SOLINK = $(LN_S) $(SHLIB_SONAME) \
19 $(DESTDIR)$(slibdir)$(SHLIB_SLIBDIR_QUAL)/$(SHLIB_SOLINK)
20
21 SHLIB_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared -nodefaultlibs \
22- $(SHLIB_LDFLAGS) \
23+ $(LDFLAGS) $(SHLIB_LDFLAGS) \
24 -o $(SHLIB_DIR)/$(SHLIB_SONAME).tmp @multilib_flags@ \
25 $(SHLIB_OBJS) $(SHLIB_LC) && \
26 rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
diff --git a/meta/recipes-devtools/gcc/gcc/0030-sync-gcc-stddef.h-with-musl.patch b/meta/recipes-devtools/gcc/gcc/0030-sync-gcc-stddef.h-with-musl.patch
deleted file mode 100644
index 4f18907a1d..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0030-sync-gcc-stddef.h-with-musl.patch
+++ /dev/null
@@ -1,88 +0,0 @@
1From 24dc04dc8d69e3bf61322615b3ef18e02ccd311e Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 3 Feb 2017 12:56:00 -0800
4Subject: [PATCH] sync gcc stddef.h with musl
5
6musl defines ptrdiff_t size_t and wchar_t
7so dont define them here if musl is definining them
8
9Upstream-Status: Pending
10
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 gcc/ginclude/stddef.h | 9 +++++++++
14 1 file changed, 9 insertions(+)
15
16diff --git a/gcc/ginclude/stddef.h b/gcc/ginclude/stddef.h
17index 9d67eac4947..6cb5edbedb4 100644
18--- a/gcc/ginclude/stddef.h
19+++ b/gcc/ginclude/stddef.h
20@@ -128,6 +128,7 @@ _TYPE_wchar_t;
21 #ifndef ___int_ptrdiff_t_h
22 #ifndef _GCC_PTRDIFF_T
23 #ifndef _PTRDIFF_T_DECLARED /* DragonFly */
24+#ifndef __DEFINED_ptrdiff_t /* musl */
25 #define _PTRDIFF_T
26 #define _T_PTRDIFF_
27 #define _T_PTRDIFF
28@@ -137,10 +138,12 @@ _TYPE_wchar_t;
29 #define ___int_ptrdiff_t_h
30 #define _GCC_PTRDIFF_T
31 #define _PTRDIFF_T_DECLARED
32+#define __DEFINED_ptrdiff_t /* musl */
33 #ifndef __PTRDIFF_TYPE__
34 #define __PTRDIFF_TYPE__ long int
35 #endif
36 typedef __PTRDIFF_TYPE__ ptrdiff_t;
37+#endif /* __DEFINED_ptrdiff_t */
38 #endif /* _PTRDIFF_T_DECLARED */
39 #endif /* _GCC_PTRDIFF_T */
40 #endif /* ___int_ptrdiff_t_h */
41@@ -178,6 +181,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
42 #ifndef _GCC_SIZE_T
43 #ifndef _SIZET_
44 #ifndef __size_t
45+#ifndef __DEFINED_size_t /* musl */
46 #define __size_t__ /* BeOS */
47 #define __SIZE_T__ /* Cray Unicos/Mk */
48 #define _SIZE_T
49@@ -194,6 +198,7 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
50 #define ___int_size_t_h
51 #define _GCC_SIZE_T
52 #define _SIZET_
53+#define __DEFINED_size_t /* musl */
54 #if defined (__FreeBSD__) \
55 || defined(__DragonFly__) \
56 || defined(__FreeBSD_kernel__) \
57@@ -228,6 +233,7 @@ typedef long ssize_t;
58 #endif /* _SIZE_T */
59 #endif /* __SIZE_T__ */
60 #endif /* __size_t__ */
61+#endif /* __DEFINED_size_t */
62 #undef __need_size_t
63 #endif /* _STDDEF_H or __need_size_t. */
64
65@@ -257,6 +263,7 @@ typedef long ssize_t;
66 #ifndef ___int_wchar_t_h
67 #ifndef __INT_WCHAR_T_H
68 #ifndef _GCC_WCHAR_T
69+#ifndef __DEFINED_wchar_t /* musl */
70 #define __wchar_t__ /* BeOS */
71 #define __WCHAR_T__ /* Cray Unicos/Mk */
72 #define _WCHAR_T
73@@ -272,6 +279,7 @@ typedef long ssize_t;
74 #define __INT_WCHAR_T_H
75 #define _GCC_WCHAR_T
76 #define _WCHAR_T_DECLARED
77+#define __DEFINED_wchar_t /* musl */
78
79 /* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_
80 instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other
81@@ -337,6 +345,7 @@ typedef __WCHAR_TYPE__ wchar_t;
82 #endif
83 #endif /* __WCHAR_T__ */
84 #endif /* __wchar_t__ */
85+#endif /* __DEFINED_wchar_t musl */
86 #undef __need_wchar_t
87 #endif /* _STDDEF_H or __need_wchar_t. */
88
diff --git a/meta/recipes-devtools/gcc/gcc/0031-fix-segmentation-fault-in-precompiled-header-generat.patch b/meta/recipes-devtools/gcc/gcc/0031-fix-segmentation-fault-in-precompiled-header-generat.patch
deleted file mode 100644
index 702279af0e..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0031-fix-segmentation-fault-in-precompiled-header-generat.patch
+++ /dev/null
@@ -1,57 +0,0 @@
1From 27b8ba5555ada2dab076988529bfb84d00a4b901 Mon Sep 17 00:00:00 2001
2From: Juro Bystricky <juro.bystricky@intel.com>
3Date: Mon, 19 Mar 2018 22:31:20 -0700
4Subject: [PATCH] fix segmentation fault in precompiled header generation
5
6Prevent a segmentation fault which occurs when using incorrect
7structure trying to access name of some named operators, such as
8CPP_NOT, CPP_AND etc. "token->val.node.spelling" cannot be used in
9those cases, as is may not be initialized at all.
10
11[YOCTO #11738]
12
13Upstream-Status: Pending
14
15Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
16Signed-off-by: Khem Raj <raj.khem@gmail.com>
17---
18 libcpp/lex.c | 26 +++++++++++++++++++++-----
19 1 file changed, 21 insertions(+), 5 deletions(-)
20
21diff --git a/libcpp/lex.c b/libcpp/lex.c
22index 56ac3a1dd73..73a951148b3 100644
23--- a/libcpp/lex.c
24+++ b/libcpp/lex.c
25@@ -3311,11 +3311,27 @@ cpp_spell_token (cpp_reader *pfile, const cpp_token *token,
26 spell_ident:
27 case SPELL_IDENT:
28 if (forstring)
29- {
30- memcpy (buffer, NODE_NAME (token->val.node.spelling),
31- NODE_LEN (token->val.node.spelling));
32- buffer += NODE_LEN (token->val.node.spelling);
33- }
34+ {
35+ if (token->type == CPP_NAME)
36+ {
37+ memcpy (buffer, NODE_NAME (token->val.node.spelling),
38+ NODE_LEN (token->val.node.spelling));
39+ buffer += NODE_LEN (token->val.node.spelling);
40+ break;
41+ }
42+ /* NAMED_OP, cannot use node.spelling */
43+ if (token->flags & NAMED_OP)
44+ {
45+ const char *str = cpp_named_operator2name (token->type);
46+ if (str)
47+ {
48+ size_t len = strlen(str);
49+ memcpy(buffer, str, len);
50+ buffer += len;
51+ }
52+ break;
53+ }
54+ }
55 else
56 buffer = _cpp_spell_ident_ucns (buffer, token->val.node.node);
57 break;
diff --git a/meta/recipes-devtools/gcc/gcc/0032-Fix-for-testsuite-failure.patch b/meta/recipes-devtools/gcc/gcc/0032-Fix-for-testsuite-failure.patch
deleted file mode 100644
index 0a0767b441..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0032-Fix-for-testsuite-failure.patch
+++ /dev/null
@@ -1,255 +0,0 @@
1From 2512aacf023c679d86d8f40caff4f6ff412b32ff Mon Sep 17 00:00:00 2001
2From: RAGHUNATH LOLUR <raghunath.lolur@kpit.com>
3Date: Wed, 6 Dec 2017 22:52:26 -0800
4Subject: [PATCH] Fix for testsuite failure
5
62017-11-16 Raghunath Lolur <raghunath.lolur@kpit.com>
7
8 * gcc.dg/pr56275.c: If SSE is disabled, ensure that
9 "-mfpmath" is not set to use SSE. Set "-mfpmath=387".
10 * gcc.dg/pr68306.c: Likewise
11 * gcc.dg/pr68306-2.c: Likewise
12 * gcc.dg/pr68306-3.c: Likewise
13 * gcc.dg/pr69634.c: Likewise
14 * gcc.target/i386/amd64-abi-1.c: Likewise
15 * gcc.target/i386/funcspec-6.c: Likewise
16 * gcc.target/i386/interrupt-387-err-1.c: Likewise
17 * gcc.target/i386/isa-14.c: Likewise
18 * gcc.target/i386/pr44948-2b.c: Likewise
19 * gcc.target/i386/pr53425-1.c: Likewise
20 * gcc.target/i386/pr53425-2.c: Likewise
21 * gcc.target/i386/pr55247.c: Likewise
22 * gcc.target/i386/pr59644.c: Likewise
23 * gcc.target/i386/pr62120.c: Likewise
24 * gcc.target/i386/pr70467-1.c: Likewise
25 * gcc.target/i386/warn-vect-op-1.c: Likewise
26
27If -Wall, -Werror are used during compilation various test cases fail
28to compile.
29
30If SSE is disabled, be sure to -mfpmath=387 to resolve this.
31
32This patch removes the changes to Changelog from the original patch.
33This will help us avoid conflicts.
34
35Upstream-Status: Pending
36
37Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
38---
39 gcc/testsuite/gcc.dg/pr56275.c | 2 +-
40 gcc/testsuite/gcc.dg/pr68306-2.c | 2 +-
41 gcc/testsuite/gcc.dg/pr68306-3.c | 2 +-
42 gcc/testsuite/gcc.dg/pr68306.c | 2 +-
43 gcc/testsuite/gcc.dg/pr69634.c | 2 +-
44 gcc/testsuite/gcc.target/i386/amd64-abi-1.c | 2 +-
45 gcc/testsuite/gcc.target/i386/funcspec-6.c | 1 +
46 gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c | 2 +-
47 gcc/testsuite/gcc.target/i386/isa-14.c | 2 +-
48 gcc/testsuite/gcc.target/i386/pr44948-2b.c | 2 +-
49 gcc/testsuite/gcc.target/i386/pr53425-1.c | 2 +-
50 gcc/testsuite/gcc.target/i386/pr53425-2.c | 2 +-
51 gcc/testsuite/gcc.target/i386/pr55247.c | 2 +-
52 gcc/testsuite/gcc.target/i386/pr59644.c | 2 +-
53 gcc/testsuite/gcc.target/i386/pr62120.c | 2 +-
54 gcc/testsuite/gcc.target/i386/pr70467-1.c | 2 +-
55 gcc/testsuite/gcc.target/i386/warn-vect-op-1.c | 2 +-
56 17 files changed, 17 insertions(+), 16 deletions(-)
57
58diff --git a/gcc/testsuite/gcc.dg/pr56275.c b/gcc/testsuite/gcc.dg/pr56275.c
59index b901bb2b199..a4f6c95e1a1 100644
60--- a/gcc/testsuite/gcc.dg/pr56275.c
61+++ b/gcc/testsuite/gcc.dg/pr56275.c
62@@ -1,6 +1,6 @@
63 /* { dg-do compile } */
64 /* { dg-options "-O2" } */
65-/* { dg-additional-options "-mno-sse" { target { i?86-*-* x86_64-*-* } } } */
66+/* { dg-additional-options "-mno-sse -mfpmath=387" { target { i?86-*-* x86_64-*-* } } } */
67
68 typedef long long v2tw __attribute__ ((vector_size (2 * sizeof (long long))));
69
70diff --git a/gcc/testsuite/gcc.dg/pr68306-2.c b/gcc/testsuite/gcc.dg/pr68306-2.c
71index 4672ebe7987..2a368c484b6 100644
72--- a/gcc/testsuite/gcc.dg/pr68306-2.c
73+++ b/gcc/testsuite/gcc.dg/pr68306-2.c
74@@ -1,6 +1,6 @@
75 /* { dg-do compile } */
76 /* { dg-options "-O3" } */
77-/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */
78+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
79
80 struct {
81 int tz_minuteswest;
82diff --git a/gcc/testsuite/gcc.dg/pr68306-3.c b/gcc/testsuite/gcc.dg/pr68306-3.c
83index f5a8c102cf8..df3390c64c2 100644
84--- a/gcc/testsuite/gcc.dg/pr68306-3.c
85+++ b/gcc/testsuite/gcc.dg/pr68306-3.c
86@@ -1,6 +1,6 @@
87 /* { dg-do compile } */
88 /* { dg-options "-O3" } */
89-/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */
90+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
91 /* { dg-additional-options "-mno-altivec -mno-vsx" { target powerpc*-*-* } } */
92
93 extern void fn2();
94diff --git a/gcc/testsuite/gcc.dg/pr68306.c b/gcc/testsuite/gcc.dg/pr68306.c
95index 54e5b40f221..0813389e2c1 100644
96--- a/gcc/testsuite/gcc.dg/pr68306.c
97+++ b/gcc/testsuite/gcc.dg/pr68306.c
98@@ -1,6 +1,6 @@
99 /* { dg-do compile } */
100 /* { dg-options "-O3" } */
101-/* { dg-additional-options "-mno-sse -mno-mmx" { target i?86-*-* x86_64-*-* } } */
102+/* { dg-additional-options "-mno-sse -mno-mmx -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
103
104 enum powerpc_pmc_type { PPC_PMC_IBM };
105 struct {
106diff --git a/gcc/testsuite/gcc.dg/pr69634.c b/gcc/testsuite/gcc.dg/pr69634.c
107index 60a56149463..bcc23f9ccd6 100644
108--- a/gcc/testsuite/gcc.dg/pr69634.c
109+++ b/gcc/testsuite/gcc.dg/pr69634.c
110@@ -1,6 +1,6 @@
111 /* { dg-do compile } */
112 /* { dg-options "-O2 -fno-dce -fschedule-insns -fno-tree-vrp -fcompare-debug -Wno-psabi" } */
113-/* { dg-additional-options "-mno-sse" { target i?86-*-* x86_64-*-* } } */
114+/* { dg-additional-options "-mno-sse -mfpmath=387" { target i?86-*-* x86_64-*-* } } */
115 /* { dg-require-effective-target scheduling } */
116
117 typedef unsigned short u16;
118diff --git a/gcc/testsuite/gcc.target/i386/amd64-abi-1.c b/gcc/testsuite/gcc.target/i386/amd64-abi-1.c
119index 69fde57bf06..7f1f1c03edf 100644
120--- a/gcc/testsuite/gcc.target/i386/amd64-abi-1.c
121+++ b/gcc/testsuite/gcc.target/i386/amd64-abi-1.c
122@@ -1,5 +1,5 @@
123 /* { dg-do compile { target { ! ia32 } } } */
124-/* { dg-options "-mno-sse" } */
125+/* { dg-options "-mno-sse -mfpmath=387" } */
126 /* { dg-additional-options "-mabi=sysv" { target *-*-mingw* } } */
127
128 double foo(void) { return 0; } /* { dg-error "SSE disabled" } */
129diff --git a/gcc/testsuite/gcc.target/i386/funcspec-6.c b/gcc/testsuite/gcc.target/i386/funcspec-6.c
130index ea896b7ebfd..bf15569b826 100644
131--- a/gcc/testsuite/gcc.target/i386/funcspec-6.c
132+++ b/gcc/testsuite/gcc.target/i386/funcspec-6.c
133@@ -1,6 +1,7 @@
134 /* Test whether all of the 64-bit function specific options are accepted
135 without error. */
136 /* { dg-do compile { target { ! ia32 } } } */
137+/* { dg-additional-options "-mfpmath=387" } */
138
139 #include "funcspec-56.inc"
140
141diff --git a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
142index 8561a3c26d6..6377f814645 100644
143--- a/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
144+++ b/gcc/testsuite/gcc.target/i386/interrupt-387-err-1.c
145@@ -1,5 +1,5 @@
146 /* { dg-do compile } */
147-/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -m80387" } */
148+/* { dg-options "-O2 -mgeneral-regs-only -mno-cld -mno-iamcu -m80387 -mfpmath=387" } */
149
150 typedef unsigned int uword_t __attribute__ ((mode (__word__)));
151
152diff --git a/gcc/testsuite/gcc.target/i386/isa-14.c b/gcc/testsuite/gcc.target/i386/isa-14.c
153index 5d49e6e77fe..1de2db92bdd 100644
154--- a/gcc/testsuite/gcc.target/i386/isa-14.c
155+++ b/gcc/testsuite/gcc.target/i386/isa-14.c
156@@ -1,5 +1,5 @@
157 /* { dg-do run } */
158-/* { dg-options "-march=x86-64 -msse4a -mfma4 -mno-sse" } */
159+/* { dg-options "-march=x86-64 -msse4a -mfma4 -mno-sse -mfpmath=387" } */
160
161 extern void abort (void);
162
163diff --git a/gcc/testsuite/gcc.target/i386/pr44948-2b.c b/gcc/testsuite/gcc.target/i386/pr44948-2b.c
164index fa1769b62fb..f79fb12726f 100644
165--- a/gcc/testsuite/gcc.target/i386/pr44948-2b.c
166+++ b/gcc/testsuite/gcc.target/i386/pr44948-2b.c
167@@ -1,5 +1,5 @@
168 /* { dg-do compile } */
169-/* { dg-options "-O -mno-sse -Wno-psabi -mtune=generic" } */
170+/* { dg-options "-O -mno-sse -Wno-psabi -mtune=generic -mfpmath=387" } */
171
172 struct A
173 {
174diff --git a/gcc/testsuite/gcc.target/i386/pr53425-1.c b/gcc/testsuite/gcc.target/i386/pr53425-1.c
175index 2e89ff7d81d..6339bf6b736 100644
176--- a/gcc/testsuite/gcc.target/i386/pr53425-1.c
177+++ b/gcc/testsuite/gcc.target/i386/pr53425-1.c
178@@ -1,6 +1,6 @@
179 /* PR target/53425 */
180 /* { dg-do compile { target { ! ia32 } } } */
181-/* { dg-options "-O2 -mno-sse" } */
182+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */
183 /* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } } */
184
185 typedef double __v2df __attribute__ ((__vector_size__ (16)));
186diff --git a/gcc/testsuite/gcc.target/i386/pr53425-2.c b/gcc/testsuite/gcc.target/i386/pr53425-2.c
187index 61f6283dbe9..2c5a55f0ac3 100644
188--- a/gcc/testsuite/gcc.target/i386/pr53425-2.c
189+++ b/gcc/testsuite/gcc.target/i386/pr53425-2.c
190@@ -1,6 +1,6 @@
191 /* PR target/53425 */
192 /* { dg-do compile { target { ! ia32 } } } */
193-/* { dg-options "-O2 -mno-sse" } */
194+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */
195 /* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } } */
196
197 typedef float __v2sf __attribute__ ((__vector_size__ (8)));
198diff --git a/gcc/testsuite/gcc.target/i386/pr55247.c b/gcc/testsuite/gcc.target/i386/pr55247.c
199index 23366d0909d..9810e3abb76 100644
200--- a/gcc/testsuite/gcc.target/i386/pr55247.c
201+++ b/gcc/testsuite/gcc.target/i386/pr55247.c
202@@ -1,6 +1,6 @@
203 /* { dg-do compile { target { ! ia32 } } } */
204 /* { dg-require-effective-target maybe_x32 } */
205-/* { dg-options "-O2 -mno-sse -mno-mmx -mx32 -maddress-mode=long" } */
206+/* { dg-options "-O2 -mno-sse -mno-mmx -mx32 -maddress-mode=long -mfpmath=387" } */
207
208 typedef unsigned int uint32_t;
209 typedef uint32_t Elf32_Word;
210diff --git a/gcc/testsuite/gcc.target/i386/pr59644.c b/gcc/testsuite/gcc.target/i386/pr59644.c
211index 96006b3e338..4287e4538bf 100644
212--- a/gcc/testsuite/gcc.target/i386/pr59644.c
213+++ b/gcc/testsuite/gcc.target/i386/pr59644.c
214@@ -1,6 +1,6 @@
215 /* PR target/59644 */
216 /* { dg-do run { target lp64 } } */
217-/* { dg-options "-O2 -ffreestanding -mno-sse -mpreferred-stack-boundary=3 -maccumulate-outgoing-args -mno-red-zone" } */
218+/* { dg-options "-O2 -ffreestanding -mno-sse -mpreferred-stack-boundary=3 -maccumulate-outgoing-args -mno-red-zone -mfpmath=387" } */
219
220 /* This test uses __builtin_trap () instead of e.g. abort,
221 because due to -mpreferred-stack-boundary=3 it should not call
222diff --git a/gcc/testsuite/gcc.target/i386/pr62120.c b/gcc/testsuite/gcc.target/i386/pr62120.c
223index 28d85d37712..c93266bd4bc 100644
224--- a/gcc/testsuite/gcc.target/i386/pr62120.c
225+++ b/gcc/testsuite/gcc.target/i386/pr62120.c
226@@ -1,5 +1,5 @@
227 /* { dg-do compile } */
228-/* { dg-options "-mno-sse" } */
229+/* { dg-options "-mno-sse -mfpmath=387" } */
230
231 void foo ()
232 {
233diff --git a/gcc/testsuite/gcc.target/i386/pr70467-1.c b/gcc/testsuite/gcc.target/i386/pr70467-1.c
234index 4e112c88d07..bcfb396a68d 100644
235--- a/gcc/testsuite/gcc.target/i386/pr70467-1.c
236+++ b/gcc/testsuite/gcc.target/i386/pr70467-1.c
237@@ -1,6 +1,6 @@
238 /* PR rtl-optimization/70467 */
239 /* { dg-do compile } */
240-/* { dg-options "-O2 -mno-sse" } */
241+/* { dg-options "-O2 -mno-sse -mfpmath=387" } */
242
243 void foo (unsigned long long *);
244
245diff --git a/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c b/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c
246index 6cda1534311..26e37f5b8ba 100644
247--- a/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c
248+++ b/gcc/testsuite/gcc.target/i386/warn-vect-op-1.c
249@@ -1,5 +1,5 @@
250 /* { dg-do compile { target { ! ia32 } } } */
251-/* { dg-options "-mno-sse -Wvector-operation-performance" } */
252+/* { dg-options "-mno-sse -Wvector-operation-performance -mfpmath=387" } */
253 #define vector(elcount, type) \
254 __attribute__((vector_size((elcount)*sizeof(type)))) type
255
diff --git a/meta/recipes-devtools/gcc/gcc/0036-mingw32-Enable-operation_not_supported.patch b/meta/recipes-devtools/gcc/gcc/0036-mingw32-Enable-operation_not_supported.patch
deleted file mode 100644
index de82a3a539..0000000000
--- a/meta/recipes-devtools/gcc/gcc/0036-mingw32-Enable-operation_not_supported.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From 6f87a095f0e696bec07a50df789c9db8bdbca43d Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 12 May 2020 10:39:09 -0700
4Subject: [PATCH] mingw32: Enable operation_not_supported
5
6Fixes nativesdk build errors on mingw32 gcc-runtime
7
8Upstream-Status: Pending
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 libstdc++-v3/config/os/mingw32/error_constants.h | 2 +-
12 1 file changed, 1 insertion(+), 1 deletion(-)
13
14diff --git a/libstdc++-v3/config/os/mingw32/error_constants.h b/libstdc++-v3/config/os/mingw32/error_constants.h
15index 68ac72a78fb..71cd5815b81 100644
16--- a/libstdc++-v3/config/os/mingw32/error_constants.h
17+++ b/libstdc++-v3/config/os/mingw32/error_constants.h
18@@ -107,7 +107,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
19 #ifdef _GLIBCXX_HAVE_EPERM
20 operation_not_permitted = EPERM,
21 #endif
22-// operation_not_supported = EOPNOTSUPP,
23+ operation_not_supported = EOPNOTSUPP,
24 #ifdef _GLIBCXX_HAVE_EWOULDBLOCK
25 operation_would_block = EWOULDBLOCK,
26 #endif
diff --git a/meta/recipes-devtools/gcc/gcc/CVE-2023-4039.patch b/meta/recipes-devtools/gcc/gcc/CVE-2023-4039.patch
new file mode 100644
index 0000000000..81b5067c33
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/CVE-2023-4039.patch
@@ -0,0 +1,3093 @@
1From: Richard Sandiford <richard.sandiford@arm.com>
2Subject: [PATCH 00/19] aarch64: Fix -fstack-protector issue
3Date: Tue, 12 Sep 2023 16:25:10 +0100
4
5This series of patches fixes deficiencies in GCC's -fstack-protector
6implementation for AArch64 when using dynamically allocated stack space.
7This is CVE-2023-4039. See:
8
9https://developer.arm.com/Arm%20Security%20Center/GCC%20Stack%20Protector%20Vulnerability%20AArch64
10https://github.com/metaredteam/external-disclosures/security/advisories/GHSA-x7ch-h5rf-w2mf
11
12for more details.
13
14The fix is to put the saved registers above the locals area when
15-fstack-protector is used.
16
17The series also fixes a stack-clash problem that I found while working
18on the CVE. In unpatched sources, the stack-clash problem would only
19trigger for unrealistic numbers of arguments (8K 64-bit arguments, or an
20equivalent). But it would be a more significant issue with the new
21-fstack-protector frame layout. It's therefore important that both
22problems are fixed together.
23
24Some reorganisation of the code seemed necessary to fix the problems in a
25cleanish way. The series is therefore quite long, but only a handful of
26patches should have any effect on code generation.
27
28See the individual patches for a detailed description.
29
30Tested on aarch64-linux-gnu. Pushed to trunk and to all active branches.
31I've also pushed backports to GCC 7+ to vendors/ARM/heads/CVE-2023-4039.
32
33CVE: CVE-2023-4039
34Upstream-Status: Backport
35Signed-off-by: Ross Burton <ross.burton@arm.com>
36
37
38From 71a2aa2127283f450c623d3604dbcabe0e14a8d4 Mon Sep 17 00:00:00 2001
39From: Richard Sandiford <richard.sandiford@arm.com>
40Date: Tue, 12 Sep 2023 16:07:12 +0100
41Subject: [PATCH 01/19] aarch64: Use local frame vars in shrink-wrapping code
42
43aarch64_layout_frame uses a shorthand for referring to
44cfun->machine->frame:
45
46 aarch64_frame &frame = cfun->machine->frame;
47
48This patch does the same for some other heavy users of the structure.
49No functional change intended.
50
51gcc/
52 * config/aarch64/aarch64.cc (aarch64_save_callee_saves): Use
53 a local shorthand for cfun->machine->frame.
54 (aarch64_restore_callee_saves, aarch64_get_separate_components):
55 (aarch64_process_components): Likewise.
56 (aarch64_allocate_and_probe_stack_space): Likewise.
57 (aarch64_expand_prologue, aarch64_expand_epilogue): Likewise.
58 (aarch64_layout_frame): Use existing shorthand for one more case.
59---
60 gcc/config/aarch64/aarch64.cc | 123 ++++++++++++++++++----------------
61 1 file changed, 64 insertions(+), 59 deletions(-)
62
63diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
64index 822a2b49a46..5d473d161d9 100644
65--- a/gcc/config/aarch64/aarch64.cc
66+++ b/gcc/config/aarch64/aarch64.cc
67@@ -8612,7 +8612,7 @@ aarch64_layout_frame (void)
68 frame.is_scs_enabled
69 = (!crtl->calls_eh_return
70 && sanitize_flags_p (SANITIZE_SHADOW_CALL_STACK)
71- && known_ge (cfun->machine->frame.reg_offset[LR_REGNUM], 0));
72+ && known_ge (frame.reg_offset[LR_REGNUM], 0));
73
74 /* When shadow call stack is enabled, the scs_pop in the epilogue will
75 restore x30, and we don't need to pop x30 again in the traditional
76@@ -9078,6 +9078,7 @@ aarch64_save_callee_saves (poly_int64 start_offset,
77 unsigned start, unsigned limit, bool skip_wb,
78 bool hard_fp_valid_p)
79 {
80+ aarch64_frame &frame = cfun->machine->frame;
81 rtx_insn *insn;
82 unsigned regno;
83 unsigned regno2;
84@@ -9092,8 +9093,8 @@ aarch64_save_callee_saves (poly_int64 start_offset,
85 bool frame_related_p = aarch64_emit_cfi_for_reg_p (regno);
86
87 if (skip_wb
88- && (regno == cfun->machine->frame.wb_push_candidate1
89- || regno == cfun->machine->frame.wb_push_candidate2))
90+ && (regno == frame.wb_push_candidate1
91+ || regno == frame.wb_push_candidate2))
92 continue;
93
94 if (cfun->machine->reg_is_wrapped_separately[regno])
95@@ -9101,7 +9102,7 @@ aarch64_save_callee_saves (poly_int64 start_offset,
96
97 machine_mode mode = aarch64_reg_save_mode (regno);
98 reg = gen_rtx_REG (mode, regno);
99- offset = start_offset + cfun->machine->frame.reg_offset[regno];
100+ offset = start_offset + frame.reg_offset[regno];
101 rtx base_rtx = stack_pointer_rtx;
102 poly_int64 sp_offset = offset;
103
104@@ -9114,7 +9115,7 @@ aarch64_save_callee_saves (poly_int64 start_offset,
105 {
106 gcc_assert (known_eq (start_offset, 0));
107 poly_int64 fp_offset
108- = cfun->machine->frame.below_hard_fp_saved_regs_size;
109+ = frame.below_hard_fp_saved_regs_size;
110 if (hard_fp_valid_p)
111 base_rtx = hard_frame_pointer_rtx;
112 else
113@@ -9136,8 +9137,7 @@ aarch64_save_callee_saves (poly_int64 start_offset,
114 && (regno2 = aarch64_next_callee_save (regno + 1, limit)) <= limit
115 && !cfun->machine->reg_is_wrapped_separately[regno2]
116 && known_eq (GET_MODE_SIZE (mode),
117- cfun->machine->frame.reg_offset[regno2]
118- - cfun->machine->frame.reg_offset[regno]))
119+ frame.reg_offset[regno2] - frame.reg_offset[regno]))
120 {
121 rtx reg2 = gen_rtx_REG (mode, regno2);
122 rtx mem2;
123@@ -9187,6 +9187,7 @@ static void
124 aarch64_restore_callee_saves (poly_int64 start_offset, unsigned start,
125 unsigned limit, bool skip_wb, rtx *cfi_ops)
126 {
127+ aarch64_frame &frame = cfun->machine->frame;
128 unsigned regno;
129 unsigned regno2;
130 poly_int64 offset;
131@@ -9203,13 +9204,13 @@ aarch64_restore_callee_saves (poly_int64 start_offset, unsigned start,
132 rtx reg, mem;
133
134 if (skip_wb
135- && (regno == cfun->machine->frame.wb_pop_candidate1
136- || regno == cfun->machine->frame.wb_pop_candidate2))
137+ && (regno == frame.wb_pop_candidate1
138+ || regno == frame.wb_pop_candidate2))
139 continue;
140
141 machine_mode mode = aarch64_reg_save_mode (regno);
142 reg = gen_rtx_REG (mode, regno);
143- offset = start_offset + cfun->machine->frame.reg_offset[regno];
144+ offset = start_offset + frame.reg_offset[regno];
145 rtx base_rtx = stack_pointer_rtx;
146 if (mode == VNx2DImode && BYTES_BIG_ENDIAN)
147 aarch64_adjust_sve_callee_save_base (mode, base_rtx, anchor_reg,
148@@ -9220,8 +9221,7 @@ aarch64_restore_callee_saves (poly_int64 start_offset, unsigned start,
149 && (regno2 = aarch64_next_callee_save (regno + 1, limit)) <= limit
150 && !cfun->machine->reg_is_wrapped_separately[regno2]
151 && known_eq (GET_MODE_SIZE (mode),
152- cfun->machine->frame.reg_offset[regno2]
153- - cfun->machine->frame.reg_offset[regno]))
154+ frame.reg_offset[regno2] - frame.reg_offset[regno]))
155 {
156 rtx reg2 = gen_rtx_REG (mode, regno2);
157 rtx mem2;
158@@ -9326,6 +9326,7 @@ offset_12bit_unsigned_scaled_p (machine_mode mode, poly_int64 offset)
159 static sbitmap
160 aarch64_get_separate_components (void)
161 {
162+ aarch64_frame &frame = cfun->machine->frame;
163 sbitmap components = sbitmap_alloc (LAST_SAVED_REGNUM + 1);
164 bitmap_clear (components);
165
166@@ -9342,18 +9343,18 @@ aarch64_get_separate_components (void)
167 if (mode == VNx2DImode && BYTES_BIG_ENDIAN)
168 continue;
169
170- poly_int64 offset = cfun->machine->frame.reg_offset[regno];
171+ poly_int64 offset = frame.reg_offset[regno];
172
173 /* If the register is saved in the first SVE save slot, we use
174 it as a stack probe for -fstack-clash-protection. */
175 if (flag_stack_clash_protection
176- && maybe_ne (cfun->machine->frame.below_hard_fp_saved_regs_size, 0)
177+ && maybe_ne (frame.below_hard_fp_saved_regs_size, 0)
178 && known_eq (offset, 0))
179 continue;
180
181 /* Get the offset relative to the register we'll use. */
182 if (frame_pointer_needed)
183- offset -= cfun->machine->frame.below_hard_fp_saved_regs_size;
184+ offset -= frame.below_hard_fp_saved_regs_size;
185 else
186 offset += crtl->outgoing_args_size;
187
188@@ -9372,11 +9373,11 @@ aarch64_get_separate_components (void)
189 /* If the spare predicate register used by big-endian SVE code
190 is call-preserved, it must be saved in the main prologue
191 before any saves that use it. */
192- if (cfun->machine->frame.spare_pred_reg != INVALID_REGNUM)
193- bitmap_clear_bit (components, cfun->machine->frame.spare_pred_reg);
194+ if (frame.spare_pred_reg != INVALID_REGNUM)
195+ bitmap_clear_bit (components, frame.spare_pred_reg);
196
197- unsigned reg1 = cfun->machine->frame.wb_push_candidate1;
198- unsigned reg2 = cfun->machine->frame.wb_push_candidate2;
199+ unsigned reg1 = frame.wb_push_candidate1;
200+ unsigned reg2 = frame.wb_push_candidate2;
201 /* If registers have been chosen to be stored/restored with
202 writeback don't interfere with them to avoid having to output explicit
203 stack adjustment instructions. */
204@@ -9485,6 +9486,7 @@ aarch64_get_next_set_bit (sbitmap bmp, unsigned int start)
205 static void
206 aarch64_process_components (sbitmap components, bool prologue_p)
207 {
208+ aarch64_frame &frame = cfun->machine->frame;
209 rtx ptr_reg = gen_rtx_REG (Pmode, frame_pointer_needed
210 ? HARD_FRAME_POINTER_REGNUM
211 : STACK_POINTER_REGNUM);
212@@ -9499,9 +9501,9 @@ aarch64_process_components (sbitmap components, bool prologue_p)
213 machine_mode mode = aarch64_reg_save_mode (regno);
214
215 rtx reg = gen_rtx_REG (mode, regno);
216- poly_int64 offset = cfun->machine->frame.reg_offset[regno];
217+ poly_int64 offset = frame.reg_offset[regno];
218 if (frame_pointer_needed)
219- offset -= cfun->machine->frame.below_hard_fp_saved_regs_size;
220+ offset -= frame.below_hard_fp_saved_regs_size;
221 else
222 offset += crtl->outgoing_args_size;
223
224@@ -9526,14 +9528,14 @@ aarch64_process_components (sbitmap components, bool prologue_p)
225 break;
226 }
227
228- poly_int64 offset2 = cfun->machine->frame.reg_offset[regno2];
229+ poly_int64 offset2 = frame.reg_offset[regno2];
230 /* The next register is not of the same class or its offset is not
231 mergeable with the current one into a pair. */
232 if (aarch64_sve_mode_p (mode)
233 || !satisfies_constraint_Ump (mem)
234 || GP_REGNUM_P (regno) != GP_REGNUM_P (regno2)
235 || (crtl->abi->id () == ARM_PCS_SIMD && FP_REGNUM_P (regno))
236- || maybe_ne ((offset2 - cfun->machine->frame.reg_offset[regno]),
237+ || maybe_ne ((offset2 - frame.reg_offset[regno]),
238 GET_MODE_SIZE (mode)))
239 {
240 insn = emit_insn (set);
241@@ -9555,7 +9557,7 @@ aarch64_process_components (sbitmap components, bool prologue_p)
242 /* REGNO2 can be saved/restored in a pair with REGNO. */
243 rtx reg2 = gen_rtx_REG (mode, regno2);
244 if (frame_pointer_needed)
245- offset2 -= cfun->machine->frame.below_hard_fp_saved_regs_size;
246+ offset2 -= frame.below_hard_fp_saved_regs_size;
247 else
248 offset2 += crtl->outgoing_args_size;
249 rtx addr2 = plus_constant (Pmode, ptr_reg, offset2);
250@@ -9650,6 +9652,7 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
251 bool frame_related_p,
252 bool final_adjustment_p)
253 {
254+ aarch64_frame &frame = cfun->machine->frame;
255 HOST_WIDE_INT guard_size
256 = 1 << param_stack_clash_protection_guard_size;
257 HOST_WIDE_INT guard_used_by_caller = STACK_CLASH_CALLER_GUARD;
258@@ -9670,25 +9673,25 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
259 register as a probe. We can't assume that LR was saved at position 0
260 though, so treat any space below it as unprobed. */
261 if (final_adjustment_p
262- && known_eq (cfun->machine->frame.below_hard_fp_saved_regs_size, 0))
263+ && known_eq (frame.below_hard_fp_saved_regs_size, 0))
264 {
265- poly_int64 lr_offset = cfun->machine->frame.reg_offset[LR_REGNUM];
266+ poly_int64 lr_offset = frame.reg_offset[LR_REGNUM];
267 if (known_ge (lr_offset, 0))
268 min_probe_threshold -= lr_offset.to_constant ();
269 else
270 gcc_assert (!flag_stack_clash_protection || known_eq (poly_size, 0));
271 }
272
273- poly_int64 frame_size = cfun->machine->frame.frame_size;
274+ poly_int64 frame_size = frame.frame_size;
275
276 /* We should always have a positive probe threshold. */
277 gcc_assert (min_probe_threshold > 0);
278
279 if (flag_stack_clash_protection && !final_adjustment_p)
280 {
281- poly_int64 initial_adjust = cfun->machine->frame.initial_adjust;
282- poly_int64 sve_callee_adjust = cfun->machine->frame.sve_callee_adjust;
283- poly_int64 final_adjust = cfun->machine->frame.final_adjust;
284+ poly_int64 initial_adjust = frame.initial_adjust;
285+ poly_int64 sve_callee_adjust = frame.sve_callee_adjust;
286+ poly_int64 final_adjust = frame.final_adjust;
287
288 if (known_eq (frame_size, 0))
289 {
290@@ -9977,17 +9980,18 @@ aarch64_epilogue_uses (int regno)
291 void
292 aarch64_expand_prologue (void)
293 {
294- poly_int64 frame_size = cfun->machine->frame.frame_size;
295- poly_int64 initial_adjust = cfun->machine->frame.initial_adjust;
296- HOST_WIDE_INT callee_adjust = cfun->machine->frame.callee_adjust;
297- poly_int64 final_adjust = cfun->machine->frame.final_adjust;
298- poly_int64 callee_offset = cfun->machine->frame.callee_offset;
299- poly_int64 sve_callee_adjust = cfun->machine->frame.sve_callee_adjust;
300+ aarch64_frame &frame = cfun->machine->frame;
301+ poly_int64 frame_size = frame.frame_size;
302+ poly_int64 initial_adjust = frame.initial_adjust;
303+ HOST_WIDE_INT callee_adjust = frame.callee_adjust;
304+ poly_int64 final_adjust = frame.final_adjust;
305+ poly_int64 callee_offset = frame.callee_offset;
306+ poly_int64 sve_callee_adjust = frame.sve_callee_adjust;
307 poly_int64 below_hard_fp_saved_regs_size
308- = cfun->machine->frame.below_hard_fp_saved_regs_size;
309- unsigned reg1 = cfun->machine->frame.wb_push_candidate1;
310- unsigned reg2 = cfun->machine->frame.wb_push_candidate2;
311- bool emit_frame_chain = cfun->machine->frame.emit_frame_chain;
312+ = frame.below_hard_fp_saved_regs_size;
313+ unsigned reg1 = frame.wb_push_candidate1;
314+ unsigned reg2 = frame.wb_push_candidate2;
315+ bool emit_frame_chain = frame.emit_frame_chain;
316 rtx_insn *insn;
317
318 if (flag_stack_clash_protection && known_eq (callee_adjust, 0))
319@@ -10018,7 +10022,7 @@ aarch64_expand_prologue (void)
320 }
321
322 /* Push return address to shadow call stack. */
323- if (cfun->machine->frame.is_scs_enabled)
324+ if (frame.is_scs_enabled)
325 emit_insn (gen_scs_push ());
326
327 if (flag_stack_usage_info)
328@@ -10057,7 +10061,7 @@ aarch64_expand_prologue (void)
329
330 /* The offset of the frame chain record (if any) from the current SP. */
331 poly_int64 chain_offset = (initial_adjust + callee_adjust
332- - cfun->machine->frame.hard_fp_offset);
333+ - frame.hard_fp_offset);
334 gcc_assert (known_ge (chain_offset, 0));
335
336 /* The offset of the bottom of the save area from the current SP. */
337@@ -10160,16 +10164,17 @@ aarch64_use_return_insn_p (void)
338 void
339 aarch64_expand_epilogue (bool for_sibcall)
340 {
341- poly_int64 initial_adjust = cfun->machine->frame.initial_adjust;
342- HOST_WIDE_INT callee_adjust = cfun->machine->frame.callee_adjust;
343- poly_int64 final_adjust = cfun->machine->frame.final_adjust;
344- poly_int64 callee_offset = cfun->machine->frame.callee_offset;
345- poly_int64 sve_callee_adjust = cfun->machine->frame.sve_callee_adjust;
346+ aarch64_frame &frame = cfun->machine->frame;
347+ poly_int64 initial_adjust = frame.initial_adjust;
348+ HOST_WIDE_INT callee_adjust = frame.callee_adjust;
349+ poly_int64 final_adjust = frame.final_adjust;
350+ poly_int64 callee_offset = frame.callee_offset;
351+ poly_int64 sve_callee_adjust = frame.sve_callee_adjust;
352 poly_int64 below_hard_fp_saved_regs_size
353- = cfun->machine->frame.below_hard_fp_saved_regs_size;
354- unsigned reg1 = cfun->machine->frame.wb_pop_candidate1;
355- unsigned reg2 = cfun->machine->frame.wb_pop_candidate2;
356- unsigned int last_gpr = (cfun->machine->frame.is_scs_enabled
357+ = frame.below_hard_fp_saved_regs_size;
358+ unsigned reg1 = frame.wb_pop_candidate1;
359+ unsigned reg2 = frame.wb_pop_candidate2;
360+ unsigned int last_gpr = (frame.is_scs_enabled
361 ? R29_REGNUM : R30_REGNUM);
362 rtx cfi_ops = NULL;
363 rtx_insn *insn;
364@@ -10203,7 +10208,7 @@ aarch64_expand_epilogue (bool for_sibcall)
365 /* We need to add memory barrier to prevent read from deallocated stack. */
366 bool need_barrier_p
367 = maybe_ne (get_frame_size ()
368- + cfun->machine->frame.saved_varargs_size, 0);
369+ + frame.saved_varargs_size, 0);
370
371 /* Emit a barrier to prevent loads from a deallocated stack. */
372 if (maybe_gt (final_adjust, crtl->outgoing_args_size)
373@@ -10284,7 +10289,7 @@ aarch64_expand_epilogue (bool for_sibcall)
374 }
375
376 /* Pop return address from shadow call stack. */
377- if (cfun->machine->frame.is_scs_enabled)
378+ if (frame.is_scs_enabled)
379 {
380 machine_mode mode = aarch64_reg_save_mode (R30_REGNUM);
381 rtx reg = gen_rtx_REG (mode, R30_REGNUM);
382@@ -12740,24 +12745,24 @@ aarch64_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to)
383 poly_int64
384 aarch64_initial_elimination_offset (unsigned from, unsigned to)
385 {
386+ aarch64_frame &frame = cfun->machine->frame;
387+
388 if (to == HARD_FRAME_POINTER_REGNUM)
389 {
390 if (from == ARG_POINTER_REGNUM)
391- return cfun->machine->frame.hard_fp_offset;
392+ return frame.hard_fp_offset;
393
394 if (from == FRAME_POINTER_REGNUM)
395- return cfun->machine->frame.hard_fp_offset
396- - cfun->machine->frame.locals_offset;
397+ return frame.hard_fp_offset - frame.locals_offset;
398 }
399
400 if (to == STACK_POINTER_REGNUM)
401 {
402 if (from == FRAME_POINTER_REGNUM)
403- return cfun->machine->frame.frame_size
404- - cfun->machine->frame.locals_offset;
405+ return frame.frame_size - frame.locals_offset;
406 }
407
408- return cfun->machine->frame.frame_size;
409+ return frame.frame_size;
410 }
411
412
413--
4142.34.1
415
416
417From 89a9fa287706c5011f61926eaf65e7b996b963a3 Mon Sep 17 00:00:00 2001
418From: Richard Sandiford <richard.sandiford@arm.com>
419Date: Tue, 12 Sep 2023 16:07:12 +0100
420Subject: [PATCH 02/19] aarch64: Avoid a use of callee_offset
421
422When we emit the frame chain, i.e. when we reach Here in this statement
423of aarch64_expand_prologue:
424
425 if (emit_frame_chain)
426 {
427 // Here
428 ...
429 }
430
431the stack is in one of two states:
432
433- We've allocated up to the frame chain, but no more.
434
435- We've allocated the whole frame, and the frame chain is within easy
436 reach of the new SP.
437
438The offset of the frame chain from the current SP is available
439in aarch64_frame as callee_offset. It is also available as the
440chain_offset local variable, where the latter is calculated from other
441data. (However, chain_offset is not always equal to callee_offset when
442!emit_frame_chain, so chain_offset isn't redundant.)
443
444In c600df9a4060da3c6121ff4d0b93f179eafd69d1 I switched to using
445chain_offset for the initialisation of the hard frame pointer:
446
447 aarch64_add_offset (Pmode, hard_frame_pointer_rtx,
448- stack_pointer_rtx, callee_offset,
449+ stack_pointer_rtx, chain_offset,
450 tmp1_rtx, tmp0_rtx, frame_pointer_needed);
451
452But the later REG_CFA_ADJUST_CFA handling still used callee_offset.
453
454I think the difference is harmless, but it's more logical for the
455CFA note to be in sync, and it's more convenient for later patches
456if it uses chain_offset.
457
458gcc/
459 * config/aarch64/aarch64.cc (aarch64_expand_prologue): Use
460 chain_offset rather than callee_offset.
461---
462 gcc/config/aarch64/aarch64.cc | 4 +---
463 1 file changed, 1 insertion(+), 3 deletions(-)
464
465diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
466index 5d473d161d9..4f233c95140 100644
467--- a/gcc/config/aarch64/aarch64.cc
468+++ b/gcc/config/aarch64/aarch64.cc
469@@ -9985,7 +9985,6 @@ aarch64_expand_prologue (void)
470 poly_int64 initial_adjust = frame.initial_adjust;
471 HOST_WIDE_INT callee_adjust = frame.callee_adjust;
472 poly_int64 final_adjust = frame.final_adjust;
473- poly_int64 callee_offset = frame.callee_offset;
474 poly_int64 sve_callee_adjust = frame.sve_callee_adjust;
475 poly_int64 below_hard_fp_saved_regs_size
476 = frame.below_hard_fp_saved_regs_size;
477@@ -10098,8 +10097,7 @@ aarch64_expand_prologue (void)
478 implicit. */
479 if (!find_reg_note (insn, REG_CFA_ADJUST_CFA, NULL_RTX))
480 {
481- rtx src = plus_constant (Pmode, stack_pointer_rtx,
482- callee_offset);
483+ rtx src = plus_constant (Pmode, stack_pointer_rtx, chain_offset);
484 add_reg_note (insn, REG_CFA_ADJUST_CFA,
485 gen_rtx_SET (hard_frame_pointer_rtx, src));
486 }
487--
4882.34.1
489
490
491From b36a2a78040722dab6124366c5d6baf8eaf80aef Mon Sep 17 00:00:00 2001
492From: Richard Sandiford <richard.sandiford@arm.com>
493Date: Tue, 12 Sep 2023 16:07:13 +0100
494Subject: [PATCH 03/19] aarch64: Explicitly handle frames with no saved
495 registers
496
497If a frame has no saved registers, it can be allocated in one go.
498There is no need to treat the areas below and above the saved
499registers as separate.
500
501And if we allocate the frame in one go, it should be allocated
502as the initial_adjust rather than the final_adjust. This allows the
503frame size to grow to guard_size - guard_used_by_caller before a stack
504probe is needed. (A frame with no register saves is necessarily a
505leaf frame.)
506
507This is a no-op as thing stand, since a leaf function will have
508no outgoing arguments, and so all the frame will be above where
509the saved registers normally go.
510
511gcc/
512 * config/aarch64/aarch64.cc (aarch64_layout_frame): Explicitly
513 allocate the frame in one go if there are no saved registers.
514---
515 gcc/config/aarch64/aarch64.cc | 8 +++++---
516 1 file changed, 5 insertions(+), 3 deletions(-)
517
518diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
519index 4f233c95140..37643041ffb 100644
520--- a/gcc/config/aarch64/aarch64.cc
521+++ b/gcc/config/aarch64/aarch64.cc
522@@ -8639,9 +8639,11 @@ aarch64_layout_frame (void)
523
524 HOST_WIDE_INT const_size, const_outgoing_args_size, const_fp_offset;
525 HOST_WIDE_INT const_saved_regs_size;
526- if (frame.frame_size.is_constant (&const_size)
527- && const_size < max_push_offset
528- && known_eq (frame.hard_fp_offset, const_size))
529+ if (known_eq (frame.saved_regs_size, 0))
530+ frame.initial_adjust = frame.frame_size;
531+ else if (frame.frame_size.is_constant (&const_size)
532+ && const_size < max_push_offset
533+ && known_eq (frame.hard_fp_offset, const_size))
534 {
535 /* Simple, small frame with no outgoing arguments:
536
537--
5382.34.1
539
540
541From ada2ab0093596be707f23a3466ac82cff59fcffe Mon Sep 17 00:00:00 2001
542From: Richard Sandiford <richard.sandiford@arm.com>
543Date: Tue, 12 Sep 2023 16:07:13 +0100
544Subject: [PATCH 04/19] aarch64: Add bytes_below_saved_regs to frame info
545
546The frame layout code currently hard-codes the assumption that
547the number of bytes below the saved registers is equal to the
548size of the outgoing arguments. This patch abstracts that
549value into a new field of aarch64_frame.
550
551gcc/
552 * config/aarch64/aarch64.h (aarch64_frame::bytes_below_saved_regs): New
553 field.
554 * config/aarch64/aarch64.cc (aarch64_layout_frame): Initialize it,
555 and use it instead of crtl->outgoing_args_size.
556 (aarch64_get_separate_components): Use bytes_below_saved_regs instead
557 of outgoing_args_size.
558 (aarch64_process_components): Likewise.
559---
560 gcc/config/aarch64/aarch64.cc | 71 ++++++++++++++++++-----------------
561 gcc/config/aarch64/aarch64.h | 5 +++
562 2 files changed, 41 insertions(+), 35 deletions(-)
563
564diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
565index 37643041ffb..dacc2b0e4dd 100644
566--- a/gcc/config/aarch64/aarch64.cc
567+++ b/gcc/config/aarch64/aarch64.cc
568@@ -8478,6 +8478,8 @@ aarch64_layout_frame (void)
569 gcc_assert (crtl->is_leaf
570 || maybe_ne (frame.reg_offset[R30_REGNUM], SLOT_NOT_REQUIRED));
571
572+ frame.bytes_below_saved_regs = crtl->outgoing_args_size;
573+
574 /* Now assign stack slots for the registers. Start with the predicate
575 registers, since predicate LDR and STR have a relatively small
576 offset range. These saves happen below the hard frame pointer. */
577@@ -8582,18 +8584,18 @@ aarch64_layout_frame (void)
578
579 poly_int64 varargs_and_saved_regs_size = offset + frame.saved_varargs_size;
580
581- poly_int64 above_outgoing_args
582+ poly_int64 saved_regs_and_above
583 = aligned_upper_bound (varargs_and_saved_regs_size
584 + get_frame_size (),
585 STACK_BOUNDARY / BITS_PER_UNIT);
586
587 frame.hard_fp_offset
588- = above_outgoing_args - frame.below_hard_fp_saved_regs_size;
589+ = saved_regs_and_above - frame.below_hard_fp_saved_regs_size;
590
591 /* Both these values are already aligned. */
592- gcc_assert (multiple_p (crtl->outgoing_args_size,
593+ gcc_assert (multiple_p (frame.bytes_below_saved_regs,
594 STACK_BOUNDARY / BITS_PER_UNIT));
595- frame.frame_size = above_outgoing_args + crtl->outgoing_args_size;
596+ frame.frame_size = saved_regs_and_above + frame.bytes_below_saved_regs;
597
598 frame.locals_offset = frame.saved_varargs_size;
599
600@@ -8637,7 +8639,7 @@ aarch64_layout_frame (void)
601 else if (frame.wb_pop_candidate1 != INVALID_REGNUM)
602 max_push_offset = 256;
603
604- HOST_WIDE_INT const_size, const_outgoing_args_size, const_fp_offset;
605+ HOST_WIDE_INT const_size, const_below_saved_regs, const_fp_offset;
606 HOST_WIDE_INT const_saved_regs_size;
607 if (known_eq (frame.saved_regs_size, 0))
608 frame.initial_adjust = frame.frame_size;
609@@ -8645,31 +8647,31 @@ aarch64_layout_frame (void)
610 && const_size < max_push_offset
611 && known_eq (frame.hard_fp_offset, const_size))
612 {
613- /* Simple, small frame with no outgoing arguments:
614+ /* Simple, small frame with no data below the saved registers.
615
616 stp reg1, reg2, [sp, -frame_size]!
617 stp reg3, reg4, [sp, 16] */
618 frame.callee_adjust = const_size;
619 }
620- else if (crtl->outgoing_args_size.is_constant (&const_outgoing_args_size)
621+ else if (frame.bytes_below_saved_regs.is_constant (&const_below_saved_regs)
622 && frame.saved_regs_size.is_constant (&const_saved_regs_size)
623- && const_outgoing_args_size + const_saved_regs_size < 512
624- /* We could handle this case even with outgoing args, provided
625- that the number of args left us with valid offsets for all
626- predicate and vector save slots. It's such a rare case that
627- it hardly seems worth the effort though. */
628- && (!saves_below_hard_fp_p || const_outgoing_args_size == 0)
629+ && const_below_saved_regs + const_saved_regs_size < 512
630+ /* We could handle this case even with data below the saved
631+ registers, provided that that data left us with valid offsets
632+ for all predicate and vector save slots. It's such a rare
633+ case that it hardly seems worth the effort though. */
634+ && (!saves_below_hard_fp_p || const_below_saved_regs == 0)
635 && !(cfun->calls_alloca
636 && frame.hard_fp_offset.is_constant (&const_fp_offset)
637 && const_fp_offset < max_push_offset))
638 {
639- /* Frame with small outgoing arguments:
640+ /* Frame with small area below the saved registers:
641
642 sub sp, sp, frame_size
643- stp reg1, reg2, [sp, outgoing_args_size]
644- stp reg3, reg4, [sp, outgoing_args_size + 16] */
645+ stp reg1, reg2, [sp, bytes_below_saved_regs]
646+ stp reg3, reg4, [sp, bytes_below_saved_regs + 16] */
647 frame.initial_adjust = frame.frame_size;
648- frame.callee_offset = const_outgoing_args_size;
649+ frame.callee_offset = const_below_saved_regs;
650 }
651 else if (saves_below_hard_fp_p
652 && known_eq (frame.saved_regs_size,
653@@ -8679,30 +8681,29 @@ aarch64_layout_frame (void)
654
655 sub sp, sp, hard_fp_offset + below_hard_fp_saved_regs_size
656 save SVE registers relative to SP
657- sub sp, sp, outgoing_args_size */
658+ sub sp, sp, bytes_below_saved_regs */
659 frame.initial_adjust = (frame.hard_fp_offset
660 + frame.below_hard_fp_saved_regs_size);
661- frame.final_adjust = crtl->outgoing_args_size;
662+ frame.final_adjust = frame.bytes_below_saved_regs;
663 }
664 else if (frame.hard_fp_offset.is_constant (&const_fp_offset)
665 && const_fp_offset < max_push_offset)
666 {
667- /* Frame with large outgoing arguments or SVE saves, but with
668- a small local area:
669+ /* Frame with large area below the saved registers, or with SVE saves,
670+ but with a small area above:
671
672 stp reg1, reg2, [sp, -hard_fp_offset]!
673 stp reg3, reg4, [sp, 16]
674 [sub sp, sp, below_hard_fp_saved_regs_size]
675 [save SVE registers relative to SP]
676- sub sp, sp, outgoing_args_size */
677+ sub sp, sp, bytes_below_saved_regs */
678 frame.callee_adjust = const_fp_offset;
679 frame.sve_callee_adjust = frame.below_hard_fp_saved_regs_size;
680- frame.final_adjust = crtl->outgoing_args_size;
681+ frame.final_adjust = frame.bytes_below_saved_regs;
682 }
683 else
684 {
685- /* Frame with large local area and outgoing arguments or SVE saves,
686- using frame pointer:
687+ /* General case:
688
689 sub sp, sp, hard_fp_offset
690 stp x29, x30, [sp, 0]
691@@ -8710,10 +8711,10 @@ aarch64_layout_frame (void)
692 stp reg3, reg4, [sp, 16]
693 [sub sp, sp, below_hard_fp_saved_regs_size]
694 [save SVE registers relative to SP]
695- sub sp, sp, outgoing_args_size */
696+ sub sp, sp, bytes_below_saved_regs */
697 frame.initial_adjust = frame.hard_fp_offset;
698 frame.sve_callee_adjust = frame.below_hard_fp_saved_regs_size;
699- frame.final_adjust = crtl->outgoing_args_size;
700+ frame.final_adjust = frame.bytes_below_saved_regs;
701 }
702
703 /* Make sure the individual adjustments add up to the full frame size. */
704@@ -9358,7 +9359,7 @@ aarch64_get_separate_components (void)
705 if (frame_pointer_needed)
706 offset -= frame.below_hard_fp_saved_regs_size;
707 else
708- offset += crtl->outgoing_args_size;
709+ offset += frame.bytes_below_saved_regs;
710
711 /* Check that we can access the stack slot of the register with one
712 direct load with no adjustments needed. */
713@@ -9507,7 +9508,7 @@ aarch64_process_components (sbitmap components, bool prologue_p)
714 if (frame_pointer_needed)
715 offset -= frame.below_hard_fp_saved_regs_size;
716 else
717- offset += crtl->outgoing_args_size;
718+ offset += frame.bytes_below_saved_regs;
719
720 rtx addr = plus_constant (Pmode, ptr_reg, offset);
721 rtx mem = gen_frame_mem (mode, addr);
722@@ -9561,7 +9562,7 @@ aarch64_process_components (sbitmap components, bool prologue_p)
723 if (frame_pointer_needed)
724 offset2 -= frame.below_hard_fp_saved_regs_size;
725 else
726- offset2 += crtl->outgoing_args_size;
727+ offset2 += frame.bytes_below_saved_regs;
728 rtx addr2 = plus_constant (Pmode, ptr_reg, offset2);
729 rtx mem2 = gen_frame_mem (mode, addr2);
730 rtx set2 = prologue_p ? gen_rtx_SET (mem2, reg2)
731@@ -9635,10 +9636,10 @@ aarch64_stack_clash_protection_alloca_probe_range (void)
732 registers. If POLY_SIZE is not large enough to require a probe this function
733 will only adjust the stack. When allocating the stack space
734 FRAME_RELATED_P is then used to indicate if the allocation is frame related.
735- FINAL_ADJUSTMENT_P indicates whether we are allocating the outgoing
736- arguments. If we are then we ensure that any allocation larger than the ABI
737- defined buffer needs a probe so that the invariant of having a 1KB buffer is
738- maintained.
739+ FINAL_ADJUSTMENT_P indicates whether we are allocating the area below
740+ the saved registers. If we are then we ensure that any allocation
741+ larger than the ABI defined buffer needs a probe so that the
742+ invariant of having a 1KB buffer is maintained.
743
744 We emit barriers after each stack adjustment to prevent optimizations from
745 breaking the invariant that we never drop the stack more than a page. This
746@@ -9847,7 +9848,7 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
747 /* Handle any residuals. Residuals of at least MIN_PROBE_THRESHOLD have to
748 be probed. This maintains the requirement that each page is probed at
749 least once. For initial probing we probe only if the allocation is
750- more than GUARD_SIZE - buffer, and for the outgoing arguments we probe
751+ more than GUARD_SIZE - buffer, and below the saved registers we probe
752 if the amount is larger than buffer. GUARD_SIZE - buffer + buffer ==
753 GUARD_SIZE. This works that for any allocation that is large enough to
754 trigger a probe here, we'll have at least one, and if they're not large
755diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
756index 73b09e20508..0b6faa3ddf1 100644
757--- a/gcc/config/aarch64/aarch64.h
758+++ b/gcc/config/aarch64/aarch64.h
759@@ -777,6 +777,11 @@ struct GTY (()) aarch64_frame
760 /* The size of the callee-save registers with a slot in REG_OFFSET. */
761 poly_int64 saved_regs_size;
762
763+ /* The number of bytes between the bottom of the static frame (the bottom
764+ of the outgoing arguments) and the bottom of the register save area.
765+ This value is always a multiple of STACK_BOUNDARY. */
766+ poly_int64 bytes_below_saved_regs;
767+
768 /* The size of the callee-save registers with a slot in REG_OFFSET that
769 are saved below the hard frame pointer. */
770 poly_int64 below_hard_fp_saved_regs_size;
771--
7722.34.1
773
774
775From 82f6b3e1b596ef0f4e3ac3bb9c6e88fb4458f402 Mon Sep 17 00:00:00 2001
776From: Richard Sandiford <richard.sandiford@arm.com>
777Date: Tue, 12 Sep 2023 16:07:14 +0100
778Subject: [PATCH 05/19] aarch64: Add bytes_below_hard_fp to frame info
779
780Following on from the previous bytes_below_saved_regs patch, this one
781records the number of bytes that are below the hard frame pointer.
782This eventually replaces below_hard_fp_saved_regs_size.
783
784If a frame pointer is not needed, the epilogue adds final_adjust
785to the stack pointer before restoring registers:
786
787 aarch64_add_sp (tmp1_rtx, tmp0_rtx, final_adjust, true);
788
789Therefore, if the epilogue needs to restore the stack pointer from
790the hard frame pointer, the directly corresponding offset is:
791
792 -bytes_below_hard_fp + final_adjust
793
794i.e. go from the hard frame pointer to the bottom of the frame,
795then add the same amount as if we were using the stack pointer
796from the outset.
797
798gcc/
799 * config/aarch64/aarch64.h (aarch64_frame::bytes_below_hard_fp): New
800 field.
801 * config/aarch64/aarch64.cc (aarch64_layout_frame): Initialize it.
802 (aarch64_expand_epilogue): Use it instead of
803 below_hard_fp_saved_regs_size.
804---
805 gcc/config/aarch64/aarch64.cc | 6 +++---
806 gcc/config/aarch64/aarch64.h | 5 +++++
807 2 files changed, 8 insertions(+), 3 deletions(-)
808
809diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
810index dacc2b0e4dd..a3f7aabcc59 100644
811--- a/gcc/config/aarch64/aarch64.cc
812+++ b/gcc/config/aarch64/aarch64.cc
813@@ -8530,6 +8530,7 @@ aarch64_layout_frame (void)
814 of the callee save area. */
815 bool saves_below_hard_fp_p = maybe_ne (offset, 0);
816 frame.below_hard_fp_saved_regs_size = offset;
817+ frame.bytes_below_hard_fp = offset + frame.bytes_below_saved_regs;
818 if (frame.emit_frame_chain)
819 {
820 /* FP and LR are placed in the linkage record. */
821@@ -10171,8 +10172,7 @@ aarch64_expand_epilogue (bool for_sibcall)
822 poly_int64 final_adjust = frame.final_adjust;
823 poly_int64 callee_offset = frame.callee_offset;
824 poly_int64 sve_callee_adjust = frame.sve_callee_adjust;
825- poly_int64 below_hard_fp_saved_regs_size
826- = frame.below_hard_fp_saved_regs_size;
827+ poly_int64 bytes_below_hard_fp = frame.bytes_below_hard_fp;
828 unsigned reg1 = frame.wb_pop_candidate1;
829 unsigned reg2 = frame.wb_pop_candidate2;
830 unsigned int last_gpr = (frame.is_scs_enabled
831@@ -10230,7 +10230,7 @@ aarch64_expand_epilogue (bool for_sibcall)
832 is restored on the instruction doing the writeback. */
833 aarch64_add_offset (Pmode, stack_pointer_rtx,
834 hard_frame_pointer_rtx,
835- -callee_offset - below_hard_fp_saved_regs_size,
836+ -bytes_below_hard_fp + final_adjust,
837 tmp1_rtx, tmp0_rtx, callee_adjust == 0);
838 else
839 /* The case where we need to re-use the register here is very rare, so
840diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
841index 0b6faa3ddf1..4263d29d29d 100644
842--- a/gcc/config/aarch64/aarch64.h
843+++ b/gcc/config/aarch64/aarch64.h
844@@ -786,6 +786,11 @@ struct GTY (()) aarch64_frame
845 are saved below the hard frame pointer. */
846 poly_int64 below_hard_fp_saved_regs_size;
847
848+ /* The number of bytes between the bottom of the static frame (the bottom
849+ of the outgoing arguments) and the hard frame pointer. This value is
850+ always a multiple of STACK_BOUNDARY. */
851+ poly_int64 bytes_below_hard_fp;
852+
853 /* Offset from the base of the frame (incomming SP) to the
854 top of the locals area. This value is always a multiple of
855 STACK_BOUNDARY. */
856--
8572.34.1
858
859
860From 86fa43e9fe4a8bf954f2919f07cbe3646d1d1df3 Mon Sep 17 00:00:00 2001
861From: Richard Sandiford <richard.sandiford@arm.com>
862Date: Tue, 12 Sep 2023 16:07:14 +0100
863Subject: [PATCH 06/19] aarch64: Tweak aarch64_save/restore_callee_saves
864
865aarch64_save_callee_saves and aarch64_restore_callee_saves took
866a parameter called start_offset that gives the offset of the
867bottom of the saved register area from the current stack pointer.
868However, it's more convenient for later patches if we use the
869bottom of the entire frame as the reference point, rather than
870the bottom of the saved registers.
871
872Doing that removes the need for the callee_offset field.
873Other than that, this is not a win on its own. It only really
874makes sense in combination with the follow-on patches.
875
876gcc/
877 * config/aarch64/aarch64.h (aarch64_frame::callee_offset): Delete.
878 * config/aarch64/aarch64.cc (aarch64_layout_frame): Remove
879 callee_offset handling.
880 (aarch64_save_callee_saves): Replace the start_offset parameter
881 with a bytes_below_sp parameter.
882 (aarch64_restore_callee_saves): Likewise.
883 (aarch64_expand_prologue): Update accordingly.
884 (aarch64_expand_epilogue): Likewise.
885---
886 gcc/config/aarch64/aarch64.cc | 56 +++++++++++++++++------------------
887 gcc/config/aarch64/aarch64.h | 4 ---
888 2 files changed, 28 insertions(+), 32 deletions(-)
889
890diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
891index a3f7aabcc59..46ae5cf7673 100644
892--- a/gcc/config/aarch64/aarch64.cc
893+++ b/gcc/config/aarch64/aarch64.cc
894@@ -8604,7 +8604,6 @@ aarch64_layout_frame (void)
895 frame.final_adjust = 0;
896 frame.callee_adjust = 0;
897 frame.sve_callee_adjust = 0;
898- frame.callee_offset = 0;
899
900 frame.wb_pop_candidate1 = frame.wb_push_candidate1;
901 frame.wb_pop_candidate2 = frame.wb_push_candidate2;
902@@ -8672,7 +8671,6 @@ aarch64_layout_frame (void)
903 stp reg1, reg2, [sp, bytes_below_saved_regs]
904 stp reg3, reg4, [sp, bytes_below_saved_regs + 16] */
905 frame.initial_adjust = frame.frame_size;
906- frame.callee_offset = const_below_saved_regs;
907 }
908 else if (saves_below_hard_fp_p
909 && known_eq (frame.saved_regs_size,
910@@ -9073,12 +9071,13 @@ aarch64_add_cfa_expression (rtx_insn *insn, rtx reg,
911 }
912
913 /* Emit code to save the callee-saved registers from register number START
914- to LIMIT to the stack at the location starting at offset START_OFFSET,
915- skipping any write-back candidates if SKIP_WB is true. HARD_FP_VALID_P
916- is true if the hard frame pointer has been set up. */
917+ to LIMIT to the stack. The stack pointer is currently BYTES_BELOW_SP
918+ bytes above the bottom of the static frame. Skip any write-back
919+ candidates if SKIP_WB is true. HARD_FP_VALID_P is true if the hard
920+ frame pointer has been set up. */
921
922 static void
923-aarch64_save_callee_saves (poly_int64 start_offset,
924+aarch64_save_callee_saves (poly_int64 bytes_below_sp,
925 unsigned start, unsigned limit, bool skip_wb,
926 bool hard_fp_valid_p)
927 {
928@@ -9106,7 +9105,9 @@ aarch64_save_callee_saves (poly_int64 start_offset,
929
930 machine_mode mode = aarch64_reg_save_mode (regno);
931 reg = gen_rtx_REG (mode, regno);
932- offset = start_offset + frame.reg_offset[regno];
933+ offset = (frame.reg_offset[regno]
934+ + frame.bytes_below_saved_regs
935+ - bytes_below_sp);
936 rtx base_rtx = stack_pointer_rtx;
937 poly_int64 sp_offset = offset;
938
939@@ -9117,9 +9118,7 @@ aarch64_save_callee_saves (poly_int64 start_offset,
940 else if (GP_REGNUM_P (regno)
941 && (!offset.is_constant (&const_offset) || const_offset >= 512))
942 {
943- gcc_assert (known_eq (start_offset, 0));
944- poly_int64 fp_offset
945- = frame.below_hard_fp_saved_regs_size;
946+ poly_int64 fp_offset = frame.bytes_below_hard_fp - bytes_below_sp;
947 if (hard_fp_valid_p)
948 base_rtx = hard_frame_pointer_rtx;
949 else
950@@ -9183,12 +9182,13 @@ aarch64_save_callee_saves (poly_int64 start_offset,
951 }
952
953 /* Emit code to restore the callee registers from register number START
954- up to and including LIMIT. Restore from the stack offset START_OFFSET,
955- skipping any write-back candidates if SKIP_WB is true. Write the
956- appropriate REG_CFA_RESTORE notes into CFI_OPS. */
957+ up to and including LIMIT. The stack pointer is currently BYTES_BELOW_SP
958+ bytes above the bottom of the static frame. Skip any write-back
959+ candidates if SKIP_WB is true. Write the appropriate REG_CFA_RESTORE
960+ notes into CFI_OPS. */
961
962 static void
963-aarch64_restore_callee_saves (poly_int64 start_offset, unsigned start,
964+aarch64_restore_callee_saves (poly_int64 bytes_below_sp, unsigned start,
965 unsigned limit, bool skip_wb, rtx *cfi_ops)
966 {
967 aarch64_frame &frame = cfun->machine->frame;
968@@ -9214,7 +9214,9 @@ aarch64_restore_callee_saves (poly_int64 start_offset, unsigned start,
969
970 machine_mode mode = aarch64_reg_save_mode (regno);
971 reg = gen_rtx_REG (mode, regno);
972- offset = start_offset + frame.reg_offset[regno];
973+ offset = (frame.reg_offset[regno]
974+ + frame.bytes_below_saved_regs
975+ - bytes_below_sp);
976 rtx base_rtx = stack_pointer_rtx;
977 if (mode == VNx2DImode && BYTES_BIG_ENDIAN)
978 aarch64_adjust_sve_callee_save_base (mode, base_rtx, anchor_reg,
979@@ -9990,8 +9992,6 @@ aarch64_expand_prologue (void)
980 HOST_WIDE_INT callee_adjust = frame.callee_adjust;
981 poly_int64 final_adjust = frame.final_adjust;
982 poly_int64 sve_callee_adjust = frame.sve_callee_adjust;
983- poly_int64 below_hard_fp_saved_regs_size
984- = frame.below_hard_fp_saved_regs_size;
985 unsigned reg1 = frame.wb_push_candidate1;
986 unsigned reg2 = frame.wb_push_candidate2;
987 bool emit_frame_chain = frame.emit_frame_chain;
988@@ -10067,8 +10067,8 @@ aarch64_expand_prologue (void)
989 - frame.hard_fp_offset);
990 gcc_assert (known_ge (chain_offset, 0));
991
992- /* The offset of the bottom of the save area from the current SP. */
993- poly_int64 saved_regs_offset = chain_offset - below_hard_fp_saved_regs_size;
994+ /* The offset of the current SP from the bottom of the static frame. */
995+ poly_int64 bytes_below_sp = frame_size - initial_adjust - callee_adjust;
996
997 if (emit_frame_chain)
998 {
999@@ -10076,7 +10076,7 @@ aarch64_expand_prologue (void)
1000 {
1001 reg1 = R29_REGNUM;
1002 reg2 = R30_REGNUM;
1003- aarch64_save_callee_saves (saved_regs_offset, reg1, reg2,
1004+ aarch64_save_callee_saves (bytes_below_sp, reg1, reg2,
1005 false, false);
1006 }
1007 else
1008@@ -10116,7 +10116,7 @@ aarch64_expand_prologue (void)
1009 emit_insn (gen_stack_tie (stack_pointer_rtx, hard_frame_pointer_rtx));
1010 }
1011
1012- aarch64_save_callee_saves (saved_regs_offset, R0_REGNUM, R30_REGNUM,
1013+ aarch64_save_callee_saves (bytes_below_sp, R0_REGNUM, R30_REGNUM,
1014 callee_adjust != 0 || emit_frame_chain,
1015 emit_frame_chain);
1016 if (maybe_ne (sve_callee_adjust, 0))
1017@@ -10126,16 +10126,17 @@ aarch64_expand_prologue (void)
1018 aarch64_allocate_and_probe_stack_space (tmp1_rtx, tmp0_rtx,
1019 sve_callee_adjust,
1020 !frame_pointer_needed, false);
1021- saved_regs_offset += sve_callee_adjust;
1022+ bytes_below_sp -= sve_callee_adjust;
1023 }
1024- aarch64_save_callee_saves (saved_regs_offset, P0_REGNUM, P15_REGNUM,
1025+ aarch64_save_callee_saves (bytes_below_sp, P0_REGNUM, P15_REGNUM,
1026 false, emit_frame_chain);
1027- aarch64_save_callee_saves (saved_regs_offset, V0_REGNUM, V31_REGNUM,
1028+ aarch64_save_callee_saves (bytes_below_sp, V0_REGNUM, V31_REGNUM,
1029 callee_adjust != 0 || emit_frame_chain,
1030 emit_frame_chain);
1031
1032 /* We may need to probe the final adjustment if it is larger than the guard
1033 that is assumed by the called. */
1034+ gcc_assert (known_eq (bytes_below_sp, final_adjust));
1035 aarch64_allocate_and_probe_stack_space (tmp1_rtx, tmp0_rtx, final_adjust,
1036 !frame_pointer_needed, true);
1037 }
1038@@ -10170,7 +10171,6 @@ aarch64_expand_epilogue (bool for_sibcall)
1039 poly_int64 initial_adjust = frame.initial_adjust;
1040 HOST_WIDE_INT callee_adjust = frame.callee_adjust;
1041 poly_int64 final_adjust = frame.final_adjust;
1042- poly_int64 callee_offset = frame.callee_offset;
1043 poly_int64 sve_callee_adjust = frame.sve_callee_adjust;
1044 poly_int64 bytes_below_hard_fp = frame.bytes_below_hard_fp;
1045 unsigned reg1 = frame.wb_pop_candidate1;
1046@@ -10240,9 +10240,9 @@ aarch64_expand_epilogue (bool for_sibcall)
1047
1048 /* Restore the vector registers before the predicate registers,
1049 so that we can use P4 as a temporary for big-endian SVE frames. */
1050- aarch64_restore_callee_saves (callee_offset, V0_REGNUM, V31_REGNUM,
1051+ aarch64_restore_callee_saves (final_adjust, V0_REGNUM, V31_REGNUM,
1052 callee_adjust != 0, &cfi_ops);
1053- aarch64_restore_callee_saves (callee_offset, P0_REGNUM, P15_REGNUM,
1054+ aarch64_restore_callee_saves (final_adjust, P0_REGNUM, P15_REGNUM,
1055 false, &cfi_ops);
1056 if (maybe_ne (sve_callee_adjust, 0))
1057 aarch64_add_sp (NULL_RTX, NULL_RTX, sve_callee_adjust, true);
1058@@ -10250,7 +10250,7 @@ aarch64_expand_epilogue (bool for_sibcall)
1059 /* When shadow call stack is enabled, the scs_pop in the epilogue will
1060 restore x30, we don't need to restore x30 again in the traditional
1061 way. */
1062- aarch64_restore_callee_saves (callee_offset - sve_callee_adjust,
1063+ aarch64_restore_callee_saves (final_adjust + sve_callee_adjust,
1064 R0_REGNUM, last_gpr,
1065 callee_adjust != 0, &cfi_ops);
1066
1067diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
1068index 4263d29d29d..fd820b1be4e 100644
1069--- a/gcc/config/aarch64/aarch64.h
1070+++ b/gcc/config/aarch64/aarch64.h
1071@@ -813,10 +813,6 @@ struct GTY (()) aarch64_frame
1072 It is zero when no push is used. */
1073 HOST_WIDE_INT callee_adjust;
1074
1075- /* The offset from SP to the callee-save registers after initial_adjust.
1076- It may be non-zero if no push is used (ie. callee_adjust == 0). */
1077- poly_int64 callee_offset;
1078-
1079 /* The size of the stack adjustment before saving or after restoring
1080 SVE registers. */
1081 poly_int64 sve_callee_adjust;
1082--
10832.34.1
1084
1085
1086From 8ae9181426f2700c2e5a2909487fa630e6fa406b Mon Sep 17 00:00:00 2001
1087From: Richard Sandiford <richard.sandiford@arm.com>
1088Date: Tue, 12 Sep 2023 16:07:15 +0100
1089Subject: [PATCH 07/19] aarch64: Only calculate chain_offset if there is a
1090 chain
1091
1092After previous patches, it is no longer necessary to calculate
1093a chain_offset in cases where there is no chain record.
1094
1095gcc/
1096 * config/aarch64/aarch64.cc (aarch64_expand_prologue): Move the
1097 calculation of chain_offset into the emit_frame_chain block.
1098---
1099 gcc/config/aarch64/aarch64.cc | 10 +++++-----
1100 1 file changed, 5 insertions(+), 5 deletions(-)
1101
1102diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1103index 46ae5cf7673..0e9b9717c08 100644
1104--- a/gcc/config/aarch64/aarch64.cc
1105+++ b/gcc/config/aarch64/aarch64.cc
1106@@ -10062,16 +10062,16 @@ aarch64_expand_prologue (void)
1107 if (callee_adjust != 0)
1108 aarch64_push_regs (reg1, reg2, callee_adjust);
1109
1110- /* The offset of the frame chain record (if any) from the current SP. */
1111- poly_int64 chain_offset = (initial_adjust + callee_adjust
1112- - frame.hard_fp_offset);
1113- gcc_assert (known_ge (chain_offset, 0));
1114-
1115 /* The offset of the current SP from the bottom of the static frame. */
1116 poly_int64 bytes_below_sp = frame_size - initial_adjust - callee_adjust;
1117
1118 if (emit_frame_chain)
1119 {
1120+ /* The offset of the frame chain record (if any) from the current SP. */
1121+ poly_int64 chain_offset = (initial_adjust + callee_adjust
1122+ - frame.hard_fp_offset);
1123+ gcc_assert (known_ge (chain_offset, 0));
1124+
1125 if (callee_adjust == 0)
1126 {
1127 reg1 = R29_REGNUM;
1128--
11292.34.1
1130
1131
1132From 375794feb614cee1f41b710b9cc1b6f25da6c1cb Mon Sep 17 00:00:00 2001
1133From: Richard Sandiford <richard.sandiford@arm.com>
1134Date: Tue, 12 Sep 2023 16:07:15 +0100
1135Subject: [PATCH 08/19] aarch64: Rename locals_offset to bytes_above_locals
1136MIME-Version: 1.0
1137Content-Type: text/plain; charset=UTF-8
1138Content-Transfer-Encoding: 8bit
1139
1140locals_offset was described as:
1141
1142 /* Offset from the base of the frame (incomming SP) to the
1143 top of the locals area. This value is always a multiple of
1144 STACK_BOUNDARY. */
1145
1146This is implicitly an “upside down” view of the frame: the incoming
1147SP is at offset 0, and anything N bytes below the incoming SP is at
1148offset N (rather than -N).
1149
1150However, reg_offset instead uses a “right way up” view; that is,
1151it views offsets in address terms. Something above X is at a
1152positive offset from X and something below X is at a negative
1153offset from X.
1154
1155Also, even on FRAME_GROWS_DOWNWARD targets like AArch64,
1156target-independent code views offsets in address terms too:
1157locals are allocated at negative offsets to virtual_stack_vars.
1158
1159It seems confusing to have *_offset fields of the same structure
1160using different polarities like this. This patch tries to avoid
1161that by renaming locals_offset to bytes_above_locals.
1162
1163gcc/
1164 * config/aarch64/aarch64.h (aarch64_frame::locals_offset): Rename to...
1165 (aarch64_frame::bytes_above_locals): ...this.
1166 * config/aarch64/aarch64.cc (aarch64_layout_frame)
1167 (aarch64_initial_elimination_offset): Update accordingly.
1168---
1169 gcc/config/aarch64/aarch64.cc | 6 +++---
1170 gcc/config/aarch64/aarch64.h | 6 +++---
1171 2 files changed, 6 insertions(+), 6 deletions(-)
1172
1173diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1174index 0e9b9717c08..0a22f91520e 100644
1175--- a/gcc/config/aarch64/aarch64.cc
1176+++ b/gcc/config/aarch64/aarch64.cc
1177@@ -8598,7 +8598,7 @@ aarch64_layout_frame (void)
1178 STACK_BOUNDARY / BITS_PER_UNIT));
1179 frame.frame_size = saved_regs_and_above + frame.bytes_below_saved_regs;
1180
1181- frame.locals_offset = frame.saved_varargs_size;
1182+ frame.bytes_above_locals = frame.saved_varargs_size;
1183
1184 frame.initial_adjust = 0;
1185 frame.final_adjust = 0;
1186@@ -12754,13 +12754,13 @@ aarch64_initial_elimination_offset (unsigned from, unsigned to)
1187 return frame.hard_fp_offset;
1188
1189 if (from == FRAME_POINTER_REGNUM)
1190- return frame.hard_fp_offset - frame.locals_offset;
1191+ return frame.hard_fp_offset - frame.bytes_above_locals;
1192 }
1193
1194 if (to == STACK_POINTER_REGNUM)
1195 {
1196 if (from == FRAME_POINTER_REGNUM)
1197- return frame.frame_size - frame.locals_offset;
1198+ return frame.frame_size - frame.bytes_above_locals;
1199 }
1200
1201 return frame.frame_size;
1202diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
1203index fd820b1be4e..7ae12d13e2b 100644
1204--- a/gcc/config/aarch64/aarch64.h
1205+++ b/gcc/config/aarch64/aarch64.h
1206@@ -791,10 +791,10 @@ struct GTY (()) aarch64_frame
1207 always a multiple of STACK_BOUNDARY. */
1208 poly_int64 bytes_below_hard_fp;
1209
1210- /* Offset from the base of the frame (incomming SP) to the
1211- top of the locals area. This value is always a multiple of
1212+ /* The number of bytes between the top of the locals area and the top
1213+ of the frame (the incomming SP). This value is always a multiple of
1214 STACK_BOUNDARY. */
1215- poly_int64 locals_offset;
1216+ poly_int64 bytes_above_locals;
1217
1218 /* Offset from the base of the frame (incomming SP) to the
1219 hard_frame_pointer. This value is always a multiple of
1220--
12212.34.1
1222
1223
1224From 1a9ea1c45c75615ffbfabe652b3598a1d7be2168 Mon Sep 17 00:00:00 2001
1225From: Richard Sandiford <richard.sandiford@arm.com>
1226Date: Tue, 12 Sep 2023 16:07:16 +0100
1227Subject: [PATCH 09/19] aarch64: Rename hard_fp_offset to bytes_above_hard_fp
1228MIME-Version: 1.0
1229Content-Type: text/plain; charset=UTF-8
1230Content-Transfer-Encoding: 8bit
1231
1232Similarly to the previous locals_offset patch, hard_fp_offset
1233was described as:
1234
1235 /* Offset from the base of the frame (incomming SP) to the
1236 hard_frame_pointer. This value is always a multiple of
1237 STACK_BOUNDARY. */
1238 poly_int64 hard_fp_offset;
1239
1240which again took an “upside-down” view: higher offsets meant lower
1241addresses. This patch renames the field to bytes_above_hard_fp instead.
1242
1243gcc/
1244 * config/aarch64/aarch64.h (aarch64_frame::hard_fp_offset): Rename
1245 to...
1246 (aarch64_frame::bytes_above_hard_fp): ...this.
1247 * config/aarch64/aarch64.cc (aarch64_layout_frame)
1248 (aarch64_expand_prologue): Update accordingly.
1249 (aarch64_initial_elimination_offset): Likewise.
1250---
1251 gcc/config/aarch64/aarch64.cc | 26 +++++++++++++-------------
1252 gcc/config/aarch64/aarch64.h | 6 +++---
1253 2 files changed, 16 insertions(+), 16 deletions(-)
1254
1255diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1256index 0a22f91520e..95499ae49ba 100644
1257--- a/gcc/config/aarch64/aarch64.cc
1258+++ b/gcc/config/aarch64/aarch64.cc
1259@@ -8590,7 +8590,7 @@ aarch64_layout_frame (void)
1260 + get_frame_size (),
1261 STACK_BOUNDARY / BITS_PER_UNIT);
1262
1263- frame.hard_fp_offset
1264+ frame.bytes_above_hard_fp
1265 = saved_regs_and_above - frame.below_hard_fp_saved_regs_size;
1266
1267 /* Both these values are already aligned. */
1268@@ -8639,13 +8639,13 @@ aarch64_layout_frame (void)
1269 else if (frame.wb_pop_candidate1 != INVALID_REGNUM)
1270 max_push_offset = 256;
1271
1272- HOST_WIDE_INT const_size, const_below_saved_regs, const_fp_offset;
1273+ HOST_WIDE_INT const_size, const_below_saved_regs, const_above_fp;
1274 HOST_WIDE_INT const_saved_regs_size;
1275 if (known_eq (frame.saved_regs_size, 0))
1276 frame.initial_adjust = frame.frame_size;
1277 else if (frame.frame_size.is_constant (&const_size)
1278 && const_size < max_push_offset
1279- && known_eq (frame.hard_fp_offset, const_size))
1280+ && known_eq (frame.bytes_above_hard_fp, const_size))
1281 {
1282 /* Simple, small frame with no data below the saved registers.
1283
1284@@ -8662,8 +8662,8 @@ aarch64_layout_frame (void)
1285 case that it hardly seems worth the effort though. */
1286 && (!saves_below_hard_fp_p || const_below_saved_regs == 0)
1287 && !(cfun->calls_alloca
1288- && frame.hard_fp_offset.is_constant (&const_fp_offset)
1289- && const_fp_offset < max_push_offset))
1290+ && frame.bytes_above_hard_fp.is_constant (&const_above_fp)
1291+ && const_above_fp < max_push_offset))
1292 {
1293 /* Frame with small area below the saved registers:
1294
1295@@ -8681,12 +8681,12 @@ aarch64_layout_frame (void)
1296 sub sp, sp, hard_fp_offset + below_hard_fp_saved_regs_size
1297 save SVE registers relative to SP
1298 sub sp, sp, bytes_below_saved_regs */
1299- frame.initial_adjust = (frame.hard_fp_offset
1300+ frame.initial_adjust = (frame.bytes_above_hard_fp
1301 + frame.below_hard_fp_saved_regs_size);
1302 frame.final_adjust = frame.bytes_below_saved_regs;
1303 }
1304- else if (frame.hard_fp_offset.is_constant (&const_fp_offset)
1305- && const_fp_offset < max_push_offset)
1306+ else if (frame.bytes_above_hard_fp.is_constant (&const_above_fp)
1307+ && const_above_fp < max_push_offset)
1308 {
1309 /* Frame with large area below the saved registers, or with SVE saves,
1310 but with a small area above:
1311@@ -8696,7 +8696,7 @@ aarch64_layout_frame (void)
1312 [sub sp, sp, below_hard_fp_saved_regs_size]
1313 [save SVE registers relative to SP]
1314 sub sp, sp, bytes_below_saved_regs */
1315- frame.callee_adjust = const_fp_offset;
1316+ frame.callee_adjust = const_above_fp;
1317 frame.sve_callee_adjust = frame.below_hard_fp_saved_regs_size;
1318 frame.final_adjust = frame.bytes_below_saved_regs;
1319 }
1320@@ -8711,7 +8711,7 @@ aarch64_layout_frame (void)
1321 [sub sp, sp, below_hard_fp_saved_regs_size]
1322 [save SVE registers relative to SP]
1323 sub sp, sp, bytes_below_saved_regs */
1324- frame.initial_adjust = frame.hard_fp_offset;
1325+ frame.initial_adjust = frame.bytes_above_hard_fp;
1326 frame.sve_callee_adjust = frame.below_hard_fp_saved_regs_size;
1327 frame.final_adjust = frame.bytes_below_saved_regs;
1328 }
1329@@ -10069,7 +10069,7 @@ aarch64_expand_prologue (void)
1330 {
1331 /* The offset of the frame chain record (if any) from the current SP. */
1332 poly_int64 chain_offset = (initial_adjust + callee_adjust
1333- - frame.hard_fp_offset);
1334+ - frame.bytes_above_hard_fp);
1335 gcc_assert (known_ge (chain_offset, 0));
1336
1337 if (callee_adjust == 0)
1338@@ -12751,10 +12751,10 @@ aarch64_initial_elimination_offset (unsigned from, unsigned to)
1339 if (to == HARD_FRAME_POINTER_REGNUM)
1340 {
1341 if (from == ARG_POINTER_REGNUM)
1342- return frame.hard_fp_offset;
1343+ return frame.bytes_above_hard_fp;
1344
1345 if (from == FRAME_POINTER_REGNUM)
1346- return frame.hard_fp_offset - frame.bytes_above_locals;
1347+ return frame.bytes_above_hard_fp - frame.bytes_above_locals;
1348 }
1349
1350 if (to == STACK_POINTER_REGNUM)
1351diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
1352index 7ae12d13e2b..3808f49e9ca 100644
1353--- a/gcc/config/aarch64/aarch64.h
1354+++ b/gcc/config/aarch64/aarch64.h
1355@@ -796,10 +796,10 @@ struct GTY (()) aarch64_frame
1356 STACK_BOUNDARY. */
1357 poly_int64 bytes_above_locals;
1358
1359- /* Offset from the base of the frame (incomming SP) to the
1360- hard_frame_pointer. This value is always a multiple of
1361+ /* The number of bytes between the hard_frame_pointer and the top of
1362+ the frame (the incomming SP). This value is always a multiple of
1363 STACK_BOUNDARY. */
1364- poly_int64 hard_fp_offset;
1365+ poly_int64 bytes_above_hard_fp;
1366
1367 /* The size of the frame. This value is the offset from base of the
1368 frame (incomming SP) to the stack_pointer. This value is always
1369--
13702.34.1
1371
1372
1373From d202ce1ecf60a36a3e1009917dd76109248ce9be Mon Sep 17 00:00:00 2001
1374From: Richard Sandiford <richard.sandiford@arm.com>
1375Date: Tue, 12 Sep 2023 16:07:16 +0100
1376Subject: [PATCH 10/19] aarch64: Tweak frame_size comment
1377MIME-Version: 1.0
1378Content-Type: text/plain; charset=UTF-8
1379Content-Transfer-Encoding: 8bit
1380
1381This patch fixes another case in which a value was described with
1382an “upside-down” view.
1383
1384gcc/
1385 * config/aarch64/aarch64.h (aarch64_frame::frame_size): Tweak comment.
1386---
1387 gcc/config/aarch64/aarch64.h | 4 ++--
1388 1 file changed, 2 insertions(+), 2 deletions(-)
1389
1390diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
1391index 3808f49e9ca..108a5731b0d 100644
1392--- a/gcc/config/aarch64/aarch64.h
1393+++ b/gcc/config/aarch64/aarch64.h
1394@@ -801,8 +801,8 @@ struct GTY (()) aarch64_frame
1395 STACK_BOUNDARY. */
1396 poly_int64 bytes_above_hard_fp;
1397
1398- /* The size of the frame. This value is the offset from base of the
1399- frame (incomming SP) to the stack_pointer. This value is always
1400+ /* The size of the frame, i.e. the number of bytes between the bottom
1401+ of the outgoing arguments and the incoming SP. This value is always
1402 a multiple of STACK_BOUNDARY. */
1403 poly_int64 frame_size;
1404
1405--
14062.34.1
1407
1408
1409From f2b585375205b0a1802d79c682ba33766ecd1f0f Mon Sep 17 00:00:00 2001
1410From: Richard Sandiford <richard.sandiford@arm.com>
1411Date: Tue, 12 Sep 2023 16:07:17 +0100
1412Subject: [PATCH 11/19] aarch64: Measure reg_offset from the bottom of the
1413 frame
1414
1415reg_offset was measured from the bottom of the saved register area.
1416This made perfect sense with the original layout, since the bottom
1417of the saved register area was also the hard frame pointer address.
1418It became slightly less obvious with SVE, since we save SVE
1419registers below the hard frame pointer, but it still made sense.
1420
1421However, if we want to allow different frame layouts, it's more
1422convenient and obvious to measure reg_offset from the bottom of
1423the frame. After previous patches, it's also a slight simplification
1424in its own right.
1425
1426gcc/
1427 * config/aarch64/aarch64.h (aarch64_frame): Add comment above
1428 reg_offset.
1429 * config/aarch64/aarch64.cc (aarch64_layout_frame): Walk offsets
1430 from the bottom of the frame, rather than the bottom of the saved
1431 register area. Measure reg_offset from the bottom of the frame
1432 rather than the bottom of the saved register area.
1433 (aarch64_save_callee_saves): Update accordingly.
1434 (aarch64_restore_callee_saves): Likewise.
1435 (aarch64_get_separate_components): Likewise.
1436 (aarch64_process_components): Likewise.
1437---
1438 gcc/config/aarch64/aarch64.cc | 53 ++++++++++++++++-------------------
1439 gcc/config/aarch64/aarch64.h | 3 ++
1440 2 files changed, 27 insertions(+), 29 deletions(-)
1441
1442diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1443index 95499ae49ba..af99807ef8a 100644
1444--- a/gcc/config/aarch64/aarch64.cc
1445+++ b/gcc/config/aarch64/aarch64.cc
1446@@ -8400,7 +8400,6 @@ aarch64_needs_frame_chain (void)
1447 static void
1448 aarch64_layout_frame (void)
1449 {
1450- poly_int64 offset = 0;
1451 int regno, last_fp_reg = INVALID_REGNUM;
1452 machine_mode vector_save_mode = aarch64_reg_save_mode (V8_REGNUM);
1453 poly_int64 vector_save_size = GET_MODE_SIZE (vector_save_mode);
1454@@ -8478,7 +8477,9 @@ aarch64_layout_frame (void)
1455 gcc_assert (crtl->is_leaf
1456 || maybe_ne (frame.reg_offset[R30_REGNUM], SLOT_NOT_REQUIRED));
1457
1458- frame.bytes_below_saved_regs = crtl->outgoing_args_size;
1459+ poly_int64 offset = crtl->outgoing_args_size;
1460+ gcc_assert (multiple_p (offset, STACK_BOUNDARY / BITS_PER_UNIT));
1461+ frame.bytes_below_saved_regs = offset;
1462
1463 /* Now assign stack slots for the registers. Start with the predicate
1464 registers, since predicate LDR and STR have a relatively small
1465@@ -8490,7 +8491,8 @@ aarch64_layout_frame (void)
1466 offset += BYTES_PER_SVE_PRED;
1467 }
1468
1469- if (maybe_ne (offset, 0))
1470+ poly_int64 saved_prs_size = offset - frame.bytes_below_saved_regs;
1471+ if (maybe_ne (saved_prs_size, 0))
1472 {
1473 /* If we have any vector registers to save above the predicate registers,
1474 the offset of the vector register save slots need to be a multiple
1475@@ -8508,10 +8510,10 @@ aarch64_layout_frame (void)
1476 offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
1477 else
1478 {
1479- if (known_le (offset, vector_save_size))
1480- offset = vector_save_size;
1481- else if (known_le (offset, vector_save_size * 2))
1482- offset = vector_save_size * 2;
1483+ if (known_le (saved_prs_size, vector_save_size))
1484+ offset = frame.bytes_below_saved_regs + vector_save_size;
1485+ else if (known_le (saved_prs_size, vector_save_size * 2))
1486+ offset = frame.bytes_below_saved_regs + vector_save_size * 2;
1487 else
1488 gcc_unreachable ();
1489 }
1490@@ -8528,9 +8530,10 @@ aarch64_layout_frame (void)
1491
1492 /* OFFSET is now the offset of the hard frame pointer from the bottom
1493 of the callee save area. */
1494- bool saves_below_hard_fp_p = maybe_ne (offset, 0);
1495- frame.below_hard_fp_saved_regs_size = offset;
1496- frame.bytes_below_hard_fp = offset + frame.bytes_below_saved_regs;
1497+ frame.below_hard_fp_saved_regs_size = offset - frame.bytes_below_saved_regs;
1498+ bool saves_below_hard_fp_p
1499+ = maybe_ne (frame.below_hard_fp_saved_regs_size, 0);
1500+ frame.bytes_below_hard_fp = offset;
1501 if (frame.emit_frame_chain)
1502 {
1503 /* FP and LR are placed in the linkage record. */
1504@@ -8581,9 +8584,10 @@ aarch64_layout_frame (void)
1505
1506 offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
1507
1508- frame.saved_regs_size = offset;
1509+ frame.saved_regs_size = offset - frame.bytes_below_saved_regs;
1510
1511- poly_int64 varargs_and_saved_regs_size = offset + frame.saved_varargs_size;
1512+ poly_int64 varargs_and_saved_regs_size
1513+ = frame.saved_regs_size + frame.saved_varargs_size;
1514
1515 poly_int64 saved_regs_and_above
1516 = aligned_upper_bound (varargs_and_saved_regs_size
1517@@ -9105,9 +9109,7 @@ aarch64_save_callee_saves (poly_int64 bytes_below_sp,
1518
1519 machine_mode mode = aarch64_reg_save_mode (regno);
1520 reg = gen_rtx_REG (mode, regno);
1521- offset = (frame.reg_offset[regno]
1522- + frame.bytes_below_saved_regs
1523- - bytes_below_sp);
1524+ offset = frame.reg_offset[regno] - bytes_below_sp;
1525 rtx base_rtx = stack_pointer_rtx;
1526 poly_int64 sp_offset = offset;
1527
1528@@ -9214,9 +9216,7 @@ aarch64_restore_callee_saves (poly_int64 bytes_below_sp, unsigned start,
1529
1530 machine_mode mode = aarch64_reg_save_mode (regno);
1531 reg = gen_rtx_REG (mode, regno);
1532- offset = (frame.reg_offset[regno]
1533- + frame.bytes_below_saved_regs
1534- - bytes_below_sp);
1535+ offset = frame.reg_offset[regno] - bytes_below_sp;
1536 rtx base_rtx = stack_pointer_rtx;
1537 if (mode == VNx2DImode && BYTES_BIG_ENDIAN)
1538 aarch64_adjust_sve_callee_save_base (mode, base_rtx, anchor_reg,
1539@@ -9355,14 +9355,12 @@ aarch64_get_separate_components (void)
1540 it as a stack probe for -fstack-clash-protection. */
1541 if (flag_stack_clash_protection
1542 && maybe_ne (frame.below_hard_fp_saved_regs_size, 0)
1543- && known_eq (offset, 0))
1544+ && known_eq (offset, frame.bytes_below_saved_regs))
1545 continue;
1546
1547 /* Get the offset relative to the register we'll use. */
1548 if (frame_pointer_needed)
1549- offset -= frame.below_hard_fp_saved_regs_size;
1550- else
1551- offset += frame.bytes_below_saved_regs;
1552+ offset -= frame.bytes_below_hard_fp;
1553
1554 /* Check that we can access the stack slot of the register with one
1555 direct load with no adjustments needed. */
1556@@ -9509,9 +9507,7 @@ aarch64_process_components (sbitmap components, bool prologue_p)
1557 rtx reg = gen_rtx_REG (mode, regno);
1558 poly_int64 offset = frame.reg_offset[regno];
1559 if (frame_pointer_needed)
1560- offset -= frame.below_hard_fp_saved_regs_size;
1561- else
1562- offset += frame.bytes_below_saved_regs;
1563+ offset -= frame.bytes_below_hard_fp;
1564
1565 rtx addr = plus_constant (Pmode, ptr_reg, offset);
1566 rtx mem = gen_frame_mem (mode, addr);
1567@@ -9563,9 +9559,7 @@ aarch64_process_components (sbitmap components, bool prologue_p)
1568 /* REGNO2 can be saved/restored in a pair with REGNO. */
1569 rtx reg2 = gen_rtx_REG (mode, regno2);
1570 if (frame_pointer_needed)
1571- offset2 -= frame.below_hard_fp_saved_regs_size;
1572- else
1573- offset2 += frame.bytes_below_saved_regs;
1574+ offset2 -= frame.bytes_below_hard_fp;
1575 rtx addr2 = plus_constant (Pmode, ptr_reg, offset2);
1576 rtx mem2 = gen_frame_mem (mode, addr2);
1577 rtx set2 = prologue_p ? gen_rtx_SET (mem2, reg2)
1578@@ -9681,7 +9675,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1579 if (final_adjustment_p
1580 && known_eq (frame.below_hard_fp_saved_regs_size, 0))
1581 {
1582- poly_int64 lr_offset = frame.reg_offset[LR_REGNUM];
1583+ poly_int64 lr_offset = (frame.reg_offset[LR_REGNUM]
1584+ - frame.bytes_below_saved_regs);
1585 if (known_ge (lr_offset, 0))
1586 min_probe_threshold -= lr_offset.to_constant ();
1587 else
1588diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
1589index 108a5731b0d..c8becb098c8 100644
1590--- a/gcc/config/aarch64/aarch64.h
1591+++ b/gcc/config/aarch64/aarch64.h
1592@@ -766,6 +766,9 @@ extern enum aarch64_processor aarch64_tune;
1593 #ifdef HAVE_POLY_INT_H
1594 struct GTY (()) aarch64_frame
1595 {
1596+ /* The offset from the bottom of the static frame (the bottom of the
1597+ outgoing arguments) of each register save slot, or -2 if no save is
1598+ needed. */
1599 poly_int64 reg_offset[LAST_SAVED_REGNUM + 1];
1600
1601 /* The number of extra stack bytes taken up by register varargs.
1602--
16032.34.1
1604
1605
1606From 79faabda181d0d9fd29a3cf5726ba65bdee945b5 Mon Sep 17 00:00:00 2001
1607From: Richard Sandiford <richard.sandiford@arm.com>
1608Date: Tue, 12 Sep 2023 16:07:17 +0100
1609Subject: [PATCH 12/19] aarch64: Simplify top of frame allocation
1610
1611After previous patches, it no longer really makes sense to allocate
1612the top of the frame in terms of varargs_and_saved_regs_size and
1613saved_regs_and_above.
1614
1615gcc/
1616 * config/aarch64/aarch64.cc (aarch64_layout_frame): Simplify
1617 the allocation of the top of the frame.
1618---
1619 gcc/config/aarch64/aarch64.cc | 23 ++++++++---------------
1620 1 file changed, 8 insertions(+), 15 deletions(-)
1621
1622diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1623index af99807ef8a..31b00094c2a 100644
1624--- a/gcc/config/aarch64/aarch64.cc
1625+++ b/gcc/config/aarch64/aarch64.cc
1626@@ -8586,23 +8586,16 @@ aarch64_layout_frame (void)
1627
1628 frame.saved_regs_size = offset - frame.bytes_below_saved_regs;
1629
1630- poly_int64 varargs_and_saved_regs_size
1631- = frame.saved_regs_size + frame.saved_varargs_size;
1632-
1633- poly_int64 saved_regs_and_above
1634- = aligned_upper_bound (varargs_and_saved_regs_size
1635- + get_frame_size (),
1636- STACK_BOUNDARY / BITS_PER_UNIT);
1637-
1638- frame.bytes_above_hard_fp
1639- = saved_regs_and_above - frame.below_hard_fp_saved_regs_size;
1640+ offset += get_frame_size ();
1641+ offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
1642+ auto top_of_locals = offset;
1643
1644- /* Both these values are already aligned. */
1645- gcc_assert (multiple_p (frame.bytes_below_saved_regs,
1646- STACK_BOUNDARY / BITS_PER_UNIT));
1647- frame.frame_size = saved_regs_and_above + frame.bytes_below_saved_regs;
1648+ offset += frame.saved_varargs_size;
1649+ gcc_assert (multiple_p (offset, STACK_BOUNDARY / BITS_PER_UNIT));
1650+ frame.frame_size = offset;
1651
1652- frame.bytes_above_locals = frame.saved_varargs_size;
1653+ frame.bytes_above_hard_fp = frame.frame_size - frame.bytes_below_hard_fp;
1654+ frame.bytes_above_locals = frame.frame_size - top_of_locals;
1655
1656 frame.initial_adjust = 0;
1657 frame.final_adjust = 0;
1658--
16592.34.1
1660
1661
1662From 4e62049e403b141e6f916176160dac8cbd65fe47 Mon Sep 17 00:00:00 2001
1663From: Richard Sandiford <richard.sandiford@arm.com>
1664Date: Tue, 12 Sep 2023 16:07:18 +0100
1665Subject: [PATCH 13/19] aarch64: Minor initial adjustment tweak
1666
1667This patch just changes a calculation of initial_adjust
1668to one that makes it slightly more obvious that the total
1669adjustment is frame.frame_size.
1670
1671gcc/
1672 * config/aarch64/aarch64.cc (aarch64_layout_frame): Tweak
1673 calculation of initial_adjust for frames in which all saves
1674 are SVE saves.
1675---
1676 gcc/config/aarch64/aarch64.cc | 5 ++---
1677 1 file changed, 2 insertions(+), 3 deletions(-)
1678
1679diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1680index 31b00094c2a..1aa79da0673 100644
1681--- a/gcc/config/aarch64/aarch64.cc
1682+++ b/gcc/config/aarch64/aarch64.cc
1683@@ -8675,11 +8675,10 @@ aarch64_layout_frame (void)
1684 {
1685 /* Frame in which all saves are SVE saves:
1686
1687- sub sp, sp, hard_fp_offset + below_hard_fp_saved_regs_size
1688+ sub sp, sp, frame_size - bytes_below_saved_regs
1689 save SVE registers relative to SP
1690 sub sp, sp, bytes_below_saved_regs */
1691- frame.initial_adjust = (frame.bytes_above_hard_fp
1692- + frame.below_hard_fp_saved_regs_size);
1693+ frame.initial_adjust = frame.frame_size - frame.bytes_below_saved_regs;
1694 frame.final_adjust = frame.bytes_below_saved_regs;
1695 }
1696 else if (frame.bytes_above_hard_fp.is_constant (&const_above_fp)
1697--
16982.34.1
1699
1700
1701From aaa1a0a5912d9e5d571e5f1c6f09ceac99544ab5 Mon Sep 17 00:00:00 2001
1702From: Richard Sandiford <richard.sandiford@arm.com>
1703Date: Tue, 12 Sep 2023 16:07:18 +0100
1704Subject: [PATCH 14/19] aarch64: Tweak stack clash boundary condition
1705
1706The AArch64 ABI says that, when stack clash protection is used,
1707there can be a maximum of 1KiB of unprobed space at sp on entry
1708to a function. Therefore, we need to probe when allocating
1709>= guard_size - 1KiB of data (>= rather than >). This is what
1710GCC does.
1711
1712If an allocation is exactly guard_size bytes, it is enough to allocate
1713those bytes and probe once at offset 1024. It isn't possible to use a
1714single probe at any other offset: higher would conmplicate later code,
1715by leaving more unprobed space than usual, while lower would risk
1716leaving an entire page unprobed. For simplicity, the code probes all
1717allocations at offset 1024.
1718
1719Some register saves also act as probes. If we need to allocate
1720more space below the last such register save probe, we need to
1721probe the allocation if it is > 1KiB. Again, this allocation is
1722then sometimes (but not always) probed at offset 1024. This sort of
1723allocation is currently only used for outgoing arguments, which are
1724rarely this big.
1725
1726However, the code also probed if this final outgoing-arguments
1727allocation was == 1KiB, rather than just > 1KiB. This isn't
1728necessary, since the register save then probes at offset 1024
1729as required. Continuing to probe allocations of exactly 1KiB
1730would complicate later patches.
1731
1732gcc/
1733 * config/aarch64/aarch64.cc (aarch64_allocate_and_probe_stack_space):
1734 Don't probe final allocations that are exactly 1KiB in size (after
1735 unprobed space above the final allocation has been deducted).
1736
1737gcc/testsuite/
1738 * gcc.target/aarch64/stack-check-prologue-17.c: New test.
1739---
1740 gcc/config/aarch64/aarch64.cc | 4 +-
1741 .../aarch64/stack-check-prologue-17.c | 55 +++++++++++++++++++
1742 2 files changed, 58 insertions(+), 1 deletion(-)
1743 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
1744
1745diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1746index 1aa79da0673..5cad847977a 100644
1747--- a/gcc/config/aarch64/aarch64.cc
1748+++ b/gcc/config/aarch64/aarch64.cc
1749@@ -9648,9 +9648,11 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1750 HOST_WIDE_INT guard_size
1751 = 1 << param_stack_clash_protection_guard_size;
1752 HOST_WIDE_INT guard_used_by_caller = STACK_CLASH_CALLER_GUARD;
1753+ HOST_WIDE_INT byte_sp_alignment = STACK_BOUNDARY / BITS_PER_UNIT;
1754+ gcc_assert (multiple_p (poly_size, byte_sp_alignment));
1755 HOST_WIDE_INT min_probe_threshold
1756 = (final_adjustment_p
1757- ? guard_used_by_caller
1758+ ? guard_used_by_caller + byte_sp_alignment
1759 : guard_size - guard_used_by_caller);
1760 /* When doing the final adjustment for the outgoing arguments, take into
1761 account any unprobed space there is above the current SP. There are
1762diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
1763new file mode 100644
1764index 00000000000..0d8a25d73a2
1765--- /dev/null
1766+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
1767@@ -0,0 +1,55 @@
1768+/* { dg-options "-O2 -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12" } */
1769+/* { dg-final { check-function-bodies "**" "" } } */
1770+
1771+void f(int, ...);
1772+void g();
1773+
1774+/*
1775+** test1:
1776+** ...
1777+** str x30, \[sp\]
1778+** sub sp, sp, #1024
1779+** cbnz w0, .*
1780+** bl g
1781+** ...
1782+*/
1783+int test1(int z) {
1784+ __uint128_t x = 0;
1785+ int y[0x400];
1786+ if (z)
1787+ {
1788+ f(0, 0, 0, 0, 0, 0, 0, &y,
1789+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1790+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1791+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1792+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x);
1793+ }
1794+ g();
1795+ return 1;
1796+}
1797+
1798+/*
1799+** test2:
1800+** ...
1801+** str x30, \[sp\]
1802+** sub sp, sp, #1040
1803+** str xzr, \[sp\]
1804+** cbnz w0, .*
1805+** bl g
1806+** ...
1807+*/
1808+int test2(int z) {
1809+ __uint128_t x = 0;
1810+ int y[0x400];
1811+ if (z)
1812+ {
1813+ f(0, 0, 0, 0, 0, 0, 0, &y,
1814+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1815+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1816+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1817+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
1818+ x);
1819+ }
1820+ g();
1821+ return 1;
1822+}
1823--
18242.34.1
1825
1826
1827From 8433953434a7b58c0923140d39eb3c5988c1d097 Mon Sep 17 00:00:00 2001
1828From: Richard Sandiford <richard.sandiford@arm.com>
1829Date: Tue, 12 Sep 2023 16:07:19 +0100
1830Subject: [PATCH 15/19] aarch64: Put LR save probe in first 16 bytes
1831
1832-fstack-clash-protection uses the save of LR as a probe for the next
1833allocation. The next allocation could be:
1834
1835* another part of the static frame, e.g. when allocating SVE save slots
1836 or outgoing arguments
1837
1838* an alloca in the same function
1839
1840* an allocation made by a callee function
1841
1842However, when -fomit-frame-pointer is used, the LR save slot is placed
1843above the other GPR save slots. It could therefore be up to 80 bytes
1844above the base of the GPR save area (which is also the hard fp address).
1845
1846aarch64_allocate_and_probe_stack_space took this into account when
1847deciding how much subsequent space could be allocated without needing
1848a probe. However, it interacted badly with:
1849
1850 /* If doing a small final adjustment, we always probe at offset 0.
1851 This is done to avoid issues when LR is not at position 0 or when
1852 the final adjustment is smaller than the probing offset. */
1853 else if (final_adjustment_p && rounded_size == 0)
1854 residual_probe_offset = 0;
1855
1856which forces any allocation that is smaller than the guard page size
1857to be probed at offset 0 rather than the usual offset 1024. It was
1858therefore possible to construct cases in which we had:
1859
1860* a probe using LR at SP + 80 bytes (or some other value >= 16)
1861* an allocation of the guard page size - 16 bytes
1862* a probe at SP + 0
1863
1864which allocates guard page size + 64 consecutive unprobed bytes.
1865
1866This patch requires the LR probe to be in the first 16 bytes of the
1867save area when stack clash protection is active. Doing it
1868unconditionally would cause code-quality regressions.
1869
1870Putting LR before other registers prevents push/pop allocation
1871when shadow call stacks are enabled, since LR is restored
1872separately from the other callee-saved registers.
1873
1874The new comment doesn't say that the probe register is required
1875to be LR, since a later patch removes that restriction.
1876
1877gcc/
1878 * config/aarch64/aarch64.cc (aarch64_layout_frame): Ensure that
1879 the LR save slot is in the first 16 bytes of the register save area.
1880 Only form STP/LDP push/pop candidates if both registers are valid.
1881 (aarch64_allocate_and_probe_stack_space): Remove workaround for
1882 when LR was not in the first 16 bytes.
1883
1884gcc/testsuite/
1885 * gcc.target/aarch64/stack-check-prologue-18.c: New test.
1886 * gcc.target/aarch64/stack-check-prologue-19.c: Likewise.
1887 * gcc.target/aarch64/stack-check-prologue-20.c: Likewise.
1888---
1889 gcc/config/aarch64/aarch64.cc | 72 ++++++-------
1890 .../aarch64/stack-check-prologue-18.c | 100 ++++++++++++++++++
1891 .../aarch64/stack-check-prologue-19.c | 100 ++++++++++++++++++
1892 .../aarch64/stack-check-prologue-20.c | 3 +
1893 4 files changed, 233 insertions(+), 42 deletions(-)
1894 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
1895 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c
1896 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-check-prologue-20.c
1897
1898diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
1899index 5cad847977a..a765f92329d 100644
1900--- a/gcc/config/aarch64/aarch64.cc
1901+++ b/gcc/config/aarch64/aarch64.cc
1902@@ -8534,26 +8534,34 @@ aarch64_layout_frame (void)
1903 bool saves_below_hard_fp_p
1904 = maybe_ne (frame.below_hard_fp_saved_regs_size, 0);
1905 frame.bytes_below_hard_fp = offset;
1906+
1907+ auto allocate_gpr_slot = [&](unsigned int regno)
1908+ {
1909+ frame.reg_offset[regno] = offset;
1910+ if (frame.wb_push_candidate1 == INVALID_REGNUM)
1911+ frame.wb_push_candidate1 = regno;
1912+ else if (frame.wb_push_candidate2 == INVALID_REGNUM)
1913+ frame.wb_push_candidate2 = regno;
1914+ offset += UNITS_PER_WORD;
1915+ };
1916+
1917 if (frame.emit_frame_chain)
1918 {
1919 /* FP and LR are placed in the linkage record. */
1920- frame.reg_offset[R29_REGNUM] = offset;
1921- frame.wb_push_candidate1 = R29_REGNUM;
1922- frame.reg_offset[R30_REGNUM] = offset + UNITS_PER_WORD;
1923- frame.wb_push_candidate2 = R30_REGNUM;
1924- offset += 2 * UNITS_PER_WORD;
1925+ allocate_gpr_slot (R29_REGNUM);
1926+ allocate_gpr_slot (R30_REGNUM);
1927 }
1928+ else if (flag_stack_clash_protection
1929+ && known_eq (frame.reg_offset[R30_REGNUM], SLOT_REQUIRED))
1930+ /* Put the LR save slot first, since it makes a good choice of probe
1931+ for stack clash purposes. The idea is that the link register usually
1932+ has to be saved before a call anyway, and so we lose little by
1933+ stopping it from being individually shrink-wrapped. */
1934+ allocate_gpr_slot (R30_REGNUM);
1935
1936 for (regno = R0_REGNUM; regno <= R30_REGNUM; regno++)
1937 if (known_eq (frame.reg_offset[regno], SLOT_REQUIRED))
1938- {
1939- frame.reg_offset[regno] = offset;
1940- if (frame.wb_push_candidate1 == INVALID_REGNUM)
1941- frame.wb_push_candidate1 = regno;
1942- else if (frame.wb_push_candidate2 == INVALID_REGNUM)
1943- frame.wb_push_candidate2 = regno;
1944- offset += UNITS_PER_WORD;
1945- }
1946+ allocate_gpr_slot (regno);
1947
1948 poly_int64 max_int_offset = offset;
1949 offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
1950@@ -8631,10 +8639,13 @@ aarch64_layout_frame (void)
1951 max_push_offset to 0, because no registers are popped at this time,
1952 so callee_adjust cannot be adjusted. */
1953 HOST_WIDE_INT max_push_offset = 0;
1954- if (frame.wb_pop_candidate2 != INVALID_REGNUM)
1955- max_push_offset = 512;
1956- else if (frame.wb_pop_candidate1 != INVALID_REGNUM)
1957- max_push_offset = 256;
1958+ if (frame.wb_pop_candidate1 != INVALID_REGNUM)
1959+ {
1960+ if (frame.wb_pop_candidate2 != INVALID_REGNUM)
1961+ max_push_offset = 512;
1962+ else
1963+ max_push_offset = 256;
1964+ }
1965
1966 HOST_WIDE_INT const_size, const_below_saved_regs, const_above_fp;
1967 HOST_WIDE_INT const_saved_regs_size;
1968@@ -9654,29 +9665,6 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1969 = (final_adjustment_p
1970 ? guard_used_by_caller + byte_sp_alignment
1971 : guard_size - guard_used_by_caller);
1972- /* When doing the final adjustment for the outgoing arguments, take into
1973- account any unprobed space there is above the current SP. There are
1974- two cases:
1975-
1976- - When saving SVE registers below the hard frame pointer, we force
1977- the lowest save to take place in the prologue before doing the final
1978- adjustment (i.e. we don't allow the save to be shrink-wrapped).
1979- This acts as a probe at SP, so there is no unprobed space.
1980-
1981- - When there are no SVE register saves, we use the store of the link
1982- register as a probe. We can't assume that LR was saved at position 0
1983- though, so treat any space below it as unprobed. */
1984- if (final_adjustment_p
1985- && known_eq (frame.below_hard_fp_saved_regs_size, 0))
1986- {
1987- poly_int64 lr_offset = (frame.reg_offset[LR_REGNUM]
1988- - frame.bytes_below_saved_regs);
1989- if (known_ge (lr_offset, 0))
1990- min_probe_threshold -= lr_offset.to_constant ();
1991- else
1992- gcc_assert (!flag_stack_clash_protection || known_eq (poly_size, 0));
1993- }
1994-
1995 poly_int64 frame_size = frame.frame_size;
1996
1997 /* We should always have a positive probe threshold. */
1998@@ -9856,8 +9844,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
1999 if (final_adjustment_p && rounded_size != 0)
2000 min_probe_threshold = 0;
2001 /* If doing a small final adjustment, we always probe at offset 0.
2002- This is done to avoid issues when LR is not at position 0 or when
2003- the final adjustment is smaller than the probing offset. */
2004+ This is done to avoid issues when the final adjustment is smaller
2005+ than the probing offset. */
2006 else if (final_adjustment_p && rounded_size == 0)
2007 residual_probe_offset = 0;
2008
2009diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
2010new file mode 100644
2011index 00000000000..82447d20fff
2012--- /dev/null
2013+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
2014@@ -0,0 +1,100 @@
2015+/* { dg-options "-O2 -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12" } */
2016+/* { dg-final { check-function-bodies "**" "" } } */
2017+
2018+void f(int, ...);
2019+void g();
2020+
2021+/*
2022+** test1:
2023+** ...
2024+** str x30, \[sp\]
2025+** sub sp, sp, #4064
2026+** str xzr, \[sp\]
2027+** cbnz w0, .*
2028+** bl g
2029+** ...
2030+** str x26, \[sp, #?4128\]
2031+** ...
2032+*/
2033+int test1(int z) {
2034+ __uint128_t x = 0;
2035+ int y[0x400];
2036+ if (z)
2037+ {
2038+ asm volatile ("" :::
2039+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
2040+ f(0, 0, 0, 0, 0, 0, 0, &y,
2041+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2042+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2043+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2044+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2045+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2046+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2047+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2048+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2049+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2050+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2051+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2052+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2053+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2054+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2055+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2056+ x, x, x, x, x, x, x, x, x, x, x, x, x, x);
2057+ }
2058+ g();
2059+ return 1;
2060+}
2061+
2062+/*
2063+** test2:
2064+** ...
2065+** str x30, \[sp\]
2066+** sub sp, sp, #1040
2067+** str xzr, \[sp\]
2068+** cbnz w0, .*
2069+** bl g
2070+** ...
2071+*/
2072+int test2(int z) {
2073+ __uint128_t x = 0;
2074+ int y[0x400];
2075+ if (z)
2076+ {
2077+ asm volatile ("" :::
2078+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
2079+ f(0, 0, 0, 0, 0, 0, 0, &y,
2080+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2081+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2082+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2083+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2084+ x);
2085+ }
2086+ g();
2087+ return 1;
2088+}
2089+
2090+/*
2091+** test3:
2092+** ...
2093+** str x30, \[sp\]
2094+** sub sp, sp, #1024
2095+** cbnz w0, .*
2096+** bl g
2097+** ...
2098+*/
2099+int test3(int z) {
2100+ __uint128_t x = 0;
2101+ int y[0x400];
2102+ if (z)
2103+ {
2104+ asm volatile ("" :::
2105+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
2106+ f(0, 0, 0, 0, 0, 0, 0, &y,
2107+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2108+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2109+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2110+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x);
2111+ }
2112+ g();
2113+ return 1;
2114+}
2115diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c
2116new file mode 100644
2117index 00000000000..73ac3e4e4eb
2118--- /dev/null
2119+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c
2120@@ -0,0 +1,100 @@
2121+/* { dg-options "-O2 -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12 -fsanitize=shadow-call-stack -ffixed-x18" } */
2122+/* { dg-final { check-function-bodies "**" "" } } */
2123+
2124+void f(int, ...);
2125+void g();
2126+
2127+/*
2128+** test1:
2129+** ...
2130+** str x30, \[sp\]
2131+** sub sp, sp, #4064
2132+** str xzr, \[sp\]
2133+** cbnz w0, .*
2134+** bl g
2135+** ...
2136+** str x26, \[sp, #?4128\]
2137+** ...
2138+*/
2139+int test1(int z) {
2140+ __uint128_t x = 0;
2141+ int y[0x400];
2142+ if (z)
2143+ {
2144+ asm volatile ("" :::
2145+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
2146+ f(0, 0, 0, 0, 0, 0, 0, &y,
2147+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2148+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2149+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2150+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2151+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2152+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2153+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2154+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2155+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2156+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2157+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2158+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2159+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2160+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2161+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2162+ x, x, x, x, x, x, x, x, x, x, x, x, x, x);
2163+ }
2164+ g();
2165+ return 1;
2166+}
2167+
2168+/*
2169+** test2:
2170+** ...
2171+** str x30, \[sp\]
2172+** sub sp, sp, #1040
2173+** str xzr, \[sp\]
2174+** cbnz w0, .*
2175+** bl g
2176+** ...
2177+*/
2178+int test2(int z) {
2179+ __uint128_t x = 0;
2180+ int y[0x400];
2181+ if (z)
2182+ {
2183+ asm volatile ("" :::
2184+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
2185+ f(0, 0, 0, 0, 0, 0, 0, &y,
2186+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2187+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2188+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2189+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2190+ x);
2191+ }
2192+ g();
2193+ return 1;
2194+}
2195+
2196+/*
2197+** test3:
2198+** ...
2199+** str x30, \[sp\]
2200+** sub sp, sp, #1024
2201+** cbnz w0, .*
2202+** bl g
2203+** ...
2204+*/
2205+int test3(int z) {
2206+ __uint128_t x = 0;
2207+ int y[0x400];
2208+ if (z)
2209+ {
2210+ asm volatile ("" :::
2211+ "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26");
2212+ f(0, 0, 0, 0, 0, 0, 0, &y,
2213+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2214+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2215+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x,
2216+ x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x);
2217+ }
2218+ g();
2219+ return 1;
2220+}
2221diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-20.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-20.c
2222new file mode 100644
2223index 00000000000..690aae8dfd5
2224--- /dev/null
2225+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-20.c
2226@@ -0,0 +1,3 @@
2227+/* { dg-options "-O2 -fstack-protector-all -fstack-clash-protection -fomit-frame-pointer --param stack-clash-protection-guard-size=12 -fsanitize=shadow-call-stack -ffixed-x18" } */
2228+
2229+#include "stack-check-prologue-19.c"
2230--
22312.34.1
2232
2233
2234From eea1759073e09dd1aefbc9a881601ab1eebfdd18 Mon Sep 17 00:00:00 2001
2235From: Richard Sandiford <richard.sandiford@arm.com>
2236Date: Tue, 12 Sep 2023 16:07:19 +0100
2237Subject: [PATCH 16/19] aarch64: Simplify probe of final frame allocation
2238
2239Previous patches ensured that the final frame allocation only needs
2240a probe when the size is strictly greater than 1KiB. It's therefore
2241safe to use the normal 1024 probe offset in all cases.
2242
2243The main motivation for doing this is to simplify the code and
2244remove the number of special cases.
2245
2246gcc/
2247 * config/aarch64/aarch64.cc (aarch64_allocate_and_probe_stack_space):
2248 Always probe the residual allocation at offset 1024, asserting
2249 that that is in range.
2250
2251gcc/testsuite/
2252 * gcc.target/aarch64/stack-check-prologue-17.c: Expect the probe
2253 to be at offset 1024 rather than offset 0.
2254 * gcc.target/aarch64/stack-check-prologue-18.c: Likewise.
2255 * gcc.target/aarch64/stack-check-prologue-19.c: Likewise.
2256---
2257 gcc/config/aarch64/aarch64.cc | 12 ++++--------
2258 .../gcc.target/aarch64/stack-check-prologue-17.c | 2 +-
2259 .../gcc.target/aarch64/stack-check-prologue-18.c | 4 ++--
2260 .../gcc.target/aarch64/stack-check-prologue-19.c | 4 ++--
2261 4 files changed, 9 insertions(+), 13 deletions(-)
2262
2263diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
2264index a765f92329d..37809a306f7 100644
2265--- a/gcc/config/aarch64/aarch64.cc
2266+++ b/gcc/config/aarch64/aarch64.cc
2267@@ -9838,16 +9838,12 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
2268 are still safe. */
2269 if (residual)
2270 {
2271- HOST_WIDE_INT residual_probe_offset = guard_used_by_caller;
2272+ gcc_assert (guard_used_by_caller + byte_sp_alignment <= size);
2273+
2274 /* If we're doing final adjustments, and we've done any full page
2275 allocations then any residual needs to be probed. */
2276 if (final_adjustment_p && rounded_size != 0)
2277 min_probe_threshold = 0;
2278- /* If doing a small final adjustment, we always probe at offset 0.
2279- This is done to avoid issues when the final adjustment is smaller
2280- than the probing offset. */
2281- else if (final_adjustment_p && rounded_size == 0)
2282- residual_probe_offset = 0;
2283
2284 aarch64_sub_sp (temp1, temp2, residual, frame_related_p);
2285 if (residual >= min_probe_threshold)
2286@@ -9858,8 +9854,8 @@ aarch64_allocate_and_probe_stack_space (rtx temp1, rtx temp2,
2287 HOST_WIDE_INT_PRINT_DEC " bytes, probing will be required."
2288 "\n", residual);
2289
2290- emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
2291- residual_probe_offset));
2292+ emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx,
2293+ guard_used_by_caller));
2294 emit_insn (gen_blockage ());
2295 }
2296 }
2297diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
2298index 0d8a25d73a2..f0ec1389771 100644
2299--- a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
2300+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-17.c
2301@@ -33,7 +33,7 @@ int test1(int z) {
2302 ** ...
2303 ** str x30, \[sp\]
2304 ** sub sp, sp, #1040
2305-** str xzr, \[sp\]
2306+** str xzr, \[sp, #?1024\]
2307 ** cbnz w0, .*
2308 ** bl g
2309 ** ...
2310diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
2311index 82447d20fff..6383bec5ebc 100644
2312--- a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
2313+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-18.c
2314@@ -9,7 +9,7 @@ void g();
2315 ** ...
2316 ** str x30, \[sp\]
2317 ** sub sp, sp, #4064
2318-** str xzr, \[sp\]
2319+** str xzr, \[sp, #?1024\]
2320 ** cbnz w0, .*
2321 ** bl g
2322 ** ...
2323@@ -50,7 +50,7 @@ int test1(int z) {
2324 ** ...
2325 ** str x30, \[sp\]
2326 ** sub sp, sp, #1040
2327-** str xzr, \[sp\]
2328+** str xzr, \[sp, #?1024\]
2329 ** cbnz w0, .*
2330 ** bl g
2331 ** ...
2332diff --git a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c
2333index 73ac3e4e4eb..562039b5e9b 100644
2334--- a/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c
2335+++ b/gcc/testsuite/gcc.target/aarch64/stack-check-prologue-19.c
2336@@ -9,7 +9,7 @@ void g();
2337 ** ...
2338 ** str x30, \[sp\]
2339 ** sub sp, sp, #4064
2340-** str xzr, \[sp\]
2341+** str xzr, \[sp, #?1024\]
2342 ** cbnz w0, .*
2343 ** bl g
2344 ** ...
2345@@ -50,7 +50,7 @@ int test1(int z) {
2346 ** ...
2347 ** str x30, \[sp\]
2348 ** sub sp, sp, #1040
2349-** str xzr, \[sp\]
2350+** str xzr, \[sp, #?1024\]
2351 ** cbnz w0, .*
2352 ** bl g
2353 ** ...
2354--
23552.34.1
2356
2357
2358From 96d85187c3b9c9a7efc2fd698c3d452e80d8aa47 Mon Sep 17 00:00:00 2001
2359From: Richard Sandiford <richard.sandiford@arm.com>
2360Date: Tue, 12 Sep 2023 16:07:20 +0100
2361Subject: [PATCH 17/19] aarch64: Explicitly record probe registers in frame
2362 info
2363
2364The stack frame is currently divided into three areas:
2365
2366A: the area above the hard frame pointer
2367B: the SVE saves below the hard frame pointer
2368C: the outgoing arguments
2369
2370If the stack frame is allocated in one chunk, the allocation needs a
2371probe if the frame size is >= guard_size - 1KiB. In addition, if the
2372function is not a leaf function, it must probe an address no more than
23731KiB above the outgoing SP. We ensured the second condition by
2374
2375(1) using single-chunk allocations for non-leaf functions only if
2376 the link register save slot is within 512 bytes of the bottom
2377 of the frame; and
2378
2379(2) using the link register save as a probe (meaning, for instance,
2380 that it can't be individually shrink wrapped)
2381
2382If instead the stack is allocated in multiple chunks, then:
2383
2384* an allocation involving only the outgoing arguments (C above) requires
2385 a probe if the allocation size is > 1KiB
2386
2387* any other allocation requires a probe if the allocation size
2388 is >= guard_size - 1KiB
2389
2390* second and subsequent allocations require the previous allocation
2391 to probe at the bottom of the allocated area, regardless of the size
2392 of that previous allocation
2393
2394The final point means that, unlike for single allocations,
2395it can be necessary to have both a non-SVE register probe and
2396an SVE register probe. For example:
2397
2398* allocate A, probe using a non-SVE register save
2399* allocate B, probe using an SVE register save
2400* allocate C
2401
2402The non-SVE register used in this case was again the link register.
2403It was previously used even if the link register save slot was some
2404bytes above the bottom of the non-SVE register saves, but an earlier
2405patch avoided that by putting the link register save slot first.
2406
2407As a belt-and-braces fix, this patch explicitly records which
2408probe registers we're using and allows the non-SVE probe to be
2409whichever register comes first (as for SVE).
2410
2411The patch also avoids unnecessary probes in sve/pcs/stack_clash_3.c.
2412
2413gcc/
2414 * config/aarch64/aarch64.h (aarch64_frame::sve_save_and_probe)
2415 (aarch64_frame::hard_fp_save_and_probe): New fields.
2416 * config/aarch64/aarch64.cc (aarch64_layout_frame): Initialize them.
2417 Rather than asserting that a leaf function saves LR, instead assert
2418 that a leaf function saves something.
2419 (aarch64_get_separate_components): Prevent the chosen probe
2420 registers from being individually shrink-wrapped.
2421 (aarch64_allocate_and_probe_stack_space): Remove workaround for
2422 probe registers that aren't at the bottom of the previous allocation.
2423
2424gcc/testsuite/
2425 * gcc.target/aarch64/sve/pcs/stack_clash_3.c: Avoid redundant probes.
2426---
2427 gcc/config/aarch64/aarch64.cc | 68 +++++++++++++++----
2428 gcc/config/aarch64/aarch64.h | 8 +++
2429 .../aarch64/sve/pcs/stack_clash_3.c | 6 +-
2430 3 files changed, 64 insertions(+), 18 deletions(-)
2431
2432diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
2433index 37809a306f7..6c59c39a639 100644
2434--- a/gcc/config/aarch64/aarch64.cc
2435+++ b/gcc/config/aarch64/aarch64.cc
2436@@ -8471,15 +8471,11 @@ aarch64_layout_frame (void)
2437 && !crtl->abi->clobbers_full_reg_p (regno))
2438 frame.reg_offset[regno] = SLOT_REQUIRED;
2439
2440- /* With stack-clash, LR must be saved in non-leaf functions. The saving of
2441- LR counts as an implicit probe which allows us to maintain the invariant
2442- described in the comment at expand_prologue. */
2443- gcc_assert (crtl->is_leaf
2444- || maybe_ne (frame.reg_offset[R30_REGNUM], SLOT_NOT_REQUIRED));
2445
2446 poly_int64 offset = crtl->outgoing_args_size;
2447 gcc_assert (multiple_p (offset, STACK_BOUNDARY / BITS_PER_UNIT));
2448 frame.bytes_below_saved_regs = offset;
2449+ frame.sve_save_and_probe = INVALID_REGNUM;
2450
2451 /* Now assign stack slots for the registers. Start with the predicate
2452 registers, since predicate LDR and STR have a relatively small
2453@@ -8487,6 +8483,8 @@ aarch64_layout_frame (void)
2454 for (regno = P0_REGNUM; regno <= P15_REGNUM; regno++)
2455 if (known_eq (frame.reg_offset[regno], SLOT_REQUIRED))
2456 {
2457+ if (frame.sve_save_and_probe == INVALID_REGNUM)
2458+ frame.sve_save_and_probe = regno;
2459 frame.reg_offset[regno] = offset;
2460 offset += BYTES_PER_SVE_PRED;
2461 }
2462@@ -8524,6 +8522,8 @@ aarch64_layout_frame (void)
2463 for (regno = V0_REGNUM; regno <= V31_REGNUM; regno++)
2464 if (known_eq (frame.reg_offset[regno], SLOT_REQUIRED))
2465 {
2466+ if (frame.sve_save_and_probe == INVALID_REGNUM)
2467+ frame.sve_save_and_probe = regno;
2468 frame.reg_offset[regno] = offset;
2469 offset += vector_save_size;
2470 }
2471@@ -8533,10 +8533,18 @@ aarch64_layout_frame (void)
2472 frame.below_hard_fp_saved_regs_size = offset - frame.bytes_below_saved_regs;
2473 bool saves_below_hard_fp_p
2474 = maybe_ne (frame.below_hard_fp_saved_regs_size, 0);
2475+ gcc_assert (!saves_below_hard_fp_p
2476+ || (frame.sve_save_and_probe != INVALID_REGNUM
2477+ && known_eq (frame.reg_offset[frame.sve_save_and_probe],
2478+ frame.bytes_below_saved_regs)));
2479+
2480 frame.bytes_below_hard_fp = offset;
2481+ frame.hard_fp_save_and_probe = INVALID_REGNUM;
2482
2483 auto allocate_gpr_slot = [&](unsigned int regno)
2484 {
2485+ if (frame.hard_fp_save_and_probe == INVALID_REGNUM)
2486+ frame.hard_fp_save_and_probe = regno;
2487 frame.reg_offset[regno] = offset;
2488 if (frame.wb_push_candidate1 == INVALID_REGNUM)
2489 frame.wb_push_candidate1 = regno;
2490@@ -8570,6 +8578,8 @@ aarch64_layout_frame (void)
2491 for (regno = V0_REGNUM; regno <= V31_REGNUM; regno++)
2492 if (known_eq (frame.reg_offset[regno], SLOT_REQUIRED))
2493 {
2494+ if (frame.hard_fp_save_and_probe == INVALID_REGNUM)
2495+ frame.hard_fp_save_and_probe = regno;
2496 /* If there is an alignment gap between integer and fp callee-saves,
2497 allocate the last fp register to it if possible. */
2498 if (regno == last_fp_reg
2499@@ -8593,6 +8603,17 @@ aarch64_layout_frame (void)
2500 offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
2501
2502 frame.saved_regs_size = offset - frame.bytes_below_saved_regs;
2503+ gcc_assert (known_eq (frame.saved_regs_size,
2504+ frame.below_hard_fp_saved_regs_size)
2505+ || (frame.hard_fp_save_and_probe != INVALID_REGNUM
2506+ && known_eq (frame.reg_offset[frame.hard_fp_save_and_probe],
2507+ frame.bytes_below_hard_fp)));
2508+
2509+ /* With stack-clash, a register must be saved in non-leaf functions.
2510+ The saving of the bottommost register counts as an implicit probe,
2511+ which allows us to maintain the invariant described in the comment
2512+ at expand_prologue. */
2513+ gcc_assert (crtl->is_leaf || maybe_ne (frame.saved_regs_size, 0));
2514
2515 offset += get_frame_size ();
2516 offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
2517@@ -8723,6 +8744,25 @@ aarch64_layout_frame (void)
2518 frame.final_adjust = frame.bytes_below_saved_regs;
2519 }
2520
2521+ /* The frame is allocated in pieces, with each non-final piece
2522+ including a register save at offset 0 that acts as a probe for
2523+ the following piece. In addition, the save of the bottommost register
2524+ acts as a probe for callees and allocas. Roll back any probes that
2525+ aren't needed.
2526+
2527+ A probe isn't needed if it is associated with the final allocation
2528+ (including callees and allocas) that happens before the epilogue is
2529+ executed. */
2530+ if (crtl->is_leaf
2531+ && !cfun->calls_alloca
2532+ && known_eq (frame.final_adjust, 0))
2533+ {
2534+ if (maybe_ne (frame.sve_callee_adjust, 0))
2535+ frame.sve_save_and_probe = INVALID_REGNUM;
2536+ else
2537+ frame.hard_fp_save_and_probe = INVALID_REGNUM;
2538+ }
2539+
2540 /* Make sure the individual adjustments add up to the full frame size. */
2541 gcc_assert (known_eq (frame.initial_adjust
2542 + frame.callee_adjust
2543@@ -9354,13 +9394,6 @@ aarch64_get_separate_components (void)
2544
2545 poly_int64 offset = frame.reg_offset[regno];
2546
2547- /* If the register is saved in the first SVE save slot, we use
2548- it as a stack probe for -fstack-clash-protection. */
2549- if (flag_stack_clash_protection
2550- && maybe_ne (frame.below_hard_fp_saved_regs_size, 0)
2551- && known_eq (offset, frame.bytes_below_saved_regs))
2552- continue;
2553-
2554 /* Get the offset relative to the register we'll use. */
2555 if (frame_pointer_needed)
2556 offset -= frame.bytes_below_hard_fp;
2557@@ -9395,6 +9428,13 @@ aarch64_get_separate_components (void)
2558
2559 bitmap_clear_bit (components, LR_REGNUM);
2560 bitmap_clear_bit (components, SP_REGNUM);
2561+ if (flag_stack_clash_protection)
2562+ {
2563+ if (frame.sve_save_and_probe != INVALID_REGNUM)
2564+ bitmap_clear_bit (components, frame.sve_save_and_probe);
2565+ if (frame.hard_fp_save_and_probe != INVALID_REGNUM)
2566+ bitmap_clear_bit (components, frame.hard_fp_save_and_probe);
2567+ }
2568
2569 return components;
2570 }
2571@@ -9931,8 +9971,8 @@ aarch64_epilogue_uses (int regno)
2572 When probing is needed, we emit a probe at the start of the prologue
2573 and every PARAM_STACK_CLASH_PROTECTION_GUARD_SIZE bytes thereafter.
2574
2575- We have to track how much space has been allocated and the only stores
2576- to the stack we track as implicit probes are the FP/LR stores.
2577+ We can also use register saves as probes. These are stored in
2578+ sve_save_and_probe and hard_fp_save_and_probe.
2579
2580 For outgoing arguments we probe if the size is larger than 1KB, such that
2581 the ABI specified buffer is maintained for the next callee.
2582diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
2583index c8becb098c8..fbfb73545ba 100644
2584--- a/gcc/config/aarch64/aarch64.h
2585+++ b/gcc/config/aarch64/aarch64.h
2586@@ -863,6 +863,14 @@ struct GTY (()) aarch64_frame
2587 This is the register they should use. */
2588 unsigned spare_pred_reg;
2589
2590+ /* An SVE register that is saved below the hard frame pointer and that acts
2591+ as a probe for later allocations, or INVALID_REGNUM if none. */
2592+ unsigned sve_save_and_probe;
2593+
2594+ /* A register that is saved at the hard frame pointer and that acts
2595+ as a probe for later allocations, or INVALID_REGNUM if none. */
2596+ unsigned hard_fp_save_and_probe;
2597+
2598 bool laid_out;
2599
2600 /* True if shadow call stack should be enabled for the current function. */
2601diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pcs/stack_clash_3.c b/gcc/testsuite/gcc.target/aarch64/sve/pcs/stack_clash_3.c
2602index 3e01ec36c3a..3530a0d504b 100644
2603--- a/gcc/testsuite/gcc.target/aarch64/sve/pcs/stack_clash_3.c
2604+++ b/gcc/testsuite/gcc.target/aarch64/sve/pcs/stack_clash_3.c
2605@@ -11,11 +11,10 @@
2606 ** mov x11, sp
2607 ** ...
2608 ** sub sp, sp, x13
2609-** str p4, \[sp\]
2610 ** cbz w0, [^\n]*
2611+** str p4, \[sp\]
2612 ** ...
2613 ** ptrue p0\.b, all
2614-** ldr p4, \[sp\]
2615 ** addvl sp, sp, #1
2616 ** ldr x24, \[sp\], 32
2617 ** ret
2618@@ -39,13 +38,12 @@ test_1 (int n)
2619 ** mov x11, sp
2620 ** ...
2621 ** sub sp, sp, x13
2622-** str p4, \[sp\]
2623 ** cbz w0, [^\n]*
2624+** str p4, \[sp\]
2625 ** str p5, \[sp, #1, mul vl\]
2626 ** str p6, \[sp, #2, mul vl\]
2627 ** ...
2628 ** ptrue p0\.b, all
2629-** ldr p4, \[sp\]
2630 ** addvl sp, sp, #1
2631 ** ldr x24, \[sp\], 32
2632 ** ret
2633--
26342.34.1
2635
2636
2637From 56df065080950bb30dda9c260f71be54269bdda5 Mon Sep 17 00:00:00 2001
2638From: Richard Sandiford <richard.sandiford@arm.com>
2639Date: Tue, 12 Sep 2023 16:07:20 +0100
2640Subject: [PATCH 18/19] aarch64: Remove below_hard_fp_saved_regs_size
2641
2642After previous patches, it's no longer necessary to store
2643saved_regs_size and below_hard_fp_saved_regs_size in the frame info.
2644All measurements instead use the top or bottom of the frame as
2645reference points.
2646
2647gcc/
2648 * config/aarch64/aarch64.h (aarch64_frame::saved_regs_size)
2649 (aarch64_frame::below_hard_fp_saved_regs_size): Delete.
2650 * config/aarch64/aarch64.cc (aarch64_layout_frame): Update accordingly.
2651---
2652 gcc/config/aarch64/aarch64.cc | 45 ++++++++++++++++-------------------
2653 gcc/config/aarch64/aarch64.h | 7 ------
2654 2 files changed, 21 insertions(+), 31 deletions(-)
2655
2656diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
2657index 6c59c39a639..b95e805a8cc 100644
2658--- a/gcc/config/aarch64/aarch64.cc
2659+++ b/gcc/config/aarch64/aarch64.cc
2660@@ -8530,9 +8530,8 @@ aarch64_layout_frame (void)
2661
2662 /* OFFSET is now the offset of the hard frame pointer from the bottom
2663 of the callee save area. */
2664- frame.below_hard_fp_saved_regs_size = offset - frame.bytes_below_saved_regs;
2665- bool saves_below_hard_fp_p
2666- = maybe_ne (frame.below_hard_fp_saved_regs_size, 0);
2667+ auto below_hard_fp_saved_regs_size = offset - frame.bytes_below_saved_regs;
2668+ bool saves_below_hard_fp_p = maybe_ne (below_hard_fp_saved_regs_size, 0);
2669 gcc_assert (!saves_below_hard_fp_p
2670 || (frame.sve_save_and_probe != INVALID_REGNUM
2671 && known_eq (frame.reg_offset[frame.sve_save_and_probe],
2672@@ -8602,9 +8601,8 @@ aarch64_layout_frame (void)
2673
2674 offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
2675
2676- frame.saved_regs_size = offset - frame.bytes_below_saved_regs;
2677- gcc_assert (known_eq (frame.saved_regs_size,
2678- frame.below_hard_fp_saved_regs_size)
2679+ auto saved_regs_size = offset - frame.bytes_below_saved_regs;
2680+ gcc_assert (known_eq (saved_regs_size, below_hard_fp_saved_regs_size)
2681 || (frame.hard_fp_save_and_probe != INVALID_REGNUM
2682 && known_eq (frame.reg_offset[frame.hard_fp_save_and_probe],
2683 frame.bytes_below_hard_fp)));
2684@@ -8613,7 +8611,7 @@ aarch64_layout_frame (void)
2685 The saving of the bottommost register counts as an implicit probe,
2686 which allows us to maintain the invariant described in the comment
2687 at expand_prologue. */
2688- gcc_assert (crtl->is_leaf || maybe_ne (frame.saved_regs_size, 0));
2689+ gcc_assert (crtl->is_leaf || maybe_ne (saved_regs_size, 0));
2690
2691 offset += get_frame_size ();
2692 offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
2693@@ -8670,7 +8668,7 @@ aarch64_layout_frame (void)
2694
2695 HOST_WIDE_INT const_size, const_below_saved_regs, const_above_fp;
2696 HOST_WIDE_INT const_saved_regs_size;
2697- if (known_eq (frame.saved_regs_size, 0))
2698+ if (known_eq (saved_regs_size, 0))
2699 frame.initial_adjust = frame.frame_size;
2700 else if (frame.frame_size.is_constant (&const_size)
2701 && const_size < max_push_offset
2702@@ -8683,7 +8681,7 @@ aarch64_layout_frame (void)
2703 frame.callee_adjust = const_size;
2704 }
2705 else if (frame.bytes_below_saved_regs.is_constant (&const_below_saved_regs)
2706- && frame.saved_regs_size.is_constant (&const_saved_regs_size)
2707+ && saved_regs_size.is_constant (&const_saved_regs_size)
2708 && const_below_saved_regs + const_saved_regs_size < 512
2709 /* We could handle this case even with data below the saved
2710 registers, provided that that data left us with valid offsets
2711@@ -8702,8 +8700,7 @@ aarch64_layout_frame (void)
2712 frame.initial_adjust = frame.frame_size;
2713 }
2714 else if (saves_below_hard_fp_p
2715- && known_eq (frame.saved_regs_size,
2716- frame.below_hard_fp_saved_regs_size))
2717+ && known_eq (saved_regs_size, below_hard_fp_saved_regs_size))
2718 {
2719 /* Frame in which all saves are SVE saves:
2720
2721@@ -8725,7 +8722,7 @@ aarch64_layout_frame (void)
2722 [save SVE registers relative to SP]
2723 sub sp, sp, bytes_below_saved_regs */
2724 frame.callee_adjust = const_above_fp;
2725- frame.sve_callee_adjust = frame.below_hard_fp_saved_regs_size;
2726+ frame.sve_callee_adjust = below_hard_fp_saved_regs_size;
2727 frame.final_adjust = frame.bytes_below_saved_regs;
2728 }
2729 else
2730@@ -8740,7 +8737,7 @@ aarch64_layout_frame (void)
2731 [save SVE registers relative to SP]
2732 sub sp, sp, bytes_below_saved_regs */
2733 frame.initial_adjust = frame.bytes_above_hard_fp;
2734- frame.sve_callee_adjust = frame.below_hard_fp_saved_regs_size;
2735+ frame.sve_callee_adjust = below_hard_fp_saved_regs_size;
2736 frame.final_adjust = frame.bytes_below_saved_regs;
2737 }
2738
2739@@ -9936,17 +9933,17 @@ aarch64_epilogue_uses (int regno)
2740 | local variables | <-- frame_pointer_rtx
2741 | |
2742 +-------------------------------+
2743- | padding | \
2744- +-------------------------------+ |
2745- | callee-saved registers | | frame.saved_regs_size
2746- +-------------------------------+ |
2747- | LR' | |
2748- +-------------------------------+ |
2749- | FP' | |
2750- +-------------------------------+ |<- hard_frame_pointer_rtx (aligned)
2751- | SVE vector registers | | \
2752- +-------------------------------+ | | below_hard_fp_saved_regs_size
2753- | SVE predicate registers | / /
2754+ | padding |
2755+ +-------------------------------+
2756+ | callee-saved registers |
2757+ +-------------------------------+
2758+ | LR' |
2759+ +-------------------------------+
2760+ | FP' |
2761+ +-------------------------------+ <-- hard_frame_pointer_rtx (aligned)
2762+ | SVE vector registers |
2763+ +-------------------------------+
2764+ | SVE predicate registers |
2765 +-------------------------------+
2766 | dynamic allocation |
2767 +-------------------------------+
2768diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
2769index fbfb73545ba..cfeaf4657ab 100644
2770--- a/gcc/config/aarch64/aarch64.h
2771+++ b/gcc/config/aarch64/aarch64.h
2772@@ -777,18 +777,11 @@ struct GTY (()) aarch64_frame
2773 STACK_BOUNDARY. */
2774 HOST_WIDE_INT saved_varargs_size;
2775
2776- /* The size of the callee-save registers with a slot in REG_OFFSET. */
2777- poly_int64 saved_regs_size;
2778-
2779 /* The number of bytes between the bottom of the static frame (the bottom
2780 of the outgoing arguments) and the bottom of the register save area.
2781 This value is always a multiple of STACK_BOUNDARY. */
2782 poly_int64 bytes_below_saved_regs;
2783
2784- /* The size of the callee-save registers with a slot in REG_OFFSET that
2785- are saved below the hard frame pointer. */
2786- poly_int64 below_hard_fp_saved_regs_size;
2787-
2788 /* The number of bytes between the bottom of the static frame (the bottom
2789 of the outgoing arguments) and the hard frame pointer. This value is
2790 always a multiple of STACK_BOUNDARY. */
2791--
27922.34.1
2793
2794
2795From b96e66fd4ef3e36983969fb8cdd1956f551a074b Mon Sep 17 00:00:00 2001
2796From: Richard Sandiford <richard.sandiford@arm.com>
2797Date: Tue, 12 Sep 2023 16:07:21 +0100
2798Subject: [PATCH 19/19] aarch64: Make stack smash canary protect saved
2799 registers
2800
2801AArch64 normally puts the saved registers near the bottom of the frame,
2802immediately above any dynamic allocations. But this means that a
2803stack-smash attack on those dynamic allocations could overwrite the
2804saved registers without needing to reach as far as the stack smash
2805canary.
2806
2807The same thing could also happen for variable-sized arguments that are
2808passed by value, since those are allocated before a call and popped on
2809return.
2810
2811This patch avoids that by putting the locals (and thus the canary) below
2812the saved registers when stack smash protection is active.
2813
2814The patch fixes CVE-2023-4039.
2815
2816gcc/
2817 * config/aarch64/aarch64.cc (aarch64_save_regs_above_locals_p):
2818 New function.
2819 (aarch64_layout_frame): Use it to decide whether locals should
2820 go above or below the saved registers.
2821 (aarch64_expand_prologue): Update stack layout comment.
2822 Emit a stack tie after the final adjustment.
2823
2824gcc/testsuite/
2825 * gcc.target/aarch64/stack-protector-8.c: New test.
2826 * gcc.target/aarch64/stack-protector-9.c: Likewise.
2827---
2828 gcc/config/aarch64/aarch64.cc | 46 +++++++--
2829 .../gcc.target/aarch64/stack-protector-8.c | 95 +++++++++++++++++++
2830 .../gcc.target/aarch64/stack-protector-9.c | 33 +++++++
2831 3 files changed, 168 insertions(+), 6 deletions(-)
2832 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-protector-8.c
2833 create mode 100644 gcc/testsuite/gcc.target/aarch64/stack-protector-9.c
2834
2835diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
2836index b95e805a8cc..389c0e29353 100644
2837--- a/gcc/config/aarch64/aarch64.cc
2838+++ b/gcc/config/aarch64/aarch64.cc
2839@@ -8394,6 +8394,20 @@ aarch64_needs_frame_chain (void)
2840 return aarch64_use_frame_pointer;
2841 }
2842
2843+/* Return true if the current function should save registers above
2844+ the locals area, rather than below it. */
2845+
2846+static bool
2847+aarch64_save_regs_above_locals_p ()
2848+{
2849+ /* When using stack smash protection, make sure that the canary slot
2850+ comes between the locals and the saved registers. Otherwise,
2851+ it would be possible for a carefully sized smash attack to change
2852+ the saved registers (particularly LR and FP) without reaching the
2853+ canary. */
2854+ return crtl->stack_protect_guard;
2855+}
2856+
2857 /* Mark the registers that need to be saved by the callee and calculate
2858 the size of the callee-saved registers area and frame record (both FP
2859 and LR may be omitted). */
2860@@ -8405,6 +8419,7 @@ aarch64_layout_frame (void)
2861 poly_int64 vector_save_size = GET_MODE_SIZE (vector_save_mode);
2862 bool frame_related_fp_reg_p = false;
2863 aarch64_frame &frame = cfun->machine->frame;
2864+ poly_int64 top_of_locals = -1;
2865
2866 frame.emit_frame_chain = aarch64_needs_frame_chain ();
2867
2868@@ -8471,9 +8486,16 @@ aarch64_layout_frame (void)
2869 && !crtl->abi->clobbers_full_reg_p (regno))
2870 frame.reg_offset[regno] = SLOT_REQUIRED;
2871
2872+ bool regs_at_top_p = aarch64_save_regs_above_locals_p ();
2873
2874 poly_int64 offset = crtl->outgoing_args_size;
2875 gcc_assert (multiple_p (offset, STACK_BOUNDARY / BITS_PER_UNIT));
2876+ if (regs_at_top_p)
2877+ {
2878+ offset += get_frame_size ();
2879+ offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
2880+ top_of_locals = offset;
2881+ }
2882 frame.bytes_below_saved_regs = offset;
2883 frame.sve_save_and_probe = INVALID_REGNUM;
2884
2885@@ -8613,15 +8635,18 @@ aarch64_layout_frame (void)
2886 at expand_prologue. */
2887 gcc_assert (crtl->is_leaf || maybe_ne (saved_regs_size, 0));
2888
2889- offset += get_frame_size ();
2890- offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
2891- auto top_of_locals = offset;
2892-
2893+ if (!regs_at_top_p)
2894+ {
2895+ offset += get_frame_size ();
2896+ offset = aligned_upper_bound (offset, STACK_BOUNDARY / BITS_PER_UNIT);
2897+ top_of_locals = offset;
2898+ }
2899 offset += frame.saved_varargs_size;
2900 gcc_assert (multiple_p (offset, STACK_BOUNDARY / BITS_PER_UNIT));
2901 frame.frame_size = offset;
2902
2903 frame.bytes_above_hard_fp = frame.frame_size - frame.bytes_below_hard_fp;
2904+ gcc_assert (known_ge (top_of_locals, 0));
2905 frame.bytes_above_locals = frame.frame_size - top_of_locals;
2906
2907 frame.initial_adjust = 0;
2908@@ -9930,10 +9955,10 @@ aarch64_epilogue_uses (int regno)
2909 | for register varargs |
2910 | |
2911 +-------------------------------+
2912- | local variables | <-- frame_pointer_rtx
2913+ | local variables (1) | <-- frame_pointer_rtx
2914 | |
2915 +-------------------------------+
2916- | padding |
2917+ | padding (1) |
2918 +-------------------------------+
2919 | callee-saved registers |
2920 +-------------------------------+
2921@@ -9945,6 +9970,10 @@ aarch64_epilogue_uses (int regno)
2922 +-------------------------------+
2923 | SVE predicate registers |
2924 +-------------------------------+
2925+ | local variables (2) |
2926+ +-------------------------------+
2927+ | padding (2) |
2928+ +-------------------------------+
2929 | dynamic allocation |
2930 +-------------------------------+
2931 | padding |
2932@@ -9954,6 +9983,9 @@ aarch64_epilogue_uses (int regno)
2933 +-------------------------------+
2934 | | <-- stack_pointer_rtx (aligned)
2935
2936+ The regions marked (1) and (2) are mutually exclusive. (2) is used
2937+ when aarch64_save_regs_above_locals_p is true.
2938+
2939 Dynamic stack allocations via alloca() decrease stack_pointer_rtx
2940 but leave frame_pointer_rtx and hard_frame_pointer_rtx
2941 unchanged.
2942@@ -10149,6 +10181,8 @@ aarch64_expand_prologue (void)
2943 gcc_assert (known_eq (bytes_below_sp, final_adjust));
2944 aarch64_allocate_and_probe_stack_space (tmp1_rtx, tmp0_rtx, final_adjust,
2945 !frame_pointer_needed, true);
2946+ if (emit_frame_chain && maybe_ne (final_adjust, 0))
2947+ emit_insn (gen_stack_tie (stack_pointer_rtx, hard_frame_pointer_rtx));
2948 }
2949
2950 /* Return TRUE if we can use a simple_return insn.
2951diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c
2952new file mode 100644
2953index 00000000000..e71d820e365
2954--- /dev/null
2955+++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-8.c
2956@@ -0,0 +1,95 @@
2957+/* { dg-options " -O -fstack-protector-strong -mstack-protector-guard=sysreg -mstack-protector-guard-reg=tpidr2_el0 -mstack-protector-guard-offset=16" } */
2958+/* { dg-final { check-function-bodies "**" "" } } */
2959+
2960+void g(void *);
2961+__SVBool_t *h(void *);
2962+
2963+/*
2964+** test1:
2965+** sub sp, sp, #288
2966+** stp x29, x30, \[sp, #?272\]
2967+** add x29, sp, #?272
2968+** mrs (x[0-9]+), tpidr2_el0
2969+** ldr (x[0-9]+), \[\1, #?16\]
2970+** str \2, \[sp, #?264\]
2971+** mov \2, #?0
2972+** add x0, sp, #?8
2973+** bl g
2974+** ...
2975+** mrs .*
2976+** ...
2977+** bne .*
2978+** ...
2979+** ldp x29, x30, \[sp, #?272\]
2980+** add sp, sp, #?288
2981+** ret
2982+** bl __stack_chk_fail
2983+*/
2984+int test1() {
2985+ int y[0x40];
2986+ g(y);
2987+ return 1;
2988+}
2989+
2990+/*
2991+** test2:
2992+** stp x29, x30, \[sp, #?-16\]!
2993+** mov x29, sp
2994+** sub sp, sp, #1040
2995+** mrs (x[0-9]+), tpidr2_el0
2996+** ldr (x[0-9]+), \[\1, #?16\]
2997+** str \2, \[sp, #?1032\]
2998+** mov \2, #?0
2999+** add x0, sp, #?8
3000+** bl g
3001+** ...
3002+** mrs .*
3003+** ...
3004+** bne .*
3005+** ...
3006+** add sp, sp, #?1040
3007+** ldp x29, x30, \[sp\], #?16
3008+** ret
3009+** bl __stack_chk_fail
3010+*/
3011+int test2() {
3012+ int y[0x100];
3013+ g(y);
3014+ return 1;
3015+}
3016+
3017+#pragma GCC target "+sve"
3018+
3019+/*
3020+** test3:
3021+** stp x29, x30, \[sp, #?-16\]!
3022+** mov x29, sp
3023+** addvl sp, sp, #-18
3024+** ...
3025+** str p4, \[sp\]
3026+** ...
3027+** sub sp, sp, #272
3028+** mrs (x[0-9]+), tpidr2_el0
3029+** ldr (x[0-9]+), \[\1, #?16\]
3030+** str \2, \[sp, #?264\]
3031+** mov \2, #?0
3032+** add x0, sp, #?8
3033+** bl h
3034+** ...
3035+** mrs .*
3036+** ...
3037+** bne .*
3038+** ...
3039+** add sp, sp, #?272
3040+** ...
3041+** ldr p4, \[sp\]
3042+** ...
3043+** addvl sp, sp, #18
3044+** ldp x29, x30, \[sp\], #?16
3045+** ret
3046+** bl __stack_chk_fail
3047+*/
3048+__SVBool_t test3() {
3049+ int y[0x40];
3050+ return *h(y);
3051+}
3052diff --git a/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c b/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c
3053new file mode 100644
3054index 00000000000..58f322aa480
3055--- /dev/null
3056+++ b/gcc/testsuite/gcc.target/aarch64/stack-protector-9.c
3057@@ -0,0 +1,33 @@
3058+/* { dg-options "-O2 -mcpu=neoverse-v1 -fstack-protector-all" } */
3059+/* { dg-final { check-function-bodies "**" "" } } */
3060+
3061+/*
3062+** main:
3063+** ...
3064+** stp x29, x30, \[sp, #?-[0-9]+\]!
3065+** ...
3066+** sub sp, sp, #[0-9]+
3067+** ...
3068+** str x[0-9]+, \[x29, #?-8\]
3069+** ...
3070+*/
3071+int f(const char *);
3072+void g(void *);
3073+int main(int argc, char* argv[])
3074+{
3075+ int a;
3076+ int b;
3077+ char c[2+f(argv[1])];
3078+ int d[0x100];
3079+ char y;
3080+
3081+ y=42; a=4; b=10;
3082+ c[0] = 'h'; c[1] = '\0';
3083+
3084+ c[f(argv[2])] = '\0';
3085+
3086+ __builtin_printf("%d %d\n%s\n", a, b, c);
3087+ g(d);
3088+
3089+ return 0;
3090+}
3091--
30922.34.1
3093
diff --git a/meta/recipes-devtools/gcc/gcc_10.2.bb b/meta/recipes-devtools/gcc/gcc_13.2.bb
index 7d93590588..255fe552bd 100644
--- a/meta/recipes-devtools/gcc/gcc_10.2.bb
+++ b/meta/recipes-devtools/gcc/gcc_13.2.bb
@@ -4,11 +4,11 @@ require gcc-target.inc
4# Building with thumb enabled on armv4t armv5t fails with 4# Building with thumb enabled on armv4t armv5t fails with
5# | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7438:(.text.unlikely+0x2fa): relocation truncated to fit: R_ARM_THM_CALL against symbol `fancy_abort(char const*, int, char const*)' defined in .glue_7 section in linker stubs 5# | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7438:(.text.unlikely+0x2fa): relocation truncated to fit: R_ARM_THM_CALL against symbol `fancy_abort(char const*, int, char const*)' defined in .glue_7 section in linker stubs
6# | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7442:(.text.unlikely+0x318): additional relocation overflows omitted from the output 6# | gcc-4.8.1-r0/gcc-4.8.1/gcc/cp/decl.c:7442:(.text.unlikely+0x318): additional relocation overflows omitted from the output
7ARM_INSTRUCTION_SET_armv4 = "arm" 7ARM_INSTRUCTION_SET:armv4 = "arm"
8ARM_INSTRUCTION_SET_armv5 = "arm" 8ARM_INSTRUCTION_SET:armv5 = "arm"
9 9
10ARMFPARCHEXT_armv6 = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}" 10ARMFPARCHEXT:armv6 = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}"
11ARMFPARCHEXT_armv7a = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}" 11ARMFPARCHEXT:armv7a = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}"
12ARMFPARCHEXT_armv7ve = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}" 12ARMFPARCHEXT:armv7ve = "${@'+fp' if d.getVar('TARGET_FPU') == 'hard' else ''}"
13 13
14BBCLASSEXTEND = "nativesdk" 14BBCLASSEXTEND = "nativesdk"
diff --git a/meta/recipes-devtools/gcc/libgcc-common.inc b/meta/recipes-devtools/gcc/libgcc-common.inc
index d959566c3f..d9084af51a 100644
--- a/meta/recipes-devtools/gcc/libgcc-common.inc
+++ b/meta/recipes-devtools/gcc/libgcc-common.inc
@@ -10,8 +10,7 @@ do_configure () {
10 mkdir -p ${B}/${TARGET_SYS}/${BPN}/ 10 mkdir -p ${B}/${TARGET_SYS}/${BPN}/
11 cd ${B}/${BPN} 11 cd ${B}/${BPN}
12 chmod a+x ${S}/${BPN}/configure 12 chmod a+x ${S}/${BPN}/configure
13 relpath=${@os.path.relpath("${S}/${BPN}", "${B}/${BPN}")} 13 ${S}/${BPN}/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
14 $relpath/configure ${CONFIGUREOPTS} ${EXTRA_OECONF}
15} 14}
16EXTRACONFFUNCS += "extract_stashed_builddir" 15EXTRACONFFUNCS += "extract_stashed_builddir"
17do_configure[depends] += "${COMPILERDEP}" 16do_configure[depends] += "${COMPILERDEP}"
@@ -44,16 +43,20 @@ do_install () {
44 rm -rf ${D}${libdir}/${TARGET_SYS}/${BINV}/include 43 rm -rf ${D}${libdir}/${TARGET_SYS}/${BINV}/include
45} 44}
46 45
47do_install_append_libc-baremetal () { 46do_install:append:libc-baremetal () {
48 rmdir ${D}${base_libdir} 47 if [ "${base_libdir}" != "${libdir}" ]; then
48 rmdir ${D}${base_libdir}
49 fi
49} 50}
50do_install_append_libc-newlib () { 51do_install:append:libc-newlib () {
51 rmdir ${D}${base_libdir} 52 if [ "${base_libdir}" != "${libdir}" ]; then
53 rmdir ${D}${base_libdir}
54 fi
52} 55}
53 56
54# No rpm package is actually created but -dev depends on it, avoid dnf error 57# No rpm package is actually created but -dev depends on it, avoid dnf error
55RDEPENDS_${PN}-dev_libc-baremetal = "" 58DEV_PKG_DEPENDENCY:libc-baremetal = ""
56RDEPENDS_${PN}-dev_libc-newlib = "" 59DEV_PKG_DEPENDENCY:libc-newlib = ""
57 60
58BBCLASSEXTEND = "nativesdk" 61BBCLASSEXTEND = "nativesdk"
59 62
@@ -98,9 +101,9 @@ fakeroot python do_multilib_install() {
98 101
99 102
100 for ml in multilibs.split(): 103 for ml in multilibs.split():
101 tune = d.getVar('DEFAULTTUNE_virtclass-multilib-' + ml) 104 tune = d.getVar('DEFAULTTUNE:virtclass-multilib-' + ml)
102 if not tune: 105 if not tune:
103 bb.warn('DEFAULTTUNE_virtclass-multilib-%s is not defined. Skipping...' % ml) 106 bb.warn('DEFAULTTUNE:virtclass-multilib-%s is not defined. Skipping...' % ml)
104 continue 107 continue
105 108
106 tune_parameters = get_tune_parameters(tune, d) 109 tune_parameters = get_tune_parameters(tune, d)
diff --git a/meta/recipes-devtools/gcc/libgcc-initial.inc b/meta/recipes-devtools/gcc/libgcc-initial.inc
index 06bf224f73..8251e3c286 100644
--- a/meta/recipes-devtools/gcc/libgcc-initial.inc
+++ b/meta/recipes-devtools/gcc/libgcc-initial.inc
@@ -42,17 +42,17 @@ inherit nopackages
42# We really only want this built by things that need it, not any recrdeptask 42# We really only want this built by things that need it, not any recrdeptask
43deltask do_build 43deltask do_build
44 44
45do_configure_prepend () { 45do_configure:prepend () {
46 install -d ${STAGING_INCDIR} 46 install -d ${STAGING_INCDIR}
47 touch ${STAGING_INCDIR}/limits.h 47 touch ${STAGING_INCDIR}/limits.h
48 sed -i -e 's#INHIBIT_LIBC_CFLAGS =.*#INHIBIT_LIBC_CFLAGS = -Dinhibit_libc#' ${B}/gcc/libgcc.mvars 48 sed -i -e 's#INHIBIT_LIBC_CFLAGS =.*#INHIBIT_LIBC_CFLAGS = -Dinhibit_libc#' ${B}/gcc/libgcc.mvars
49 sed -i -e 's#inhibit_libc = false#inhibit_libc = true#' ${B}/gcc/Makefile 49 sed -i -e 's#inhibit_libc = false#inhibit_libc = true#' ${B}/gcc/Makefile
50} 50}
51 51
52do_configure_append () { 52do_configure:append () {
53 sed -i -e 's#thread_header = .*#thread_header = gthr-single.h#' ${B}/${BPN}/Makefile 53 sed -i -e 's#thread_header = .*#thread_header = gthr-single.h#' ${B}/${BPN}/Makefile
54} 54}
55 55
56do_install_append () { 56do_install:append () {
57 ln -s libgcc.a ${D}${libdir}/${TARGET_SYS}/${BINV}/libgcc_eh.a 57 ln -s libgcc.a ${D}${libdir}/${TARGET_SYS}/${BINV}/libgcc_eh.a
58} 58}
diff --git a/meta/recipes-devtools/gcc/libgcc-initial_10.2.bb b/meta/recipes-devtools/gcc/libgcc-initial_13.2.bb
index 0c698c26ec..a259082b47 100644
--- a/meta/recipes-devtools/gcc/libgcc-initial_10.2.bb
+++ b/meta/recipes-devtools/gcc/libgcc-initial_13.2.bb
@@ -2,4 +2,4 @@ require recipes-devtools/gcc/gcc-${PV}.inc
2require libgcc-initial.inc 2require libgcc-initial.inc
3 3
4# Building with thumb enabled on armv6t fails 4# Building with thumb enabled on armv6t fails
5ARM_INSTRUCTION_SET_armv6 = "arm" 5ARM_INSTRUCTION_SET:armv6 = "arm"
diff --git a/meta/recipes-devtools/gcc/libgcc.inc b/meta/recipes-devtools/gcc/libgcc.inc
index 6d48ec9809..84a2d930df 100644
--- a/meta/recipes-devtools/gcc/libgcc.inc
+++ b/meta/recipes-devtools/gcc/libgcc.inc
@@ -2,7 +2,7 @@ require libgcc-common.inc
2 2
3DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++ virtual/${MLPREFIX}libc" 3DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++ virtual/${MLPREFIX}libc"
4 4
5do_install_append_class-target () { 5do_install:append:class-target () {
6 if [ "${TCLIBC}" != "glibc" ]; then 6 if [ "${TCLIBC}" != "glibc" ]; then
7 case "${TARGET_OS}" in 7 case "${TARGET_OS}" in
8 "linux-musl" | "linux-*spe") extra_target_os="linux";; 8 "linux-musl" | "linux-*spe") extra_target_os="linux";;
@@ -32,12 +32,12 @@ PACKAGES = "\
32 32
33# All libgcc source is marked with the exception. 33# All libgcc source is marked with the exception.
34# 34#
35LICENSE_${PN} = "GPL-3.0-with-GCC-exception" 35LICENSE:${PN} = "GPL-3.0-with-GCC-exception"
36LICENSE_${PN}-dev = "GPL-3.0-with-GCC-exception" 36LICENSE:${PN}-dev = "GPL-3.0-with-GCC-exception"
37LICENSE_${PN}-dbg = "GPL-3.0-with-GCC-exception" 37LICENSE:${PN}-dbg = "GPL-3.0-with-GCC-exception"
38 38
39 39
40FILES_${PN}-dev = "\ 40FILES:${PN}-dev = "\
41 ${base_libdir}/libgcc*.so \ 41 ${base_libdir}/libgcc*.so \
42 ${@oe.utils.conditional('BASETARGET_SYS', '${TARGET_SYS}', '', '${libdir}/${BASETARGET_SYS}', d)} \ 42 ${@oe.utils.conditional('BASETARGET_SYS', '${TARGET_SYS}', '', '${libdir}/${BASETARGET_SYS}', d)} \
43 ${libdir}/${TARGET_SYS}/${BINV}* \ 43 ${libdir}/${TARGET_SYS}/${BINV}* \
@@ -49,5 +49,5 @@ do_package_write_ipk[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
49do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata" 49do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
50do_package_write_rpm[depends] += "virtual/${MLPREFIX}libc:do_packagedata" 50do_package_write_rpm[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
51 51
52INSANE_SKIP_${PN}-dev = "staticdev" 52INSANE_SKIP:${PN}-dev = "staticdev"
53 53
diff --git a/meta/recipes-devtools/gcc/libgcc_10.2.bb b/meta/recipes-devtools/gcc/libgcc_13.2.bb
index ea210a1130..fdcd6cc0da 100644
--- a/meta/recipes-devtools/gcc/libgcc_10.2.bb
+++ b/meta/recipes-devtools/gcc/libgcc_13.2.bb
@@ -1,5 +1,7 @@
1require recipes-devtools/gcc/gcc-${PV}.inc 1require recipes-devtools/gcc/gcc-${PV}.inc
2require libgcc.inc 2require libgcc.inc
3 3
4LDFLAGS += "-fuse-ld=bfd"
5
4# Building with thumb enabled on armv6t fails 6# Building with thumb enabled on armv6t fails
5ARM_INSTRUCTION_SET_armv6 = "arm" 7ARM_INSTRUCTION_SET:armv6 = "arm"
diff --git a/meta/recipes-devtools/gcc/libgfortran.inc b/meta/recipes-devtools/gcc/libgfortran.inc
index 7543585e6e..e810146d4d 100644
--- a/meta/recipes-devtools/gcc/libgfortran.inc
+++ b/meta/recipes-devtools/gcc/libgfortran.inc
@@ -5,6 +5,11 @@ EXTRA_OECONF_PATHS = "\
5 --with-build-sysroot=${STAGING_DIR_TARGET} \ 5 --with-build-sysroot=${STAGING_DIR_TARGET} \
6" 6"
7 7
8# An arm hard float target like raspberrypi4 won't build
9# as CFLAGS don't make it to the fortran compiler otherwise
10# (the configure script sets FC to $GFORTRAN unconditionally)
11export GFORTRAN = "${FC}"
12
8do_configure () { 13do_configure () {
9 for target in libbacktrace libgfortran 14 for target in libbacktrace libgfortran
10 do 15 do
@@ -54,12 +59,12 @@ PACKAGES = "\
54 libgfortran-staticdev \ 59 libgfortran-staticdev \
55" 60"
56 61
57LICENSE_${PN} = "GPL-3.0-with-GCC-exception" 62LICENSE:${PN} = "GPL-3.0-with-GCC-exception"
58LICENSE_${PN}-dev = "GPL-3.0-with-GCC-exception" 63LICENSE:${PN}-dev = "GPL-3.0-with-GCC-exception"
59LICENSE_${PN}-dbg = "GPL-3.0-with-GCC-exception" 64LICENSE:${PN}-dbg = "GPL-3.0-with-GCC-exception"
60 65
61FILES_${PN} = "${libdir}/libgfortran.so.*" 66FILES:${PN} = "${libdir}/libgfortran.so.*"
62FILES_${PN}-dev = "\ 67FILES:${PN}-dev = "\
63 ${libdir}/libgfortran*.so \ 68 ${libdir}/libgfortran*.so \
64 ${libdir}/libgfortran.spec \ 69 ${libdir}/libgfortran.spec \
65 ${libdir}/libgfortran.la \ 70 ${libdir}/libgfortran.la \
@@ -68,9 +73,9 @@ FILES_${PN}-dev = "\
68 ${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude/ \ 73 ${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude/ \
69 ${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ \ 74 ${libdir}/gcc/${TARGET_SYS}/${BINV}/include/ \
70" 75"
71FILES_${PN}-staticdev = "${libdir}/libgfortran.a" 76FILES:${PN}-staticdev = "${libdir}/libgfortran.a"
72 77
73INSANE_SKIP_${MLPREFIX}libgfortran-dev = "staticdev" 78INSANE_SKIP:${MLPREFIX}libgfortran-dev = "staticdev"
74 79
75do_package_write_ipk[depends] += "virtual/${MLPREFIX}libc:do_packagedata" 80do_package_write_ipk[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
76do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata" 81do_package_write_deb[depends] += "virtual/${MLPREFIX}libc:do_packagedata"
diff --git a/meta/recipes-devtools/gcc/libgfortran_10.2.bb b/meta/recipes-devtools/gcc/libgfortran_13.2.bb
index 71dd8b4bdc..71dd8b4bdc 100644
--- a/meta/recipes-devtools/gcc/libgfortran_10.2.bb
+++ b/meta/recipes-devtools/gcc/libgfortran_13.2.bb