From 5145517f7b3adae80cc534d7e5a55389ae399b30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bernhard=20Rosenkr=C3=A4nzer?=
 <bernhard.rosenkraenzer.ext@huawei.com>
Date: Wed, 14 Jul 2021 00:53:20 +0200
Subject: [PATCH] gcc: Fix tm.h plugin header
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

On x86-64, tm.h (needed to build gcc plugins) tries to include
config/i386/linux64.h, which isn't installed. Fortunately it also
isn't used, so simply removing the include statement is an ok fix.

Sample failure see
https://git.ostc-eu.org/OSTC/OHOS/meta-ohos/-/jobs/43762

Signed-off-by: Bernhard Rosenkränzer <bernhard.rosenkraenzer.ext@huawei.com>
---
 meta-ohos-staging/recipes-devtools/gcc/gcc-cross-canadian.inc | 3 +++
 meta-ohos-staging/recipes-devtools/gcc/gcc-cross.inc          | 3 +++
 meta-ohos-staging/recipes-devtools/gcc/gcc-target.inc         | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/meta-ohos-staging/recipes-devtools/gcc/gcc-cross-canadian.inc b/meta-ohos-staging/recipes-devtools/gcc/gcc-cross-canadian.inc
index 1872faee..eaf4f57e 100644
--- a/meta-ohos-staging/recipes-devtools/gcc/gcc-cross-canadian.inc
+++ b/meta-ohos-staging/recipes-devtools/gcc/gcc-cross-canadian.inc
@@ -139,6 +139,9 @@ do_install () {
 	cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
 	cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
 
+	# Fix a plugin header including a nonexistant (and unnecessary) header
+	sed -i -e '/config\/i386\/linux64\.h/d' ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/tm.h
+
 	# install LTO linker plugins where binutils tools can find it
 	install -d ${D}${libdir}/bfd-plugins
 	ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
diff --git a/meta-ohos-staging/recipes-devtools/gcc/gcc-cross.inc b/meta-ohos-staging/recipes-devtools/gcc/gcc-cross.inc
index dca4036a..348bd1df 100644
--- a/meta-ohos-staging/recipes-devtools/gcc/gcc-cross.inc
+++ b/meta-ohos-staging/recipes-devtools/gcc/gcc-cross.inc
@@ -119,6 +119,9 @@ do_install () {
 	cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
 	cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
 
+	# Fix a plugin header including a nonexistant (and unnecessary) header
+	sed -i -e '/config\/i386\/linux64\.h/d' ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/tm.h
+
 	find ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed -type f -not -name "README" -not -name limits.h -not -name syslimits.h | xargs rm -f
 
 	# install LTO linker plugins where binutils tools can find it
diff --git a/meta-ohos-staging/recipes-devtools/gcc/gcc-target.inc b/meta-ohos-staging/recipes-devtools/gcc/gcc-target.inc
index 0ee3e83d..48dfd9ce 100644
--- a/meta-ohos-staging/recipes-devtools/gcc/gcc-target.inc
+++ b/meta-ohos-staging/recipes-devtools/gcc/gcc-target.inc
@@ -186,6 +186,8 @@ do_install () {
 	# Don't package details about the build host
 	rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/auto-build.h
 	rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/bconfig.h
+	# Fix a plugin header including a nonexistant (and unnecessary) header
+	sed -i -e '/config\/i386\/linux64\.h/d' ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/tm.h
 
 	cd ${D}${bindir}
 
-- 
GitLab