Skip to contentSkip to conversation

toolchain/toolchain-buildroot: error if no libc available

PATCH In review Romain Naour 2 participants 3 messages May 15, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 toolchain/toolchain-buildroot: error if no libc available

Each libc available in Buildroot to build an internal toolchain have dependencies (architecture, static build only, mmu only etc...).

For examples, uClibc-ng is the only toolchain that support static only builds. But since uClibc-ng doesn't support all architecture available in Buildroot (nios2, riscv), we must prevent selecting static only configuration (BR2_STATIC_LIBS) on such architectures.

For such broken configuration, we can start building a toolchain by building host-binutils and host-gcc-final without building host-gcc-initial, linux-headers and uclibc package.

The build fail during host-gcc-final build with the following error:

In file included from ../../../libgcc/libgcc2.c:27:
../../../libgcc/../gcc/tsystem.h:87:10: fatal error: stdio.h: No such file or directory
87 | #include <stdio.h>

      |          ^~~~~~~~~

compilation terminated.

We can't add an uClibc-ng dependency on BR2_STATIC_LIBS option since it's also used for external toolchain backend.
Instead add a check if BR2_TOOLCHAIN_BUILDROOT_LIBC is not empty

While at it, add a Kconfig comment for the user.

Fixes:
http://autobuild.buildroot.net/results/42965d286285d5d6cfbb39f6195c87fa05dd3283/

Cc Giulio Benetti <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
Cc Thomas Petazzoni <[email protected]>
---
 toolchain/toolchain-buildroot/Config.in              | 3 +++
 toolchain/toolchain-buildroot/toolchain-buildroot.mk | 4 ++++
 2 files changed, 7 insertions(+)
toolchain/toolchain-buildroot/Config.in +3 -0
index 8d9cf4cc68..a97b17acb8 100644
@@ -107,6 +107,9 @@ config BR2_TOOLCHAIN_BUILDROOT_LIBC
 	default "glibc"  if BR2_TOOLCHAIN_BUILDROOT_GLIBC
 	default "musl"	 if BR2_TOOLCHAIN_BUILDROOT_MUSL
 
+comment "No libc available for this target! Please check your configuration"
+	depends on !BR2_TOOLCHAIN_BUILDROOT_LIBC
+
 source "package/linux-headers/Config.in.host"
 source "package/linux-headers/Config.in"
 source "package/musl/Config.in"
toolchain/toolchain-buildroot/toolchain-buildroot.mk +4 -0
index b30cc332d2..7688d44615 100644
@@ -6,6 +6,10 @@
 
 BR_LIBC = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_LIBC))
 
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT):$(BR_LIBC),y:)
+$(error "No libc available for this target! Please check your configuration.")
+endif
+
 # Triggering the build of the host-gcc-final will automatically do the
 # build of binutils, uClibc, kernel headers and all the intermediate
 # gcc steps.
Signature · 6 lines
2.35.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 18 lines · Romain Naour

Each libc available in Buildroot to build an internal toolchain have dependencies (architecture, static build only, mmu only etc...).

For examples, uClibc-ng is the only toolchain that support static only builds. But since uClibc-ng doesn't support all architecture available in Buildroot (nios2, riscv), we must prevent selecting static only configuration (BR2_STATIC_LIBS) on such architectures.

For such broken configuration, we can start building a toolchain by building host-binutils and host-gcc-final without building host-gcc-initial, linux-headers and uclibc package.

The build fail during host-gcc-final build with the following error:

In file included from ../../../libgcc/libgcc2.c:27:
../../../libgcc/../gcc/tsystem.h:87:10: fatal error: stdio.h: No such file or directory
87 | #include <stdio.h>

Quoted 6 lines
      |          ^~~~~~~~~

compilation terminated.

We can't add an uClibc-ng dependency on BR2_STATIC_LIBS option since it's also used for external toolchain backend.
Instead add a check if BR2_TOOLCHAIN_BUILDROOT_LIBC is not empty

I think something like this is probably better:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 47 lines

While at it, add a Kconfig comment for the user.

Fixes:
http://autobuild.buildroot.net/results/42965d286285d5d6cfbb39f6195c87fa05dd3283/

Cc Giulio Benetti <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
Cc Thomas Petazzoni <[email protected]>
---
 toolchain/toolchain-buildroot/Config.in              | 3 +++
 toolchain/toolchain-buildroot/toolchain-buildroot.mk | 4 ++++
 2 files changed, 7 insertions(+)
