Skip to contentSkip to conversation

Add and workaround gcc bug 83143

PATCH Superseded Giulio Benetti 3 participants 13 messages Aug 27, 2021 – Sep 11, 2021

lore
Share & tools
lore
#0 lore raw

cover Add and workaround gcc bug 83143

This patchset add gcc bug 83143 and work it around for package ruby with a more specific CFLAG instead of the classic -O0. The work around has been suggested here[1] and saves lot of memory since here ruby is the package affected by this bug and it's pretty big.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143#c15

Giulio Benetti (2):
toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143 package/ruby: fix build failure due to gcc bug 83143

 package/ruby/ruby.mk | 8 ++++++++
 toolchain/Config.in  | 9 +++++++++
 2 files changed, 17 insertions(+)
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#1 lore raw

PATCH 1/2 toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

ruby package fails to build for the SH4 architecture with optimization enabled with gcc = 9.3.0:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

It's already been reported upstream:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143

---
 toolchain/Config.in | 9 +++++++++
 1 file changed, 9 insertions(+)
toolchain/Config.in +9 -0
index bf2bb3efe4..4419443930 100644
@@ -133,6 +133,15 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_68485
 	bool
 	default y if BR2_microblaze
 
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143
+# Error: invalid operands (*UND* and .text sections) for `-' on sh4.
+# This bug no longer exists in gcc 10.x but reappeared on gcc 11.x and
+# it still not been fixed yet.
+config BR2_TOOLCHAIN_HAS_GCC_BUG_83143
+	bool
+	default y if !BR2_TOOLCHAIN_GCC_AT_LEAST_10
+	depends on BR2_sh4
+
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180. This bug no
 # longer exists in gcc 8.x.
 config BR2_TOOLCHAIN_HAS_GCC_BUG_85180
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#2 lore raw

Re: [Buildroot] [PATCH 1/2] toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

Quoted 17 lines · Giulio Benetti

ruby package fails to build for the SH4 architecture with optimization enabled with gcc = 9.3.0:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

It's already been reported upstream:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143

---
 toolchain/Config.in | 9 +++++++++
 1 file changed, 9 insertions(+)
toolchain/Config.in +0 -0
index bf2bb3efe4..4419443930 100644

toolchain/Config.in config BR2_TOOLCHAIN_HAS_GCC_BUG_68485 · line 142

Quoted 10 lines
toolchain/Config.in +7 -0
@@ -133,6 +133,15 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_68485
 	bool
 	default y if BR2_microblaze
 
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143
+# Error: invalid operands (*UND* and .text sections) for `-' on sh4.
+# This bug no longer exists in gcc 10.x but reappeared on gcc 11.x and
+# it still not been fixed yet.
+config BR2_TOOLCHAIN_HAS_GCC_BUG_83143
+	bool
+	default y if !BR2_TOOLCHAIN_GCC_AT_LEAST_10

The condition doesn't correspond to the comment above...

Regards,
Arnout

toolchain/Config.in config BR2_TOOLCHAIN_HAS_GCC_BUG_68485 · line 147

Quoted 6 lines
toolchain/Config.in +2 -0
+	depends on BR2_sh4
+
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180. This bug no
 # longer exists in gcc 8.x.
 config BR2_TOOLCHAIN_HAS_GCC_BUG_85180

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#3 lore raw

Re: [Buildroot] [PATCH 1/2] toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

Hi Arnout,

Quoted 25 lines

Il giorno 28 ago 2021, alle ore 14:06, Arnout Vandecappelle <[email protected]> ha scritto:



Quoted 21 lines · Giulio Benetti

ruby package fails to build for the SH4 architecture with optimization enabled with gcc = 9.3.0:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

It's already been reported upstream:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143

---
toolchain/Config.in | 9 +++++++++

1 file changed, 9 insertions(+)
toolchain/Config.in +0 -0
index bf2bb3efe4..4419443930 100644
@@ -133,6 +133,15 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_68485
   bool
   default y if BR2_microblaze
 
Quoted 9 lines

toolchain/Config.in config BR2_TOOLCHAIN_HAS_GCC_BUG_68485 · line 142

Quoted 7 lines
toolchain/Config.in +7 -0
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143
+# Error: invalid operands (*UND* and .text sections) for `-' on sh4.
+# This bug no longer exists in gcc 10.x but reappeared on gcc 11.x and
+# it still not been fixed yet.
+config BR2_TOOLCHAIN_HAS_GCC_BUG_83143
+    bool
+    default y if !BR2_TOOLCHAIN_GCC_AT_LEAST_10

The condition doesn't correspond to the comment above...

