Skip to contentSkip to conversation

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

PATCH Superseded Neal Frager via buildroot 1 participant 13 messages Feb 15, 2025 – Feb 18, 2025 Arm/Zynq architecture

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/5 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
V2->V3:
- removed unnecessary symlinks
- removed unnecessary semi-colons

---
 .../binutils-bare-metal.mk                    | 54 +++++++++++++++----
 1 file changed, 45 insertions(+), 9 deletions(-)
package/binutils-bare-metal/binutils-bare-metal.mk +45 -9
index 3525e9fdf2..7a3017a12c 100644
@@ -21,14 +21,50 @@ 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
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		$(@D)/configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--disable-shared --enable-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 v3 2/5 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
V2->V3:
- removed unnecessary symlinks
- removed unnecessary semi-colons

---
 package/gcc-bare-metal/gcc-bare-metal.mk | 89 +++++++++++++++---------
 1 file changed, 58 insertions(+), 31 deletions(-)
package/gcc-bare-metal/gcc-bare-metal.mk +58 -31
index adaae6c307..c47852d759 100644
@@ -20,16 +20,6 @@ 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
-endef
-
-HOST_GCC_BARE_METAL_PRE_CONFIGURE_HOOKS += HOST_GCC_BARE_METAL_CONFIGURE_SYMLINK
-HOST_GCC_BARE_METAL_SUBDIR = build
-
 HOST_GCC_BARE_METAL_MAKE_OPTS = \
 	$(HOST_GCC_COMMON_MAKE_OPTS) \
 	all-gcc \
@@ -37,26 +27,63 @@ 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), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(@D)/configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--disable-shared --enable-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

PATCH v3 3/5 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
V2->V3:
- removed unnecessary symlinks
- removed unnecessary semi-colons

---
 .../newlib-bare-metal/newlib-bare-metal.mk    | 24 +++++++++++++------
 1 file changed, 17 insertions(+), 7 deletions(-)
package/newlib-bare-metal/newlib-bare-metal.mk +17 -7
index e28e7a717c..c0da38dca9 100644
@@ -23,27 +23,37 @@ NEWLIB_BARE_METAL_INSTALL_TARGET = NO
 NEWLIB_BARE_METAL_MAKE_OPTS = MAKEINFO=true
 
 define NEWLIB_BARE_METAL_CONFIGURE_CMDS
-	(cd $(@D) && \
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		cd $(@D)/build-$(arch_tuple) && \
 		PATH=$(BR_PATH) \
-		./configure \
-			--target=$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE) \
+		$(@D)/configure \
+			--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
#3 lore raw

PATCH v3 4/5 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
V2->V3:
- improved help text

---
 toolchain/Config.in                                  |  2 +-
 toolchain/toolchain-bare-metal-buildroot/Config.in   | 12 +++++++++---
 .../toolchain-bare-metal-buildroot.mk                |  1 -
 3 files changed, 10 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 +9 -3
index 6fe969357f..19c97410c6 100644
@@ -1,10 +1,16 @@
 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 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.
+
+	  For example, to build both a Microblaze and a RISC-V bare
+	  metal toolchain, use the following definition:
+	  "microblazeel-buildroot-elf riscv32-buildroot-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
#4 lore raw

PATCH v3 5/5 boot/xilinx-embeddedsw: change dependency

In reply to Neal Frager via buildroot

Now that BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH can contain multiple tuples, BR2_TARGET_XILINX_EMBEDDEDSW can no longer be dependent on:

depends on BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH = "microblazeel-xilinx-elf"

A valid definition could have "microblazeel-xilinx-elf" as just one of many tuples in the list.

For this reason, this patch changes the dependency to:

depends on BR2_TOOLCHAIN_BARE_METAL_BUILDROOT

One side effect of this is that the user comment will be displayed now when using multiple tuples, even if one of them is the required tuple.

---
V1->V3:
- new patch with V3 of series

---
 boot/xilinx-embeddedsw/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
boot/xilinx-embeddedsw/Config.in +1 -1
index 757ff59e35..b0691d7e7b 100644
@@ -1,7 +1,7 @@
 config BR2_TARGET_XILINX_EMBEDDEDSW
 	bool "xilinx-embeddedsw"
 	depends on BR2_aarch64
