Skip to contentSkip to conversation

toolchain: invert glibc <-> !static dependency

RFC In review Arnout Vandecappelle (Essensium/Mind) 4 participants 6 messages Oct 6, 2021 – Jul 27, 2022

lore
Share & tools
lore
#0 lore raw

RFC 1/2 toolchain: invert glibc <-> !static dependency

Currently, glibc depends on !BR2_STATIC_LIBS in all the toolchain variants.

However, for some architectures, glibc is the only supported libc. Therefore, for these, it's possible to select static libs, at which point no libc is selectable any more.

To overcome this situation, invert the dependency between glibc and static libs: BR2_STATIC_LIBS depends on !BR2_TOOLCHAIN_USES_GLIBC, and all the dependencies on !BR2_STATIC_LIBS are removed from the glibc variants of all toolchains.

An alternative (simpler) fix would be to let BR2_STATIC_LIBS depend on !BR2_s390x. However, that doesn't solve the problem for the myriad of other architectures that only support glibc. In addition, there are some architecture variants that only support glibc, etc. etc., which really complicates stuff.

---
 Config.in                                     |  1 +
 toolchain/toolchain-buildroot/Config.in       |  5 +-
 toolchain/toolchain-external/Config.in        |  3 -
 .../toolchain-external-andes-nds32/Config.in  |  1 -
 .../Config.in                                 |  1 -
 .../toolchain-external-arm-aarch64/Config.in  |  1 -
 .../toolchain-external-arm-arm/Config.in      |  1 -
 .../Config.in.options                         | 60 -------------------
 .../Config.in                                 |  1 -
 .../Config.in                                 |  1 -
 .../Config.in                                 |  1 -
 .../Config.in                                 |  1 -
 .../Config.in.options                         |  4 --
 .../Config.in                                 |  1 -
 .../Config.in                                 |  1 -
 .../toolchain-external-linaro-arm/Config.in   |  2 -
 .../toolchain-external-linaro-armeb/Config.in |  2 -
 17 files changed, 3 insertions(+), 84 deletions(-)
Config.in +1 -0
index 3db2c8dcab..8ed11c994d 100644
@@ -597,6 +597,7 @@ choice
 
 config BR2_STATIC_LIBS
 	bool "static only"
+	depends on !BR2_TOOLCHAIN_USES_GLIBC
 	help
 	  Build and use only static libraries. No shared libraries will
 	  be installed on the target. This potentially increases your
toolchain/toolchain-buildroot/Config.in +2 -3
index 4004c0edf8..3a64cd36d5 100644
@@ -51,7 +51,6 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC
 		   BR2_sparc64     || BR2_x86_64     || BR2_microblaze  || \
 		   BR2_nios2       || (BR2_arc && BR2_ARC_ATOMIC_EXT)   || BR2_csky
 	depends on BR2_USE_MMU
-	depends on !BR2_STATIC_LIBS
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_2
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_10 || !BR2_powerpc64le
 	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_5 || !BR2_MIPS_NAN_2008
@@ -66,9 +65,9 @@ config BR2_TOOLCHAIN_BUILDROOT_GLIBC
 
 	  http://www.gnu.org/software/libc/
 
-comment "glibc needs a toolchain w/ dynamic library, kernel headers >= 3.2"
+comment "glibc needs a toolchain w/ kernel headers >= 3.2"
 	depends on BR2_USE_MMU
-	depends on BR2_STATIC_LIBS || !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_2
+	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_2
 
 # glibc >= 2.26 require kernel headers >= 3.10 on powerpc64le.
 comment "glibc on powerpc64le needs a toolchain w/ headers >= 3.10"
toolchain/toolchain-external/Config.in +0 -3
index 2177e6a678..fb61b8e8bd 100644
@@ -5,9 +5,6 @@ comment "Toolchain External Options"
 choice
 	prompt "Toolchain"
 
-comment "glibc toolchains only available with shared lib support"
-	depends on BR2_STATIC_LIBS
-
 # Kept toolchains sorted by architecture in order to use some toolchain
 # as default choice
 
toolchain/toolchain-external/toolchain-external-andes-nds32/Config.in +0 -1
index 9c937b8c44..77ec51e219 100644
@@ -1,7 +1,6 @@
 config BR2_TOOLCHAIN_EXTERNAL_ANDES_NDS32
 	bool "Andes nds32"
 	depends on BR2_nds32
-	depends on !BR2_STATIC_LIBS
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
 	select BR2_HOSTARCH_NEEDS_IA32_LIBS
 	select BR2_TOOLCHAIN_GCC_AT_LEAST_8
