Skip to contentSkip to conversation

package/binutils-bare-metal: add multiple tuple support

PATCH Superseded Neal Frager via buildroot 3 participants 14 messages Feb 14, 2025 – Feb 16, 2025

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/4 package/binutils-bare-metal: add multiple tuple support

Add support to binutils-bare-metal to support multiple architecture tuples with the BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH string.

---
V1->V2:
- no changes

---
 .../binutils-bare-metal.mk                    | 61 ++++++++++++++++---
 1 file changed, 52 insertions(+), 9 deletions(-)
package/binutils-bare-metal/binutils-bare-metal.mk +52 -9
index 3525e9fdf2..0a90560471 100644
@@ -21,14 +21,57 @@ HOST_BINUTILS_BARE_METAL_CONF_ENV += MAKEINFO=true
 HOST_BINUTILS_BARE_METAL_MAKE_OPTS += MAKEINFO=true
 HOST_BINUTILS_BARE_METAL_INSTALL_OPTS += MAKEINFO=true install
 
-HOST_BINUTILS_BARE_METAL_CONF_OPTS = \
-	--target=$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE) \
-	--disable-gprof \
-	--disable-shared \
-	--enable-lto \
-	--enable-static \
-	--disable-initfini-array \
-	--disable-multilib \
-	--disable-werror
+# to build for multiple arch tuples, it is necesssary to build out of the
+# source tree, so that each arch tuple can have its own build location
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		ln -sf ../configure $(@D)/build-$(arch_tuple)/configure;)
+endef
+
+HOST_BINUTILS_BARE_METAL_PRE_CONFIGURE_HOOKS += HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS
+
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		./configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--enable-shared --disable-static \
+			--disable-gtk-doc \
+			--disable-gtk-doc-html \
+			--disable-doc \
+			--disable-docs \
+			--disable-documentation \
+			--disable-debug \
+			--with-xmlto=no \
+			--with-fop=no \
+			--disable-nls \
+			--disable-dependency-tracking \
+			--target=$(arch_tuple) \
+			--disable-gprof \
+			--enable-lto \
+			--disable-initfini-array \
+			--disable-multilib \
+			--disable-werror; \
+	)
+endef
+
+define HOST_BINUTILS_BARE_METAL_BUILD_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_BINUTILS_BARE_METAL_MAKE_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)
+endef
+
+define HOST_BINUTILS_BARE_METAL_INSTALL_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_BINUTILS_BARE_METAL_INSTALL_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)
+endef
 
 $(eval $(host-autotools-package))
Signature · 6 lines
2.25.1

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

PATCH v2 2/4 package/gcc-bare-metal: add multiple tuple support

Add support to gcc-bare-metal to support multiple architecture tuples with the BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH string.

---
V1->V2:
- corrected sysroot configuration

---
 package/gcc-bare-metal/gcc-bare-metal.mk | 90 ++++++++++++++++--------
 1 file changed, 62 insertions(+), 28 deletions(-)
package/gcc-bare-metal/gcc-bare-metal.mk +62 -28
index adaae6c307..66cebcf730 100644
@@ -20,15 +20,15 @@ HOST_GCC_BARE_METAL_DEPENDENCIES = \
 	host-mpfr \
 	host-isl
 
-# gcc doesn't support in-tree build, so we create a 'build'
-# subdirectory in the gcc sources, and build from there.
-define HOST_GCC_BARE_METAL_CONFIGURE_SYMLINK
-	mkdir -p $(@D)/build
-	ln -sf ../configure $(@D)/build/configure
+# to build for multiple arch tuples, it is necesssary to build out of the
+# source tree, so that each arch tuple can have its own build location
+define HOST_GCC_BARE_METAL_CONFIGURE_SYMLINKS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		ln -sf ../configure $(@D)/build-$(arch_tuple)/configure;)
 endef
 
