Skip to content

Commit

Permalink
toolchain: add patch to fix cpp in gcc-10
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-zero committed Jul 31, 2020
1 parent 8f44552 commit fed02d5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tools/toolchain/scripts/files/gcc-10.2.0-cpp-__has_include.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From b7bb13d4a5fcb593dc745ca3b6180f8babb54893 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tiziano=20M=C3=BCller?= <tiziano.mueller@chem.uzh.ch>
Date: Mon, 27 Jul 2020 15:40:38 +0200
Subject: [PATCH] libcpp: fix __has_include handling with traditional-cpp

fixes #95889
---
libcpp/init.c | 3 +++
libcpp/traditional.c | 4 +++-
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libcpp/init.c b/libcpp/init.c
index 0aac5acd0a35..b0cf71192589 100644
--- a/libcpp/init.c
+++ b/libcpp/init.c
@@ -400,6 +400,9 @@ static const struct builtin_macro builtin_array[] =
B("__LINE__", BT_SPECLINE, true),
B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL, true),
B("__COUNTER__", BT_COUNTER, true),
+ /* Make sure to update the list of built-in
+ function-like macros in traditional.c:
+ fun_like_macro() when adding more following */
B("__has_attribute", BT_HAS_ATTRIBUTE, true),
B("__has_cpp_attribute", BT_HAS_ATTRIBUTE, true),
B("__has_builtin", BT_HAS_BUILTIN, true),
diff --git a/libcpp/traditional.c b/libcpp/traditional.c
index 77adb3bf595f..b087072c9b4c 100644
--- a/libcpp/traditional.c
+++ b/libcpp/traditional.c
@@ -330,7 +330,9 @@ fun_like_macro (cpp_hashnode *node)
{
if (cpp_builtin_macro_p (node))
return (node->value.builtin == BT_HAS_ATTRIBUTE
- || node->value.builtin == BT_HAS_BUILTIN);
+ || node->value.builtin == BT_HAS_BUILTIN
+ || node->value.builtin == BT_HAS_INCLUDE
+ || node->value.builtin == BT_HAS_INCLUDE_NEXT);
return node->value.macro->fun_like;
}

10 changes: 10 additions & 0 deletions tools/toolchain/scripts/install_gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_NAME")" && pwd -P)"

gcc_ver="10.2.0"
gcc_sha256="27e879dccc639cd7b0cc08ed575c1669492579529b53c9ff27b0b96265fa867d"

patches=(
"${SCRIPT_DIR}/files/gcc-${gcc_ver}-cpp-__has_include.patch"
)

source "${SCRIPT_DIR}"/common_vars.sh
source "${SCRIPT_DIR}"/tool_kit.sh
source "${SCRIPT_DIR}"/signal_trap.sh
Expand Down Expand Up @@ -41,6 +46,11 @@ case "$with_gcc" in
fi
echo "Installing GCC from scratch into ${pkg_install_dir}"
cd gcc-${gcc_ver}

for patch in "${patches[@]}" ; do
patch -p1 < "${patch}"
done

./contrib/download_prerequisites > prereq.log 2>&1
GCCROOT=${PWD}
mkdir obj
Expand Down

0 comments on commit fed02d5

Please sign in to comment.