Skip to contentSkip to conversation

Introduce and work-around Gcc Bug 101737

PATCH In review Giulio Benetti 3 participants 8 messages Aug 3, 2021 – Aug 8, 2021

lore
Share & tools
lore
#0 lore raw

cover Introduce and work-around Gcc Bug 101737

This patchset introduce and work-around Gcc Bug 101737 opened by Thomas Petazzoni:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101737

Bug shows up while building package pixman and it's worked around disabling optimization by passing -O0 to CFLAGS.

Giulio Benetti (2):
toolchain: introduce BR2_TOOLCHAIN_HAS_GCC_BUG_101737 package/pixman: fix build failure due to gcc bug 101737

 package/pixman/pixman.mk | 10 +++++++++-
 toolchain/Config.in      |  7 +++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
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_101737

pixman package fails to build for the SH4 architecture with optimization enabled with gcc up to 11.1.0:
http://autobuild.buildroot.net/results/b20/b20869bbb48edb1f0a847ea9e2e1a0462d6350be/

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

---
 toolchain/Config.in | 7 +++++++
 1 file changed, 7 insertions(+)
toolchain/Config.in +7 -0
index 3598307b20..3888eeafe2 100644
@@ -170,6 +170,13 @@ config BR2_TOOLCHAIN_HAS_GCC_BUG_99140
 	bool
 	default y if BR2_nios2 && !BR2_TOOLCHAIN_GCC_AT_LEAST_9
 
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101737
+# ICE: SH4 -Os causes internal compiler error. This bug
+# still exists in gcc = 11.1.0
+config BR2_TOOLCHAIN_HAS_GCC_BUG_101737
+	bool
+	default y if BR2_sh4
+
 config BR2_TOOLCHAIN_HAS_NATIVE_RPC
 	bool
 
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_101737

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Giulio" == Giulio Benetti <[email protected]> writes:

pixman package fails to build for the SH4 architecture with optimization enabled with gcc up to 11.1.0:
http://autobuild.buildroot.net/results/b20/b20869bbb48edb1f0a847ea9e2e1a0462d6350be/

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

Committed to 2021.02.x and 2021.05.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot
#3 lore raw

PATCH 2/2 package/pixman: fix build failure due to gcc bug 101737

In reply to Giulio Benetti

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

As done for other packages in Buildroot work around this gcc bug by setting optimization to -O0 if BR2_TOOLCHAIN_HAS_GCC_BUG_101737=y. Also let's add PIXMAN_CFLAGS and pass the Codesourcery work around CFLAGS to it for consistency like we do for the rest of the packages.

Fixes:
http://autobuild.buildroot.net/results/b20/b20869bbb48edb1f0a847ea9e2e1a0462d6350be/

---
 package/pixman/pixman.mk | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
package/pixman/pixman.mk +9 -1
index d99005ecb7..6fab539593 100644
@@ -44,12 +44,20 @@ ifneq ($(BR2_iwmmxt),y)
 PIXMAN_CONF_OPTS += --disable-arm-iwmmxt
 endif
 
+PIXMAN_CFLAGS = $(TARGET_CFLAGS)
+
 # toolchain gets confused about TLS access through GOT (PIC), so disable TLS
 # movhi	r4, %got_hiadj(%tls_ldo(fast_path_cache))
 # {standard input}:172: Error: bad expression
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII),y)
-PIXMAN_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -DPIXMAN_NO_TLS"
+PIXMAN_CFLAGS += -DPIXMAN_NO_TLS
+endif
+
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_101737),y)
+PIXMAN_CFLAGS += -O0
 endif
 
+PIXMAN_CONF_OPTS += CFLAGS="$(PIXMAN_CFLAGS)"
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))
Signature · 6 lines
2.25.1

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

Re: [Buildroot] [PATCH 2/2] package/pixman: fix build failure due to gcc bug 101737

Hi Giulio,

Quoted 25 lines · Giulio Benetti

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

As done for other packages in Buildroot work around this gcc bug by setting optimization to -O0 if BR2_TOOLCHAIN_HAS_GCC_BUG_101737=y. Also let's add PIXMAN_CFLAGS and pass the Codesourcery work around CFLAGS to it for consistency like we do for the rest of the packages.