toolchain/toolchain-external/toolchain-external-arm-aarch64-be/Config.in +0 -1
index 783ed35314..eeb88579fe 100644
@@ -2,7 +2,6 @@ config BR2_TOOLCHAIN_EXTERNAL_ARM_AARCH64_BE
 	bool "Arm AArch64 BE 2021.07"
 	depends on BR2_aarch64_be
 	depends on BR2_HOSTARCH = "x86_64"
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_INSTALL_LIBSTDCPP
toolchain/toolchain-external/toolchain-external-arm-aarch64/Config.in +0 -1
index 4557debe5d..9eb5d64a9d 100644
@@ -2,7 +2,6 @@ config BR2_TOOLCHAIN_EXTERNAL_ARM_AARCH64
 	bool "Arm AArch64 2021.07"
 	depends on BR2_aarch64
 	depends on BR2_HOSTARCH = "x86_64"
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_INSTALL_LIBSTDCPP
toolchain/toolchain-external/toolchain-external-arm-arm/Config.in +0 -1
index 0fbeba6aae..86a6f9fd25 100644
@@ -10,7 +10,6 @@ config BR2_TOOLCHAIN_EXTERNAL_ARM_ARM
 	depends on BR2_ARM_CPU_HAS_NEON
 	depends on BR2_HOSTARCH = "x86_64"
 	depends on BR2_ARM_EABIHF
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_INSTALL_LIBSTDCPP
toolchain/toolchain-external/toolchain-external-bootlin/Config.in.options +0 -60

420 lines not on this page · raw message

toolchain/toolchain-external/toolchain-external-codesourcery-aarch64/Config.in +0 -1
index 24cbcffa29..8c0f985c5b 100644
@@ -5,7 +5,6 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_AARCH64
 	# a57/a53 and a72/a53 appeared in gcc-6 or were broken before
 	depends on !BR2_cortex_a57_a53 && !BR2_cortex_a72_a53
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_INSTALL_LIBSTDCPP
toolchain/toolchain-external/toolchain-external-codesourcery-arm/Config.in +0 -1
index bdbe2acaea..c1e423b7bb 100644
@@ -6,7 +6,6 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_ARM
 	depends on BR2_ARM_EABI
 	# Unsupported ARM cores
 	depends on !BR2_cortex_a12 && !BR2_cortex_a17 && !BR2_ARM_CPU_ARMV8A
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
toolchain/toolchain-external/toolchain-external-codesourcery-mips/Config.in +0 -1
index 1a3bdc9393..cb66255cf3 100644
@@ -7,7 +7,6 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_MIPS
 	depends on !BR2_mips_interaptiv
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
 	depends on !BR2_MIPS_NABI32
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
toolchain/toolchain-external/toolchain-external-codesourcery-niosII/Config.in +0 -1
index 9d785a4b6b..cf3ce69a68 100644
@@ -3,7 +3,6 @@ config BR2_TOOLCHAIN_EXTERNAL_CODESOURCERY_NIOSII
 	depends on BR2_nios2
 	depends on !BR2_ARCH_NEEDS_GCC_AT_LEAST_8
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
toolchain/toolchain-external/toolchain-external-custom/Config.in.options +0 -4
index ae78c0ef9e..d8af6ea2f3 100644
@@ -370,7 +370,6 @@ config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_UCLIBC
 
 config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC
 	bool "glibc/eglibc"
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	help
 	  Select this option if your external toolchain uses the GNU C
@@ -382,9 +381,6 @@ config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC
 	  toolchain with eglibc configured to exclude key features may
 	  cause build failures to some packages.
 
-comment "(e)glibc only available with shared lib support"
-	depends on BR2_STATIC_LIBS
-
 config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_MUSL
 	bool "musl (experimental)"
 	select BR2_TOOLCHAIN_EXTERNAL_MUSL
toolchain/toolchain-external/toolchain-external-linaro-aarch64-be/Config.in +0 -1
index bac90374cf..53d5dfd8f2 100644
@@ -2,7 +2,6 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64_BE
 	bool "Linaro AArch64 BE 2018.05"
 	depends on BR2_aarch64_be
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_INSTALL_LIBSTDCPP
toolchain/toolchain-external/toolchain-external-linaro-aarch64/Config.in +0 -1
index 824eb76c72..c9b84b1d30 100644
@@ -2,7 +2,6 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64
 	bool "Linaro AArch64 2018.05"
 	depends on BR2_aarch64
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_INSTALL_LIBSTDCPP
toolchain/toolchain-external/toolchain-external-linaro-arm/Config.in +0 -2
index beb38609c3..015e92f17c 100644
@@ -1,7 +1,6 @@
 comment "Linaro toolchains available for Cortex-A + EABIhf"
 	depends on BR2_arm
 	depends on !BR2_ARM_CPU_ARMV7A || !BR2_ARM_EABIHF
