Skip to contentSkip to conversation

gcc: Fix tm.h plugin header

PATCH In review Andrei Gherzan 4 participants 7 messages Dec 9, 2021 – Dec 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gcc: Fix tm.h plugin header

From: Andrei Gherzan <[email protected]>

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.

---
 meta/recipes-devtools/gcc/gcc-cross-canadian.inc | 3 +++
 meta/recipes-devtools/gcc/gcc-cross.inc          | 3 +++
 meta/recipes-devtools/gcc/gcc-target.inc         | 3 +++
 3 files changed, 9 insertions(+)
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +3 -0
index 495dd9070b..a64fcc50ce 100644
@@ -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
meta/recipes-devtools/gcc/gcc-cross.inc +3 -0
index 3ffa1f0c46..ac34d5116a 100644
@@ -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
meta/recipes-devtools/gcc/gcc-target.inc +3 -0
index bf55e692e6..4d087c5183 100644
@@ -187,6 +187,9 @@ do_install () {
 	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}
 
 	# We care about g++ not c++
Signature · 1 line
2.25.1
#1 lore raw
Quoted 7 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

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.

is it due to multilib support ? if so we might be ok since we may not be using it
but really it will be good to check it with multilib builds of x86_64/x86

Quoted 62 lines
---
 meta/recipes-devtools/gcc/gcc-cross-canadian.inc | 3 +++
 meta/recipes-devtools/gcc/gcc-cross.inc          | 3 +++
 meta/recipes-devtools/gcc/gcc-target.inc         | 3 +++
 3 files changed, 9 insertions(+)
meta/recipes-devtools/gcc/gcc-cross-canadian.inc +3 -0
index 495dd9070b..a64fcc50ce 100644
@@ -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
meta/recipes-devtools/gcc/gcc-cross.inc +3 -0
index 3ffa1f0c46..ac34d5116a 100644
@@ -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
meta/recipes-devtools/gcc/gcc-target.inc +3 -1
index bf55e692e6..4d087c5183 100644
@@ -187,6 +187,9 @@ do_install () {
        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}
 
        # We care about g++ not c++
--

2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#159457): https://lists.openembedded.org/g/openembedded-core/message/159457
Mute This Topic: https://lists.openembedded.org/mt/87614108/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#2 lore raw
Quoted 4 lines · Khem Raj
Quoted 3 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

Quoted 8 lines
Quoted 4 lines

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.

is it due to multilib support ? if so we might be ok since we may not be using it
but really it will be good to check it with multilib builds of x86_64/x86

I don't think it is related to multilib but I'll give multilib a try. In my case, the issue was revealed when compiling a kernel plugin config. I can't remember right now which one but I can replicate it for logs.

--
Andrei

#3 lore raw
Quoted 11 lines · Andrei Gherzan
Quoted 8 lines · Khem Raj
Quoted 5 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

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.

Quoted 7 lines
Quoted 3 lines

is it due to multilib support ? if so we might be ok since we may not be using it
but really it will be good to check it with multilib builds of x86_64/x86

I don't think it is related to multilib but I'll give multilib a try. In my case, the issue was revealed when compiling a kernel plugin config. I can't remember right now which one but I can replicate it for logs.

Hi,
I've had a closer look at the problem, and can confirm the patch doesn't break even in multilib setups.

