Skip to contentSkip to conversation

package/gcc-bare-metal: Add extra options to bare-metal gcc

PATCH In review Jesse Taube 2 participants 4 messages Aug 5, 2025 – Aug 6, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/gcc-bare-metal: Add extra options to bare-metal gcc

Users may want to add extra options to the bare-metal gcc configuration, such as a default abi. Add a new option to allow this, similar to the existing one for the regular gcc.

---
 package/gcc-bare-metal/gcc-bare-metal.mk           | 3 ++-
 toolchain/toolchain-bare-metal-buildroot/Config.in | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
package/gcc-bare-metal/gcc-bare-metal.mk +2 -1
index 17232a8ef1..e7290a11bf 100644
@@ -53,7 +53,8 @@ HOST_GCC_BARE_METAL_CONF_OPTS = \
 	--with-gmp=$(HOST_DIR) \
 	--with-mpc=$(HOST_DIR) \
 	--with-mpfr=$(HOST_DIR) \
-	--with-isl=$(HOST_DIR)
+	--with-isl=$(HOST_DIR) \
+	$(call qstrip,$(BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS))
 
 define HOST_GCC_BARE_METAL_CONFIGURE_CMDS
 	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
toolchain/toolchain-bare-metal-buildroot/Config.in +8 -0
index 19c97410c6..89b0a98fdd 100644
@@ -12,6 +12,14 @@ config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH
 	  metal toolchain, use the following definition:
 	  "microblazeel-buildroot-elf riscv32-buildroot-elf"
 
+config BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS
+	string "Additional bare-metal gcc options"
+	default ""
+	help
+	  Any additional bare-metal gcc configure options you
+	  may want to include. Affects al architecture tuples
+	  specified in BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH.
+
 source "package/newlib-bare-metal/Config.in"
 
 endif # BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
Signature · 6 lines
2.49.0

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

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Jesse,

Quoted 5 lines

Users may want to add extra options to the bare-metal gcc configuration, such as a default abi. Add a new option to allow this, similar to the existing one for the regular gcc.

Thank you for contributing to the bare-metal toolchain!

Regarding the default abi option, I just have two questions about that.

1. If you change the gcc default abi option, doesn't the newlib abi option also need to change?

2. The abi names are different from arch to arch, so if we have a string of bare-metal toolchains, this option will not work because a valid abi for one arch will be invalid for another. If you only need this config for the default abi, could my multilib patch below be a solution for you?

https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 24 lines

---
package/gcc-bare-metal/gcc-bare-metal.mk | 3 ++-
toolchain/toolchain-bare-metal-buildroot/Config.in | 8 ++++++++

2 files changed, 10 insertions(+), 1 deletion(-)
package/gcc-bare-metal/gcc-bare-metal.mk +2 -1
index 17232a8ef1..e7290a11bf 100644
@@ -53,7 +53,8 @@ HOST_GCC_BARE_METAL_CONF_OPTS = \
      --with-gmp=$(HOST_DIR) \
      --with-mpc=$(HOST_DIR) \
      --with-mpfr=$(HOST_DIR) \
-     --with-isl=$(HOST_DIR)
+     --with-isl=$(HOST_DIR) \
+     $(call qstrip,$(BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS))
 