Fixes:
http://autobuild.buildroot.net/results/b20/b20869bbb48edb1f0a847ea9e2e1a0462d6350be/

---
 package/pixman/pixman.mk | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
package/pixman/pixman.mk +1 -0
index d99005ecb7..6fab539593 100644
@@ -44,12 +44,20 @@ ifneq ($(BR2_iwmmxt),y)
 PIXMAN_CONF_OPTS += --disable-arm-iwmmxt
 endif
 
+PIXMAN_CFLAGS = $(TARGET_CFLAGS)

package/pixman/pixman.mk ifneq ($(BR2_iwmmxt),y) · line 56

Quoted 10 lines
package/pixman/pixman.mk +5 -1
+
 # toolchain gets confused about TLS access through GOT (PIC), so disable TLS
 # movhi	r4, %got_hiadj(%tls_ldo(fast_path_cache))
 # {standard input}:172: Error: bad expression
 ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII),y)
-PIXMAN_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -DPIXMAN_NO_TLS"
+PIXMAN_CFLAGS += -DPIXMAN_NO_TLS
+endif
+
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_101737),y)

I believe Thomas's experiments showed that it only occurs under -Os. So I think
we should do this conditionally under BR2_OPTIMIZE_S, and use -O2 rather than -O0.

Regards,
Arnout

package/pixman/pixman.mk ifneq ($(BR2_iwmmxt),y) · line 63

Quoted 8 lines
package/pixman/pixman.mk +3 -0
+PIXMAN_CFLAGS += -O0
 endif
 
+PIXMAN_CONF_OPTS += CFLAGS="$(PIXMAN_CFLAGS)"
+
 $(eval $(autotools-package))
 $(eval $(host-autotools-package))

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

#5 lore raw

Re: [Buildroot] [PATCH 2/2] package/pixman: fix build failure due to gcc bug 101737

Hi Arnout, Thomas,

Quoted 29 lines

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

 Hi Giulio,

Quoted 25 lines · Giulio Benetti

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

As done for other packages in Buildroot work around this gcc bug by setting optimization to -O0 if BR2_TOOLCHAIN_HAS_GCC_BUG_101737=y. Also let's add PIXMAN_CFLAGS and pass the Codesourcery work around CFLAGS to it for consistency like we do for the rest of the packages.

Fixes:
http://autobuild.buildroot.net/results/b20/b20869bbb48edb1f0a847ea9e2e1a0462d6350be/

---
package/pixman/pixman.mk | 10 +++++++++-

1 file changed, 9 insertions(+), 1 deletion(-)
package/pixman/pixman.mk +0 -0
index d99005ecb7..6fab539593 100644
@@ -44,12 +44,20 @@ ifneq ($(BR2_iwmmxt),y)

PIXMAN_CONF_OPTS += --disable-arm-iwmmxt
endif

Quoted 14 lines

package/pixman/pixman.mk ifneq ($(BR2_iwmmxt),y) · line 56

Quoted 11 lines
package/pixman/pixman.mk +2 -0
+PIXMAN_CFLAGS = $(TARGET_CFLAGS)
+
# toolchain gets confused about TLS access through GOT (PIC), so disable TLS
# movhi    r4, %got_hiadj(%tls_ldo(fast_path_cache))
# {standard input}:172: Error: bad expression
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII),y)
package/pixman/pixman.mk +4 -1
-PIXMAN_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -DPIXMAN_NO_TLS"
+PIXMAN_CFLAGS += -DPIXMAN_NO_TLS
+endif
+
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_101737),y)

I believe Thomas's experiments showed that it only occurs under -Os. So I think we should do this conditionally under BR2_OPTIMIZE_S, and use -O2 rather than -O0.

Yes, you’re right, but at a certain point, if I remember correctly, we’ve decided to uniform this kind work-arounds using -O0,
indeed some other gcc bug could be solved differently but we kept -O0 way to have a “standard” solution.

What do you think about it?

Otherwise I do as you’ve described above, no problem.