-	depends on BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH = "microblazeel-xilinx-elf"
+	depends on BR2_TOOLCHAIN_BARE_METAL_BUILDROOT
 	help
 	  Build boot firmware applications from source for Xilinx
 	  boards. Users can mix and match applications to be built
Signature · 6 lines
2.25.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw
In reply to Neal Frager via buildroot
Quoted 42 lines · Neal Frager via buildroot

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

---
V1->V2:
- no changes
V2->V3:
- removed unnecessary symlinks
- removed unnecessary semi-colons

---
  .../binutils-bare-metal.mk                    | 54 +++++++++++++++----
  1 file changed, 45 insertions(+), 9 deletions(-)
package/binutils-bare-metal/binutils-bare-metal.mk +11 -9
index 3525e9fdf2..7a3017a12c 100644
@@ -21,14 +21,50 @@ 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_BUILDR OOT_ARCH_TUPLE) \
-	--disable-gprof \
-	--disable-shared \
-	--enable-lto \
-	--enable-static \
-	--disable-initfini-array \
-	--disable-multilib \
-	--disable-werror
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		$(@D)/configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--disable-shared --enable-static \

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

Quoted 10 lines
package/binutils-bare-metal/binutils-bare-metal.mk +10 -0
+			--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 \

It's a bit confusing to me... All of the above are copied from
host-autotools-package, except:

- --enable-shared --disable-static is reverted (because that's what binutils.mk does);
- $(if $($(PKG)_OVERRIDE_SRCDIR),,...) is dropped
- $(QUIET) is dropped
- CFLAGS and LDFLAGS environment variables are dropped
- CONFIG_SITE is dropped.

For the latter four, I don't see why they should be dropped.

In addition, there are a lot of configure options that don't exist. We add
them to the generic autotools infra because unknown options are ignored (with a warning) and it saves a lot of repetition in autotools package, but here we could include just the options that actually exist.

I think we have two possibilities here: either we use the stuff from
autotools-package _exactly_ and just add to it (perhaps even keeping HOST_BINUTILS_BARE_METAL_CONF_OPTS as a variable) or we adapt the entire thing to precisely what is needed and useful for host-binutils-baremetal (so dropping all the useless options). Either option works for me.

In the first case, we could even rewrite the autotools infra so all the common
stuff gets put in variables HOST_CONF_ENV and HOST_CONF_OPTS.

Regards,
Arnout

Quoted 16 lines
package/binutils-bare-metal/binutils-bare-metal.mk +16 -0
+			--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

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

Quoted 10 lines
package/binutils-bare-metal/binutils-bare-metal.mk +8 -0
+
+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))

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

#6 lore raw

Hi Arnout,

Quoted 77 lines

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

---
V1->V2:
- no changes
V2->V3:
- removed unnecessary symlinks
- removed unnecessary semi-colons

---
  .../binutils-bare-metal.mk                    | 54 +++++++++++++++----
  1 file changed, 45 insertions(+), 9 deletions(-)
package/binutils-bare-metal/binutils-bare-metal.mk +21 -9
index 3525e9fdf2..7a3017a12c 100644
@@ -21,14 +21,50 @@ 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_BUILDR OOT_ARCH_TUPLE) \
-	--disable-gprof \
-	--disable-shared \
-	--enable-lto \
-	--enable-static \
-	--disable-initfini-array \
-	--disable-multilib \
-	--disable-werror
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		$(@D)/configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--disable-shared --enable-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 \
 
 It's a bit confusing to me... All of the above are copied from 

host-autotools-package, except:

- --enable-shared --disable-static is reverted (because that's what binutils.mk does);
- $(if $($(PKG)_OVERRIDE_SRCDIR),,...) is dropped
- $(QUIET) is dropped
- CFLAGS and LDFLAGS environment variables are dropped
- CONFIG_SITE is dropped.

For the latter four, I don't see why they should be dropped.

In addition, there are a lot of configure options that don't exist. We add
them to the generic autotools infra because unknown options are ignored (with a warning) and it saves a lot of repetition in autotools package, but here we could include just the options that actually exist.

I think we have two possibilities here: either we use the stuff from
autotools-package _exactly_ and just add to it (perhaps even keeping HOST_BINUTILS_BARE_METAL_CONF_OPTS as a variable) or we adapt the entire thing to precisely what is needed and useful for host-binutils-baremetal (so dropping all the useless options). Either option works for me.

Quoted 5 lines

In the first case, we could even rewrite the autotools infra so all the common
stuff gets put in variables HOST_CONF_ENV and HOST_CONF_OPTS.

Regards,
Arnout

I agree with you, and was already thinking along the same path for v4. To be transparent, I always find the software development goes quicker when I have active participation from maintainers like yourself. This is why I submitted the patch set as soon as I had something that was "working". Cleaning it up with your help has always been much quicker than my taking the time to do it all by myself.

That said, I am thinking the first option is the better one. For v4, I will wrap up all the common autotools environment and conf options in variables HOST_CONF_ENV and HOST_CONF_OPTS without changing anything to avoid unexpected consequences of other packages dependent on the autotools infrastructure.

I will also bring back the HOST_BINUTILS_BARE_METAL_CONF_OPTS and HOST_GCC_BARE_METAL_CONF_OPTS to include only the options needed by these packages and nothing more.

Once this is done, I think the patch set should be ready to go.

Thanks for your help!

Best regards,
Neal Frager
AMD

Quoted 16 lines
package/binutils-bare-metal/binutils-bare-metal.mk +16 -0
+			--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

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

Quoted 10 lines
package/binutils-bare-metal/binutils-bare-metal.mk +8 -0
+
+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))

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

#7 lore raw

Hi Arnout,

Quoted 95 lines

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

---
V1->V2:
- no changes
V2->V3:
- removed unnecessary symlinks
- removed unnecessary semi-colons

---
  .../binutils-bare-metal.mk                    | 54 +++++++++++++++----
  1 file changed, 45 insertions(+), 9 deletions(-)
package/binutils-bare-metal/binutils-bare-metal.mk +21 -9
index 3525e9fdf2..7a3017a12c 100644
@@ -21,14 +21,50 @@ 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_BUILDR OOT_ARCH_TUPLE) \
-	--disable-gprof \
-	--disable-shared \
-	--enable-lto \
-	--enable-static \
-	--disable-initfini-array \
-	--disable-multilib \
-	--disable-werror
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		$(@D)/configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--disable-shared --enable-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 \
 
 It's a bit confusing to me... All of the above are copied from 

host-autotools-package, except:

- --enable-shared --disable-static is reverted (because that's what binutils.mk does);
- $(if $($(PKG)_OVERRIDE_SRCDIR),,...) is dropped
- $(QUIET) is dropped
- CFLAGS and LDFLAGS environment variables are dropped
- CONFIG_SITE is dropped.

For the latter four, I don't see why they should be dropped.

In addition, there are a lot of configure options that don't exist. We add
them to the generic autotools infra because unknown options are ignored (with a warning) and it saves a lot of repetition in autotools package, but here we could include just the options that actually exist.

I think we have two possibilities here: either we use the stuff from
autotools-package _exactly_ and just add to it (perhaps even keeping HOST_BINUTILS_BARE_METAL_CONF_OPTS as a variable) or we adapt the entire thing to precisely what is needed and useful for host-binutils-baremetal (so dropping all the useless options). Either option works for me.

In the first case, we could even rewrite the autotools infra so all the common
stuff gets put in variables HOST_CONF_ENV and HOST_CONF_OPTS.

Regards,
Arnout

I agree with you, and was already thinking along the same path for v4. To be transparent, I always find the software development goes quicker when I have active participation from maintainers like yourself. This is why I submitted the patch set as soon as I had something that was "working". Cleaning it up with your help has always been much quicker than my taking the time to do it all by myself.

That said, I am thinking the first option is the better one. For v4, I will wrap up all the common autotools environment and conf options in variables HOST_CONF_ENV and HOST_CONF_OPTS without changing anything to avoid unexpected consequences of other packages dependent on the autotools infrastructure.

Quoted 7 lines

I will also bring back the HOST_BINUTILS_BARE_METAL_CONF_OPTS and HOST_GCC_BARE_METAL_CONF_OPTS to include only the options needed by these packages and nothing more.

Once this is done, I think the patch set should be ready to go.

Thanks for your help!

I take back my previous opinion. Looking closer at the autotools infrastructure, we would need to handle wrapping up the conf options as variables for both target options and host options to do it right.

Since there would not be any packages using the target options wrapped up configs, I think it is probably more prudent that I just create config options for binutils-bare-metal and gcc-bare-metal that only include what is applicable from the autotools configuration and nothing more.

Best regards,
Neal Frager
AMD

Quoted 16 lines
package/binutils-bare-metal/binutils-bare-metal.mk +16 -0
+			--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

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

Quoted 10 lines
package/binutils-bare-metal/binutils-bare-metal.mk +8 -0
+
+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))

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