I’ve tried it and checked .config
I find it emitted on gcc 9 and 11 while on gcc 10 not as described. It’s always difficult to me to understand how that variable works.

Giulio

Quoted 11 lines

Regards,
Arnout

Quoted 6 lines
toolchain/Config.in +2 -0
+    depends on BR2_sh4
+
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180. This bug no
 # longer exists in gcc 8.x.

config BR2_TOOLCHAIN_HAS_GCC_BUG_85180

Quoted 4 lines

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#4 lore raw

Re: [Buildroot] [PATCH 1/2] toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

Quoted 37 lines · Giulio Benetti

Hi Arnout,

Quoted 25 lines

Il giorno 28 ago 2021, alle ore 14:06, Arnout Vandecappelle <[email protected]> ha scritto:



Quoted 21 lines · Giulio Benetti

ruby package fails to build for the SH4 architecture with optimization enabled with gcc = 9.3.0:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

It's already been reported upstream:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143

---
toolchain/Config.in | 9 +++++++++

1 file changed, 9 insertions(+)
toolchain/Config.in +0 -0
index bf2bb3efe4..4419443930 100644
@@ -133,6 +133,15 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_68485
   bool
   default y if BR2_microblaze
 
Quoted 9 lines

toolchain/Config.in config BR2_TOOLCHAIN_HAS_GCC_BUG_68485 · line 142

Quoted 7 lines
toolchain/Config.in +7 -0
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143
+# Error: invalid operands (*UND* and .text sections) for `-' on sh4.
+# This bug no longer exists in gcc 10.x but reappeared on gcc 11.x and
+# it still not been fixed yet.
+config BR2_TOOLCHAIN_HAS_GCC_BUG_83143
+    bool
+    default y if !BR2_TOOLCHAIN_GCC_AT_LEAST_10

The condition doesn't correspond to the comment above...

Quoted 2 lines

I’ve tried it and checked .config
I find it emitted on gcc 9 and 11 while on gcc 10 not as described.

I don't know what you did differently, but that's not what I have...

With this defconfig:

BR2_sh=y
BR2_GCC_VERSION_11_X=y

grep GCC_BUG_83143 .config

produces no output, while with this defconfig:

BR2_sh=y
BR2_GCC_VERSION_9_X=y

it does show it.

BTW, I didn't notice before, but: why is this only for sh4, and not any other
SuperH? I mean, are you sure it's only on sh4? sh4 is the only one tested in the autobuilders, of course, but it's kind of likely that other SuperH suffer from the same bug...

Quoted 1 line

It’s always difficult to me to understand how that variable works.

It's very simple: AT_LEAST_10_X is true for all GCC >= 10.0, so also for GCC
11. If you want exactly one version, it's AT_LEAST_10 && !AT_LEAST_11. In this case, you want the negative of that, so !AT_LEAST_10 || AT_LEAST_11.

Regards,
Arnout

Quoted 19 lines

Giulio

Quoted 15 lines

Regards,
Arnout

Quoted 6 lines
toolchain/Config.in +2 -0
+    depends on BR2_sh4
+
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180. This bug no
 # longer exists in gcc 8.x.

config BR2_TOOLCHAIN_HAS_GCC_BUG_85180

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot

#5 lore raw

Re: [Buildroot] [PATCH 1/2] toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

Hi Arnout,

Quoted 50 lines · Arnout Vandecappelle
Quoted 37 lines · Giulio Benetti

Hi Arnout,

Quoted 25 lines

Il giorno 28 ago 2021, alle ore 14:06, Arnout Vandecappelle <[email protected]> ha scritto:



Quoted 21 lines · Giulio Benetti

ruby package fails to build for the SH4 architecture with optimization enabled with gcc = 9.3.0:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

It's already been reported upstream:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143

---
toolchain/Config.in | 9 +++++++++

1 file changed, 9 insertions(+)
toolchain/Config.in +0 -0
index bf2bb3efe4..4419443930 100644
@@ -133,6 +133,15 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_68485
    bool
    default y if BR2_microblaze
 
Quoted 9 lines

toolchain/Config.in config BR2_TOOLCHAIN_HAS_GCC_BUG_68485 · line 142

Quoted 7 lines
toolchain/Config.in +7 -0
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143
+# Error: invalid operands (*UND* and .text sections) for `-' on sh4.
+# This bug no longer exists in gcc 10.x but reappeared on gcc 11.x and
+# it still not been fixed yet.
+config BR2_TOOLCHAIN_HAS_GCC_BUG_83143
+    bool
+    default y if !BR2_TOOLCHAIN_GCC_AT_LEAST_10

The condition doesn't correspond to the comment above...

Quoted 2 lines