Best regards
Giulio Benetti

Quoted 5 lines

Regards,
Arnout

Quoted 8 lines
Quoted 8 lines

+PIXMAN_CFLAGS += -O0
endif

package/pixman/pixman.mk +2 -0
+PIXMAN_CONF_OPTS += CFLAGS="$(PIXMAN_CFLAGS)"
+

$(eval $(autotools-package))
$(eval $(host-autotools-package))

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

#6 lore raw

Re: [Buildroot] [PATCH 2/2] package/pixman: fix build failure due to gcc bug 101737

Quoted 46 lines · Giulio Benetti

Hi Arnout, Thomas,

Quoted 29 lines

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

 Hi Giulio,

Quoted 25 lines · Giulio Benetti

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

As done for other packages in Buildroot work around this gcc bug by setting optimization to -O0 if BR2_TOOLCHAIN_HAS_GCC_BUG_101737=y. Also let's add PIXMAN_CFLAGS and pass the Codesourcery work around CFLAGS to it for consistency like we do for the rest of the packages.

Fixes:
http://autobuild.buildroot.net/results/b20/b20869bbb48edb1f0a847ea9e2e1a0462d6350be/

---
package/pixman/pixman.mk | 10 +++++++++-

1 file changed, 9 insertions(+), 1 deletion(-)
package/pixman/pixman.mk +0 -0
index d99005ecb7..6fab539593 100644
@@ -44,12 +44,20 @@ ifneq ($(BR2_iwmmxt),y)

PIXMAN_CONF_OPTS += --disable-arm-iwmmxt
endif

Quoted 14 lines

package/pixman/pixman.mk ifneq ($(BR2_iwmmxt),y) · line 56

Quoted 11 lines
package/pixman/pixman.mk +2 -0
+PIXMAN_CFLAGS = $(TARGET_CFLAGS)
+
# toolchain gets confused about TLS access through GOT (PIC), so disable TLS
# movhi    r4, %got_hiadj(%tls_ldo(fast_path_cache))
# {standard input}:172: Error: bad expression
ifeq ($(BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII),y)
package/pixman/pixman.mk +4 -1
-PIXMAN_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -DPIXMAN_NO_TLS"
+PIXMAN_CFLAGS += -DPIXMAN_NO_TLS
+endif
+
+ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_101737),y)

I believe Thomas's experiments showed that it only occurs under -Os. So I think we should do this conditionally under BR2_OPTIMIZE_S, and use -O2 rather than -O0.

Quoted 2 lines

Yes, you’re right, but at a certain point, if I remember correctly, we’ve decided to uniform this kind work-arounds using -O0,
indeed some other gcc bug could be solved differently but we kept -O0 way to have a “standard” solution.

Fair enough. Both applied to master, thanks.

Regards,
Arnout

Quoted 13 lines

What do you think about it?

Otherwise I do as you’ve described above, no problem.

Best regards
Giulio Benetti

Quoted 5 lines

Regards,
Arnout

Quoted 9 lines
Quoted 8 lines
Quoted 8 lines

+PIXMAN_CFLAGS += -O0
endif

package/pixman/pixman.mk +2 -0
+PIXMAN_CONF_OPTS += CFLAGS="$(PIXMAN_CFLAGS)"
+

$(eval $(autotools-package))
$(eval $(host-autotools-package))

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

#7 lore raw

Re: [Buildroot] [PATCH 2/2] package/pixman: fix build failure due to gcc bug 101737

In reply to Giulio Benetti
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Giulio" == Giulio Benetti <[email protected]> writes:

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

As done for other packages in Buildroot work around this gcc bug by setting optimization to -O0 if BR2_TOOLCHAIN_HAS_GCC_BUG_101737=y. Also let's add PIXMAN_CFLAGS and pass the Codesourcery work around CFLAGS to it for consistency like we do for the rest of the packages.

Quoted 4 lines

Fixes:
http://autobuild.buildroot.net/results/b20/b20869bbb48edb1f0a847ea9e2e1a0462d6350be/

Committed to 2021.02.x and 2021.05.x, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/buildroot