-	depends on !BR2_STATIC_LIBS
 
 config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	bool "Linaro ARM 2018.05"
@@ -9,7 +8,6 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM
 	depends on BR2_ARM_CPU_ARMV7A || BR2_ARM_CPU_ARMV8A
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
 	depends on BR2_ARM_EABIHF
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
toolchain/toolchain-external/toolchain-external-linaro-armeb/Config.in +0 -2
index aa21e44860..b338a72bff 100644
@@ -1,7 +1,6 @@
 comment "Linaro toolchains available for Cortex-A + EABIhf"
 	depends on BR2_armeb
 	depends on !BR2_ARM_CPU_ARMV7A || !BR2_ARM_EABIHF
-	depends on !BR2_STATIC_LIBS
 
 config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	bool "Linaro armeb 2018.05"
@@ -9,7 +8,6 @@ config BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB
 	depends on BR2_ARM_CPU_ARMV7A || BR2_ARM_CPU_ARMV8A
 	depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "x86"
 	depends on BR2_ARM_EABIHF
-	depends on !BR2_STATIC_LIBS
 	select BR2_TOOLCHAIN_EXTERNAL_GLIBC
 	select BR2_TOOLCHAIN_HAS_SSP
 	select BR2_TOOLCHAIN_HAS_NATIVE_RPC
Signature · 6 lines
2.31.1

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

RFC 2/2 Config.in: move toolchain menu before build options

Many of the build options depend on the toolchain configuration. In addition, it's pretty logical that you select first target architecture, then the toolchain, and only then things like debug and pic/pie. Therefore, move the "Toolchain" menu before the "Build options" menu instead of after.

---
 Config.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Config.in +2 -2
index 8ed11c994d..efdf397c01 100644
@@ -87,6 +87,8 @@ config BR2_NEEDS_HOST_GCC_PLUGIN_SUPPORT
 
 source "arch/Config.in"
 
+source "toolchain/Config.in"
+
 menu "Build options"
 
 menu "Commands"
@@ -908,8 +910,6 @@ comment "Fortify Source needs a glibc toolchain and optimization"
 	depends on (!BR2_TOOLCHAIN_USES_GLIBC || BR2_OPTIMIZE_0)
 endmenu
 
-source "toolchain/Config.in"
-
 source "system/Config.in"
 
 source "linux/Config.in"
Signature · 6 lines
2.31.1

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

Re: [Buildroot] [RFC 2/2] Config.in: move toolchain menu before build options

Arnout, All,

On 2021-10-06 22:41 +0200, Arnout Vandecappelle (Essensium/Mind) spake thusly:

Quoted 5 lines

Many of the build options depend on the toolchain configuration. In addition, it's pretty logical that you select first target architecture, then the toolchain, and only then things like debug and pic/pie. Therefore, move the "Toolchain" menu before the "Build options" menu instead of after.