I’ve tried it and checked .config
I find it emitted on gcc 9 and 11 while on gcc 10 not as described.

I don't know what you did differently, but that's not what I have...

With this defconfig:

BR2_sh=y
BR2_GCC_VERSION_11_X=y

Quoted 8 lines

grep GCC_BUG_83143 .config

produces no output, while with this defconfig:

BR2_sh=y
BR2_GCC_VERSION_9_X=y

it does show it.

My bad, I've only issued 'make menuconfig' and saved after adding the bug and some mess came out. So now doing make a _defconfig from scratch gives me your same result.

Quoted 5 lines

BTW, I didn't notice before, but: why is this only for sh4, and not any other
SuperH? I mean, are you sure it's only on sh4? sh4 is the only one tested in the autobuilders, of course, but it's kind of likely that other SuperH suffer from the same bug...

This makes a lot of sense, indeed I'm trying to build for sh2a with Big Endian for example and I've found a bug while trying to build gcc9/10-final for it:
xgcc: error: SH2a does not support little-endian
I need to find the reason, since:
BR2_ENDIAN="BIG"
probably a bug in gcc? Need to find.

I try with another sh arch then I try to build ruby and check if the error is the same, that is very likely to happen and then I could transform BR2_sh4 to BR2_sh. And same goes for other sh4 bugs already present. But need to re-test them.

Quoted 6 lines
Quoted 2 lines

It’s always difficult to me to understand how that variable works.

It's very simple: AT_LEAST_10_X is true for all GCC >= 10.0, so also for GCC
11. If you want exactly one version, it's AT_LEAST_10 && !AT_LEAST_11. In this case, you want the negative of that, so !AT_LEAST_10 || AT_LEAST_11.

Ok, thank you. Indeed at the moment it only emits that bug with gcc 9 only. Instead with !AT_LEAST_10 || AT_LEAST_11 it works as described.

Thank you for explaining!

Best regards

Signature · 6 lines
Giulio Benetti
Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#6 lore raw

Re: [Buildroot] [PATCH 1/2] toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

Hello Giulio,

Quoted 4 lines · On Sun, 29 Aug 2021 23:49:57 +0200 Giulio Benetti…

I try with another sh arch then I try to build ruby and check if the error is the same, that is very likely to happen and then I could transform BR2_sh4 to BR2_sh. And same goes for other sh4 bugs already present. But need to re-test them.

To be honest, I wouldn't bother testing all possible SuperH architecture variants. If one issue affects SH4, just assume it affects all SuperH variants, and be done with it. SuperH is basically dead, and the only products using SuperH are under maintenance mode so I don't think we should put too much effort in determining specifically which variant of SuperH is affected by each specific gcc bug.

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#7 lore raw

Re: [Buildroot] [PATCH 1/2] toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

Hi Thomas, Arnout, All,

Quoted 10 lines · Thomas Petazzoni

Hello Giulio,

Quoted 4 lines · On Sun, 29 Aug 2021 23:49:57 +0200 Giulio Benetti…

I try with another sh arch then I try to build ruby and check if the error is the same, that is very likely to happen and then I could transform BR2_sh4 to BR2_sh. And same goes for other sh4 bugs already present. But need to re-test them.

Quoted 6 lines

To be honest, I wouldn't bother testing all possible SuperH architecture variants. If one issue affects SH4, just assume it affects all SuperH variants, and be done with it. SuperH is basically dead, and the only products using SuperH are under maintenance mode so I don't think we should put too much effort in determining specifically which variant of SuperH is affected by each specific gcc bug.

Fine, I've just sent the v2 series with BR2_sh.

Since the already committed bugs are not listed in order(101952 is before 101915/101916), I would send a patch for re-ordering them and another to substitute BR_sh4 with BR_sh(bug 101952 and 101916 has BR_sh4), so we have a standard form for SuperH, is it fine for you?

Best regards

Signature · 6 lines
Giulio Benetti
Benetti Engineering sas
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#8 lore raw

v2 cover Add and workaround gcc bug 83143

In reply to Thomas Petazzoni

This patchset add gcc bug 83143 and work it around for package ruby with a more specific CFLAG instead of the classic -O0. The work around has been suggested here[1] and saves lot of memory since here ruby is the package affected by this bug and it's pretty big.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143#c15

V1->V2:
* fixed bug gcc version condition
* introduce this bug for BR2_sh and not only for BR2_sh4

Giulio Benetti (2):
toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143 package/ruby: fix build failure due to gcc bug 83143

 package/ruby/ruby.mk | 8 ++++++++
 toolchain/Config.in  | 9 +++++++++
 2 files changed, 17 insertions(+)
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#9 lore raw

PATCH v2 1/2 toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143