-HOST_GCC_BARE_METAL_PRE_CONFIGURE_HOOKS += HOST_GCC_BARE_METAL_CONFIGURE_SYMLINK
-HOST_GCC_BARE_METAL_SUBDIR = build
+HOST_GCC_BARE_METAL_PRE_CONFIGURE_HOOKS += HOST_GCC_BARE_METAL_CONFIGURE_SYMLINKS
 
 HOST_GCC_BARE_METAL_MAKE_OPTS = \
 	$(HOST_GCC_COMMON_MAKE_OPTS) \
@@ -37,26 +37,60 @@ HOST_GCC_BARE_METAL_MAKE_OPTS = \
 
 HOST_GCC_BARE_METAL_INSTALL_OPTS = install-gcc install-target-libgcc
 
-HOST_GCC_BARE_METAL_CONF_OPTS = \
-	--target=$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE) \
-	--disable-initfini_array \
-	--disable-__cxa_atexit \
-	--disable-libstdcxx-pch \
-	--with-newlib \
-	--disable-threads \
-	--enable-plugins \
-	--with-gnu-as \
-	--disable-libitm \
-	--without-long-double-128 \
-	--without-headers \
-	--enable-languages=c \
-	--disable-multilib \
-	--with-gmp=$(HOST_DIR) \
-	--with-mpc=$(HOST_DIR) \
-	--with-mpfr=$(HOST_DIR) \
-	--with-isl=$(HOST_DIR) \
-	--with-sysroot=$(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT) \
-	AR_FOR_TARGET=$(HOST_DIR)/bin/$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE)-ar \
-	RANLIB_FOR_TARGET=$(HOST_DIR)/bin/$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE)-ranlib
+define HOST_GCC_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		./configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--enable-shared --disable-static \
+			--disable-gtk-doc \
+			--disable-gtk-doc-html \
+			--disable-doc \
+			--disable-docs \
+			--disable-documentation \
+			--disable-debug \
+			--with-xmlto=no \
+			--with-fop=no \
+			--disable-nls \
+			--disable-dependency-tracking \
+			--target=$(arch_tuple) \
+			--disable-initfini_array \
+			--disable-__cxa_atexit \
+			--disable-libstdcxx-pch \
+			--with-newlib \
+			--disable-threads \
+			--enable-plugins \
+			--with-gnu-as \
+			--disable-libitm \
+			--without-long-double-128 \
+			--without-headers \
+			--enable-languages=c \
+			--disable-multilib \
+			--with-gmp=$(HOST_DIR) \
+			--with-mpc=$(HOST_DIR) \
+			--with-mpfr=$(HOST_DIR) \
+			--with-isl=$(HOST_DIR) \
+			--with-sysroot=$(HOST_DIR)/$(arch_tuple)/sysroot \
+			AR_FOR_TARGET=$(HOST_DIR)/bin/$(arch_tuple)-ar \
+			RANLIB_FOR_TARGET=$(HOST_DIR)/bin/$(arch_tuple)-ranlib; \
+	)
+endef
+
+define HOST_GCC_BARE_METAL_BUILD_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_GCC_BARE_METAL_MAKE_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)
+endef
+
+define HOST_GCC_BARE_METAL_INSTALL_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_GCC_BARE_METAL_INSTALL_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)
+endef
 
 $(eval $(host-autotools-package))
Signature · 6 lines
2.25.1

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

Re: [Buildroot] [PATCH v2 2/4] package/gcc-bare-metal: add multiple tuple support

Hello Neal,

Quoted 4 lines · On Fri, 14 Feb 2025 16:54:00 +0000 Neal Frager via buildroot…

Add support to gcc-bare-metal to support multiple architecture tuples with the BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH string.

I have the same comments as for the binutils-bare-metal patch, they are also applicable to this gcc-bare-metal patch.

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
#3 lore raw

PATCH v2 3/4 package/newlib-bare-metal: add multiple tuple support

In reply to Neal Frager via buildroot

Add support to newlib-bare-metal to support multiple architecture tuples with the BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH string.

---
V1->V2:
- no changes