#8 lore raw
In reply to Arnout Vandecappelle via buildroot

Hi Arnout,

Quoted 54 lines

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

---
V1->V2:
- no changes
V2->V3:
- removed unnecessary symlinks
- removed unnecessary semi-colons

---
  .../binutils-bare-metal.mk                    | 54 +++++++++++++++----
  1 file changed, 45 insertions(+), 9 deletions(-)
package/binutils-bare-metal/binutils-bare-metal.mk +21 -9
index 3525e9fdf2..7a3017a12c 100644
@@ -21,14 +21,50 @@ 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_BUILDR OOT_ARCH_TUPLE) \
-	--disable-gprof \
-	--disable-shared \
-	--enable-lto \
-	--enable-static \
-	--disable-initfini-array \
-	--disable-multilib \
-	--disable-werror
+define HOST_BINUTILS_BARE_METAL_CONFIGURE_CMDS
+	$(foreach arch_tuple, $(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE), \
+		mkdir -p $(@D)/build-$(arch_tuple) && \
+		cd $(@D)/build-$(arch_tuple) && \
+		$(HOST_CONFIGURE_OPTS) \
+		$(HOST_BINUTILS_BARE_METAL_CONF_ENV) \
+		$(@D)/configure \
+			--prefix=$(HOST_DIR) \
+			--sysconfdir=$(HOST_DIR)/etc \
+			--localstatedir=$(HOST_DIR)/var \
+			--disable-shared --enable-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 \
 
 It's a bit confusing to me... All of the above are copied from 
Quoted 1 line

host-autotools-package, except:

Looking closer at these:

Quoted 1 line

- --enable-shared --disable-static is reverted (because that's what binutils.mk

does);

--dis/enable-static does not appear to be a configure option for either binutils or gcc, so I will remove it.

I am keeping --disable-shared however.

Quoted 1 line

- $(if $($(PKG)_OVERRIDE_SRCDIR),,...) is dropped

Not sure it makes sense to do this if check when we are in the package in question. The infrastructure needs to check whether the SRCDIR is overwritten for each package, but since we are in the package, we know SRCDIR has not been changed. So I will keep it out.

Quoted 1 line

- $(QUIET) is dropped

$(QUIET) seems to be empty. Not sure what it is for, so not sure why we should add it.

Quoted 2 lines

- CFLAGS and LDFLAGS environment variables are dropped
- CONFIG_SITE is dropped.

I agree with adding these 3.

Quoted 6 lines

For the latter four, I don't see why they should be dropped.

In addition, there are a lot of configure options that don't exist. We add
them to the generic autotools infra because unknown options are ignored (with a warning) and it saves a lot of repetition in autotools package, but here we could include just the options that actually exist.

Yes, none of these options exist in either binutils or gcc:

+ --disable-gtk-doc \
+ --disable-gtk-doc-html \
+ --disable-doc \
+ --disable-docs \
+ --disable-documentation \
+ --disable-debug \
+ --with-xmlto=no \
+ --with-fop=no \
+ --disable-nls \

So I will remove all of them.

Quoted 8 lines

I think we have two possibilities here: either we use the stuff from
autotools-package _exactly_ and just add to it (perhaps even keeping HOST_BINUTILS_BARE_METAL_CONF_OPTS as a variable) or we adapt the entire thing to precisely what is needed and useful for host-binutils-baremetal (so dropping all the useless options). Either option works for me.

In the first case, we could even rewrite the autotools infra so all the common
stuff gets put in variables HOST_CONF_ENV and HOST_CONF_OPTS.

I am going with the second option now as it is the easiest to implement and a lot of the configs in autotools do not apply to binutils or gcc.

Quoted 2 lines

Regards,
Arnout

Thanks again for your help!

Best regards,
Neal Frager
AMD

Quoted 16 lines
package/binutils-bare-metal/binutils-bare-metal.mk +16 -0
+			--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

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

Quoted 10 lines
package/binutils-bare-metal/binutils-bare-metal.mk +8 -0
+
+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))

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

