diff mbox series

[v9,04/11] package/newlib-bare-metal: new package

Message ID 20240131112223.2175855-4-neal.frager@amd.com
State Accepted
Headers show
Series [v9,01/11] toolchain/toolchain-bare-metal-buildroot: new toolchain | expand

Commit Message

Neal Frager Jan. 31, 2024, 11:22 a.m. UTC
This patch adds a new package for building newlib for a bare-metal toolchain.
The cpu architecture is defined by a toolchain-bare-metal virtual package.
While any cpu architecture could be used, the default configuration will be a
Xilinx microblaze little endian architecture, so that buildroot will be able
to build the microblaze firmware applications for zynqmp and versal.

Signed-off-by: Neal Frager <neal.frager@amd.com>
Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@amd.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
---
V1->V2:
 - removed default enable to be replaced with toolchain select config
V2->V3:
 - no changes
V3->V4:
 - replaced unnecessary =? with = for assignments
 - improved menuconfig help comment
V4->V5:
 - added license files
 - reduced all lines to <80 chars
V5->V6:
 - migrated to toolchain-bare-metal-buildroot
V6->V7:
 - hard-coded version
 - converted to target package with gcc-bare-metal sysroot install
V7->V8:
 - no changes
V8->V9:
 - bumped to version 4.4.0
---
 DEVELOPERS                                    |  2 +
 package/newlib-bare-metal/Config.in           |  2 +
 .../newlib-bare-metal/newlib-bare-metal.hash  |  8 +++
 .../newlib-bare-metal/newlib-bare-metal.mk    | 52 +++++++++++++++++++
 4 files changed, 64 insertions(+)
 create mode 100644 package/newlib-bare-metal/Config.in
 create mode 100644 package/newlib-bare-metal/newlib-bare-metal.hash
 create mode 100644 package/newlib-bare-metal/newlib-bare-metal.mk

Comments

Michaelis, Adam J Collins via buildroot Feb. 2, 2024, 12:11 p.m. UTC | #1
Hi Thomas,

Have you had a chance to look at v9 of the bare-metal patch set?