toolchain/toolchain-buildroot/Config.in +3 -0
index 8d9cf4cc68..a97b17acb8 100644
@@ -107,6 +107,9 @@ config BR2_TOOLCHAIN_BUILDROOT_LIBC
        default "glibc"  if BR2_TOOLCHAIN_BUILDROOT_GLIBC
        default "musl"   if BR2_TOOLCHAIN_BUILDROOT_MUSL
 
+comment "No libc available for this target! Please check your configuration"
+       depends on !BR2_TOOLCHAIN_BUILDROOT_LIBC
+
 source "package/linux-headers/Config.in.host"
 source "package/linux-headers/Config.in"
 source "package/musl/Config.in"
toolchain/toolchain-buildroot/toolchain-buildroot.mk +4 -1
index b30cc332d2..7688d44615 100644
@@ -6,6 +6,10 @@
 
 BR_LIBC = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_LIBC))
 
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT):$(BR_LIBC),y:)
+$(error "No libc available for this target! Please check your configuration.")
+endif
+
 # Triggering the build of the host-gcc-final will automatically do the
 # build of binutils, uClibc, kernel headers and all the intermediate
 # gcc steps.
--

2.35.3

Quoted 4 lines

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

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

#2 lore raw

Le 15/05/2022 à 21:32, James Hilliard a écrit :

Quoted 22 lines · Romain Naour
Quoted 21 lines

Each libc available in Buildroot to build an internal toolchain have dependencies (architecture, static build only, mmu only etc...).

For examples, uClibc-ng is the only toolchain that support static only builds. But since uClibc-ng doesn't support all architecture available in Buildroot (nios2, riscv), we must prevent selecting static only configuration (BR2_STATIC_LIBS) on such architectures.

For such broken configuration, we can start building a toolchain by building host-binutils and host-gcc-final without building host-gcc-initial, linux-headers and uclibc package.

The build fail during host-gcc-final build with the following error:

In file included from ../../../libgcc/libgcc2.c:27:
../../../libgcc/../gcc/tsystem.h:87:10: fatal error: stdio.h: No such file or directory
87 | #include <stdio.h>

      |          ^~~~~~~~~

compilation terminated.

Quoted 6 lines
Quoted 3 lines

We can't add an uClibc-ng dependency on BR2_STATIC_LIBS option since it's also used for external toolchain backend.
Instead add a check if BR2_TOOLCHAIN_BUILDROOT_LIBC is not empty

I think something like this is probably better:
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Thanks,
I marked this patch rejected then.

Best regards,
Romain

Quoted 48 lines
Quoted 48 lines

While at it, add a Kconfig comment for the user.

Fixes:
http://autobuild.buildroot.net/results/42965d286285d5d6cfbb39f6195c87fa05dd3283/

Cc Giulio Benetti <[email protected]>
Cc Thomas De Schampheleire <[email protected]>
Cc Thomas Petazzoni <[email protected]>
---
 toolchain/toolchain-buildroot/Config.in              | 3 +++
 toolchain/toolchain-buildroot/toolchain-buildroot.mk | 4 ++++
 2 files changed, 7 insertions(+)
toolchain/toolchain-buildroot/Config.in +3 -0
index 8d9cf4cc68..a97b17acb8 100644
@@ -107,6 +107,9 @@ config BR2_TOOLCHAIN_BUILDROOT_LIBC
        default "glibc"  if BR2_TOOLCHAIN_BUILDROOT_GLIBC
        default "musl"   if BR2_TOOLCHAIN_BUILDROOT_MUSL
 
+comment "No libc available for this target! Please check your configuration"
+       depends on !BR2_TOOLCHAIN_BUILDROOT_LIBC
+
 source "package/linux-headers/Config.in.host"
 source "package/linux-headers/Config.in"
 source "package/musl/Config.in"
toolchain/toolchain-buildroot/toolchain-buildroot.mk +4 -1
index b30cc332d2..7688d44615 100644
@@ -6,6 +6,10 @@
 
 BR_LIBC = $(call qstrip,$(BR2_TOOLCHAIN_BUILDROOT_LIBC))
 
+ifeq ($(BR2_TOOLCHAIN_BUILDROOT):$(BR_LIBC),y:)
+$(error "No libc available for this target! Please check your configuration.")
+endif
+
 # Triggering the build of the host-gcc-final will automatically do the
 # build of binutils, uClibc, kernel headers and all the intermediate
 # gcc steps.
--

2.35.3

Quoted 4 lines
Quoted 4 lines

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

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