ruby package fails to build for the SH4 architecture with optimization enabled with gcc = 9.3.0:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

It's already been reported upstream:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143

Anyway let's assume all SuperH(BR2_sh) have this bug according to:
http://lists.busybox.net/pipermail/buildroot/2021-August/621906.html

---
V1->V2:
* fixed bug gcc version condition
* introduce this bug for BR2_sh and not only for BR2_sh4

---
 toolchain/Config.in | 9 +++++++++
 1 file changed, 9 insertions(+)
toolchain/Config.in +9 -0
index bf2bb3efe4..d6381f64a0 100644
@@ -133,6 +133,15 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_68485
 	bool
 	default y if BR2_microblaze
 
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143
+# Error: invalid operands (*UND* and .text sections) for `-' on sh4.
+# This bug no longer exists in gcc 10.x but reappeared on gcc 11.x and
+# it still not been fixed yet.
+config BR2_TOOLCHAIN_HAS_GCC_BUG_83143
+	bool
+	default y if BR2_sh
+	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_10 || BR2_TOOLCHAIN_GCC_AT_LEAST_11
+
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180. This bug no
 # longer exists in gcc 8.x.
 config BR2_TOOLCHAIN_HAS_GCC_BUG_85180
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#10 lore raw

PATCH v2 2/2 package/ruby: fix build failure due to gcc bug 83143

In reply to Giulio Benetti

The ruby package exhibits gcc bug 83143 when built for the SH4 architecture with optimization enabled, which causes a build failure.

Differentely from other packages in Buildroot where we work around this gcc bug by setting optimization to -O0 we can use -freorder-blocks-algorithm=simple as suggested here [1] if BR2_TOOLCHAIN_HAS_GCC_BUG_83143=y.

Fixes:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143#c15

---
 package/ruby/ruby.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/ruby/ruby.mk +8 -0
index 2434ce946b..b02744f0e5 100644
@@ -77,6 +77,14 @@ else
 RUBY_CONF_OPTS += --without-gmp
 endif
 
+RUBY_CFLAGS = $(TARGET_CFLAGS)
+
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_83143),y)
+RUBY_CFLAGS += -freorder-blocks-algorithm=simple
+endif
+
+RUBY_CONF_OPTS += CFLAGS="$(RUBY_CFLAGS)"
+
 # Remove rubygems and friends, as they need extensions that aren't
 # built and a target compiler.
 RUBY_EXTENSIONS_REMOVE = rake* rdoc* rubygems*
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#11 lore raw
In reply to Giulio Benetti
Quoted 7 lines · Giulio Benetti

This patchset add gcc bug 83143 and work it around for package ruby with a more specific CFLAG instead of the classic -O0. The work around has been suggested here[1] and saves lot of memory since here ruby is the package affected by this bug and it's pretty big.

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143#c15

Quoted 7 lines

V1->V2:
* fixed bug gcc version condition
* introduce this bug for BR2_sh and not only for BR2_sh4

Giulio Benetti (2):
toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_83143 package/ruby: fix build failure due to gcc bug 83143

Both applied to master, thanks.

Regards,
Arnout

Quoted 5 lines
 package/ruby/ruby.mk | 8 ++++++++
 toolchain/Config.in  | 9 +++++++++
 2 files changed, 17 insertions(+)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#12 lore raw

PATCH 2/2 package/ruby: fix build failure due to gcc bug 83143

In reply to Giulio Benetti

The ruby package exhibits gcc bug 83143 when built for the SH4 architecture with optimization enabled, which causes a build failure.

Differentely from other packages in Buildroot where we work around this gcc bug by setting optimization to -O0 we can use -freorder-blocks-algorithm=simple as suggested here [1] if BR2_TOOLCHAIN_HAS_GCC_BUG_83143=y.

Fixes:
http://autobuild.buildroot.net/results/f57/f5742e7fb6e8142bcdb53b7f4f5e9c1bea3558cd/

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83143#c15

---
 package/ruby/ruby.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/ruby/ruby.mk +8 -0
index 2434ce946b..b02744f0e5 100644
@@ -77,6 +77,14 @@ else
 RUBY_CONF_OPTS += --without-gmp
 endif
 
+RUBY_CFLAGS = $(TARGET_CFLAGS)
+
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_83143),y)
+RUBY_CFLAGS += -freorder-blocks-algorithm=simple
+endif
+
+RUBY_CONF_OPTS += CFLAGS="$(RUBY_CFLAGS)"
+
 # Remove rubygems and friends, as they need extensions that aren't
 # built and a target compiler.
 RUBY_EXTENSIONS_REMOVE = rake* rdoc* rubygems*
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot