diff mbox series

[2/2] linux: Disable -ftree-loop-distribute-patterns when building for microblaze with gcc >= 10

Message ID 20200926191330.96074-2-romain.naour@gmail.com
State Superseded
Headers show
Series [1/2] linux: introduce LINUX_KCFLAGS to add additional options to the C compiler | expand

Commit Message

Romain Naour Sept. 26, 2020, 7:13 p.m. UTC
GCC 10 now enable by default -ftree-loop-distribute-patterns at -O2 or -Os
optimization level instead of -O3, see commit [1].

Due to this change, the microblaze kernel doesn't boot (as reported by
toolchain-builder project).

The gcc docs between version 9 and 10 has been updated accordingly [2] [3]
but there no word about this change in the gcc 10 changelog [4].

Fixes microblazebe:
https://gitlab.com/bootlin/toolchains-builder/-/jobs/729359536 (glibc)
https://gitlab.com/bootlin/toolchains-builder/-/jobs/729359538 (musl)
https://gitlab.com/bootlin/toolchains-builder/-/jobs/729359540 (uClubc-ng)

Fixes microblazeel:
https://gitlab.com/bootlin/toolchains-builder/-/jobs/729359542 (glibc)
https://gitlab.com/bootlin/toolchains-builder/-/jobs/729359544 (musl)
https://gitlab.com/bootlin/toolchains-builder/-/jobs/729359546 (uClibc-ng)

This has been reported upsteam [5].

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5879ab5fafedc8f6f9bfe95a4cf8501b0df90edd
[2] https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Optimize-Options.html#Optimize-Options
[3] https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Optimize-Options.html#Optimize-Options
[4] https://gcc.gnu.org/gcc-10/changes.html
[5] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97208

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
 linux/linux.mk | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Thomas Petazzoni Sept. 30, 2020, 8:59 p.m. UTC | #1
On Sat, 26 Sep 2020 21:13:30 +0200
Romain Naour <romain.naour@gmail.com> wrote:

> +# https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5879ab5fafedc8f6f9bfe95a4cf8501b0df90edd
> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97208
> +ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_10)$(BR2_microblaze),yy)
> +LINUX_KCFLAGS += -fno-tree-loop-distribute-patterns
> +endif

I am wondering if this is the right approach. If the
-ftree-loop-distribute-patterns breaks stuff for the kernel, presumably
it could also break stuff for user-space software. So I guess we should
instead disable it entirely in TARGET_CFLAGS.

The gotcha being of course that we don't pass TARGET_CFLAGS to the
Linux package...

Thomas
Romain Naour Sept. 30, 2020, 9:04 p.m. UTC | #2
Hi Thomas,

Le 30/09/2020 à 22:59, Thomas Petazzoni a écrit :
> On Sat, 26 Sep 2020 21:13:30 +0200
> Romain Naour <romain.naour@gmail.com> wrote:
> 
>> +# https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5879ab5fafedc8f6f9bfe95a4cf8501b0df90edd
>> +# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97208
>> +ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_10)$(BR2_microblaze),yy)
>> +LINUX_KCFLAGS += -fno-tree-loop-distribute-patterns
>> +endif
> 
> I am wondering if this is the right approach. If the
> -ftree-loop-distribute-patterns breaks stuff for the kernel, presumably
> it could also break stuff for user-space software. So I guess we should
> instead disable it entirely in TARGET_CFLAGS.
> 
> The gotcha being of course that we don't pass TARGET_CFLAGS to the
> Linux package...

Indeed, I have no ideas if the userspace built with this toolchain is really
working... except for busybox which was used by qemu_microblazeel_mmu_defconfig

Best regards,
Romain

> 
> Thomas
>
Thomas Petazzoni Oct. 1, 2020, 8:06 a.m. UTC | #3
On Wed, 30 Sep 2020 23:04:22 +0200
Romain Naour <romain.naour@gmail.com> wrote:

> > The gotcha being of course that we don't pass TARGET_CFLAGS to the
> > Linux package...  
> 
> Indeed, I have no ideas if the userspace built with this toolchain is really
> working... except for busybox which was used by qemu_microblazeel_mmu_defconfig

I think we should be passing this flag in TARGET_CFLAGS. What bothers
me is that passing it in TARGET_CFLAGS would not resolve the Linux
build issue, as Linux isn't built with TARGET_CFLAGS...

Thomas
Arnout Vandecappelle Oct. 6, 2020, 6:46 p.m. UTC | #4
On 01/10/2020 10:06, Thomas Petazzoni wrote:
> On Wed, 30 Sep 2020 23:04:22 +0200
> Romain Naour <romain.naour@gmail.com> wrote:
> 
>>> The gotcha being of course that we don't pass TARGET_CFLAGS to the
>>> Linux package...  
>>
>> Indeed, I have no ideas if the userspace built with this toolchain is really
>> working... except for busybox which was used by qemu_microblazeel_mmu_defconfig
> 
> I think we should be passing this flag in TARGET_CFLAGS. What bothers
> me is that passing it in TARGET_CFLAGS would not resolve the Linux
> build issue, as Linux isn't built with TARGET_CFLAGS...

 If it's something needed to "fix the compiler", then it should be in the
toolchain wrapper (i.e. TOOLCHAIN_WRAPPER_OPTS).

 Regards,
 Arnout
Thomas Petazzoni Oct. 6, 2020, 6:50 p.m. UTC | #5
On Tue, 6 Oct 2020 20:46:04 +0200
Arnout Vandecappelle <arnout@mind.be> wrote:

>  If it's something needed to "fix the compiler", then it should be in the
> toolchain wrapper (i.e. TOOLCHAIN_WRAPPER_OPTS).

Right, good idea!

Romain, do you think you can revisit this using TOOLCHAIN_WRAPPER_OPTS ?

Thanks,

Thomas
diff mbox series

Patch

diff --git a/linux/linux.mk b/linux/linux.mk
index b9b223e3f3..9ee9054bed 100644
--- a/linux/linux.mk
+++ b/linux/linux.mk
@@ -158,6 +158,12 @@  ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y)
 LINUX_KCFLAGS += -Wno-attribute-alias
 endif
 
+# https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=5879ab5fafedc8f6f9bfe95a4cf8501b0df90edd
+# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97208
+ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_10)$(BR2_microblaze),yy)
+LINUX_KCFLAGS += -fno-tree-loop-distribute-patterns
+endif
+
 ifeq ($(BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT),y)
 LINUX_MAKE_ENV += DTC_FLAGS=-@
 endif