Index | Thread | Search

From:
Jeremie Courreges-Anglas <jca@wxcvbn.org>
Subject:
Re: new net/ipxe
To:
Klemens Nanni <kn@openbsd.org>
Cc:
ports <ports@openbsd.org>
Date:
Sun, 21 Dec 2025 13:42:32 +0100

Download raw body.

Thread
On Sat, Dec 13, 2025 at 05:07:39PM +0000, Klemens Nanni wrote:
> 22.11.2025 14:48, Klemens Nanni пишет:
> > The port itself supports any architecture, but builds only amd64 and arm64
> > as others have not been tested (riscv64 and loongson might be of interest).
> > 
> > It requires GNU tools incl. compiler and linker, we have everything except
> > - ports@ "binutils: enable ld.bfd ?"
> > 
> > Once all knobs and found and set properly, GNU make compiles all files
> > always compiles all files (see https://dox.ipxe.org/ifdef_harmful.html)
> > and then links targets according to config.
> > 
> > I want to be able to serve images for several architectures from a single
> > netboot server and avoid cross compilation, so this port uses MACHINE_ARCH
> > in PKGNAME and sets PKG_ARCH=*;  per-arch files don't conflict and even
> > per-platform (e.g. EFI or BIOS) files seem to end up with unique tuples
> > of what upstream calls drivers and extensions, see Files below as well as
> > https://ipxe.org/appnote/buildtargets.
> > 
> > Then I can serve, e.g. ipxe.efi over TFTP or HTTP and further do whatever
> > on the clients, for example through autoexec.ipxe, which it tries to load
> > from the server by default.
> Here's an updated and tidied version.  As with binutils, I left support and
> merely omitted/commented arm64 in ONLY_FOR_ARCHS.
> 
> The port is available in openbsd-wip.
> 
> Feedback? OK to import once ports@ "binutils: enable ld.bfd ?" is settled?

Not ok as is.  Quoting my latest reply to the ld.bfd thread:
|I still think that's the wrong way to go.  I see no point tying our
|hands with building standalone programs using a generic "native
|ports-gcc" + "native devel/binutils" toolchain, when all that is
|needed is a freestanding toolchain.
|
|Who will fix net/ipxe when it's on the way of a ports-gcc or devel/gas
|update?  On this matter: you've explicitely made the devel/gas and
|devel/binutils ports tightly bound, making it impossible to update
|devel/gas without updating devel/binutils.  Someone updating devel/gas
|would then feel forced to check that the new devel/binutils version
|can still build net/ipxe on all architectures where it is enabled.
|
|All of this disappears if you use cross-compiling with a stable
|toolchain like u-boot does.

The diff below is a *PoC* to build ipxe for aarch64 using
devel/arm-none-eabi/*,aarch64, allowing us to cross-compile from amd64
and others if desired (tested, build succeeds then fails at pcbios,
but this is only a PoC).  _I haven't tested the resulting aarch64
standalone executables_.

Obviously such a freestanding toolchain doesn't exist for i386/x86_64,
so we'd have to add that first if we wanted to go on the same path for
all architectures.  Since I don't have a need for such a toolchain,
I'm not volunteering for the job.


diff --git net/ipxe/Makefile net/ipxe/Makefile
index 6650348b1..e52b7259c 100644
--- net/ipxe/Makefile
+++ net/ipxe/Makefile
@@ -2,7 +2,7 @@
 # arm     arm32   arm64   i386    loong64 riscv   riscv32 riscv64 x86     x86_64
 #
 # arm64 builds and boots, but see devel/binutils LD_ARCHS comment
-ONLY_FOR_ARCHS =	amd64
+ONLY_FOR_ARCHS =	aarch64 amd64
 
 CATEGORIES =		net firmware
 COMMENT =		PXE network boot firmware
@@ -41,27 +41,17 @@ PERMIT_PACKAGE =	Yes
 
 MAINTAINER =		Klemens Nanni <kn@openbsd.org>
 
-# Only GNU tools are suported.
-COMPILER =		ports-gcc
-COMPILER_LANGS =	c
 USE_GMAKE =		Yes
-MAKE_FLAGS =		CC=${CC} \
+MAKE_FLAGS =		CC=aarch64-none-elf-gcc \
+			HOST_CC="${CC}" \
 			HOST_CFLAGS=${HOST_CFLAGS:Q} \
 			V=1 \
 			VERSION=${VERSION:Q}
-# arch/x86/prefix/romprefix.S:911: Error: unknown pseudo-op: `.reloc'
-# objcopy: unrecognized option `--enable-deterministic-archives'
-# base ld.bfd(1) 2.17 segfaults, base ld.lld(1) always fails:
-# ld: error: section .text file range overlaps with .shstrtab
-# ld: error: output file too large: 18446744073709485768 bytes
-GNU_UTILS =		as objcopy ld
-.for util in ${GNU_UTILS}
-MAKE_FLAGS +=		${util:U}=/usr/local/bin/g${util}
-.endfor
-# Disable stack protector guard in Makefile.efi:
-# ... undefined reference to `__guard_local'
-# ... undefined reference to `__stack_smash_handler'
-MAKE_FLAGS +=		SPG_TEST=false
+MAKE_FLAGS +=		AS=aarch64-none-elf-as
+MAKE_FLAGS +=		LD=aarch64-none-elf-ld
+MAKE_FLAGS +=		OBJDUMP=aarch64-none-elf-objdump
+MAKE_FLAGS +=		OBJCOPY=aarch64-none-elf-objcopy
+MAKE_FLAGS +=		RANLIB=aarch64-none-elf-ranlib
 
 # Avoid package changes on rebuilds.
 BUILD_ID_CMD =		cksum -s OpenBSD -q | cut -d' ' -f1
@@ -69,24 +59,24 @@ MAKE_FLAGS +=		BUILD_ID_CMD=${BUILD_ID_CMD:Q} \
 			SOURCE_DATE_EPOCH=0
 
 BUILD_DEPENDS =		archivers/xz \
-			devel/binutils>=2.45.1p1 \
-			devel/gas \
 			sysutils/libisoburn,-xorriso \
 			sysutils/mtools \
 			sysutils/truncate
+BUILD_DEPENDS +=	devel/arm-none-eabi/gcc,aarch64
+BUILD_DEPENDS +=	devel/arm-none-eabi/binutils,aarch64
 
 # lzma.h
 HOST_CFLAGS +=		-I/usr/local/include
 
 # Default is i386, see ONLY_FOR_ARCHS comment.
-_ARCH =			${MACHINE_ARCH:amd64=x86_64}
-MAKE_FLAGS +=		ARCH=${_ARCH}
+_ARCH =			${MACHINE_ARCH:aarch64=arm64}
+MAKE_FLAGS +=		ARCH=arm64
 
 # See https://ipxe.org/appnote/buildtargets for all supported variations.
 PLATFORMS ?=		# empty, no architecture-independent default
 
 .if ${MACHINE_ARCH:Mamd64} || \
-    ${MACHINE_ARCH:Marm64}
+    ${MACHINE_ARCH:Maarch64}
 PLATFORMS +=		efi
 DRIVERS-efi =		ipxe snp snponly
 # USB images require some unported syslinux script/program.



-- 
jca