> +
> +define NEWLIB_BARE_METAL_FIXUP
> +	mv $(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE)/include \
> +		$(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/include
> +	mv $(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE)/lib \
> +		$(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/lib
> +endef
> +NEWLIB_BARE_METAL_POST_INSTALL_STAGING_HOOKS += NEWLIB_BARE_METAL_FIXUP
> +
> +$(eval $(generic-package))

There are two things I wish to highlight.

1. Thanks to the binutils 2.42 release, we do not need microblaze patches
anymore.

2. I chose to keep the newlib fixup. Even though the --with-tooldir patch was
accepted upstream, newlib requires autoconf 2.69 for this patch to be applied.
So rather than including a version of the patch that works on the output
configure script directly, I thought it would be better to just keep the fixup
for now.  We can remove the fixup with the next newlib release which will have
a configurable --with-tooldir option.

What are your thoughts?  Do you think any more changes are needed before
applying this bare-metal toolchain patch set?

Thank you for your support.

Best regards,
Neal Frager
AMD
Thomas Petazzoni Feb. 6, 2024, 5:52 p.m. UTC | #2
On Wed, 31 Jan 2024 11:22:16 +0000
Neal Frager via buildroot <buildroot@buildroot.org> wrote:

> This patch adds a new package for building newlib for a bare-metal toolchain.
> The cpu architecture is defined by a toolchain-bare-metal virtual package.
> While any cpu architecture could be used, the default configuration will be a
> Xilinx microblaze little endian architecture, so that buildroot will be able
> to build the microblaze firmware applications for zynqmp and versal.
> 
> Signed-off-by: Neal Frager <neal.frager@amd.com>
> Signed-off-by: Ibai Erkiaga <ibai.erkiaga-elorza@amd.com>
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> ---
> V1->V2:
>  - removed default enable to be replaced with toolchain select config
> V2->V3:
>  - no changes
> V3->V4:
>  - replaced unnecessary =? with = for assignments
>  - improved menuconfig help comment
> V4->V5:
>  - added license files
>  - reduced all lines to <80 chars
> V5->V6:
>  - migrated to toolchain-bare-metal-buildroot
> V6->V7:
>  - hard-coded version
>  - converted to target package with gcc-bare-metal sysroot install
> V7->V8:
>  - no changes
> V8->V9:
>  - bumped to version 4.4.0
> ---
>  DEVELOPERS                                    |  2 +
>  package/newlib-bare-metal/Config.in           |  2 +
>  .../newlib-bare-metal/newlib-bare-metal.hash  |  8 +++
>  .../newlib-bare-metal/newlib-bare-metal.mk    | 52 +++++++++++++++++++
>  4 files changed, 64 insertions(+)
>  create mode 100644 package/newlib-bare-metal/Config.in
>  create mode 100644 package/newlib-bare-metal/newlib-bare-metal.hash
>  create mode 100644 package/newlib-bare-metal/newlib-bare-metal.mk

Applied to master, thanks.

Thomas
Thomas Petazzoni Feb. 6, 2024, 5:53 p.m. UTC | #3
On Fri, 2 Feb 2024 12:11:29 +0000
"Frager, Neal via buildroot" <buildroot@buildroot.org> wrote:

> 1. Thanks to the binutils 2.42 release, we do not need microblaze patches
> anymore.

Excellent!

> 2. I chose to keep the newlib fixup. Even though the --with-tooldir patch was
> accepted upstream, newlib requires autoconf 2.69 for this patch to be applied.
> So rather than including a version of the patch that works on the output
> configure script directly, I thought it would be better to just keep the fixup
> for now.  We can remove the fixup with the next newlib release which will have
> a configurable --with-tooldir option.

I think it's a reasonable trade-off indeed.

Thomas
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index af6c01c72f..057eac7845 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1388,6 +1388,7 @@  F:	package/python-rpi-gpio/
 N:	Ibai Erkiaga <ibai.erkiaga-elorza@amd.com>
 F:	package/binutils-bare-metal/
 F:	package/gcc-bare-metal/
+F:	package/newlib-bare-metal/
 F:	toolchain/toolchain-bare-metal-buildroot/
 
 N:	Ignacy Gawędzki <ignacy.gawedzki@green-communications.fr>
@@ -2245,6 +2246,7 @@  F:	configs/zynqmp_zcu106_defconfig
 F:	package/binutils-bare-metal/
 F:	package/bootgen/
 F:	package/gcc-bare-metal/
+F:	package/newlib-bare-metal/
 F:	package/versal-firmware/
 F:	toolchain/toolchain-bare-metal-buildroot/
 
diff --git a/package/newlib-bare-metal/Config.in b/package/newlib-bare-metal/Config.in
new file mode 100644
index 0000000000..1ff3d5d8ec
--- /dev/null
+++ b/package/newlib-bare-metal/Config.in
@@ -0,0 +1,2 @@ 
+config BR2_PACKAGE_NEWLIB_BARE_METAL
+	bool
diff --git a/package/newlib-bare-metal/newlib-bare-metal.hash b/package/newlib-bare-metal/newlib-bare-metal.hash
new file mode 100644
index 0000000000..f8c553cf86
--- /dev/null
+++ b/package/newlib-bare-metal/newlib-bare-metal.hash
@@ -0,0 +1,8 @@ 
+# Locally calculated
+sha256  0c166a39e1bf0951dfafcd68949fe0e4b6d3658081d6282f39aeefc6310f2f13  newlib-4.4.0.20231231.tar.gz
+
+# Hashes for license files locally calculated
+sha256  231f7edcc7352d7734a96eef0b8030f77982678c516876fcb81e25b32d68564c  COPYING
+sha256  a9bdde5616ecdd1e980b44f360600ee8783b1f99b8cc83a2beb163a0a390e861  COPYING.LIB
+sha256  f3b7f3e4426b1fa6f60198dae7adfedd94b77b28db2d108adc0253575011e0ff  COPYING.LIBGLOSS
+sha256  422aa40293093fb54fc66e692a0d68fd0b24ed5602e5d1d33ad05ba3909057e9  COPYING.NEWLIB
diff --git a/package/newlib-bare-metal/newlib-bare-metal.mk b/package/newlib-bare-metal/newlib-bare-metal.mk
new file mode 100644
index 0000000000..452bc4da25
--- /dev/null
+++ b/package/newlib-bare-metal/newlib-bare-metal.mk
@@ -0,0 +1,52 @@ 
+################################################################################
+#
+# newlib-bare-metal
+#
+################################################################################
+
+NEWLIB_BARE_METAL_VERSION = 4.4.0
+NEWLIB_BARE_METAL_SITE = ftp://sourceware.org/pub/newlib
+NEWLIB_BARE_METAL_SOURCE = newlib-$(NEWLIB_BARE_METAL_VERSION).20231231.tar.gz
+NEWLIB_BARE_METAL_DEPENDENCIES = host-gcc-bare-metal
+NEWLIB_BARE_METAL_ADD_TOOLCHAIN_DEPENDENCY = NO
+NEWLIB_BARE_METAL_LICENSE = GPL-2.0, GPL-3.0, LGPL-2.1, LGPL-3.0
+NEWLIB_BARE_METAL_LICENSE_FILES = \
+	COPYING \
+	COPYING.LIB \
+	COPYING.LIBGLOSS \
+	COPYING.NEWLIB
+
+NEWLIB_BARE_METAL_INSTALL_STAGING = YES
+NEWLIB_BARE_METAL_INSTALL_TARGET = NO
+
+define NEWLIB_BARE_METAL_CONFIGURE_CMDS
+	(cd $(@D) && \
+		PATH=$(BR_PATH) \
+		./configure \
+			--target=$(TOOLCHAIN_BARE_METAL_BUILDROOT_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 \
+	)
+endef
+
+define NEWLIB_BARE_METAL_BUILD_CMDS
+	PATH=$(BR_PATH) $(MAKE1) -C $(@D)
+endef
+
+define NEWLIB_BARE_METAL_INSTALL_STAGING_CMDS
+	PATH=$(BR_PATH) $(MAKE1) -C $(@D) DESTDIR=$(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT) install
+endef
+
+define NEWLIB_BARE_METAL_FIXUP
+	mv $(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE)/include \
+		$(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/include
+	mv $(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/$(TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH_TUPLE)/lib \
+		$(TOOLCHAIN_BARE_METAL_BUILDROOT_SYSROOT)/usr/lib
+endef
+NEWLIB_BARE_METAL_POST_INSTALL_STAGING_HOOKS += NEWLIB_BARE_METAL_FIXUP
+
+$(eval $(generic-package))