---
 .../newlib-bare-metal/newlib-bare-metal.mk    | 29 +++++++++++++++----
 1 file changed, 23 insertions(+), 6 deletions(-)
package/newlib-bare-metal/newlib-bare-metal.mk +23 -6
index e28e7a717c..4acc11deb2 100644
@@ -22,28 +22,45 @@ NEWLIB_BARE_METAL_INSTALL_STAGING = YES
 NEWLIB_BARE_METAL_INSTALL_TARGET = NO
 NEWLIB_BARE_METAL_MAKE_OPTS = MAKEINFO=true
 
+# to build for multiple arch tuples, it is necesssary to build out of the
+# source tree, so that each arch tuple can have its own build location
+define NEWLIB_BARE_METAL_CONFIGURE_SYMLINKS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		ln -sf ../configure $(@D)/build-$(arch_tuple)/configure;)
+endef
+
+NEWLIB_BARE_METAL_PRE_CONFIGURE_HOOKS += NEWLIB_BARE_METAL_CONFIGURE_SYMLINKS
+
 define NEWLIB_BARE_METAL_CONFIGURE_CMDS
-	(cd $(@D) && \
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+	cd $(@D)/build-$(arch_tuple) && \
 		PATH=$(BR_PATH) \
 		./configure \
-			--target=$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE) \
+			--target=$(arch_tuple) \
 			--prefix=/usr \
 			--enable-newlib-io-c99-formats \
 			--enable-newlib-io-long-long \
 			--enable-newlib-io-float \
 			--enable-newlib-io-long-double \
 			--disable-multilib \
-			--with-tooldir=/usr \
+			--with-tooldir=/usr; \
 	)
 endef
 
 define NEWLIB_BARE_METAL_BUILD_CMDS
-	PATH=$(BR_PATH) $(MAKE1) $(NEWLIB_BARE_METAL_MAKE_OPTS) -C $(@D)
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		PATH=$(BR_PATH) $(MAKE1) \
+			$(NEWLIB_BARE_METAL_MAKE_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)
 endef
 
 define NEWLIB_BARE_METAL_INSTALL_STAGING_CMDS
-	PATH=$(BR_PATH) $(MAKE1) -C $(@D) $(NEWLIB_BARE_METAL_MAKE_OPTS) \
-		DESTDIR=$(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT) install
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		PATH=$(BR_PATH) $(MAKE1) \
+			$(NEWLIB_BARE_METAL_MAKE_OPTS) \
+			-C $(@D)/build-$(arch_tuple) \
+			DESTDIR=$(HOST_DIR)/$(arch_tuple)/sysroot install;)
 endef
 
 $(eval $(generic-package))
Signature · 6 lines
2.25.1

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

Re: [Buildroot] [PATCH v2 3/4] package/newlib-bare-metal: add multiple tuple support

Quoted 4 lines · On Fri, 14 Feb 2025 16:54:01 +0000 Neal Frager via buildroot…

Add support to newlib-bare-metal to support multiple architecture tuples with the BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH string.

And same as binutils-bare-metal for this patch as well, for consistency reasons.

Thanks!

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

PATCH v2 4/4 toolchain/toolchain-bare-metal-buildroot: update help text for multiple tuple support

In reply to Neal Frager via buildroot

Now that binutils-bare-metal, gcc-bare-metal and newlib-bare-metal packages have been upgraded to support a list of architecture tuples, this patch updates the toolchain-bare-metal-buildroot help text to describe the new capability.

BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH is still backwards compatible with its prior definition as defining a single tuple with this new definition works exactly the same as before.

---
V1->V2:
no changes

---
 toolchain/Config.in                                   |  2 +-
 toolchain/toolchain-bare-metal-buildroot/Config.in    | 11 ++++++++---
 .../toolchain-bare-metal-buildroot.mk                 |  1 -
 3 files changed, 9 insertions(+), 5 deletions(-)