I think a much better solution would be to move the toolchain-related build options to the "Toolchain" menu, and keep in the "Build options" menu focused on the actual generic build "infra" (arg, I can't find a proper word...). Parallel jobs, download tools, patch directories et al. really are related to the build infrastructure, while static, -Os et al. are more about the toolchain "configuration".

Regards,
Yann E. MORIN.

Quoted 34 lines
---
 Config.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Config.in +2 -2
index 8ed11c994d..efdf397c01 100644
@@ -87,6 +87,8 @@ config BR2_NEEDS_HOST_GCC_PLUGIN_SUPPORT
 
 source "arch/Config.in"
 
+source "toolchain/Config.in"
+
 menu "Build options"
 
 menu "Commands"
@@ -908,8 +910,6 @@ comment "Fortify Source needs a glibc toolchain and optimization"
 	depends on (!BR2_TOOLCHAIN_USES_GLIBC || BR2_OPTIMIZE_0)
 endmenu
 
-source "toolchain/Config.in"
-
 source "system/Config.in"
 
 source "linux/Config.in"
Signature · 6 lines
2.31.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

Re: [Buildroot] [RFC 2/2] Config.in: move toolchain menu before build options

Quoted 9 lines · Yann E. MORIN

Arnout, All,

On 2021-10-06 22:41 +0200, Arnout Vandecappelle (Essensium/Mind) spake thusly:

Quoted 5 lines

Many of the build options depend on the toolchain configuration. In addition, it's pretty logical that you select first target architecture, then the toolchain, and only then things like debug and pic/pie. Therefore, move the "Toolchain" menu before the "Build options" menu instead of after.

Quoted 6 lines

I think a much better solution would be to move the toolchain-related build options to the "Toolchain" menu, and keep in the "Build options" menu focused on the actual generic build "infra" (arg, I can't find a proper word...). Parallel jobs, download tools, patch directories et al. really are related to the build infrastructure, while static, -Os et al. are more about the toolchain "configuration".

Although I agree that static etc. is distinct from wget etc. options, I
wouldn't say that they are toolchain options either...

That said: we do say that you need to do a clean rebuild when you change
toolchain options, and static etc. definitely require a clean rebuild.

Regards,
Arnout

Quoted 30 lines

Regards,
Yann E. MORIN.

Quoted 26 lines
---
  Config.in | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
Config.in +2 -2
index 8ed11c994d..efdf397c01 100644
@@ -87,6 +87,8 @@ config BR2_NEEDS_HOST_GCC_PLUGIN_SUPPORT
 
  source "arch/Config.in"
 
+source "toolchain/Config.in"
+
  menu "Build options"
 
  menu "Commands"
@@ -908,8 +910,6 @@ comment "Fortify Source needs a glibc toolchain and optimization"
  	depends on (!BR2_TOOLCHAIN_USES_GLIBC || BR2_OPTIMIZE_0)
  endmenu
 
-source "toolchain/Config.in"
-
  source "system/Config.in"
 
Quoted 9 lines
Quoted 8 lines
Config.in +0 -0
  source "linux/Config.in"
Signature · 6 lines
2.31.1

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

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

#4 lore raw
In reply to Arnout Vandecappelle (Essensium/Mind)

Hello,

Quoted 14 lines · On Wed, 6 Oct 2021 22:41:32 +0200 "Arnout Vandecappelle (Essensium/Mind)"…

Currently, glibc depends on !BR2_STATIC_LIBS in all the toolchain variants.

However, for some architectures, glibc is the only supported libc. Therefore, for these, it's possible to select static libs, at which point no libc is selectable any more.

To overcome this situation, invert the dependency between glibc and static libs: BR2_STATIC_LIBS depends on !BR2_TOOLCHAIN_USES_GLIBC, and all the dependencies on !BR2_STATIC_LIBS are removed from the glibc variants of all toolchains.

Quoted 7 lines

An alternative (simpler) fix would be to let BR2_STATIC_LIBS depend on !BR2_s390x. However, that doesn't solve the problem for the myriad of other architectures that only support glibc. In addition, there are some architecture variants that only support glibc, etc. etc., which really complicates stuff.

The reason why it was done this way is because the static/shared decision appears in menuconfig before the toolchain selection. It would be odd for a user to select "static libs" (which would be possible in most configurations as we default to uClibc), then to select "glibc" for the toolchain, do a build, and end up with a non static build.

Obviously, you can tell me that the user could also set glibc as a toolchain, then go back to the build option, decide to do a static build, and without notification the toolchain will be changed to uclibc.

So there's no ideal solution.

But then I see your PATCH 2/2, which indeed kind of "resolves" this questioning.

The only alternative that I could think of is having a hidden boolean BR2_ARCH_SUPPORTS_STATIC_LIBS, which would be selected by architectures that support at least one C library that allows static linking. I don't know if that's better, though.

What you did in this patch + inverting toolchain/build options in PATCH 2 is probably simpler/better.

I have not reviewed the patches carefully, but I'm fine with the principle.

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw
In reply to Arnout Vandecappelle (Essensium/Mind)
Quoted 14 lines · On Wed, 6 Oct 2021 22:41:32 +0200 "Arnout Vandecappelle (Essensium/Mind)"…

Currently, glibc depends on !BR2_STATIC_LIBS in all the toolchain variants.

However, for some architectures, glibc is the only supported libc. Therefore, for these, it's possible to select static libs, at which point no libc is selectable any more.

To overcome this situation, invert the dependency between glibc and static libs: BR2_STATIC_LIBS depends on !BR2_TOOLCHAIN_USES_GLIBC, and all the dependencies on !BR2_STATIC_LIBS are removed from the glibc variants of all toolchains.

Quoted 7 lines

An alternative (simpler) fix would be to let BR2_STATIC_LIBS depend on !BR2_s390x. However, that doesn't solve the problem for the myriad of other architectures that only support glibc. In addition, there are some architecture variants that only support glibc, etc. etc., which really complicates stuff.

I have applied this, after making sure it applies on master, since there were conflicting changes. I rewrote most of the commit log, because the situation in master was different than what it was when you wrote this patch: we had already changed BR2_STATIC_LIBS to not be selectable when the internal backend uses glibc. Your patch generalizes this to the external toolchain backend as well.

Also, you had forgotten to adjust the gen-bootlin-toolchains script, so I did that. And I added a Config.in comment inside the static/shared choice that explains why static is not available.

Thanks for this!

Thomas

Signature · 7 lines
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot