summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/gcc/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/gcc/gcc')
-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.patch185
-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)74
-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)222
-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)9
-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)9
-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.patch67
-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)6
-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)6
-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)14
-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.patch227
-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-arm-fully-validate-mem_noofs_operand-PR120351.patch95
-rw-r--r--meta/recipes-devtools/gcc/gcc/0026-fix-incorrect-preprocessor-line-numbers.patch475
-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
50 files changed, 1816 insertions, 3297 deletions
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..e36b7f7b17 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 7e8c2b6bd87d221158f43bc1d770e04ddeed4176 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 ebc44416b6c..af1d1e24b3d 100755
16--- a/configure 16--- a/configure
17+++ b/configure 17+++ b/configure
18@@ -7722,7 +7722,7 @@ fi 18@@ -11509,7 +11509,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 730db3c1402..6de64a4777c 100644
29--- a/configure.ac 29--- a/configure.ac
30+++ b/configure.ac 30+++ b/configure.ac
31@@ -3227,7 +3227,7 @@ fi 31@@ -3736,7 +3736,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..53d2dc63da 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 f7c26bbbf0496d179f5e71107fe6cf1320b25901 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: Thu, 23 Jan 2025 17:12:51 -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,25 @@ 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>
16Signed-off-by: sunil dora <sunilkumar.dora@windriver.com>
15Signed-off-by: Khem Raj <raj.khem@gmail.com> 17Signed-off-by: Khem Raj <raj.khem@gmail.com>
16
17Upstream-Status: Pending
18--- 18---
19 gcc/common.opt | 4 ++++ 19 gcc/common.opt | 4 ++++
20 gcc/config.in | 6 ++++++ 20 gcc/config.in | 10 ++++++++++
21 gcc/configure | 16 ++++++++++++++++ 21 gcc/configure | 19 +++++++++++++++++++
22 gcc/configure.ac | 10 ++++++++++ 22 gcc/configure.ac | 16 ++++++++++++++++
23 gcc/doc/invoke.texi | 9 +++++++++ 23 gcc/doc/invoke.texi | 9 +++++++++
24 gcc/gcc.c | 2 ++ 24 gcc/gcc.cc | 12 ++++++++++--
25 gcc/incpath.c | 21 +++++++++++++++++++++ 25 gcc/incpath.cc | 25 +++++++++++++++++++++++++
26 7 files changed, 68 insertions(+) 26 7 files changed, 93 insertions(+), 2 deletions(-)
27 27
28diff --git a/gcc/common.opt b/gcc/common.opt 28diff --git a/gcc/common.opt b/gcc/common.opt
29index 65a82410abc..415f38fa1f4 100644 29index e3fa0dacec4..bea1adc0940 100644
30--- a/gcc/common.opt 30--- a/gcc/common.opt
31+++ b/gcc/common.opt 31+++ b/gcc/common.opt
32@@ -682,6 +682,10 @@ Wreturn-local-addr 32@@ -729,6 +729,10 @@ Wreturn-local-addr
33 Common Var(warn_return_local_addr) Init(1) Warning 33 Common Var(warn_return_local_addr) Init(1) Warning
34 Warn about returning a pointer/reference to a local or temporary variable. 34 Warn about returning a pointer/reference to a local or temporary variable.
35 35
@@ -41,10 +41,10 @@ index 65a82410abc..415f38fa1f4 100644
41 Common Var(warn_shadow) Warning 41 Common Var(warn_shadow) Warning
42 Warn when one variable shadows another. Same as -Wshadow=global. 42 Warn when one variable shadows another. Same as -Wshadow=global.
43diff --git a/gcc/config.in b/gcc/config.in 43diff --git a/gcc/config.in b/gcc/config.in
44index 809e7b26823..5adeaeed36b 100644 44index a79c51adb2b..8a531ed591c 100644
45--- a/gcc/config.in 45--- a/gcc/config.in
46+++ b/gcc/config.in 46+++ b/gcc/config.in
47@@ -224,6 +224,12 @@ 47@@ -249,6 +249,16 @@
48 #endif 48 #endif
49 49
50 50
@@ -52,24 +52,28 @@ index 809e7b26823..5adeaeed36b 100644
52+#ifndef USED_FOR_TARGET 52+#ifndef USED_FOR_TARGET
53+#undef ENABLE_POISON_SYSTEM_DIRECTORIES 53+#undef ENABLE_POISON_SYSTEM_DIRECTORIES
54+#endif 54+#endif
55+/* Define to warn for use of native system header directories */
56+#ifndef USED_FOR_TARGET
57+#undef POISON_BY_DEFAULT
58+#endif
55+ 59+
56+ 60+
57 /* Define if you want all operations on RTL (the basic data structure of the 61 /* 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. 62 optimizer and back end) to be checked for dynamic type safety at runtime.
59 This is quite expensive. */ 63 This is quite expensive. */
60diff --git a/gcc/configure b/gcc/configure 64diff --git a/gcc/configure b/gcc/configure
61index cd3d9516fce..8de766a942c 100755 65index 16965953f05..0f4a5d52c30 100755
62--- a/gcc/configure 66--- a/gcc/configure
63+++ b/gcc/configure 67+++ b/gcc/configure
64@@ -1010,6 +1010,7 @@ with_system_zlib 68@@ -1051,6 +1051,7 @@ enable_maintainer_mode
65 enable_maintainer_mode
66 enable_link_mutex 69 enable_link_mutex
70 enable_link_serialization
67 enable_version_specific_runtime_libs 71 enable_version_specific_runtime_libs
68+enable_poison_system_directories 72+enable_poison_system_directories
69 enable_plugin 73 enable_plugin
70 enable_host_shared 74 enable_host_shared
71 enable_libquadmath_support 75 enable_host_pie
72@@ -1766,6 +1767,8 @@ Optional Features: 76@@ -1828,6 +1829,8 @@ Optional Features:
73 --enable-version-specific-runtime-libs 77 --enable-version-specific-runtime-libs
74 specify that runtime libraries should be installed 78 specify that runtime libraries should be installed
75 in a compiler-specific directory 79 in a compiler-specific directory
@@ -77,8 +81,8 @@ index cd3d9516fce..8de766a942c 100755
77+ warn for use of native system header directories 81+ warn for use of native system header directories
78 --enable-plugin enable plugin support 82 --enable-plugin enable plugin support
79 --enable-host-shared build host code as shared libraries 83 --enable-host-shared build host code as shared libraries
80 --disable-libquadmath-support 84 --enable-host-pie build host code as PIE
81@@ -30235,6 +30238,19 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then : 85@@ -34027,6 +34030,22 @@ if test "${enable_version_specific_runtime_libs+set}" = set; then :
82 fi 86 fi
83 87
84 88
@@ -89,9 +93,12 @@ index cd3d9516fce..8de766a942c 100755
89+ enable_poison_system_directories=no 93+ enable_poison_system_directories=no
90+fi 94+fi
91+ 95+
92+if test "x${enable_poison_system_directories}" = "xyes"; then 96+if test "x${enable_poison_system_directories}" != "xno"; then
93+ 97+
94+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h 98+$as_echo "#define ENABLE_POISON_SYSTEM_DIRECTORIES 1" >>confdefs.h
99+if test "$enable_poison_system_directories" = "error"; then
100+$as_echo "#define POISON_BY_DEFAULT 1" >>confdefs.h
101+fi
95+ 102+
96+fi 103+fi
97+ 104+
@@ -99,70 +106,107 @@ index cd3d9516fce..8de766a942c 100755
99 106
100 107
101diff --git a/gcc/configure.ac b/gcc/configure.ac 108diff --git a/gcc/configure.ac b/gcc/configure.ac
102index 0de3b4bf97b..8bfd6feb780 100644 109index 9f67e62950a..b0e3615e5aa 100644
103--- a/gcc/configure.ac 110--- a/gcc/configure.ac
104+++ b/gcc/configure.ac 111+++ b/gcc/configure.ac
105@@ -6595,6 +6595,16 @@ AC_ARG_ENABLE(version-specific-runtime-libs, 112@@ -7502,6 +7502,22 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
106 [specify that runtime libraries should be 113 [specify that runtime libraries should be
107 installed in a compiler-specific directory])]) 114 installed in a compiler-specific directory])])
108 115
109+AC_ARG_ENABLE([poison-system-directories], 116+AC_ARG_ENABLE([poison-system-directories],
110+ AS_HELP_STRING([--enable-poison-system-directories], 117+ AS_HELP_STRING([--enable-poison-system-directories],
111+ [warn for use of native system header directories]),, 118+ [warn for use of native system header directories (no/yes/error)]),,
112+ [enable_poison_system_directories=no]) 119+ [enable_poison_system_directories=no])
113+if test "x${enable_poison_system_directories}" = "xyes"; then 120+AC_MSG_NOTICE([poisoned directories $enable_poison_system_directories])
121+if test "x${enable_poison_system_directories}" != "xno"; then
122+ AC_MSG_NOTICE([poisoned directories enabled])
114+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES], 123+ AC_DEFINE([ENABLE_POISON_SYSTEM_DIRECTORIES],
115+ [1], 124+ [1],
116+ [Define to warn for use of native system header directories]) 125+ [Define to warn for use of native system header directories])
126+ if test $enable_poison_system_directories = "error"; then
127+ AC_MSG_NOTICE([poisoned directories are fatal])
128+ AC_DEFINE([POISON_BY_DEFAULT], [1], [Define to make poison warnings errors])
129+ fi
117+fi 130+fi
118+ 131+
119 # Substitute configuration variables 132 # Substitute configuration variables
120 AC_SUBST(subdirs) 133 AC_SUBST(subdirs)
121 AC_SUBST(srcdir) 134 AC_SUBST(srcdir)
122diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi 135diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
123index f98161391a0..f12d8d12150 100644 136index c2e1bf8031b..d33e2042f38 100644
124--- a/gcc/doc/invoke.texi 137--- a/gcc/doc/invoke.texi
125+++ b/gcc/doc/invoke.texi 138+++ b/gcc/doc/invoke.texi
126@@ -348,6 +348,7 @@ Objective-C and Objective-C++ Dialects}. 139@@ -405,6 +405,7 @@ Objective-C and Objective-C++ Dialects}.
127 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded @gol 140 -Wpacked -Wno-packed-bitfield-compat -Wpacked-not-aligned -Wpadded
128 -Wparentheses -Wno-pedantic-ms-format @gol 141 -Wparentheses -Wno-pedantic-ms-format
129 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast @gol 142 -Wpointer-arith -Wno-pointer-compare -Wno-pointer-to-int-cast
130+-Wno-poison-system-directories @gol 143+-Wno-poison-system-directories
131 -Wno-pragmas -Wno-prio-ctor-dtor -Wredundant-decls @gol 144 -Wno-pragmas -Wno-pragma-once-outside-header -Wno-prio-ctor-dtor
132 -Wrestrict -Wno-return-local-addr -Wreturn-type @gol 145 -Wno-psabi
133 -Wno-scalar-storage-order -Wsequence-point @gol 146 -Wredundant-decls -Wrestrict
134@@ -6924,6 +6925,14 @@ made up of data only and thus requires no special treatment. But, for 147@@ -10727,6 +10728,14 @@ an error. @option{Wint-to-pointer-cast} is enabled by default.
135 most targets, it is made up of code and thus requires the stack to be 148 Suppress warnings from casts from a pointer to an integer type of a
136 made executable in order for the program to work properly. 149 different size.
137 150
138+@item -Wno-poison-system-directories
139+@opindex Wno-poison-system-directories 151+@opindex Wno-poison-system-directories
152+@item -Wno-poison-system-directories
140+Do not warn for @option{-I} or @option{-L} options using system 153+Do not warn for @option{-I} or @option{-L} options using system
141+directories such as @file{/usr/include} when cross compiling. This 154+directories such as @file{/usr/include} when cross compiling. This
142+option is intended for use in chroot environments when such 155+option is intended for use in chroot environments when such
143+directories contain the correct headers and libraries for the target 156+directories contain the correct headers and libraries for the target
144+system rather than the host. 157+system rather than the host.
145+ 158+
146 @item -Wfloat-equal 159 @opindex Winvalid-pch
147 @opindex Wfloat-equal 160 @opindex Wno-invalid-pch
148 @opindex Wno-float-equal 161 @item -Winvalid-pch
149diff --git a/gcc/gcc.c b/gcc/gcc.c 162diff --git a/gcc/gcc.cc b/gcc/gcc.cc
150index 9f790db0daf..b2200c5185a 100644 163index 4fd87f2c4a1..79d4920a047 100644
151--- a/gcc/gcc.c 164--- a/gcc/gcc.cc
152+++ b/gcc/gcc.c 165+++ b/gcc/gcc.cc
153@@ -1041,6 +1041,8 @@ proper position among the other output files. */ 166@@ -909,6 +909,12 @@ proper position among the other output files. */
167 #define ASM_MAP ""
168 #endif
169
170+#ifdef POISON_BY_DEFAULT
171+#define POISON_IS_ERROR " -Werror=poison-system-directories"
172+#else
173+#define POISON_IS_ERROR
174+#endif
175+
176 /* Assembler options for compressed debug sections. */
177 #if HAVE_LD_COMPRESS_DEBUG == 0
178 /* Reject if the linker cannot write compressed debug sections. */
179@@ -1166,6 +1172,8 @@ proper position among the other output files. */
154 "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \ 180 "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
155 "%X %{o*} %{e*} %{N} %{n} %{r}\ 181 "%X %{o*} %{e*} %{N} %{n} %{r}\
156 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \ 182 %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
157+ %{Wno-poison-system-directories:--no-poison-system-directories} \ 183+ %{Wno-poison-system-directories:--no-poison-system-directories} \
158+ %{Werror=poison-system-directories:--error-poison-system-directories} \ 184+ %{Werror=poison-system-directories:--error-poison-system-directories} \
159 %{static|no-pie|static-pie:} %@{L*} %(mfwrap) %(link_libgcc) " \ 185 %{static|no-pie|static-pie:} %@{L*} %(link_libgcc) " \
160 VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \ 186 VTABLE_VERIFICATION_SPEC " " SANITIZER_EARLY_SPEC " %o "" \
161 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\ 187 %{fopenacc|fopenmp|%:gt(%{ftree-parallelize-loops=*:%*} 1):\
162diff --git a/gcc/incpath.c b/gcc/incpath.c 188@@ -1268,7 +1276,7 @@ static const char *cpp_options =
163index 8a2bda00f80..9098ab044ab 100644 189 "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
164--- a/gcc/incpath.c 190 %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\
165+++ b/gcc/incpath.c 191 %{!fno-working-directory:-fworking-directory}}} %{O*}\
192- %{undef} %{save-temps*:-fpch-preprocess}";
193+ %{undef} %{save-temps*:-fpch-preprocess}" POISON_IS_ERROR;
194
195 /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al.
196
197@@ -1297,7 +1305,7 @@ static const char *cc1_options =
198 %{coverage:-fprofile-arcs -ftest-coverage}\
199 %{fprofile-arcs|fcondition-coverage|fpath-coverage|fprofile-generate*|coverage:\
200 %{!fprofile-update=single:\
201- %{pthread:-fprofile-update=prefer-atomic}}}";
202+ %{pthread:-fprofile-update=prefer-atomic}}}" POISON_IS_ERROR;
203
204 static const char *asm_options =
205 "%{-target-help:%:print-asm-header()} "
206diff --git a/gcc/incpath.cc b/gcc/incpath.cc
207index c1bbfd3872a..2cdbebc4c50 100644
208--- a/gcc/incpath.cc
209+++ b/gcc/incpath.cc
166@@ -26,6 +26,7 @@ 210@@ -26,6 +26,7 @@
167 #include "intl.h" 211 #include "intl.h"
168 #include "incpath.h" 212 #include "incpath.h"
@@ -171,9 +215,20 @@ index 8a2bda00f80..9098ab044ab 100644
171 215
172 /* Microsoft Windows does not natively support inodes. 216 /* Microsoft Windows does not natively support inodes.
173 VMS has non-numeric inodes. */ 217 VMS has non-numeric inodes. */
174@@ -393,6 +394,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose) 218@@ -273,6 +274,10 @@ remove_duplicates (cpp_reader *pfile, struct cpp_dir *head,
219 cur->name, xstrerror (errno));
220 reason = REASON_NOENT;
221 }
222+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
223+ pcur = &cur->next;
224+ continue;
225+#endif
226 }
227 else if (!S_ISDIR (st.st_mode))
228 cpp_error_with_line (pfile, CPP_DL_WARNING, 0, 0,
229@@ -411,6 +416,26 @@ merge_include_chains (const char *sysroot, cpp_reader *pfile, int verbose)
230 fprintf (stderr, _("End of #embed search list.\n"));
175 } 231 }
176 fprintf (stderr, _("End of search list.\n"));
177 } 232 }
178+ 233+
179+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES 234+#ifdef ENABLE_POISON_SYSTEM_DIRECTORIES
@@ -182,17 +237,17 @@ index 8a2bda00f80..9098ab044ab 100644
182+ struct cpp_dir *p; 237+ struct cpp_dir *p;
183+ 238+
184+ for (p = heads[INC_QUOTE]; p; p = p->next) 239+ for (p = heads[INC_QUOTE]; p; p = p->next)
185+ { 240+ {
186+ if ((!strncmp (p->name, "/usr/include", 12)) 241+ if ((!strncmp (p->name, "/usr/include", 12))
187+ || (!strncmp (p->name, "/usr/local/include", 18)) 242+ || (!strncmp (p->name, "/usr/local/include", 18))
188+ || (!strncmp (p->name, "/usr/X11R6/include", 18)) 243+ || (!strncmp (p->name, "/usr/X11R6/include", 18))
189+ || (!strncmp (p->name, "/sw/include", 11)) 244+ || (!strncmp (p->name, "/sw/include", 11))
190+ || (!strncmp (p->name, "/opt/include", 12))) 245+ || (!strncmp (p->name, "/opt/include", 12)))
191+ warning (OPT_Wpoison_system_directories, 246+ warning (OPT_Wpoison_system_directories,
192+ "include location \"%s\" is unsafe for " 247+ "include location \"%s\" is unsafe for "
193+ "cross-compilation", 248+ "cross-compilation",
194+ p->name); 249+ p->name);
195+ } 250+ }
196+ } 251+ }
197+#endif 252+#endif
198 } 253 }
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..0c9edf189e 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 a4f799209882107726f547a4637659068ae07476 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,26 @@ 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>
31--- 31---
32 gcc/config/aarch64/t-aarch64-linux | 8 ++++---- 32 gcc/config/aarch64/t-aarch64-linux | 8 ++++----
33 gcc/config/arc/t-multilib-linux | 4 ++--
33 gcc/config/i386/t-linux64 | 6 ++---- 34 gcc/config/i386/t-linux64 | 6 ++----
34 gcc/config/mips/t-linux64 | 10 +++------- 35 gcc/config/mips/t-linux64 | 28 ++--------------------------
35 gcc/config/riscv/t-linux | 6 ++++-- 36 gcc/config/riscv/t-linux | 6 +++---
36 gcc/config/rs6000/t-linux64 | 5 ++--- 37 gcc/config/rs6000/t-linux64 | 5 ++---
37 5 files changed, 15 insertions(+), 20 deletions(-) 38 6 files changed, 15 insertions(+), 42 deletions(-)
38 39
39diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux 40diff --git a/gcc/config/aarch64/t-aarch64-linux b/gcc/config/aarch64/t-aarch64-linux
40index 83e59e33b85..b1356be1fb4 100644 41index 70e36b3299e..4267c32763c 100644
41--- a/gcc/config/aarch64/t-aarch64-linux 42--- a/gcc/config/aarch64/t-aarch64-linux
42+++ b/gcc/config/aarch64/t-aarch64-linux 43+++ b/gcc/config/aarch64/t-aarch64-linux
43@@ -21,8 +21,8 @@ 44@@ -21,8 +21,8 @@
@@ -53,8 +54,24 @@ index 83e59e33b85..b1356be1fb4 100644
53 54
54-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)
55+#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32) 56+#MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
57diff --git a/gcc/config/arc/t-multilib-linux b/gcc/config/arc/t-multilib-linux
58index e72687260eb..f701fa9e201 100644
59--- a/gcc/config/arc/t-multilib-linux
60+++ b/gcc/config/arc/t-multilib-linux
61@@ -16,9 +16,9 @@
62 # along with GCC; see the file COPYING3. If not see
63 # <http://www.gnu.org/licenses/>.
64
65-MULTILIB_OPTIONS = mcpu=hs/mcpu=archs/mcpu=hs38/mcpu=hs38_linux/mcpu=arc700/mcpu=nps400
66+#MULTILIB_OPTIONS = mcpu=hs/mcpu=archs/mcpu=hs38/mcpu=hs38_linux/mcpu=arc700/mcpu=nps400
67
68-MULTILIB_DIRNAMES = hs archs hs38 hs38_linux arc700 nps400
69+#MULTILIB_DIRNAMES = hs archs hs38 hs38_linux arc700 nps400
70
71 # Aliases:
72 MULTILIB_MATCHES += mcpu?arc700=mA7
56diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64 73diff --git a/gcc/config/i386/t-linux64 b/gcc/config/i386/t-linux64
57index 1171e218578..5e057b7e5db 100644 74index 64a4a20e64f..2666e731dd6 100644
58--- a/gcc/config/i386/t-linux64 75--- a/gcc/config/i386/t-linux64
59+++ b/gcc/config/i386/t-linux64 76+++ b/gcc/config/i386/t-linux64
60@@ -32,7 +32,5 @@ 77@@ -32,7 +32,5 @@
@@ -68,37 +85,56 @@ index 1171e218578..5e057b7e5db 100644
68+MULTILIB_DIRNAMES = . . 85+MULTILIB_DIRNAMES = . .
69+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) 86+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
70diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64 87diff --git a/gcc/config/mips/t-linux64 b/gcc/config/mips/t-linux64
71index ceb58d3b5f3..43fe2bf28ab 100644 88index 34a84461ebb..431a6b5183f 100644
72--- a/gcc/config/mips/t-linux64 89--- a/gcc/config/mips/t-linux64
73+++ b/gcc/config/mips/t-linux64 90+++ b/gcc/config/mips/t-linux64
74@@ -17,10 +17,6 @@ 91@@ -17,29 +17,5 @@
75 # <http://www.gnu.org/licenses/>. 92 # <http://www.gnu.org/licenses/>.
76 93
77 MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64 94 MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
78-MULTILIB_DIRNAMES = n32 32 64 95-MULTILIB_DIRNAMES = n32 32 64
79-MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el) 96-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) 97-MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
81-MULTILIB_OSDIRNAMES = \ 98-ifeq (yes,$(enable_multiarch))
99- ifneq (,$(findstring gnuabi64,$(target)))
100- MULTILIB_OSDIRNAMES = \
101- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
102- ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
103- ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
104- else ifneq (,$(findstring gnuabin32,$(target)))
105- MULTILIB_OSDIRNAMES = \
106- ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
107- ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
108- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
109- else
110- MULTILIB_OSDIRNAMES = \
82- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \ 111- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
83- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \ 112- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
84- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT)) 113- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
114- endif
115-else
116- MULTILIB_OSDIRNAMES = \
117- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
118- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
119- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
120-endif
85+MULTILIB_DIRNAMES = . . . 121+MULTILIB_DIRNAMES = . . .
86+MULTILIB_OSDIRNAMES = ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) 122+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 123diff --git a/gcc/config/riscv/t-linux b/gcc/config/riscv/t-linux
89index 216d2776a18..e4d817621fc 100644 124index a6f64f88d25..0e21db58f7d 100644
90--- a/gcc/config/riscv/t-linux 125--- a/gcc/config/riscv/t-linux
91+++ b/gcc/config/riscv/t-linux 126+++ b/gcc/config/riscv/t-linux
92@@ -1,3 +1,5 @@ 127@@ -1,5 +1,5 @@
93 # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/ 128 # Only XLEN and ABI affect Linux multilib dir names, e.g. /lib32/ilp32d/
94-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) 129-MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
95-MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) 130-MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
96+#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES))) 131+#MULTILIB_DIRNAMES := $(patsubst rv32%,lib32,$(patsubst rv64%,lib64,$(MULTILIB_DIRNAMES)))
97+MULTILIB_DIRNAMES := . .
98+#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES)) 132+#MULTILIB_OSDIRNAMES := $(patsubst lib%,../lib%,$(MULTILIB_DIRNAMES))
99+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir)) 133
134-MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
135+#MULTIARCH_DIRNAME := $(call if_multiarch,$(firstword $(subst -, ,$(target)))-linux-gnu)
100diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64 136diff --git a/gcc/config/rs6000/t-linux64 b/gcc/config/rs6000/t-linux64
101index 264a7e27524..dc9d440f66b 100644 137index f56b47c268e..c408c32d8f4 100644
102--- a/gcc/config/rs6000/t-linux64 138--- a/gcc/config/rs6000/t-linux64
103+++ b/gcc/config/rs6000/t-linux64 139+++ b/gcc/config/rs6000/t-linux64
104@@ -26,10 +26,9 @@ 140@@ -26,10 +26,9 @@
@@ -112,5 +148,5 @@ 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) 148-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)) 149+MULTILIB_OSDIRNAMES := ../$(shell basename $(base_libdir)) ../$(shell basename $(base_libdir))
114 150
115 rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.c 151 rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc
116 $(COMPILE) $< 152 $(COMPILE) $<
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..03139326c9
--- /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 bcc97c2c8558cd5d3879a907a216eb0e2008c976 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 b1ed67d3d4f..4d7f45455a3 100644
27--- a/Makefile.in
28+++ b/Makefile.in
29@@ -179,6 +179,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@@ -212,6 +213,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 7dccf91ed8e..7cb61bf63ea 100644
47--- a/Makefile.tpl
48+++ b/Makefile.tpl
49@@ -182,6 +182,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@@ -215,6 +216,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..e8e829d9f5 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 fd6aa3c3ff5361a738b31d6127cb05910cd6b8c0 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 55b4cd7dbed..5546e259a20 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@@ -596,7 +596,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 0f4a5d52c30..a2a8761055c 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@@ -15106,8 +15106,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 b0e3615e5aa..58ad9dc01fe 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@@ -2426,8 +2426,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 e02466b4416..0ea1a0c9ca6 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..26476de33f 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 b931ab5282cc11627b6f68a6477b79f41ae80b3a 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 a67ce4c22a5..ce07a1c4b1d 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@@ -122,7 +122,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 79d4920a047..c1488865b8b 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@@ -1497,7 +1497,7 @@ static const struct compiler default_compilers[] =
46 %W{o*:--output-pch %w%*}}%{!S:%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..2b727b09af 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 d9513f8c3fa3f228358fd4d0716941e84bda413e 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,47 @@ 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/riscv/linux.h | 4 ++--
30 gcc/config/sparc/linux64.h | 4 ++-- 29 gcc/config/rs6000/linux64.h | 15 +++++----------
31 12 files changed, 29 insertions(+), 34 deletions(-) 30 gcc/config/rs6000/sysv4.h | 4 ++--
31 gcc/config/s390/linux.h | 8 ++++----
32 gcc/config/sh/linux.h | 4 ++--
33 gcc/config/sparc/linux.h | 2 +-
34 gcc/config/sparc/linux64.h | 4 ++--
35 17 files changed, 51 insertions(+), 56 deletions(-)
32 36
37diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
38index 116bb4e69f3..c0de4900dc2 100644
39--- a/gcc/config/aarch64/aarch64-linux.h
40+++ b/gcc/config/aarch64/aarch64-linux.h
41@@ -21,10 +21,10 @@
42 #ifndef GCC_AARCH64_LINUX_H
43 #define GCC_AARCH64_LINUX_H
44
45-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
46+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
47
48 #undef MUSL_DYNAMIC_LINKER
49-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
50+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
51
52 #undef ASAN_CC1_SPEC
53 #define ASAN_CC1_SPEC "%{%:sanitize(address):-funwind-tables}"
33diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h 54diff --git a/gcc/config/alpha/linux-elf.h b/gcc/config/alpha/linux-elf.h
34index e25fcac3c59..01aca0c6542 100644 55index 3fd3b831166..6471fa32b0b 100644
35--- a/gcc/config/alpha/linux-elf.h 56--- a/gcc/config/alpha/linux-elf.h
36+++ b/gcc/config/alpha/linux-elf.h 57+++ b/gcc/config/alpha/linux-elf.h
37@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see 58@@ -23,8 +23,8 @@ along with GCC; see the file COPYING3. If not see
@@ -46,7 +67,7 @@ index e25fcac3c59..01aca0c6542 100644
46 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}" 67 #define CHOOSE_DYNAMIC_LINKER(G, U) "%{mglibc:" G ";:" U "}"
47 #elif DEFAULT_LIBC == LIBC_GLIBC 68 #elif DEFAULT_LIBC == LIBC_GLIBC
48diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h 69diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
49index 5bdcfa0c5d3..0c0332f317f 100644 70index 8ef5643b5d6..76893197773 100644
50--- a/gcc/config/arm/linux-eabi.h 71--- a/gcc/config/arm/linux-eabi.h
51+++ b/gcc/config/arm/linux-eabi.h 72+++ b/gcc/config/arm/linux-eabi.h
52@@ -65,8 +65,8 @@ 73@@ -65,8 +65,8 @@
@@ -60,8 +81,17 @@ index 5bdcfa0c5d3..0c0332f317f 100644
60 #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT 81 #define GLIBC_DYNAMIC_LINKER_DEFAULT GLIBC_DYNAMIC_LINKER_SOFT_FLOAT
61 82
62 #define GLIBC_DYNAMIC_LINKER \ 83 #define GLIBC_DYNAMIC_LINKER \
84@@ -89,7 +89,7 @@
85 #define MUSL_DYNAMIC_LINKER_E "%{mbig-endian:eb}"
86 #endif
87 #define MUSL_DYNAMIC_LINKER \
88- "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
89+ SYSTEMLIBS_DIR "ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
90
91 /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
92 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 93diff --git a/gcc/config/arm/linux-elf.h b/gcc/config/arm/linux-elf.h
64index 0ec3aa53189..abfa9566d74 100644 94index d4d389e2aa8..6c4b1e13463 100644
65--- a/gcc/config/arm/linux-elf.h 95--- a/gcc/config/arm/linux-elf.h
66+++ b/gcc/config/arm/linux-elf.h 96+++ b/gcc/config/arm/linux-elf.h
67@@ -60,7 +60,7 @@ 97@@ -60,7 +60,7 @@
@@ -74,7 +104,7 @@ index 0ec3aa53189..abfa9566d74 100644
74 #define LINUX_TARGET_LINK_SPEC "%{h*} \ 104 #define LINUX_TARGET_LINK_SPEC "%{h*} \
75 %{static:-Bstatic} \ 105 %{static:-Bstatic} \
76diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h 106diff --git a/gcc/config/i386/linux.h b/gcc/config/i386/linux.h
77index 9f823f125ed..e0390b7d5e3 100644 107index efbd978c610..9ea0261b0fc 100644
78--- a/gcc/config/i386/linux.h 108--- a/gcc/config/i386/linux.h
79+++ b/gcc/config/i386/linux.h 109+++ b/gcc/config/i386/linux.h
80@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see 110@@ -20,7 +20,7 @@ along with GCC; see the file COPYING3. If not see
@@ -85,12 +115,13 @@ index 9f823f125ed..e0390b7d5e3 100644
85+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2" 115+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-linux.so.2"
86 116
87 #undef MUSL_DYNAMIC_LINKER 117 #undef MUSL_DYNAMIC_LINKER
88 #define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1" 118-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-i386.so.1"
119+#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 120diff --git a/gcc/config/i386/linux64.h b/gcc/config/i386/linux64.h
90index 6cb68d1ccfa..7de09ec857c 100644 121index 24170ee2845..733e3e4945a 100644
91--- a/gcc/config/i386/linux64.h 122--- a/gcc/config/i386/linux64.h
92+++ b/gcc/config/i386/linux64.h 123+++ b/gcc/config/i386/linux64.h
93@@ -27,9 +27,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 124@@ -27,13 +27,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
94 #define GNU_USER_LINK_EMULATION64 "elf_x86_64" 125 #define GNU_USER_LINK_EMULATION64 "elf_x86_64"
95 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64" 126 #define GNU_USER_LINK_EMULATIONX32 "elf32_x86_64"
96 127
@@ -102,12 +133,19 @@ index 6cb68d1ccfa..7de09ec857c 100644
102+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2" 133+#define GLIBC_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-linux-x32.so.2"
103 134
104 #undef MUSL_DYNAMIC_LINKER32 135 #undef MUSL_DYNAMIC_LINKER32
105 #define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1" 136-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-i386.so.1"
137+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-i386.so.1"
138 #undef MUSL_DYNAMIC_LINKER64
139-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-x86_64.so.1"
140+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-x86_64.so.1"
141 #undef MUSL_DYNAMIC_LINKERX32
142-#define MUSL_DYNAMIC_LINKERX32 "/lib/ld-musl-x32.so.1"
143+#define MUSL_DYNAMIC_LINKERX32 SYSTEMLIBS_DIR "ld-musl-x32.so.1"
106diff --git a/gcc/config/linux.h b/gcc/config/linux.h 144diff --git a/gcc/config/linux.h b/gcc/config/linux.h
107index 95654bcdb5a..0c1a8118a26 100644 145index d6280a4d4dd..c79d4902f85 100644
108--- a/gcc/config/linux.h 146--- a/gcc/config/linux.h
109+++ b/gcc/config/linux.h 147+++ b/gcc/config/linux.h
110@@ -94,10 +94,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 148@@ -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 149 GLIBC_DYNAMIC_LINKER must be defined for each target using them, or
112 GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets 150 GLIBC_DYNAMIC_LINKER32 and GLIBC_DYNAMIC_LINKER64 for targets
113 supporting both 32-bit and 64-bit compilation. */ 151 supporting both 32-bit and 64-bit compilation. */
@@ -122,11 +160,55 @@ index 95654bcdb5a..0c1a8118a26 100644
122 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker" 160 #define BIONIC_DYNAMIC_LINKER "/system/bin/linker"
123 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker" 161 #define BIONIC_DYNAMIC_LINKER32 "/system/bin/linker"
124 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64" 162 #define BIONIC_DYNAMIC_LINKER64 "/system/bin/linker64"
163diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h
164index fbc75a90ad5..38c239940bd 100644
165--- a/gcc/config/loongarch/gnu-user.h
166+++ b/gcc/config/loongarch/gnu-user.h
167@@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
168
169 #undef GLIBC_DYNAMIC_LINKER
170 #define GLIBC_DYNAMIC_LINKER \
171- "/lib" ABI_GRLEN_SPEC "/ld-linux-loongarch-" ABI_SPEC ".so.1"
172+ SYSTEMLIBS_DIR "ld-linux-loongarch-" ABI_SPEC ".so.1"
173
174 #define MUSL_ABI_SPEC \
175 "%{mabi=lp64d:}" \
176@@ -40,7 +40,7 @@ along with GCC; see the file COPYING3. If not see
177
178 #undef MUSL_DYNAMIC_LINKER
179 #define MUSL_DYNAMIC_LINKER \
180- "/lib/ld-musl-loongarch" ABI_GRLEN_SPEC MUSL_ABI_SPEC ".so.1"
181+ SYSTEMLIBS_DIR "ld-musl-loongarch" ABI_GRLEN_SPEC MUSL_ABI_SPEC ".so.1"
182
183 #undef GNU_USER_TARGET_LINK_SPEC
184 #define GNU_USER_TARGET_LINK_SPEC \
185diff --git a/gcc/config/microblaze/linux.h b/gcc/config/microblaze/linux.h
186index 7b09cde7693..8bfafaf87f7 100644
187--- a/gcc/config/microblaze/linux.h
188+++ b/gcc/config/microblaze/linux.h
189@@ -28,7 +28,7 @@
190 #undef TLS_NEEDS_GOT
191 #define TLS_NEEDS_GOT 1
192
193-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
194+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld.so.1"
195 #define UCLIBC_DYNAMIC_LINKER "/lib/ld-uClibc.so.0"
196
197 #if TARGET_BIG_ENDIAN_DEFAULT == 0 /* LE */
198@@ -38,7 +38,7 @@
199 #endif
200
201 #undef MUSL_DYNAMIC_LINKER
202-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
203+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-microblaze" MUSL_DYNAMIC_LINKER_E ".so.1"
204
205 #undef SUBTARGET_EXTRA_SPECS
206 #define SUBTARGET_EXTRA_SPECS \
125diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h 207diff --git a/gcc/config/mips/linux.h b/gcc/config/mips/linux.h
126index 54446e58e5f..4786ee304c1 100644 208index ae15d490108..0281650009d 100644
127--- a/gcc/config/mips/linux.h 209--- a/gcc/config/mips/linux.h
128+++ b/gcc/config/mips/linux.h 210+++ b/gcc/config/mips/linux.h
129@@ -22,20 +22,20 @@ along with GCC; see the file COPYING3. If not see 211@@ -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" 212 #define GNU_USER_LINK_EMULATIONN32 "elf32%{EB:b}%{EL:l}tsmipn32"
131 213
132 #define GLIBC_DYNAMIC_LINKER32 \ 214 #define GLIBC_DYNAMIC_LINKER32 \
@@ -153,8 +235,20 @@ index 54446e58e5f..4786ee304c1 100644
153 235
154 #undef MUSL_DYNAMIC_LINKER32 236 #undef MUSL_DYNAMIC_LINKER32
155 #define MUSL_DYNAMIC_LINKER32 \ 237 #define MUSL_DYNAMIC_LINKER32 \
238- "/lib/ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
239+ SYSTEMLIBS_DIR "ld-musl-mips%{mips32r6|mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
240 #undef MUSL_DYNAMIC_LINKER64
241 #define MUSL_DYNAMIC_LINKER64 \
242- "/lib/ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
243+ SYSTEMLIBS_DIR "ld-musl-mips64%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
244 #define MUSL_DYNAMIC_LINKERN32 \
245- "/lib/ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
246+ SYSTEMLIBS_DIR "ld-musl-mipsn32%{mips64r6:r6}%{EL:el}%{msoft-float:-sf}.so.1"
247
248 #define BIONIC_DYNAMIC_LINKERN32 "/system/bin/linker32"
249 #define GNU_USER_DYNAMIC_LINKERN32 \
156diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h 250diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
157index 4afef7c228c..01997330741 100644 251index 9060c940a44..c7712db194a 100644
158--- a/gcc/config/riscv/linux.h 252--- a/gcc/config/riscv/linux.h
159+++ b/gcc/config/riscv/linux.h 253+++ b/gcc/config/riscv/linux.h
160@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see 254@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see
@@ -166,11 +260,20 @@ index 4afef7c228c..01997330741 100644
166 260
167 #define MUSL_ABI_SUFFIX \ 261 #define MUSL_ABI_SUFFIX \
168 "%{mabi=ilp32:-sf}" \ 262 "%{mabi=ilp32:-sf}" \
263@@ -33,7 +33,7 @@ along with GCC; see the file COPYING3. If not see
264 "%{mabi=lp64d:}"
265
266 #undef MUSL_DYNAMIC_LINKER
267-#define MUSL_DYNAMIC_LINKER "/lib/ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
268+#define MUSL_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld-musl-riscv" XLEN_SPEC MUSL_ABI_SUFFIX ".so.1"
269
270 #define ICACHE_FLUSH_FUNC "__riscv_flush_icache"
271
169diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h 272diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
170index 34776c8421e..967c1c43c63 100644 273index 0316d8cb65d..8de5eb8bb49 100644
171--- a/gcc/config/rs6000/linux64.h 274--- a/gcc/config/rs6000/linux64.h
172+++ b/gcc/config/rs6000/linux64.h 275+++ b/gcc/config/rs6000/linux64.h
173@@ -419,24 +419,19 @@ extern int dot_symbols; 276@@ -340,24 +340,19 @@ extern int dot_symbols;
174 #undef LINK_OS_DEFAULT_SPEC 277 #undef LINK_OS_DEFAULT_SPEC
175 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)" 278 #define LINK_OS_DEFAULT_SPEC "%(link_os_linux)"
176 279
@@ -200,12 +303,55 @@ index 34776c8421e..967c1c43c63 100644
200 303
201 #undef DEFAULT_ASM_ENDIAN 304 #undef DEFAULT_ASM_ENDIAN
202 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN) 305 #if (TARGET_DEFAULT & MASK_LITTLE_ENDIAN)
306diff --git a/gcc/config/rs6000/sysv4.h b/gcc/config/rs6000/sysv4.h
307index afb5c6ad867..3eb6c814ced 100644
308--- a/gcc/config/rs6000/sysv4.h
309+++ b/gcc/config/rs6000/sysv4.h
310@@ -772,10 +772,10 @@ GNU_USER_TARGET_CC1_SPEC
311
312 #define MUSL_DYNAMIC_LINKER_E ENDIAN_SELECT("","le","")
313
314-#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
315+#define GLIBC_DYNAMIC_LINKER SYSTEMLIBS_DIR "ld.so.1"
316 #undef MUSL_DYNAMIC_LINKER
317 #define MUSL_DYNAMIC_LINKER \
318- "/lib/ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
319+ SYSTEMLIBS_DIR "ld-musl-powerpc" MUSL_DYNAMIC_LINKER_E "%{msoft-float:-sf}.so.1"
320
321 #ifndef GNU_USER_DYNAMIC_LINKER
322 #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
323diff --git a/gcc/config/s390/linux.h b/gcc/config/s390/linux.h
324index 2c3bca5dfcb..1332624abad 100644
325--- a/gcc/config/s390/linux.h
326+++ b/gcc/config/s390/linux.h
327@@ -72,13 +72,13 @@ along with GCC; see the file COPYING3. If not see
328 #define MULTILIB_DEFAULTS { "m31" }
329 #endif
330
331-#define GLIBC_DYNAMIC_LINKER32 "/lib/ld.so.1"
332-#define GLIBC_DYNAMIC_LINKER64 "/lib/ld64.so.1"
333+#define GLIBC_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld.so.1"
334+#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld64.so.1"
335
336 #undef MUSL_DYNAMIC_LINKER32
337-#define MUSL_DYNAMIC_LINKER32 "/lib/ld-musl-s390.so.1"
338+#define MUSL_DYNAMIC_LINKER32 SYSTEMLIBS_DIR "ld-musl-s390.so.1"
339 #undef MUSL_DYNAMIC_LINKER64
340-#define MUSL_DYNAMIC_LINKER64 "/lib/ld-musl-s390x.so.1"
341+#define MUSL_DYNAMIC_LINKER64 SYSTEMLIBS_DIR "ld-musl-s390x.so.1"
342
343 #undef LINK_SPEC
344 #define LINK_SPEC \
203diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h 345diff --git a/gcc/config/sh/linux.h b/gcc/config/sh/linux.h
204index c1d0441d488..81373eb8336 100644 346index 78a7905a919..28493851982 100644
205--- a/gcc/config/sh/linux.h 347--- a/gcc/config/sh/linux.h
206+++ b/gcc/config/sh/linux.h 348+++ b/gcc/config/sh/linux.h
207@@ -64,7 +64,7 @@ along with GCC; see the file COPYING3. If not see 349@@ -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 \ 350
351 #undef MUSL_DYNAMIC_LINKER
352 #define MUSL_DYNAMIC_LINKER \
353- "/lib/ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
354+ SYSTEMLIBS_DIR "ld-musl-sh" MUSL_DYNAMIC_LINKER_E MUSL_DYNAMIC_LINKER_FP \
209 "%{mfdpic:-fdpic}.so.1" 355 "%{mfdpic:-fdpic}.so.1"
210 356
211-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2" 357-#define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
@@ -214,10 +360,10 @@ index c1d0441d488..81373eb8336 100644
214 #undef SUBTARGET_LINK_EMUL_SUFFIX 360 #undef SUBTARGET_LINK_EMUL_SUFFIX
215 #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}" 361 #define SUBTARGET_LINK_EMUL_SUFFIX "%{mfdpic:_fd;:_linux}"
216diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h 362diff --git a/gcc/config/sparc/linux.h b/gcc/config/sparc/linux.h
217index 81201e67a2f..8b6fc577594 100644 363index 6d928846895..cd35dc8fa30 100644
218--- a/gcc/config/sparc/linux.h 364--- a/gcc/config/sparc/linux.h
219+++ b/gcc/config/sparc/linux.h 365+++ b/gcc/config/sparc/linux.h
220@@ -84,7 +84,7 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); 366@@ -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 367 When the -shared link option is used a final link is not being
222 done. */ 368 done. */
223 369
@@ -227,10 +373,10 @@ index 81201e67a2f..8b6fc577594 100644
227 #undef LINK_SPEC 373 #undef LINK_SPEC
228 #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \ 374 #define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
229diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h 375diff --git a/gcc/config/sparc/linux64.h b/gcc/config/sparc/linux64.h
230index a1a0efd8f28..85d1084afc2 100644 376index 97d5012f43f..65162c7c300 100644
231--- a/gcc/config/sparc/linux64.h 377--- a/gcc/config/sparc/linux64.h
232+++ b/gcc/config/sparc/linux64.h 378+++ b/gcc/config/sparc/linux64.h
233@@ -84,8 +84,8 @@ along with GCC; see the file COPYING3. If not see 379@@ -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 380 When the -shared link option is used a final link is not being
235 done. */ 381 done. */
236 382
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..f24bb2acf0 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 7108016f82a3ce9d275b5d0f37dbde422de6ab15 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,18 +15,17 @@ 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(+)
24 23
25diff --git a/ltmain.sh b/ltmain.sh 24diff --git a/ltmain.sh b/ltmain.sh
26index 70990740b6c..ee938056bef 100644 25index 1a710177fb2..e8474602b0b 100644
27--- a/ltmain.sh 26--- a/ltmain.sh
28+++ b/ltmain.sh 27+++ b/ltmain.sh
29@@ -6359,6 +6359,10 @@ func_mode_link () 28@@ -6381,6 +6381,10 @@ func_mode_link ()
30 func_warning "ignoring multiple \`-rpath's for a libtool library" 29 func_warning "ignoring multiple \`-rpath's for a libtool library"
31 30
32 install_libdir="$1" 31 install_libdir="$1"
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..215a599cb8 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 135523bfabbd37cc6326da1a7ec3cd8bc7387439 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 76893197773..12c334463c6 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@@ -91,10 +91,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..c3c4212115 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 2ede6edb029ef3d98f3ead90f7be54b71cb42ae2 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 a2a8761055c..a5a028f39c3 100755
22--- a/gcc/configure 22--- a/gcc/configure
23+++ b/gcc/configure 23+++ b/gcc/configure
24@@ -12685,10 +12685,20 @@ done 24@@ -15086,10 +15086,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@@ -15100,6 +15110,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 58ad9dc01fe..36ed7153398 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@@ -2406,10 +2406,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@@ -2420,6 +2430,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..9e05277515
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0011-aarch64-Fix-include-paths-when-S-B.patch
@@ -0,0 +1,67 @@
1From a60798dd091f46dbb5f2fa9cf7655b41e9431a73 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 | 14 +++++++-------
28 1 file changed, 7 insertions(+), 7 deletions(-)
29
30diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
31index e8bd8c73c12..6ea05b64601 100644
32--- a/gcc/config/aarch64/aarch64.h
33+++ b/gcc/config/aarch64/aarch64.h
34@@ -163,9 +163,9 @@ enum class aarch64_feature : unsigned char {
35 #define DEF_AARCH64_ISA_MODE(IDENT) IDENT,
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-isa-modes.def"
39-#include "aarch64-option-extensions.def"
40-#include "aarch64-arches.def"
41+#include "config/aarch64/aarch64-isa-modes.def"
42+#include "config/aarch64/aarch64-option-extensions.def"
43+#include "config/aarch64/aarch64-arches.def"
44 };
45
46 /* Define unique flags for each of the above. */
47@@ -175,16 +175,16 @@ enum class aarch64_feature : unsigned char {
48 #define DEF_AARCH64_ISA_MODE(IDENT) HANDLE (IDENT)
49 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) HANDLE (IDENT)
50 #define AARCH64_ARCH(A, B, IDENT, D, E) HANDLE (IDENT)
51-#include "aarch64-isa-modes.def"
52-#include "aarch64-option-extensions.def"
53-#include "aarch64-arches.def"
54+#include "config/aarch64/aarch64-isa-modes.def"
55+#include "config/aarch64/aarch64-option-extensions.def"
56+#include "config/aarch64/aarch64-arches.def"
57 #undef HANDLE
58
59 /* Define aarch64_isa_mode masks. */
60 #define DEF_AARCH64_ISA_MODE(IDENT) \
61 constexpr auto AARCH64_ISA_MODE_##IDENT ATTRIBUTE_UNUSED \
62 = aarch64_isa_mode (1) << int (aarch64_feature::IDENT);
63-#include "aarch64-isa-modes.def"
64+#include "config/aarch64/aarch64-isa-modes.def"
65 #undef HANDLE
66
67 constexpr auto AARCH64_FL_SM_STATE ATTRIBUTE_UNUSED
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..8d0c39f9ce 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 3745be5dece41bc2c633e1702980965e28888f62 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
@@ -13,10 +13,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
13 1 file changed, 3 insertions(+) 13 1 file changed, 3 insertions(+)
14 14
15diff --git a/ltmain.sh b/ltmain.sh 15diff --git a/ltmain.sh b/ltmain.sh
16index ee938056bef..9ebc7e3d1e0 100644 16index e8474602b0b..ef93f977a52 100644
17--- a/ltmain.sh 17--- a/ltmain.sh
18+++ b/ltmain.sh 18+++ b/ltmain.sh
19@@ -5628,6 +5628,9 @@ func_mode_link () 19@@ -5650,6 +5650,9 @@ func_mode_link ()
20 absdir="$abs_ladir" 20 absdir="$abs_ladir"
21 libdir="$abs_ladir" 21 libdir="$abs_ladir"
22 else 22 else
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..906ef3f74b
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0013-Ensure-target-gcc-headers-can-be-included.patch
@@ -0,0 +1,113 @@
1From 860aae0d1f5dce7a879690d53a6ab54c6a32107e 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 5546e259a20..944d0a6680a 100644
29--- a/gcc/Makefile.in
30+++ b/gcc/Makefile.in
31@@ -680,6 +680,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@@ -3397,6 +3398,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 c79d4902f85..640def63c27 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 3eb6c814ced..d534b9d2295 100644
75--- a/gcc/config/rs6000/sysv4.h
76+++ b/gcc/config/rs6000/sysv4.h
77@@ -987,6 +987,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@@ -1013,6 +1020,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 f98c39c53ec..db1e517fadc 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..c7bf8d1c8e 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 f28f581fbafa76a48cc7e88ab9c6eb63db6342c4 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
@@ -14,10 +14,10 @@ Signed-off-by: Khem Raj <raj.khem@gmail.com>
14 1 file changed, 3 insertions(+), 2 deletions(-) 14 1 file changed, 3 insertions(+), 2 deletions(-)
15 15
16diff --git a/ltmain.sh b/ltmain.sh 16diff --git a/ltmain.sh b/ltmain.sh
17index 9ebc7e3d1e0..7ea79fa8be6 100644 17index ef93f977a52..2ae16bf5d63 100644
18--- a/ltmain.sh 18--- a/ltmain.sh
19+++ b/ltmain.sh 19+++ b/ltmain.sh
20@@ -6004,12 +6004,13 @@ func_mode_link () 20@@ -6026,12 +6026,13 @@ func_mode_link ()
21 fi 21 fi
22 else 22 else
23 # We cannot seem to hardcode it, guess we'll fake it. 23 # We cannot seem to hardcode it, guess we'll fake it.
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..9abf72b8e8 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 b54d51c58012f9eac31cf83a8e02c7069bf80a74 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 f79e48a9aa2..bd8390946a2 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 9d56a8323b0..4deb08d8b34 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..682317fee8 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 ccfe6d014e8cc04b0d3420f82dca8920fb659a07 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 d43b3aef102..b157ad37483 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@@ -1610,8 +1610,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 640def63c27..0f937abe729 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 d534b9d2295..c5257425705 100644
143--- a/gcc/config/rs6000/sysv4.h
144+++ b/gcc/config/rs6000/sysv4.h
145@@ -951,53 +951,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@@ -1022,7 +1022,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 db1e517fadc..8867e8bb341 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 e033af78280..0af197df7b2 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 c1488865b8b..007c91780f6 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@@ -265,6 +265,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@@ -598,6 +600,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@@ -1648,10 +1651,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@@ -1659,9 +1662,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@@ -6837,6 +6840,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 2cdbebc4c50..b61a9d1b2fc 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 0c79d60a6c8..27c79f09be4 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..b3ab4996c3 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 1756ca43dc85ee9d367350d68b908e6681ddd986 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 007c91780f6..22eb17bc099 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@@ -2837,7 +2837,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@@ -2849,6 +2849,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..1b2da32a42 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 777963807e14a091c263d603cebfd7bb02f63b24 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 0f937abe729..88e59d1f78c 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 6c4480b70c4..89ae8267482 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@@ -102,6 +102,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 8de5eb8bb49..4eb5cc2c7cf 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@@ -373,6 +373,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..f23876b10a 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 f2649410d2eb1c3983054020c9238887bd31273f 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 88cf16ca581..fc283ccc934 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@@ -348,6 +348,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..cd22dba878 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 be81ee850cdf720f87733046cfa8f3fa43704a7d 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 cdfd94d3c73..de6fa7cc5ce 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@@ -13643,10 +13643,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 2484dc839bf..e980030ef23 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..5b67c194df 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 734760138d07236289c5e548efc6083ddcfda650 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 6a3621c96cd..3f6c36dcff5 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@@ -5238,7 +5238,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 7af79720189..3bdb82ef8bf 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..9292767037 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 95ee2cf97c5c2a4bd66c54d078b960a1d541d35e 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,26 +17,26 @@ 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 0f1a7156084..255fe448e63 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@@ -128,7 +128,6 @@ libatomic_la_LIBADD = $(foreach s,$(SIZES),$(addsuffix _$(s)_.lo,$(SIZEOBJS)))
24 ## On a target-specific basis, include alternates to be selected by IFUNC. 24 ## On a target-specific basis, include alternates to be selected by IFUNC.
25 if HAVE_IFUNC 25 if HAVE_IFUNC
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
29 endif 30 endif
30 if ARCH_ARM_LINUX
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 9798e7c09e9..3b3027eb77d 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@@ -452,7 +452,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_2) \
38 $(am__append_3) $(am__append_4) 38 $(am__append_3) $(am__append_4)
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..da91d85eb9
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0023-Fix-install-path-of-linux64.h.patch
@@ -0,0 +1,31 @@
1From cd7353f45bc2af9a9ea9694544d40ea03a1310d1 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 944d0a6680a..4cea9b20af5 100644
21--- a/gcc/Makefile.in
22+++ b/gcc/Makefile.in
23@@ -4115,6 +4115,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..b7edeef6eb
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0024-Avoid-hardcoded-build-paths-into-ppc-libgcc.patch
@@ -0,0 +1,28 @@
1From 159545123cfe05136037e302409cf82ec5c0263c 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..0a61862332
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0025-gcc-testsuite-tweaks-for-mips-OE.patch
@@ -0,0 +1,227 @@
1From 62e25edd60d45eaec331a3273880f6ff3248ef62 Mon Sep 17 00:00:00 2001
2From: Richard Purdie <richard.purdie@linuxfoundation.org>
3Date: Thu, 17 Aug 2023 09:01:40 -0700
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
30[Parts of the patch may be able to be split off and acceptable to upstream with
31discussion. Need to investigate why qemu-user passes the 'bad' instructions']
32
33Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
34Signed-off-by: Khem Raj <raj.khem@gmail.com>
35---
36 gcc/testsuite/gcc.target/mips/mips.exp | 16 ++++++++++
37 gcc/testsuite/lib/gcc-dg.exp | 11 +++++++
38 gcc/testsuite/lib/target-supports.exp | 44 ++++++++------------------
39 3 files changed, 40 insertions(+), 31 deletions(-)
40
41diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
42index 82d418a7cd4..46f7bf4ef92 100644
43--- a/gcc/testsuite/gcc.target/mips/mips.exp
44+++ b/gcc/testsuite/gcc.target/mips/mips.exp
45@@ -711,7 +711,23 @@ proc mips_first_unsupported_option { upstatus } {
46 global mips_option_tests
47 upvar $upstatus status
48
49+ if { [mips_have_test_option_p status "-mmsa"] } {
50+ verbose -log "Found -mmsa"
51+ if { ![check_mips_msa_hw_available] } {
52+ verbose -log "No MSA avail"
53+ return "-mmsa"
54+ }
55+ }
56+ if { [mips_have_test_option_p status "-mloongson-mmi"] } {
57+ verbose -log "Found -mloonson-mmi"
58+ if { ![check_mips_loongson_mmi_hw_available] } {
59+ verbose -log "No MMI avail"
60+ return "-mloonson-mmi"
61+ }
62+ }
63+
64 foreach { option code } [array get mips_option_tests] {
65+
66 if { [mips_have_test_option_p status $option] } {
67 regsub -all "\n" $code "\\n\\\n" asm
68 # Use check_runtime from target-supports.exp, which caches
69diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
70index 6dd8fa3fce9..95672008219 100644
71--- a/gcc/testsuite/lib/gcc-dg.exp
72+++ b/gcc/testsuite/lib/gcc-dg.exp
73@@ -233,9 +233,20 @@ proc schedule-cleanups { opts } {
74
75 proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
76 # Set up the compiler flags, based on what we're going to do.
77+ global do-what-limit
78
79 set options [list]
80
81+ if [info exists do-what-limit] then {
82+ # Demote run tests to $do-what-limit if set
83+ switch $do_what {
84+ run {
85+ set do_what ${do-what-limit}
86+ set dg-do-what ${do-what-limit}
87+ }
88+ }
89+ }
90+
91 switch $do_what {
92 "preprocess" {
93 set compile_type "preprocess"
94diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
95index a62f459ad7e..6886cfeee49 100644
96--- a/gcc/testsuite/lib/target-supports.exp
97+++ b/gcc/testsuite/lib/target-supports.exp
98@@ -2949,14 +2949,7 @@ proc check_mips_loongson_mmi_hw_available { } {
99 if { !([istarget mips*-*-*]) } {
100 expr 0
101 } else {
102- check_runtime_nocache mips_loongson_mmi_hw_available {
103- #include <loongson-mmiintrin.h>
104- int main()
105- {
106- asm volatile ("paddw $f2,$f4,$f6");
107- return 0;
108- }
109- } "-mloongson-mmi"
110+ expr 0
111 }
112 }]
113 }
114@@ -2970,29 +2963,7 @@ proc check_mips_msa_hw_available { } {
115 if { !([istarget mips*-*-*]) } {
116 expr 0
117 } else {
118- check_runtime_nocache mips_msa_hw_available {
119- #if !defined(__mips_msa)
120- #error "MSA NOT AVAIL"
121- #else
122- #if !(((__mips == 64) || (__mips == 32)) && (__mips_isa_rev >= 2))
123- #error "MSA NOT AVAIL FOR ISA REV < 2"
124- #endif
125- #if !defined(__mips_hard_float)
126- #error "MSA HARD_FLOAT REQUIRED"
127- #endif
128- #if __mips_fpr != 64
129- #error "MSA 64-bit FPR REQUIRED"
130- #endif
131- #include <msa.h>
132-
133- int main()
134- {
135- v8i16 v = __builtin_msa_ldi_h (0);
136- v[0] = 0;
137- return v[0];
138- }
139- #endif
140- } "-mmsa"
141+ expr 0
142 }
143 }]
144 }
145@@ -10354,6 +10325,7 @@ proc is-effective-target-keyword { arg } {
146
147 proc et-dg-runtest { runtest testcases flags default-extra-flags } {
148 global dg-do-what-default
149+ global do-what-limit
150 global EFFECTIVE_TARGETS
151 global et_index
152
153@@ -10361,6 +10333,7 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
154 foreach target $EFFECTIVE_TARGETS {
155 set target_flags $flags
156 set dg-do-what-default compile
157+ set do-what-limit link
158 set et_index [lsearch -exact $EFFECTIVE_TARGETS $target]
159 if { [info procs add_options_for_${target}] != [list] } {
160 set target_flags [add_options_for_${target} "$flags"]
161@@ -10368,8 +10341,10 @@ proc et-dg-runtest { runtest testcases flags default-extra-flags } {
162 if { [info procs check_effective_target_${target}_runtime]
163 != [list] && [check_effective_target_${target}_runtime] } {
164 set dg-do-what-default run
165+ set do-what-limit run
166 }
167 $runtest $testcases $target_flags ${default-extra-flags}
168+ unset do-what-limit
169 }
170 } else {
171 set et_index 0
172@@ -12155,6 +12130,7 @@ proc check_effective_target_sigsetjmp {} {
173 proc check_vect_support_and_set_flags { } {
174 global DEFAULT_VECTCFLAGS
175 global dg-do-what-default
176+ global do-what-limit
177 global EFFECTIVE_TARGETS
178
179 if [istarget powerpc*-*-*] {
180@@ -12186,6 +12162,7 @@ proc check_vect_support_and_set_flags { } {
181 set DEFAULT_VECTCFLAGS [linsert $DEFAULT_VECTCFLAGS 0 "-mcpu=970"]
182 }
183 set dg-do-what-default compile
184+ set do-what-limit link
185 }
186 } elseif { [check_effective_target_x86] } {
187 lappend DEFAULT_VECTCFLAGS "-msse2"
188@@ -12193,6 +12170,7 @@ proc check_vect_support_and_set_flags { } {
189 set dg-do-what-default run
190 } else {
191 set dg-do-what-default compile
192+ set do-what-limit link
193 }
194 } elseif { [istarget mips*-*-*]
195 && [check_effective_target_nomips16] } {
196@@ -12212,6 +12190,7 @@ proc check_vect_support_and_set_flags { } {
197 set dg-do-what-default run
198 } else {
199 set dg-do-what-default compile
200+ set do-what-limit link
201 }
202 } elseif [istarget alpha*-*-*] {
203 # Alpha's vectorization capabilities are extremely limited.
204@@ -12225,6 +12204,7 @@ proc check_vect_support_and_set_flags { } {
205 set dg-do-what-default run
206 } else {
207 set dg-do-what-default compile
208+ set do-what-limit link
209 }
210 } elseif [istarget ia64-*-*] {
211 set dg-do-what-default run
212@@ -12238,6 +12218,7 @@ proc check_vect_support_and_set_flags { } {
213 set dg-do-what-default run
214 } else {
215 set dg-do-what-default compile
216+ set do-what-limit link
217 }
218 } elseif [istarget aarch64*-*-*] {
219 set dg-do-what-default run
220@@ -12262,6 +12243,7 @@ proc check_vect_support_and_set_flags { } {
221 } else {
222 lappend DEFAULT_VECTCFLAGS "-march=z14" "-mzarch"
223 set dg-do-what-default compile
224+ set do-what-limit link
225 }
226 } elseif [istarget amdgcn-*-*] {
227 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-arm-fully-validate-mem_noofs_operand-PR120351.patch b/meta/recipes-devtools/gcc/gcc/0026-arm-fully-validate-mem_noofs_operand-PR120351.patch
new file mode 100644
index 0000000000..3f324fdc22
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0026-arm-fully-validate-mem_noofs_operand-PR120351.patch
@@ -0,0 +1,95 @@
1From bb7adc5dab8bcee2ef1c0d2af370ea77c49bb5c5 Mon Sep 17 00:00:00 2001
2From: Richard Earnshaw <rearnsha@arm.com>
3Date: Mon, 19 May 2025 16:19:39 +0100
4Subject: [PATCH] arm: fully validate mem_noofs_operand [PR120351]
5
6It's not enough to just check that a memory operand is of the form
7mem(reg); after RA we also need to validate the register being used.
8The safest way to do this is to call memory_operand.
9
10 PR target/120351
11
12gcc/ChangeLog:
13
14 * config/arm/predicates.md (mem_noofs_operand): Also check the op
15 is a valid memory_operand.
16
17gcc/testsuite/ChangeLog:
18
19 * gcc.target/arm/pr120351.c: New test.
20
21Upstream-Status: Backport [https://gcc.gnu.org/cgit/gcc/commit/?id=e5bb7a328eb71daa02d15b48d3a6c6b8cd24abc5]
22Signed-off-by: Khem Raj <raj.khem@gmail.com>
23---
24 gcc/config/arm/predicates.md | 3 +-
25 gcc/testsuite/gcc.target/arm/pr120351.c | 47 +++++++++++++++++++++++++
26 2 files changed, 49 insertions(+), 1 deletion(-)
27 create mode 100644 gcc/testsuite/gcc.target/arm/pr120351.c
28
29diff --git a/gcc/config/arm/predicates.md b/gcc/config/arm/predicates.md
30index 75c06d9be25..655f60312de 100644
31--- a/gcc/config/arm/predicates.md
32+++ b/gcc/config/arm/predicates.md
33@@ -907,7 +907,8 @@
34
35 (define_predicate "mem_noofs_operand"
36 (and (match_code "mem")
37- (match_code "reg" "0")))
38+ (match_code "reg" "0")
39+ (match_operand 0 "memory_operand")))
40
41 (define_predicate "call_insn_operand"
42 (ior (and (match_code "symbol_ref")
43diff --git a/gcc/testsuite/gcc.target/arm/pr120351.c b/gcc/testsuite/gcc.target/arm/pr120351.c
44new file mode 100644
45index 00000000000..d8e9d73275c
46--- /dev/null
47+++ b/gcc/testsuite/gcc.target/arm/pr120351.c
48@@ -0,0 +1,47 @@
49+/* { dg-do assemble } */
50+/* { dg-require-effective-target arm_neon_ok } */
51+/* { dg-add-options arm_neon } */
52+/* { dg-additional-options "-O2" } */
53+
54+
55+typedef struct A
56+{
57+ int f1;
58+} A;
59+
60+__inline void ref (A* x)
61+{
62+ __atomic_fetch_add(&x->f1, 1, 0);
63+}
64+
65+typedef struct B
66+{
67+ A *d;
68+ int *ptr;
69+} B;
70+
71+void insertOne (B*, B*);
72+
73+void init (B *);
74+__inline void copy (B *p, B *q)
75+{
76+ p->d = q->d;
77+ p->ptr = q->ptr;
78+ ref (p->d);
79+}
80+
81+__inline void emplace(B* x)
82+{
83+ B dummy;
84+ B _tmp;
85+ init (&dummy);
86+ copy (&_tmp, &dummy);
87+ insertOne(x, &_tmp);
88+}
89+
90+void testing ()
91+{
92+ B test;
93+ init (&test);
94+ emplace(&test);
95+}
diff --git a/meta/recipes-devtools/gcc/gcc/0026-fix-incorrect-preprocessor-line-numbers.patch b/meta/recipes-devtools/gcc/gcc/0026-fix-incorrect-preprocessor-line-numbers.patch
new file mode 100644
index 0000000000..f799085662
--- /dev/null
+++ b/meta/recipes-devtools/gcc/gcc/0026-fix-incorrect-preprocessor-line-numbers.patch
@@ -0,0 +1,475 @@
1From edf745dc519ddbfef127e2789bf11bfbacd300b7 Mon Sep 17 00:00:00 2001
2From: Jakub Jelinek <jakub@redhat.com>
3Date: Wed, 7 May 2025 17:25:42 +0200
4Subject: libcpp: Further fixes for incorrect line numbers in large files
5 [PR120061]
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10The backport of the PR108900 fix to 14 branch broke building chromium
11because static_assert (__LINE__ == expected_line_number, ""); now triggers
12as the __LINE__ values are off by one.
13This isn't the case on the trunk and 15 branch because we've switched
14to 64-bit location_t and so one actually needs far longer header files
15to trigger it.
16https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c11
17https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c12
18contain (large) testcases in patch form which show on the 14 branch
19that the first one used to fail before the PR108900 backport and now
20works correctly, while the second one attempts to match the chromium
21behavior and it used to pass before the PR108900 backport and now it
22FAILs.
23The two testcases show rare problematic cases, because
24do_include_common -> parse_include -> check_eol -> check_eol_1 ->
25cpp_get_token_1 -> _cpp_lex_token -> _cpp_lex_direct -> linemap_line_start
26triggers there
27 /* Allocate the new line_map. However, if the current map only has a
28 single line we can sometimes just increase its column_bits instead. */
29 if (line_delta < 0
30 || last_line != ORDINARY_MAP_STARTING_LINE_NUMBER (map)
31 || SOURCE_COLUMN (map, highest) >= (1U << (column_bits - range_bits))
32 || ( /* We can't reuse the map if the line offset is sufficiently
33 large to cause overflow when computing location_t values. */
34 (to_line - ORDINARY_MAP_STARTING_LINE_NUMBER (map))
35 >= (((uint64_t) 1)
36 << (CHAR_BIT * sizeof (linenum_type) - column_bits)))
37 || range_bits < map->m_range_bits)
38 map = linemap_check_ordinary
39 (const_cast <line_map *>
40 (linemap_add (set, LC_RENAME,
41 ORDINARY_MAP_IN_SYSTEM_HEADER_P (map),
42 ORDINARY_MAP_FILE_NAME (map),
43 to_line)));
44and so creates a new ordinary map on the line right after the
45(problematic) #include line.
46Now, in the spot that r14-11679-g8a884140c2bcb7 patched,
47pfile->line_table->highest_location in all 3 tests (also
48https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120061#c13
49) is before the decrement the start of the line after the #include line and so
50the decrement is really desirable in that case to put highest_location
51somewhere on the line where the #include actually is.
52But at the same time it is also undesirable, because if we do decrement it,
53then linemap_add LC_ENTER called from _cpp_do_file_change will then
54 /* Generate a start_location above the current highest_location.
55 If possible, make the low range bits be zero. */
56 location_t start_location = set->highest_location + 1;
57 unsigned range_bits = 0;
58 if (start_location < LINE_MAP_MAX_LOCATION_WITH_COLS)
59 range_bits = set->default_range_bits;
60 start_location += (1 << range_bits) - 1;
61 start_location &= ~((1 << range_bits) - 1);
62
63 linemap_assert (!LINEMAPS_ORDINARY_USED (set)
64 || (start_location
65 >= MAP_START_LOCATION (LINEMAPS_LAST_ORDINARY_MAP (set))));
66and we can end up with the new LC_ENTER ordinary map having the same
67start_location as the preceding LC_RENAME one.
68Next thing that happens is computation of included_from:
69 if (reason == LC_ENTER)
70 {
71 if (set->depth == 0)
72 map->included_from = 0;
73 else
74 /* The location of the end of the just-closed map. */
75 map->included_from
76 = (((map[0].start_location - 1 - map[-1].start_location)
77 & ~((1 << map[-1].m_column_and_range_bits) - 1))
78 + map[-1].start_location);
79The normal case (e.g. with the testcase included at the start of this comment) is
80that map[-1] starts somewhere earlier and so map->included_from computation above
81nicely computes location_t which expands to the start of the #include line.
82With r14-11679 reverted, for #c11 as well as #c12
83map[0].start_location == map[-1].start_location above, and so it is
84((location_t) -1 & ~((1 << map[-1].m_column_and_range_bits) - 1)))
85+ map[-1].start_location,
86which happens to be start of the #include line.
87For #c11 map[0].start_location is 0x500003a0 and map[-1] has
88m_column_and_range_bits 7 and map[-2] has m_column_and_range_bits 12 and
89map[0].included_from is set to 0x50000320.
90For #c12 map[0].start_location is 0x606c0402 and map[-2].start_location is
910x606c0400 and m_column_and_range_bits is 0 for all 3 maps.
92map[0].included_from is set to 0x606c0401.
93The last important part is again in linemap_add when doing LC_LEAVE:
94 /* (MAP - 1) points to the map we are leaving. The
95 map from which (MAP - 1) got included should be the map
96 that comes right before MAP in the same file. */
97 from = linemap_included_from_linemap (set, map - 1);
98
99 /* A TO_FILE of NULL is special - we use the natural values. */
100 if (to_file == NULL)
101 {
102 to_file = ORDINARY_MAP_FILE_NAME (from);
103 to_line = SOURCE_LINE (from, from[1].start_location);
104 sysp = ORDINARY_MAP_IN_SYSTEM_HEADER_P (from);
105 }
106Here it wants to compute the right to_line which ought to be the line after
107the #include directive.
108On the #c11 testcase that doesn't work correctly though, because
109map[-1].included_from is 0x50000320, from[0] for that is LC_ENTER with
110start_location 0x4080 and m_column_and_range_bits 12 but note that we've
111earlier computed map[-1].start_location + (-1 & 0xffffff80) and so only
112decreased by 7 bits, so to_line is still on the line with #include and not
113after it. In the #c12 that doesn't happen, all the ordinary maps involved
114there had 0 m_column_and_range_bits and so this computes correct line.
115
116Below is a fix for the trunk including testcases using the
117location_overflow_plugin hack to simulate the bugs without needing huge
118files (in the 14 case it is just 330KB and almost 10MB, but in the 15
119case it would need to be far bigger).
120The pre- r15-9018 trunk has
121FAIL: gcc.dg/plugin/location-overflow-test-pr116047.c -fplugin=./location_overflow_plugin.so scan-file static_assert[^\n\r]*6[^\n\r]*== 6
122and current trunk
123FAIL: gcc.dg/plugin/location-overflow-test-pr116047.c -fplugin=./location_overflow_plugin.so scan-file static_assert[^\n\r]*6[^\n\r]*== 6
124FAIL: gcc.dg/plugin/location-overflow-test-pr120061.c -fplugin=./location_overflow_plugin.so scan-file static_assert[^\n\r]*5[^\n\r]*== 5
125and with the patch everything PASSes.
126I'll post afterwards a 14 version of the patch.
127
128The patch reverts the r15-9018 change, because it is incorrect,
129we really need to decrement it even when crossing ordinary map
130boundaries, so that the location is not on the line after the #include
131line but somewhere on the #include line. It also patches two spots
132in linemap_add mentioned above to make sure we get correct locations
133both in the included_from location_t when doing LC_ENTER (second
134line-map.cc hunk) and when doing LC_LEAVE to compute the right to_line
135(first line-map.cc hunk), both in presence of an added LC_RENAME
136with the same start_location as the following LC_ENTER (i.e. the
137problematic cases).
138The LC_ENTER hunk is mostly to ensure included_form location_t is
139at the start of the #include line (column 0), without it we can
140decrease include_from not enough and end up at some random column
141in the middle of the line, because it is masking away
142map[-1].m_column_and_range_bits bits even when in the end the resulting
143include_from location_t will be found in map[-2] map with perhaps
144different m_column_and_range_bits. That alone doesn't fix the bug
145though.
146The more important is the LC_LEAVE hunk and the problem there is
147caused by linemap_line_start not actually doing
148 r = set->highest_line + (line_delta << map->m_column_and_range_bits);
149when adding a new map (the LC_RENAME one because we need to switch to
150different number of directly encoded ranges, or columns, etc.).
151So, in the original PR108900 case that
152 to_line = SOURCE_LINE (from, from[1].start_location);
153doesn't do the right thing, from there is the last < 0x50000000 map
154with m_column_and_range_bits 12, from[1] is the first one above it
155and map[-1].included_from is the correct location of column 0 on
156the #include line, but as the new LC_RENAME map has been created without
157actually increasing highest_location to be on the new line (we've just
158set to_line of the new LC_RENAME map to the correct line),
159 to_line = SOURCE_LINE (from, from[1].start_location);
160stays on the same source line. I've tried to just replace that with
161 to_line = SOURCE_LINE (from, linemap_included_from (map - 1)) + 1;
162i.e. just find out the #include line from map[-1].included_from and
163add 1 to it, unfortunately that breaks the
164c-c++-common/cpp/line-4.c
165test where we expect to stay on the same 0 line for LC_LEAVE from
166<command line> and gcc.dg/cpp/trad/Wunused.c, gcc.dg/cpp/trad/builtins.c
167and c-c++-common/analyzer/named-constants-via-macros-traditional.c tests
168all with -traditional-cpp preprocessing where to_line is also off-by-one
169from the expected one.
170So, this patch instead conditionalizes it, uses the
171 to_line = SOURCE_LINE (from, linemap_included_from (map - 1)) + 1;
172way only if from[1] is a LC_RENAME map (rather than the usual
173LC_ENTER one), that should limit it to the problematic cases of when
174parse_include peeked after EOL and had to create LC_RENAME map with
175the same start_location as the LC_ENTER after it.
176
177Some further justification for the LC_ENTER hunk, using the
178https://gcc.gnu.org/pipermail/gcc-patches/2025-May/682774.html testcase
179(old is 14 before r14-11679, vanilla current 14 and new with the 14 patch)
180I get
181$ /usr/src/gcc-14/obj/gcc/cc1.old -quiet -std=c23 pr116047.c -nostdinc
182In file included from pr116047-1.h:327677:21,
183 from pr116047.c:4:
184pr116047-2.h:1:1: error: unknown type name ‘a’
185 1 | a b c;
186 | ^
187pr116047-2.h:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’
188 1 | a b c;
189 | ^
190pr116047-1.h:327677:1: error: static assertion failed: ""
191327677 | #include "pr116047-2.h"
192 | ^~~~~~~~~~~~~
193$ /usr/src/gcc-14/obj/gcc/cc1.vanilla -quiet -std=c23 pr116047.c -nostdinc
194In file included from pr116047-1.h:327678,
195 from pr116047.c:4:
196pr116047-2.h:1:1: error: unknown type name ‘a’
197 1 | a b c;
198 | ^
199pr116047-2.h:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’
200 1 | a b c;
201 | ^
202$ /usr/src/gcc-14/obj/gcc/cc1.new -quiet -std=c23 pr116047.c -nostdinc
203In file included from pr116047-1.h:327677,
204 from pr116047.c:4:
205pr116047-2.h:1:1: error: unknown type name ‘a’
206 1 | a b c;
207 | ^
208pr116047-2.h:1:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c’
209 1 | a b c;
210 | ^
211
212pr116047-1.h has on lines 327677+327678:
213 #include "pr116047-2.h"
214 static_assert (__LINE__ == 327678, "");
215so the static_assert failure is something that was dealt mainly in the
216LC_LEAVE hunk and files.cc reversion, but please have a look at the
217In file included from lines.
21814.2 emits correct line (#include "pr116047-2.h" is indeed on line
219327677) but some random column in there (which is not normally printed
220for smaller headers; 21 is the . before extension in the filename).
221Current trunk emits incorrect line (327678 instead of 327677, clearly
222it didn't decrement).
223And the patched compiler emits the right line with no column, as would
224be printed if I remove e.g. 300000 newlines from the file.
225
2262025-05-07 Jakub Jelinek <jakub@redhat.com>
227
228 PR preprocessor/108900
229 PR preprocessor/116047
230 PR preprocessor/120061
231 * files.cc (_cpp_stack_file): Revert 2025-03-28 change.
232 * line-map.cc (linemap_add): Use
233 SOURCE_LINE (from, linemap_included_from (map - 1)) + 1; instead of
234 SOURCE_LINE (from, from[1].start_location); to compute to_line
235 for LC_LEAVE. For LC_ENTER included_from computation, look at
236 map[-2] or even lower if map[-1] has the same start_location as
237 map[0].
238
239 * gcc.dg/plugin/plugin.exp: Add location-overflow-test-pr116047.c
240 and location-overflow-test-pr120061.c.
241 * gcc.dg/plugin/location_overflow_plugin.cc (plugin_init): Don't error
242 on unknown values, instead just break. Handle 0x4fHHHHHH arguments
243 differently.
244 * gcc.dg/plugin/location-overflow-test-pr116047.c: New test.
245 * gcc.dg/plugin/location-overflow-test-pr116047-1.h: New test.
246 * gcc.dg/plugin/location-overflow-test-pr116047-2.h: New test.
247 * gcc.dg/plugin/location-overflow-test-pr120061.c: New test.
248 * gcc.dg/plugin/location-overflow-test-pr120061-1.h: New test.
249 * gcc.dg/plugin/location-overflow-test-pr120061-2.h: New test.
250
251Upstream-Status: Backport [https://gcc.gnu.org/cgit/gcc/commit/?id=edf745dc519ddbfef127e2789bf11bfbacd300b7]
252Signed-off-by: Yash Shinde <Yash.Shinde@windriver.com>
253---
254 .../plugin/location-overflow-test-pr116047-1.h | 6 +++
255 .../plugin/location-overflow-test-pr116047-2.h | 1 +
256 .../plugin/location-overflow-test-pr116047.c | 5 +++
257 .../plugin/location-overflow-test-pr120061-1.h | 6 +++
258 .../plugin/location-overflow-test-pr120061-2.h | 1 +
259 .../plugin/location-overflow-test-pr120061.c | 6 +++
260 .../gcc.dg/plugin/location_overflow_plugin.cc | 15 +++++--
261 gcc/testsuite/gcc.dg/plugin/plugin.exp | 4 +-
262 libcpp/files.cc | 8 ----
263 libcpp/line-map.cc | 48 ++++++++++++++++++----
264 10 files changed, 80 insertions(+), 20 deletions(-)
265 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-1.h
266 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-2.h
267 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047.c
268 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-1.h
269 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-2.h
270 create mode 100644 gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061.c
271
272diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-1.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-1.h
273new file mode 100644
274index 000000000000..3dd6434a938b
275--- /dev/null
276+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-1.h
277@@ -0,0 +1,6 @@
278+
279+
280+
281+
282+#include "location-overflow-test-pr116047-2.h"
283+static_assert (__LINE__ == 6, "");
284diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-2.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-2.h
285new file mode 100644
286index 000000000000..048f715b4656
287--- /dev/null
288+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047-2.h
289@@ -0,0 +1 @@
290+int i;
291diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047.c b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047.c
292new file mode 100644
293index 000000000000..75161fa5f055
294--- /dev/null
295+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr116047.c
296@@ -0,0 +1,5 @@
297+/* PR preprocessor/116047 */
298+/* { dg-do preprocess } */
299+/* { dg-options "-nostdinc -std=c23 -fplugin-arg-location_overflow_plugin-value=0x4ffe0180" } */
300+#include "location-overflow-test-pr116047-1.h"
301+/* { dg-final { scan-file location-overflow-test-pr116047.i "static_assert\[^\n\r]\*6\[^\n\r]\*== 6" } } */
302diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-1.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-1.h
303new file mode 100644
304index 000000000000..ebf7704f568e
305--- /dev/null
306+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-1.h
307@@ -0,0 +1,6 @@
308+
309+
310+
311+
312+#include "location-overflow-test-pr120061-2.h"
313+
314diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-2.h b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-2.h
315new file mode 100644
316index 000000000000..048f715b4656
317--- /dev/null
318+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061-2.h
319@@ -0,0 +1 @@
320+int i;
321diff --git a/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061.c b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061.c
322new file mode 100644
323index 000000000000..e8e803898da3
324--- /dev/null
325+++ b/gcc/testsuite/gcc.dg/plugin/location-overflow-test-pr120061.c
326@@ -0,0 +1,6 @@
327+/* PR preprocessor/120061 */
328+/* { dg-do preprocess } */
329+/* { dg-options "-nostdinc -std=c23 -fplugin-arg-location_overflow_plugin-value=0x61000000" } */
330+#include "location-overflow-test-pr120061-1.h"
331+static_assert (__LINE__ == 5, "");
332+/* { dg-final { scan-file location-overflow-test-pr120061.i "static_assert\[^\n\r]\*5\[^\n\r]\*== 5" } } */
333diff --git a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc
334index f731b1421b0f..f770d35ea518 100644
335--- a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc
336+++ b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.cc
337@@ -85,9 +85,18 @@ plugin_init (struct plugin_name_args *plugin_info,
338 error_at (UNKNOWN_LOCATION, "missing plugin argument");
339
340 /* With 64-bit locations, the thresholds are larger, so shift the base
341- location argument accordingly. */
342+ location argument accordingly, basically remap the GCC 14 32-bit
343+ location_t argument values to 64-bit location_t counterparts. There
344+ is one exception for values slightly before the 32-bit location_t
345+ LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES (0x50000000). In that case
346+ remap them to the same amount before the 64-bit location_t
347+ LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES -
348+ ((location_t) 0x50000000) << 31. */
349 gcc_assert (sizeof (location_t) == sizeof (uint64_t));
350- base_location = 1 + ((base_location - 1) << 31);
351+ if (base_location >= 0x4f000000 && base_location <= 0x4fffffff)
352+ base_location += (((location_t) 0x50000000) << 31) - 0x50000000;
353+ else
354+ base_location = 1 + ((base_location - 1) << 31);
355
356 register_callback (plugin_info->base_name,
357 PLUGIN_PRAGMAS,
358@@ -107,7 +116,7 @@ plugin_init (struct plugin_name_args *plugin_info,
359 break;
360
361 default:
362- error_at (UNKNOWN_LOCATION, "unrecognized value for plugin argument");
363+ break;
364 }
365
366 return 0;
367diff --git a/gcc/testsuite/gcc.dg/plugin/plugin.exp b/gcc/testsuite/gcc.dg/plugin/plugin.exp
368index 90c91621d0aa..96e76d2e0c36 100644
369--- a/gcc/testsuite/gcc.dg/plugin/plugin.exp
370+++ b/gcc/testsuite/gcc.dg/plugin/plugin.exp
371@@ -138,7 +138,9 @@ set plugin_test_list [list \
372 { location_overflow_plugin.cc \
373 location-overflow-test-1.c \
374 location-overflow-test-2.c \
375- location-overflow-test-pr83173.c } \
376+ location-overflow-test-pr83173.c \
377+ location-overflow-test-pr116047.c \
378+ location-overflow-test-pr120061.c } \
379 { must_tail_call_plugin.cc \
380 must-tail-call-1.c \
381 must-tail-call-2.c } \
382diff --git a/libcpp/files.cc b/libcpp/files.cc
383index c1abde6639fe..d80c4bfd9077 100644
384--- a/libcpp/files.cc
385+++ b/libcpp/files.cc
386@@ -1047,14 +1047,6 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, include_type type,
387 && (pfile->line_table->highest_location
388 != LINE_MAP_MAX_LOCATION - 1));
389
390- if (decrement && LINEMAPS_ORDINARY_USED (pfile->line_table))
391- {
392- const line_map_ordinary *map
393- = LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table);
394- if (map && map->start_location == pfile->line_table->highest_location)
395- decrement = false;
396- }
397-
398 if (decrement)
399 pfile->line_table->highest_location--;
400
401diff --git a/libcpp/line-map.cc b/libcpp/line-map.cc
402index 17e7f12551c0..cf6557117c81 100644
403--- a/libcpp/line-map.cc
404+++ b/libcpp/line-map.cc
405@@ -621,8 +621,8 @@ linemap_add (line_maps *set, enum lc_reason reason,
406 #include "included", inside the same "includer" file. */
407
408 linemap_assert (!MAIN_FILE_P (map - 1));
409- /* (MAP - 1) points to the map we are leaving. The
410- map from which (MAP - 1) got included should be the map
411+ /* (MAP - 1) points to the map we are leaving. The
412+ map from which (MAP - 1) got included should be usually the map
413 that comes right before MAP in the same file. */
414 from = linemap_included_from_linemap (set, map - 1);
415
416@@ -630,7 +630,24 @@ linemap_add (line_maps *set, enum lc_reason reason,
417 if (to_file == NULL)
418 {
419 to_file = ORDINARY_MAP_FILE_NAME (from);
420- to_line = SOURCE_LINE (from, from[1].start_location);
421+ /* Compute the line on which the map resumes, for #include this
422+ should be the line after the #include line. Usually FROM is
423+ the map right before LC_ENTER map - the first map of the included
424+ file, and in that case SOURCE_LINE (from, from[1].start_location);
425+ computes the right line (and does handle even some special cases
426+ (e.g. where for returning from <command line> we still want to
427+ be at line 0 or some -traditional-cpp cases). In rare cases
428+ FROM can be followed by LC_RENAME created by linemap_line_start
429+ for line right after #include line. If that happens,
430+ start_location of the FROM[1] map will be the same as
431+ start_location of FROM[2] LC_ENTER, but FROM[1] start_location
432+ might not have advance enough for moving to a full next line.
433+ In that case compute the line of #include line and add 1 to it
434+ to advance to the next line. See PR120061. */
435+ if (from[1].reason == LC_RENAME)
436+ to_line = SOURCE_LINE (from, linemap_included_from (map - 1)) + 1;
437+ else
438+ to_line = SOURCE_LINE (from, from[1].start_location);
439 sysp = ORDINARY_MAP_IN_SYSTEM_HEADER_P (from);
440 }
441 else
442@@ -660,11 +677,26 @@ linemap_add (line_maps *set, enum lc_reason reason,
443 if (set->depth == 0)
444 map->included_from = 0;
445 else
446- /* The location of the end of the just-closed map. */
447- map->included_from
448- = (((map[0].start_location - 1 - map[-1].start_location)
449- & ~((loc_one << map[-1].m_column_and_range_bits) - 1))
450- + map[-1].start_location);
451+ {
452+ /* Compute location from whence this line map was included.
453+ For #include this should be preferrably column 0 of the
454+ line on which #include directive appears.
455+ map[-1] is the just closed map and usually included_from
456+ falls within that map. In rare cases linemap_line_start
457+ can insert a new LC_RENAME map for the line immediately
458+ after #include line, in that case map[-1] will have the
459+ same start_location as the new one and so included_from
460+ would not be from map[-1] but likely map[-2]. If that
461+ happens, mask off map[-2] m_column_and_range_bits bits
462+ instead of map[-1]. See PR120061. */
463+ int i = -1;
464+ while (map[i].start_location == map[0].start_location)
465+ --i;
466+ map->included_from
467+ = (((map[0].start_location - 1 - map[i].start_location)
468+ & ~((loc_one << map[i].m_column_and_range_bits) - 1))
469+ + map[i].start_location);
470+ }
471 set->depth++;
472 if (set->trace_includes)
473 trace_include (set, map);
474--
475
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