toolchain/Config.in +1 -1
index d6ed25ff96..94723da141 100644
@@ -941,7 +941,7 @@ config BR2_TOOLCHAIN_HAS_LIBQUADMATH
 comment "Bare metal toolchain"
 
 config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
-	bool "Build a bare metal toolchain"
+	bool "Build bare metal toolchains"
 	select BR2_PACKAGE_NEWLIB_BARE_METAL
 	help
 	  Select if you need a bare-metal toolchain for building
toolchain/toolchain-bare-metal-buildroot/Config.in +8 -3
index 6fe969357f..ca3129444f 100644
@@ -1,10 +1,15 @@
 if BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
 
 config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH
-	string "architecture tuple"
+	string "list of architecture tuples"
 	help
-	  This option allows to define the architecture tuple for the
-	  bare-metal toolchain.
+	  This option defines a list of architecture tuples for
+	  building bare metal toolchains.
+
+	  For example, to build both a microblaze and a riscv bare
+	  metal toolchain for Xilinx platforms, use the following
+	  definition:
+	  "microblazeel-xilinx-elf riscv32-xilinx-elf"
 
 source "package/newlib-bare-metal/Config.in"
 
toolchain/toolchain-bare-metal-buildroot/toolchain-bare-metal-buildroot.mk +0 -1
index dbfe30a910..71063fcee4 100644
@@ -6,7 +6,6 @@
 
 TOOLCHAIN_BARE_METAL_BUILDROOT_DEPENDENCIES = newlib-bare-metal
 TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE = $(call qstrip,$(BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH))
-TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT = $(HOST_DIR)/$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE)/sysroot
 TOOLCHAIN_BARE_METAL_BUILDROOT_ADD_TOOLCHAIN_DEPENDENCY = NO
 
 $(eval $(virtual-package))
Signature · 6 lines
2.25.1

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

Re: [Buildroot] [PATCH v2 4/4] toolchain/toolchain-bare-metal-buildroot: update help text for multiple tuple support

Hello Neal,

Quoted 10 lines · On Fri, 14 Feb 2025 16:54:02 +0000 Neal Frager via buildroot…

Now that binutils-bare-metal, gcc-bare-metal and newlib-bare-metal packages have been upgraded to support a list of architecture tuples, this patch updates the toolchain-bare-metal-buildroot help text to describe the new capability.

BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH is still backwards compatible with its prior definition as defining a single tuple with this new definition works exactly the same as before.

Overall looks good. Maybe one minor wording comment.

toolchain/toolchain-bare-metal-buildroot/Config.in line 7

Quoted 8 lines

config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH

toolchain/toolchain-bare-metal-buildroot/Config.in +3 -3
-	string "architecture tuple"
+	string "list of architecture tuples"
 	help
-	  This option allows to define the architecture tuple for the
-	  bare-metal toolchain.
+	  This option defines a list of architecture tuples for
+	  building bare metal toolchains.

This option allows to define the list of architecture tuples for which bare-metal toolchains will be created. One toolchain will be built for each of the architecture tuples specified in this option.

toolchain/toolchain-bare-metal-buildroot/Config.in line 9

Quoted 2 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +2 -0
+
+	  For example, to build both a microblaze and a riscv bare

microblaze -> Microblaze

riscv -> RISC-V

toolchain/toolchain-bare-metal-buildroot/Config.in line 10

Quoted 1 line
toolchain/toolchain-bare-metal-buildroot/Config.in +1 -0
+	  metal toolchain for Xilinx platforms, use the following

I'm not sure the "Xilinx platforms" here is very relevant.

toolchain/toolchain-bare-metal-buildroot/Config.in line 12

Quoted 2 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +2 -0
+	  definition:
+	  "microblazeel-xilinx-elf riscv32-xilinx-elf"

In fact, I'm not sure the "xilinx" parts of the tuples here are very relevant/useful. It's the vendor part of the tuple, so it has basically no effect. It would probably be even more logical to use microblazel-none-elf, or even microblazeel-buildroot-elf.