The problem is that in a non-multilib setup, the config/i386/linux64.h header is not generated, but tm.h tries to include it nevertheless, causing any gcc plugin that #includes tm.h (such as all the gcc plugins in the kernel -- tm.h is included by scripts/gcc-plugins/gcc-common.h) to fail to build. An alternative fix would be adding
mkdir -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386
touch ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386/linux64.h
(creating the file if it isn't there) instead. This would make sure that in cases where config/i386/linux64.h does exist, it doesn't get removed from tm.h (potentially fixing plugins that reference any of the #defines in i386/linux64.h without including the file manually -- but I have yet to see any such plugin).

I will try to get a better fix (not adding the include statement to tm.h in the first place rather than having to remove it later in install scripts) upstream, but in the mean time, the patch fixes our builds before the better fix is ready/applied.

ttyl
bero

#4 lore raw
Quoted 18 lines · Bernhard Rosenkränzer via lists.openembedded.org
Quoted 6 lines · Andrei Gherzan
Quoted 4 lines · Khem Raj
Quoted 2 lines · Andrei Gherzan

From: Andrei Gherzan <[email protected]>

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

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.

is it due to multilib support ? if so we might be ok since we may not be using it
but really it will be good to check it with multilib builds of x86_64/x86

I don't think it is related to multilib but I'll give multilib a try. In my case, the issue was revealed when compiling a kernel plugin config. I can't remember right now which one but I can replicate it for logs.

Hi,
I've had a closer look at the problem, and can confirm the patch doesn't break even in multilib setups.

Quoted 7 lines

The problem is that in a non-multilib setup, the config/i386/linux64.h header is not generated, but tm.h tries to include it nevertheless, causing any gcc plugin that #includes tm.h (such as all the gcc plugins in the kernel -- tm.h is included by scripts/gcc-plugins/gcc-common.h) to fail to build. An alternative fix would be adding
mkdir -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386
touch ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386/linux64.h
(creating the file if it isn't there) instead. This would make sure that in cases where config/i386/linux64.h does exist, it doesn't get removed from tm.h (potentially fixing plugins that reference any of the #defines in i386/linux64.h without including the file manually -- but I have yet to see any such plugin).

I will try to get a better fix (not adding the include statement to tm.h in the first place rather than having to remove it later in install scripts) upstream, but in the mean time, the patch fixes our builds before the better fix is ready/applied.

Ping on this patch. Any chance we can pull it in as a first iteration of the solution?

---
Andrei

#5 lore raw
Quoted 41 lines · Andrei Gherzan
Quoted 39 lines · Bernhard Rosenkränzer via lists.openembedded.org

On Thu, Dec 9, 2021 at 07:40 PM, Andrei Gherzan wrote:

Quoted 11 lines · Khem Raj

Quoted 9 lines

On Thu, Dec 9, 2021 at 7:40 AM Andrei Gherzan <[email protected]> wrote:

Quoted 6 lines

From: Andrei Gherzan <[email protected]>

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.

Quoted 7 lines
Quoted 4 lines

is it due to multilib support ? if so we might be ok since we may not be using it
but really it will be good to check it with multilib builds of x86_64/x86

I don't think it is related to multilib but I'll give multilib a try. In my case, the issue was revealed when compiling a kernel plugin config. I can't remember right now which one but I can replicate it for logs.

Hi,
I've had a closer look at the problem, and can confirm the patch doesn't break even in multilib setups.

The problem is that in a non-multilib setup, the config/i386/linux64.h header is not generated, but tm.h tries to include it nevertheless, causing any gcc plugin that #includes tm.h (such as all the gcc plugins in the kernel -- tm.h is included by scripts/gcc-plugins/gcc-common.h) to fail to build.
An alternative fix would be adding
mkdir -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386 touch ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386/lin ux64.h
(creating the file if it isn't there) instead. This would make sure that in cases where config/i386/linux64.h does exist, it doesn't get removed from tm.h (potentially fixing plugins that reference any of the #defines in i386/linux64.h without including the file manually -- but I have yet to see any such plugin).

Quoted 7 lines
Quoted 4 lines

I will try to get a better fix (not adding the include statement to tm.h in the first place rather than having to remove it later in install scripts) upstream, but in the mean time, the patch fixes our builds before the better fix is ready/applied.

Ping on this patch. Any chance we can pull it in as a first iteration of the solution?

I don't like sed in this context as if the code changes, it silently stops working and we struggle to know what broke or whether we need to fix it. We don't have any test case.

Given all that, the touch of the file is a neater solution as it is more obvious what it is doing. I'd also want to see some more detailed comments in the code about what it is doing and why.

Maintainability of these kinds of fixes is key.

Cheers,

Richard

#6 lore raw

Hi Richard,

Quoted 54 lines · Richard Purdie
Quoted 41 lines · Andrei Gherzan
Quoted 39 lines · Bernhard Rosenkränzer via lists.openembedded.org

On Thu, Dec 9, 2021 at 07:40 PM, Andrei Gherzan wrote:

Quoted 11 lines · Khem Raj

Quoted 9 lines

On Thu, Dec 9, 2021 at 7:40 AM Andrei Gherzan <[email protected]> wrote:

Quoted 6 lines

From: Andrei Gherzan <[email protected]>

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.

Quoted 7 lines
Quoted 4 lines

is it due to multilib support ? if so we might be ok since we may not be using it
but really it will be good to check it with multilib builds of x86_64/x86

I don't think it is related to multilib but I'll give multilib a try. In my case, the issue was revealed when compiling a kernel plugin config. I can't remember right now which one but I can replicate it for logs.

Hi,
I've had a closer look at the problem, and can confirm the patch doesn't break even in multilib setups.

The problem is that in a non-multilib setup, the config/i386/linux64.h header is not generated, but tm.h tries to include it nevertheless, causing any gcc plugin that #includes tm.h (such as all the gcc plugins in the kernel -- tm.h is included by scripts/gcc-plugins/gcc-common.h) to fail to build.
An alternative fix would be adding
mkdir -p ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386 touch ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/config/i386/lin ux64.h
(creating the file if it isn't there) instead. This would make sure that in cases where config/i386/linux64.h does exist, it doesn't get removed from tm.h (potentially fixing plugins that reference any of the #defines in i386/linux64.h without including the file manually -- but I have yet to see any such plugin).

Quoted 7 lines
Quoted 4 lines

I will try to get a better fix (not adding the include statement to tm.h in the first place rather than having to remove it later in install scripts) upstream, but in the mean time, the patch fixes our builds before the better fix is ready/applied.

Ping on this patch. Any chance we can pull it in as a first iteration of the solution?

I don't like sed in this context as if the code changes, it silently stops working and we struggle to know what broke or whether we need to fix it. We don't have any test case.

Quoted 5 lines

Given all that, the touch of the file is a neater solution as it is more obvious what it is doing. I'd also want to see some more detailed comments in the code about what it is doing and why.

Maintainability of these kinds of fixes is key.

I totally agree so I dug a bit more into this and arrived at a different fix. Pushed it to the ml - https://lists.openembedded.org/g/openembedded-core/message/159978

---
Andrei