Skip to contentSkip to conversation

linux: introduce LINUX_KCFLAGS to add additional options to the C compiler

PATCH New Romain Naour 3 participants 7 messages Sep 26, 2020 – Oct 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 linux: introduce LINUX_KCFLAGS to add additional options to the C compiler

Since 9a50447b5d4b2ab0162e3235395ab9a4c8a647d5 KCFLAGS is set to disable a compiler warning but doesn't allow to provide more flags.

This refactoring introduce LINUX_KCFLAGS to provide more options to the C compiler.

---
 linux/linux.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
linux/linux.mk +3 -2
index e07e014d1e..b9b223e3f3 100644
@@ -71,7 +71,8 @@ LINUX_PATCH = $(filter ftp://% http://% https://%,$(LINUX_PATCHES))
 # host-pkgconf will look for host libraries and not target ones.
 LINUX_MAKE_ENV = \
 	$(HOST_MAKE_ENV) \
-	BR_BINARIES_DIR=$(BINARIES_DIR)
+	BR_BINARIES_DIR=$(BINARIES_DIR) \
+	KCFLAGS="$(LINUX_KCFLAGS)"
 
 LINUX_INSTALL_IMAGES = YES
 LINUX_DEPENDENCIES = host-kmod \
@@ -154,7 +155,7 @@ endif
 # sanitize the arguments passed from user space in registers.
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82435
 ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y)
-LINUX_MAKE_ENV += KCFLAGS=-Wno-attribute-alias
+LINUX_KCFLAGS += -Wno-attribute-alias
 endif
 
 ifeq ($(BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT),y)
Signature · 1 line
2.25.4
#1 lore raw

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

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

Cc Thomas Petazzoni <[email protected]>
---
 linux/linux.mk | 6 ++++++
 1 file changed, 6 insertions(+)
linux/linux.mk +6 -0
index b9b223e3f3..9ee9054bed 100644
@@ -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
Signature · 1 line
2.25.4
#2 lore raw

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

linux/linux.mk ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y) · line 165

Quoted 5 lines · On Sat, 26 Sep 2020 21:13:30 +0200 Romain Naour <[email protected]> wrote:
linux/linux.mk +5 -0
+# 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

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

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

Hi Thomas,

Le 30/09/2020 ? 22:59, Thomas Petazzoni a ?crit?:

Quoted 14 lines

linux/linux.mk ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y) · line 165

Quoted 5 lines · On Sat, 26 Sep 2020 21:13:30 +0200 Romain Naour <[email protected]> wrote:
linux/linux.mk +5 -0
+# 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.

Quoted 2 lines

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

Quoted 3 lines

Thomas

#4 lore raw

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

Quoted 5 lines · On Wed, 30 Sep 2020 23:04:22 +0200 Romain Naour <[email protected]> wrote:
Quoted 2 lines

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

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#5 lore raw

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

Quoted 6 lines · Thomas Petazzoni
Quoted 3 lines · On Wed, 30 Sep 2020 23:04:22 +0200 Romain Naour <[email protected]> wrote:
Quoted 2 lines

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

Quoted 6 lines
Quoted 2 lines

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

#6 lore raw

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

Quoted 2 lines · On Tue, 6 Oct 2020 20:46:04 +0200 Arnout Vandecappelle <[email protected]> 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

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com