Thanks!

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
#7 lore raw

Re: [Buildroot] [PATCH v2 4/4] toolchain/toolchain-bare-metal-buildroot: update help text for multiple tuple support

Hi Thomas,

Quoted 5 lines

Now that binutils-bare-metal, gcc-bare-metal and newlib-bare-metal packages have been upgraded to support a list of architecture tuples, this patch updates the toolchain-bare-metal-buildroot help text to describe the new capability.

Quoted 7 lines

BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH is still backwards compatible with its prior definition as defining a single tuple with this new definition works exactly the same as before.

Overall looks good. Maybe one minor wording comment.

Thanks for the review.

Quoted 9 lines

config BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH

toolchain/toolchain-bare-metal-buildroot/Config.in +3 -3
-	string "architecture tuple"
+	string "list of architecture tuples"
 	help
-	  This option allows to define the architecture tuple for the
-	  bare-metal toolchain.
+	  This option defines a list of architecture tuples for
+	  building bare metal toolchains.
Quoted 3 lines

This option allows to define the list of architecture tuples for which bare-metal toolchains will be created. One toolchain will be built for each of the architecture tuples specified in this option.

Ok for me.

Quoted 6 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +2 -0
+
+	  For example, to build both a microblaze and a riscv bare

microblaze -> Microblaze

riscv -> RISC-V

I will change this.

Quoted 3 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +1 -0
+	  metal toolchain for Xilinx platforms, use the following

I'm not sure the "Xilinx platforms" here is very relevant.

Yes, you are right.

Quoted 7 lines
toolchain/toolchain-bare-metal-buildroot/Config.in +2 -0
+	  definition:
+	  "microblazeel-xilinx-elf riscv32-xilinx-elf"

In fact, I'm not sure the "xilinx" parts of the tuples here are very relevant/useful. It's the vendor part of the tuple, so it has basically no effect. It would probably be even more logical to use microblazel-none-elf, or even microblazeel-buildroot-elf.

Since we are using Buildroot to build these toolchains, I will use Buildroot as the vendor. I will probably update the xilinx-embeddedsw package to use Buildroot as the toolchain vendor as well.

Quoted 7 lines

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com

Thanks again!

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

#8 lore raw
In reply to Neal Frager via buildroot

Hello Neal,

Thanks for your work on this topic. Overall, the approach you have taken is exactly what I had in mind, so that's very good. I only have some implementation details to comment on below.

package/binutils-bare-metal/binutils-bare-metal.mk HOST_BINUTILS_BARE_METAL_CONF_ENV += MAKEINFO=true · line 30

Quoted 7 lines · On Fri, 14 Feb 2025 16:53:59 +0000 Neal Frager via buildroot…
package/binutils-bare-metal/binutils-bare-metal.mk +7 -0
+# to build for multiple arch tuples, it is necesssary to build out of the
+# source tree, so that each arch tuple can have its own build location
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		ln -sf ../configure $(@D)/build-$(arch_tuple)/configure;)
+endef

You don't need to create a symlink. We do that in gcc because we're using <pkg>_SUBDIR, with which the default CONFIGURE_CMDS from autotools-package assumes the configure script will be in the <pkg>_SUBDIR. But here, since we are anyway implementing our custom CONFIGURE_CMDS, creating this symlink is not needed. So I would drop this HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS entirely.

See below how things would work.

package/binutils-bare-metal/binutils-bare-metal.mk HOST_BINUTILS_BARE_METAL_CONF_ENV += MAKEINFO=true · line 35

Quoted 5 lines
package/binutils-bare-metal/binutils-bare-metal.mk +5 -0
+
+HOST_BINUTILS_BARE_METAL_PRE_CONFIGURE_HOOKS += HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS
+
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \

Add here:

		mkdir -p $(@D)/build-$(arch_tuple) && \

package/binutils-bare-metal/binutils-bare-metal.mk HOST_BINUTILS_BARE_METAL_CONF_ENV += MAKEINFO=true · line 39

