Brad Bishop | bec4ebc | 2022-08-03 09:55:16 -0400 | [diff] [blame] | 1 | From: Richard Purdie <richard.purdie@linuxfoundation.org> |
| 2 | Subject: [PATCH 5/5] gcc: Pass sysroot options to cpp for preprocessed source |
| 3 | |
| 4 | OpenEmbedded/Yocto Project extensively uses the --sysroot support within gcc. |
| 5 | We discovered that when compiling preprocessed source (.i or .ii files), the |
| 6 | compiler will try and access the builtin sysroot location rather than the |
| 7 | --sysroot option specified on the commandline. If access to that directory is |
| 8 | permission denied (unreadable), gcc will error. This is particularly problematic |
| 9 | when ccache is involved. |
| 10 | |
| 11 | This 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. |
| 13 | |
| 14 | 2021-10-27 Richard Purdie <richard.purdie@linuxfoundation.org> |
| 15 | |
| 16 | gcc/cp/ChangeLog: |
| 17 | |
| 18 | * lang-specs.h: Pass sysroot options to cpp for preprocessed source |
| 19 | |
| 20 | gcc/ChangeLog: |
| 21 | |
| 22 | * gcc.c: Pass sysroot options to cpp for preprocessed source |
| 23 | |
| 24 | Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> |
| 25 | |
| 26 | [YOCTO #2074] |
| 27 | |
| 28 | Upstream-Status: Submitted [https://gcc.gnu.org/pipermail/gcc-patches/2021-October/582725.html] |
| 29 | --- |
| 30 | gcc/cp/lang-specs.h | 2 +- |
| 31 | gcc/gcc.c | 2 +- |
| 32 | 2 files changed, 2 insertions(+), 2 deletions(-) |
| 33 | |
| 34 | Index: 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. |
| 39 | {".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" |
| 44 | " %{!fsyntax-only:" |
| 45 | " %{fmodule-only:%{!S:-o %g.s%V}}" |
| 46 | " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}" |
| 47 | Index: 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 |
| 52 | %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}, |