blob: 37f26f0728bd4e6a58f0365e09e8a368c5dd991c [file] [log] [blame]
Andrew Geisslereff27472021-10-29 15:35:00 -05001From: Richard Purdie <richard.purdie@linuxfoundation.org>
2Subject: [PATCH 5/5] gcc: Pass sysroot options to cpp for preprocessed source
Andrew Geissler82c905d2020-04-13 13:39:40 -05003
Andrew Geisslereff27472021-10-29 15:35:00 -05004OpenEmbedded/Yocto Project extensively uses the --sysroot support within gcc.
5We discovered that when compiling preprocessed source (.i or .ii files), the
6compiler will try and access the builtin sysroot location rather than the
7--sysroot option specified on the commandline. If access to that directory is
8permission denied (unreadable), gcc will error. This is particularly problematic
9when ccache is involved.
Andrew Geissler82c905d2020-04-13 13:39:40 -050010
Andrew Geisslereff27472021-10-29 15:35:00 -050011This patch adds %I to the cpp-output spec macro so the default substitutions for
12-iprefix, -isystem, -isysroot happen and the correct sysroot is used.
Andrew Geissler82c905d2020-04-13 13:39:40 -050013
Andrew Geisslereff27472021-10-29 15:35:00 -0500142021-10-27 Richard Purdie <richard.purdie@linuxfoundation.org>
15
16gcc/cp/ChangeLog:
17
18 * lang-specs.h: Pass sysroot options to cpp for preprocessed source
19
20gcc/ChangeLog:
21
22 * gcc.c: Pass sysroot options to cpp for preprocessed source
23
24Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Andrew Geissler82c905d2020-04-13 13:39:40 -050025
26[YOCTO #2074]
27
Andrew Geisslereff27472021-10-29 15:35:00 -050028Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582725.html]
Andrew Geissler82c905d2020-04-13 13:39:40 -050029---
30 gcc/cp/lang-specs.h | 2 +-
31 gcc/gcc.c | 2 +-
32 2 files changed, 2 insertions(+), 2 deletions(-)
33
Andrew Geisslereff27472021-10-29 15:35:00 -050034Index: gcc-11.2.0/gcc/cp/lang-specs.h
35===================================================================
36--- gcc-11.2.0.orig/gcc/cp/lang-specs.h
37+++ gcc-11.2.0/gcc/cp/lang-specs.h
38@@ -116,7 +116,7 @@ along with GCC; see the file COPYING3.
Andrew Geissler82c905d2020-04-13 13:39:40 -050039 {".ii", "@c++-cpp-output", 0, 0, 0},
40 {"@c++-cpp-output",
41 "%{!E:%{!M:%{!MM:"
42- " cc1plus -fpreprocessed %i %(cc1_options) %2"
43+ " cc1plus -fpreprocessed %i %I %(cc1_options) %2"
Andrew Geisslerc926e172021-05-07 16:11:35 -050044 " %{!fsyntax-only:"
45 " %{fmodule-only:%{!S:-o %g.s%V}}"
46 " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}"
Andrew Geisslereff27472021-10-29 15:35:00 -050047Index: gcc-11.2.0/gcc/gcc.c
48===================================================================
49--- gcc-11.2.0.orig/gcc/gcc.c
50+++ gcc-11.2.0/gcc/gcc.c
51@@ -1470,7 +1470,7 @@ static const struct compiler default_com
Andrew Geissler82c905d2020-04-13 13:39:40 -050052 %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0},
53 {".i", "@cpp-output", 0, 0, 0},
54 {"@cpp-output",
55- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
56+ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %I %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
57 {".s", "@assembler", 0, 0, 0},
58 {"@assembler",
59 "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0},