Quoted 4 lines
package/binutils-bare-metal/binutils-bare-metal.mk +4 -0
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		./configure \

Replace with:

../configure

or:

		$(@D)/configure

whichever you prefer.

Quoted 10 lines
package/binutils-bare-metal/binutils-bare-metal.mk +10 -0
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--enable-shared --disable-static \
+			--disable-gtk-doc \
+			--disable-gtk-doc-html \
+			--disable-doc \
+			--disable-docs \
+			--disable-documentation \
+			--disable-debug \

package/binutils-bare-metal/binutils-bare-metal.mk HOST_BINUTILS_BARE_METAL_CONF_ENV += MAKEINFO=true · line 59

Quoted 10 lines
package/binutils-bare-metal/binutils-bare-metal.mk +10 -0
+			--with-xmlto=no \
+			--with-fop=no \
+			--disable-nls \
+			--disable-dependency-tracking \
+			--target=$(arch_tuple) \
+			--disable-gprof \
+			--enable-lto \
+			--disable-initfini-array \
+			--disable-multilib \
+			--disable-werror; \

I think the final semi-colon here is not needed.

package/binutils-bare-metal/binutils-bare-metal.mk HOST_BINUTILS_BARE_METAL_CONF_ENV += MAKEINFO=true · line 67

Quoted 8 lines
package/binutils-bare-metal/binutils-bare-metal.mk +8 -0
+	)
+endef
+
+define HOST_BINUTILS_BARE_METAL_BUILD_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_BINUTILS_BARE_METAL_MAKE_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)

Instead of this final semi-colon, put the closing parenthesis on the next line, so that the loop looks like this:

	$(foreach bla,$(list),
		something
	)

package/binutils-bare-metal/binutils-bare-metal.mk HOST_BINUTILS_BARE_METAL_CONF_ENV += MAKEINFO=true · line 74

Quoted 7 lines
package/binutils-bare-metal/binutils-bare-metal.mk +7 -0
+endef
+
+define HOST_BINUTILS_BARE_METAL_INSTALL_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_BINUTILS_BARE_METAL_INSTALL_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)

Ditto here.

Thanks!

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
#9 lore raw

Hello Thomas,

Quoted 17 lines

Hello Neal,

Thanks for your work on this topic. Overall, the approach you have taken is exactly what I had in mind, so that's very good. I only have some implementation details to comment on below.

On Fri, 14 Feb 2025 16:53:59 +0000
Neal Frager via buildroot <[email protected]> wrote:

package/binutils-bare-metal/binutils-bare-metal.mk +7 -0
+# to build for multiple arch tuples, it is necesssary to build out of the
+# source tree, so that each arch tuple can have its own build location
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		ln -sf ../configure $(@D)/build-$(arch_tuple)/configure;)
+endef
Quoted 6 lines

You don't need to create a symlink. We do that in gcc because we're using <pkg>_SUBDIR, with which the default CONFIGURE_CMDS from autotools-package assumes the configure script will be in the <pkg>_SUBDIR. But here, since we are anyway implementing our custom CONFIGURE_CMDS, creating this symlink is not needed. So I would drop this HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS entirely.

Lovely!

Quoted 19 lines

See below how things would work.

package/binutils-bare-metal/binutils-bare-metal.mk +5 -0
+
+HOST_BINUTILS_BARE_METAL_PRE_CONFIGURE_HOOKS += HOST_BINUTILS_BARE_METAL_CONFIGURE_SYMLINKS
+
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \

Add here:

		mkdir -p $(@D)/build-$(arch_tuple) && \
package/binutils-bare-metal/binutils-bare-metal.mk +4 -0
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		./configure \

Replace with:

Quoted 7 lines

../configure

or:

		$(@D)/configure

whichever you prefer.

I confirm this works. Thank you!

Quoted 21 lines
package/binutils-bare-metal/binutils-bare-metal.mk +20 -0
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--enable-shared --disable-static \
+			--disable-gtk-doc \
+			--disable-gtk-doc-html \
+			--disable-doc \
+			--disable-docs \
+			--disable-documentation \
+			--disable-debug \
+			--with-xmlto=no \
+			--with-fop=no \
+			--disable-nls \
+			--disable-dependency-tracking \
+			--target=$(arch_tuple) \
+			--disable-gprof \
+			--enable-lto \
+			--disable-initfini-array \
+			--disable-multilib \
+			--disable-werror; \
Quoted 1 line

I think the final semi-colon here is not needed.

Without the semi-colon, I get the following configure error:

configure: WARNING: you should use --build, --host, --target
configure: error: unrecognized option: `-p'

It seems that the loop wraps around the next mkdir instruction with the configure unless the instructions are separated with a semi-colon.

However, you are correct that the semi-colon is not needed for the build and install steps since these are single instruction loops.

Quoted 9 lines
package/binutils-bare-metal/binutils-bare-metal.mk +8 -0
+	)
+endef
+
+define HOST_BINUTILS_BARE_METAL_BUILD_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_BINUTILS_BARE_METAL_MAKE_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)
Quoted 6 lines

Instead of this final semi-colon, put the closing parenthesis on the next line, so that the loop looks like this:

	$(foreach bla,$(list),
		something
	)

Done. Thanks!

Quoted 9 lines
package/binutils-bare-metal/binutils-bare-metal.mk +7 -0
+endef
+
+define HOST_BINUTILS_BARE_METAL_INSTALL_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		$(HOST_MAKE_ENV) $(MAKE) \
+			$(HOST_BINUTILS_BARE_METAL_INSTALL_OPTS) \
+			-C $(@D)/build-$(arch_tuple);)

Ditto here.

Done. Thanks!

Quoted 7 lines

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com

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

#10 lore raw
Quoted 10 lines · Neal via buildroot

Hello Thomas,

Quoted 8 lines

Hello Neal,

Thanks for your work on this topic. Overall, the approach you have taken is exactly what I had in mind, so that's very good. I only have some implementation details to comment on below.

On Fri, 14 Feb 2025 16:53:59 +0000
Neal Frager via buildroot <[email protected]> wrote:

[snip]

Quoted 8 lines
Quoted 5 lines
package/binutils-bare-metal/binutils-bare-metal.mk +3 -0
+			--disable-initfini-array \
+			--disable-multilib \
+			--disable-werror; \

I think the final semi-colon here is not needed.

Without the semi-colon, I get the following configure error:

Quoted 8 lines

configure: WARNING: you should use --build, --host, --target
configure: error: unrecognized option: `-p'

It seems that the loop wraps around the next mkdir instruction with the configure unless the instructions are separated with a semi-colon.

However, you are correct that the semi-colon is not needed for the build and install steps since these are single instruction loops.

That shouldn't make any difference though - the newline and the leading tab
tell make that this is a new command. It shouldn't make a difference to 'make' if there are one or more commands on the line.

Also, where does that '-p' even come from? I don't see it anywhere in the
configure commands...

Regards,
Arnout

[snip]

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

#11 lore raw

Hello Arnout,

Quoted 10 lines

Hello Thomas,

Quoted 8 lines

Hello Neal,

Thanks for your work on this topic. Overall, the approach you have taken is exactly what I had in mind, so that's very good. I only have some implementation details to comment on below.

On Fri, 14 Feb 2025 16:53:59 +0000
Neal Frager via buildroot <[email protected]> wrote:

[snip]

Quoted 17 lines
Quoted 5 lines
package/binutils-bare-metal/binutils-bare-metal.mk +3 -0
+                    --disable-initfini-array \
+                    --disable-multilib \
+                    --disable-werror; \

I think the final semi-colon here is not needed.

Without the semi-colon, I get the following configure error:

configure: WARNING: you should use --build, --host, --target
configure: error: unrecognized option: `-p'

It seems that the loop wraps around the next mkdir instruction with the configure unless the instructions are separated with a semi-colon.

However, you are correct that the semi-colon is not needed for the build and install steps since these are single instruction loops.

Quoted 6 lines

That shouldn't make any difference though - the newline and the leading tab
tell make that this is a new command. It shouldn't make a difference to 'make' if there are one or more commands on the line.

Also, where does that '-p' even come from? I don't see it anywhere in the configure commands...

I agree it should not be needed.

But if you look at v3 of this series and remove the semi-colon from the end of the configure command, you will see this error with the -p seeming to come from the mkdir command which is the first command to run in the next iteration of the loop.

Best regards,
Neal Frager
AMD

[snip]

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

#12 lore raw
Quoted 36 lines · Neal

Hello Arnout,

Quoted 10 lines

Hello Thomas,

Quoted 8 lines

Hello Neal,

Thanks for your work on this topic. Overall, the approach you have taken is exactly what I had in mind, so that's very good. I only have some implementation details to comment on below.

On Fri, 14 Feb 2025 16:53:59 +0000
Neal Frager via buildroot <[email protected]> wrote:

[snip]

Quoted 14 lines
Quoted 5 lines

+                    --disable-initfini-array \
+                    --disable-multilib \
+                    --disable-werror; \

I think the final semi-colon here is not needed.

Without the semi-colon, I get the following configure error:

configure: WARNING: you should use --build, --host, --target
configure: error: unrecognized option: `-p'

It seems that the loop wraps around the next mkdir instruction with the configure unless the instructions are separated with a semi-colon.

Quoted 8 lines

However, you are correct that the semi-colon is not needed for the build and install steps since these are single instruction loops.

 That shouldn't make any difference though - the newline and the leading tab  tell make that this is a new command. It shouldn't make a difference to 'make' if there are one or more commands on the line.

 Also, where does that '-p' even come from? I don't see it anywhere in the configure commands...

Quoted 8 lines

I agree it should not be needed.

But if you look at v3 of this series and remove the semi-colon from the end of the configure command, you will see this error with the -p seeming to come from the mkdir command which is the first command to run in the next iteration of the loop.

The trailing \ puts the two commands on the same line. For the other two you
didn't add a trailing backslash so it's different lines...

Can be fixed while applying.

Regards,
Arnout

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

#13 lore raw

Hello Arnout,

Quoted 46 lines

Hello Arnout,

Quoted 10 lines

Hello Thomas,

Quoted 8 lines

Hello Neal,

Thanks for your work on this topic. Overall, the approach you have taken is exactly what I had in mind, so that's very good. I only have some implementation details to comment on below.

On Fri, 14 Feb 2025 16:53:59 +0000
Neal Frager via buildroot <[email protected]> wrote:

[snip]

Quoted 17 lines
Quoted 5 lines

+                    --disable-initfini-array \
+                    --disable-multilib \
+                    --disable-werror; \

I think the final semi-colon here is not needed.

Without the semi-colon, I get the following configure error:

configure: WARNING: you should use --build, --host, --target
configure: error: unrecognized option: `-p'

It seems that the loop wraps around the next mkdir instruction with the configure unless the instructions are separated with a semi-colon.

However, you are correct that the semi-colon is not needed for the build and install steps since these are single instruction loops.

Quoted 6 lines

 That shouldn't make any difference though - the newline and the leading tab tell make that this is a new command. It shouldn't make a difference to 'make' if there are one or more commands on the line.

 Also, where does that '-p' even come from? I don't see it anywhere in the configure commands...

I agree it should not be needed.

But if you look at v3 of this series and remove the semi-colon from the end of the configure command, you will see this error with the -p seeming to come from the mkdir command which is the first command to run in the next iteration of the loop.

Quoted 4 lines

The trailing \ puts the two commands on the same line. For the other two you
didn't add a trailing backslash so it's different lines...

Can be fixed while applying.

Thank you!!! I knew it had to be something obvious.

Quoted 2 lines

Regards,
Arnout

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