#9 lore raw

On 16/02/2025 18:54, Frager, Neal wrote:
[snip]

Quoted 6 lines
Quoted 1 line

- $(if $($(PKG)_OVERRIDE_SRCDIR),,...) is dropped

Not sure it makes sense to do this if check when we are in the package in question. The infrastructure needs to check whether the SRCDIR is overwritten for each package, but since we are in the package, we know SRCDIR has not been changed. So I will keep it out.

_OVERRIDE_SRCDIR is something you set in local.mk, typically in order to try
out a patch before you commit it to a Buildroot patch (or to GLOBAL_PATCH_DIR if you're in an external). So you do actually still need that in order to stay consistent.

Quoted 4 lines
Quoted 1 line

- $(QUIET) is dropped

$(QUIET) seems to be empty. Not sure what it is for, so not sure why we should add it.

QUIET is set to -q if Buildroot is started with make -s. It makes configure
suppress almost all output.

$ make printvars VARS=QUIET
QUIET=
$ make -s printvars VARS=QUIET
QUIET=-q

[snip]

Quoted 11 lines
Quoted 8 lines

I think we have two possibilities here: either we use the stuff from
autotools-package _exactly_ and just add to it (perhaps even keeping HOST_BINUTILS_BARE_METAL_CONF_OPTS as a variable) or we adapt the entire thing to precisely what is needed and useful for host-binutils-baremetal (so dropping all the useless options). Either option works for me.

In the first case, we could even rewrite the autotools infra so all the common
stuff gets put in variables HOST_CONF_ENV and HOST_CONF_OPTS.

I am going with the second option now as it is the easiest to implement and a lot of the configs in autotools do not apply to binutils or gcc.

Make sure to explain in the commit message why they can be
removed/rewritten/whatever. It may make sense to do that in a separate patch, i.e. first copy it as is and in a second patch remove the redundant ones. Although in this case it is not really necessary - it only helps with the review and at this point we can trust that you looked at all the configure arguments.

Also make sure that the commit message explains the two options and why this
one is selected (basically what you wrote in this thread two mails before).

Regards,
Arnout

[snip]

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

#10 lore raw

Hi Arnout,

Quoted 8 lines

[snip]

Quoted 1 line

- $(if $($(PKG)_OVERRIDE_SRCDIR),,...) is dropped

Not sure it makes sense to do this if check when we are in the package in question. The infrastructure needs to check whether the SRCDIR is overwritten for each package, but since we are in the package, we know SRCDIR has not been changed. So I will keep it out.

Quoted 4 lines

_OVERRIDE_SRCDIR is something you set in local.mk, typically in order to try
out a patch before you commit it to a Buildroot patch (or to GLOBAL_PATCH_DIR if you're in an external). So you do actually still need that in order to stay consistent.

Ok. I will add it.

Quoted 5 lines
Quoted 1 line

- $(QUIET) is dropped

$(QUIET) seems to be empty. Not sure what it is for, so not sure why we should add it.

Quoted 7 lines

QUIET is set to -q if Buildroot is started with make -s. It makes configure
suppress almost all output.

$ make printvars VARS=QUIET
QUIET=
$ make -s printvars VARS=QUIET
QUIET=-q

Ok. I will add $(QUIET) as well.

Quoted 19 lines

[snip]

Quoted 8 lines

I think we have two possibilities here: either we use the stuff from
autotools-package _exactly_ and just add to it (perhaps even keeping HOST_BINUTILS_BARE_METAL_CONF_OPTS as a variable) or we adapt the entire thing to precisely what is needed and useful for host-binutils-baremetal (so dropping all the useless options). Either option works for me.

In the first case, we could even rewrite the autotools infra so all the common
stuff gets put in variables HOST_CONF_ENV and HOST_CONF_OPTS.

I am going with the second option now as it is the easiest to implement and a lot of the configs in autotools do not apply to binutils or gcc.

Make sure to explain in the commit message why they can be
removed/rewritten/whatever. It may make sense to do that in a separate patch, i.e. first copy it as is and in a second patch remove the redundant ones. Although in this case it is not really necessary - it only helps with the review and at this point we can trust that you looked at all the configure arguments.

Quoted 5 lines

Also make sure that the commit message explains the two options and why this
one is selected (basically what you wrote in this thread two mails before).

Regards,
Arnout

If it is ok with you, I would prefer to squash the changes for each package to a single commit with a clear commit message explaining the changes in detail.

On top of this, as I have been going through my due diligence will all the config options, I noticed some duplication.

CFLAGS and LDFLAGS are already defined as part of HOST_CONFIGURE_OPTS. Is this always the case? And are they always the same path definitions?

From what I am seeing, I believe we can do the following with the autotools infrastructure.

pkg-autotools.mk:

define $(2)_CONFIGURE_CMDS

	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
	$$(HOST_CONFIGURE_OPTS) \
-	CFLAGS="$$(HOST_CFLAGS)" \
-	LDFLAGS="$$(HOST_LDFLAGS)" \
	$$($$(PKG)_CONF_ENV) \
	CONFIG_SITE=/dev/null \
	./configure \

Could you verify this?

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

#11 lore raw
Quoted 17 lines · Neal

CFLAGS and LDFLAGS are already defined as part of HOST_CONFIGURE_OPTS. Is this always the case? And are they always the same path definitions?

From what I am seeing, I believe we can do the following with the autotools
infrastructure.

pkg-autotools.mk:

define $(2)_CONFIGURE_CMDS

	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
	$$(HOST_CONFIGURE_OPTS) \
(quoted diff) +0 -2
-	CFLAGS="$$(HOST_CFLAGS)" \
-	LDFLAGS="$$(HOST_LDFLAGS)" \
	$$($$(PKG)_CONF_ENV) \
	CONFIG_SITE=/dev/null \
	./configure \
Quoted 1 line

Could you verify this?

Indeed! This redundancy was introduced by Thomas 15 years ago in commit
b07030a708293756e25edd6432ed02cc53ff758e. Before that, HOST_CONFIGURE_OPTS defined

CC="$(HOSTCC) $(HOST_CFLAGS)"

which is not actually sufficient in many cases because configure wants to parse and interpret CFLAGS... So an additional CFLAGS=... had to be added in the configure call.

So yes, please remove that redundancy!

Regards,
Arnout

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

#12 lore raw

Hi Arnout,

Quoted 22 lines

CFLAGS and LDFLAGS are already defined as part of HOST_CONFIGURE_OPTS. Is this always the case? And are they always the same path definitions?

From what I am seeing, I believe we can do the following with the autotools
infrastructure.

pkg-autotools.mk:

define $(2)_CONFIGURE_CMDS

	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
	$$(HOST_CONFIGURE_OPTS) \
(quoted diff) +0 -2
-	CFLAGS="$$(HOST_CFLAGS)" \
-	LDFLAGS="$$(HOST_LDFLAGS)" \
	$$($$(PKG)_CONF_ENV) \
	CONFIG_SITE=/dev/null \
	./configure \

Could you verify this?

Indeed! This redundancy was introduced by Thomas 15 years ago in commit
b07030a708293756e25edd6432ed02cc53ff758e. Before that, HOST_CONFIGURE_OPTS defined

Quoted 7 lines

CC="$(HOSTCC) $(HOST_CFLAGS)"

which is not actually sufficient in many cases because configure wants to parse and interpret CFLAGS... So an additional CFLAGS=... had to be added in the configure call.

So yes, please remove that redundancy!

Ok! I will do that.

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