define HOST_GCC_BARE_METAL_CONFIGURE_CMDS

      $(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
toolchain/toolchain-bare-metal-buildroot/Config.in +0 -0
index 19c97410c6..89b0a98fdd 100644

toolchain/toolchain-bare-metal-buildroot/Config.in config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH · line 15

Quoted 4 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +1 -0
@@ -12,6 +12,14 @@ config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH
        metal toolchain, use the following definition:
        "microblazeel-buildroot-elf riscv32-buildroot-elf"
 
+config BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS

I believe the naming convention should be:
BR2_HOST_GCC_BARE_METAL_EXTRA_CONF_OPTIONS

This way all options have format BR2_<package_name>_<option_name>.

Also, since this option is specific to gcc-bare-metal and not the other packages included by toolchain-bare-metal-buildroot, I think this option would belong in a new file called:
../package/gcc-bare-metal/Config.in.host

instead of:
..toolchain/toolchain-bare-metal-buildroot/Config.in

Quoted 9 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +7 -0
+     string "Additional bare-metal gcc options"
+     default ""
+     help
+       Any additional bare-metal gcc configure options you
+       may want to include. Affects al architecture tuples
+       specified in BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH.
+

source "package/newlib-bare-metal/Config.in"

Quoted 3 lines

endif # BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
--
2.49.0

Thanks again for contributing!

Best regards,
Neal Frager
AMD
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

author
#2 lore raw
Quoted 9 lines · Neal

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Jesse,

Quoted 3 lines

Users may want to add extra options to the bare-metal gcc configuration, such as a default abi. Add a new option to allow this, similar to the existing one for the regular gcc.

Quoted 8 lines
Quoted 1 line

Thank you for contributing to the bare-metal toolchain!

Regarding the default abi option, I just have two questions about that.

1. If you change the gcc default abi option, doesn't the newlib abi option also need to change?

I could not figure out how to set the default ABI that newlib uses without setting multilib.
The solution I found was to set the ABI on gcc with --with-abi= like the other toolchains do.
This does change the ABI that newlib uses, without the need for multilib.

Quoted 5 lines

2. The abi names are different from arch to arch, so if we have a string of bare-metal toolchains, this option will not work because a valid abi for one arch will be invalid for another. If you only need this config for the default abi, could my multilib patch below be a solution for you?

Yes, it does solve my problem, though it significantly increases the compile time.

The problem that I encountered is that the default ABI for riscv32 is ilp32d, so newlib uses that ABI even though my CPU doesn't have floating point support. I was going to send a patch to set the default ABI, ARCH, etc to match that of the target, but as you mentioned, for multiple or differing architectures or ABIs that wouldn't work.

Quoted 37 lines

https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 24 lines

---
package/gcc-bare-metal/gcc-bare-metal.mk | 3 ++-
toolchain/toolchain-bare-metal-buildroot/Config.in | 8 ++++++++

2 files changed, 10 insertions(+), 1 deletion(-)
package/gcc-bare-metal/gcc-bare-metal.mk +2 -1
index 17232a8ef1..e7290a11bf 100644
@@ -53,7 +53,8 @@ HOST_GCC_BARE_METAL_CONF_OPTS = \
      --with-gmp=$(HOST_DIR) \
      --with-mpc=$(HOST_DIR) \
      --with-mpfr=$(HOST_DIR) \
-     --with-isl=$(HOST_DIR)
+     --with-isl=$(HOST_DIR) \
+     $(call qstrip,$(BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS))
 

define HOST_GCC_BARE_METAL_CONFIGURE_CMDS

      $(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
toolchain/toolchain-bare-metal-buildroot/Config.in +0 -0
index 19c97410c6..89b0a98fdd 100644

toolchain/toolchain-bare-metal-buildroot/Config.in config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH · line 15

Quoted 4 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +1 -0
@@ -12,6 +12,14 @@ config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH
        metal toolchain, use the following definition:
        "microblazeel-buildroot-elf riscv32-buildroot-elf"
 
+config BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS

I believe the naming convention should be:
BR2_HOST_GCC_BARE_METAL_EXTRA_CONF_OPTIONS

This way all options have format BR2_<package_name>_<option_name>.

Quoted 7 lines

Also, since this option is specific to gcc-bare-metal and not the other packages included by toolchain-bare-metal-buildroot, I think this option would belong in a new file called:
../package/gcc-bare-metal/Config.in.host

instead of:
..toolchain/toolchain-bare-metal-buildroot/Config.in

Ok, will send V2 wasn't sure about these two issues, as the built-in toolchain does
it like this, not the typical format.

Quoted 6 lines

toolchain/toolchain-bare-metal-buildroot/Config.in config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH · line 20

Quoted 6 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +5 -0
+     string "Additional bare-metal gcc options"
+     default ""
+     help
+       Any additional bare-metal gcc configure options you
+       may want to include. Affects al architecture tuples

Also will fix this typo...

Thanks,
Jesse Taube

Quoted 8 lines
Quoted 7 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +2 -0
+       specified in BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH.
+

source "package/newlib-bare-metal/Config.in"

endif # BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
--
2.49.0

Quoted 5 lines

Thanks again for contributing!

Best regards,
Neal Frager
AMD

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

#3 lore raw

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Jesse,

Quoted 15 lines

[AMD Official Use Only - AMD Internal Distribution Only]

Hi Jesse,

Quoted 5 lines

Users may want to add extra options to the bare-metal gcc configuration, such as a default abi. Add a new option to allow this, similar to the existing one for the regular gcc.

Thank you for contributing to the bare-metal toolchain!

Regarding the default abi option, I just have two questions about that.

Quoted 8 lines

1. If you change the gcc default abi option, doesn't the newlib abi option also need to change?

I could not figure out how to set the default ABI that newlib uses without setting multilib.
The solution I found was to set the ABI on gcc with --with-abi= like the other toolchains do.
This does change the ABI that newlib uses, without the need for multilib.

Thanks for verifying this. I think it is ok to have extra config options, including a different abi from the default. You may want to add a note in the help that since the extra options are applied to all arch tuples defined in the list, only options that will work with all the tuples should be used. If an arch specific option needs to be added, such as an arch specific abi, only one tuple should be in the toolchain-bare-metal-buildroot tuples list.

Quoted 8 lines

2. The abi names are different from arch to arch, so if we have a string of bare-metal toolchains, this option will not work because a valid abi for one arch will be invalid for another. If you only need this config for the default abi, could my multilib patch below be a solution for you?

Yes, it does solve my problem, though it significantly increases the compile time.

Yes, I know. On my side, I need the enable multilib option because the xilinx versal-gen2 family will need two bare-metal toolchains, riscv32 and microblaze. Since I also need to configure the riscv32 abi for this case, I need to be able to enable multilib, so that I can also build a microblaze bare-metal toolchain.

Quoted 5 lines

The problem that I encountered is that the default ABI for riscv32 is ilp32d, so newlib uses that ABI even though my CPU doesn't have floating point support. I was going to send a patch to set the default ABI, ARCH, etc to match that of the target, but as you mentioned, for multiple or differing architectures or ABIs that wouldn't work.

I am ok with adding both your gcc-bare-metal extra config option and the enable-multilib option. I see why having both would be beneficial for different use cases.

Quoted 42 lines

https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/

Quoted 24 lines

---
package/gcc-bare-metal/gcc-bare-metal.mk | 3 ++-
toolchain/toolchain-bare-metal-buildroot/Config.in | 8 ++++++++

2 files changed, 10 insertions(+), 1 deletion(-)
package/gcc-bare-metal/gcc-bare-metal.mk +2 -1
index 17232a8ef1..e7290a11bf 100644
@@ -53,7 +53,8 @@ HOST_GCC_BARE_METAL_CONF_OPTS = \
      --with-gmp=$(HOST_DIR) \
      --with-mpc=$(HOST_DIR) \
      --with-mpfr=$(HOST_DIR) \
-     --with-isl=$(HOST_DIR)
+     --with-isl=$(HOST_DIR) \
+     $(call qstrip,$(BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS))
 

define HOST_GCC_BARE_METAL_CONFIGURE_CMDS

      $(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
toolchain/toolchain-bare-metal-buildroot/Config.in +0 -0
index 19c97410c6..89b0a98fdd 100644

toolchain/toolchain-bare-metal-buildroot/Config.in config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH · line 15

Quoted 4 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +1 -0
@@ -12,6 +12,14 @@ config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH
        metal toolchain, use the following definition:
        "microblazeel-buildroot-elf riscv32-buildroot-elf"
 
+config BR2_EXTRA_GCC_BARE_METAL_CONF_OPTIONS

I believe the naming convention should be:
BR2_HOST_GCC_BARE_METAL_EXTRA_CONF_OPTIONS

This way all options have format BR2_<package_name>_<option_name>.

Also, since this option is specific to gcc-bare-metal and not the other packages included by toolchain-bare-metal-buildroot, I think this option would belong in a new file called:
../package/gcc-bare-metal/Config.in.host

Quoted 6 lines

instead of:
..toolchain/toolchain-bare-metal-buildroot/Config.in

Ok, will send V2 wasn't sure about these two issues, as the built-in toolchain does
it like this, not the typical format.

I see what you mean. Maybe one of the maintainers could explain the history on that? I guess the issue is once the config is created, it needs to be supported basically forever...

In any case, a gcc-bare-metal specific config should be in the package/gcc-bare-metal/Config.in.host file which your patch will create.

Quoted 8 lines

toolchain/toolchain-bare-metal-buildroot/Config.in config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH · line 20

Quoted 6 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +5 -0
+     string "Additional bare-metal gcc options"
+     default ""
+     help
+       Any additional bare-metal gcc configure options you
+       may want to include. Affects al architecture tuples

Also will fix this typo...

Good catch!

Quoted 7 lines

Thanks,
Jesse Taube

Quoted 3 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +2 -0
+       specified in BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH.
+

source "package/newlib-bare-metal/Config.in"

Quoted 6 lines
Quoted 3 lines

endif # BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
--
2.49.0

Thanks again for contributing!

Best regards,
Neal Frager
AMD
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot