Skip to contentSkip to conversation

macOS improvements

PATCH In review Josef Schlehofer 2 participants 9 messages Oct 28 – Nov 13 Library code

lore
Share & tools
lore
#0 lore raw

cover macOS improvements

With HOST_TOOLS_ALL=y, the U-Boot host tools do not build on macOS. crc8.o does not compile and kwboot does not link. The kwboot link error also stops board builds such as turris_omnia.

Patch 1 links kwboot with the system libncurses, patch 2 removes an unused function warning in kwboot, and patch 3 keeps the sandbox asm/sections.h out of the host build of crc8.c.

Tested on macOS 27.0.1 with Apple clang 21: tools-only with HOST_TOOLS_ALL=y and the host tools of turris_omnia_defconfig now build, and kwboot boots a Turris Omnia over UART. On Linux (Debian trixie, GCC 14.2) the same tools-only build and a full turris_omnia build still pass, and kwboot still links against libtinfo.

Josef Schlehofer (3):
tools: kwboot: Link with libncurses on macOS
tools: kwboot: Define _is_within_tolerance() only with BOTHER
lib: crc8: Do not include asm/sections.h in host builds

 lib/crc8.c     | 4 +++-
 tools/Makefile | 5 +++++
 tools/kwboot.c | 2 ++
 3 files changed, 10 insertions(+), 1 deletion(-)
Signature · 1 line
2.54.0 (Apple Git-157)
#1 lore raw

PATCH 1/3 tools: kwboot: Link with libncurses on macOS

Building the host tools on macOS stops at kwboot:

ld: library 'tinfo' not found

macOS has no libtinfo. The terminfo functions that kwboot uses are in the system libncurses, and the ncurses from Homebrew installs no tinfo.pc for pkg-config to find. Link kwboot with -lncurses on macOS.

The darwin block above checks HOSTOS, which is no longer set since commit 5f520875bdf0 ("kbuild: Bump the build system to 5.1"), so check uname directly.

Tested with "make turris_omnia_defconfig tools" on macOS 27.0.1 and Apple clang 21. kwboot links against /usr/lib/libncurses.5.4.dylib and boots a Turris Omnia over UART.

Fixes e8d26e827635 ("tools: kwboot: Add support for backspace key in mini terminal")
---
 tools/Makefile | 5 +++++
 1 file changed, 5 insertions(+)
tools/Makefile +5 -0
index fc0aa52455a..a23e8af12ca 100644
@@ -221,8 +221,13 @@ HOSTCFLAGS_mkexynosspl.o := -pedantic
 
 HOSTCFLAGS_kwboot.o += -pthread
 HOSTLDLIBS_kwboot += -pthread
+# macOS has no libtinfo, its libncurses provides the terminfo functions
+ifeq ($(shell uname -s),Darwin)
+HOSTLDLIBS_kwboot += -lncurses
+else
 HOSTLDLIBS_kwboot += \
 	$(shell pkg-config --libs tinfo 2> /dev/null || echo "-ltinfo")
+endif
 
 ifdtool-objs := $(LIBFDT_OBJS) ifdtool.o
 hostprogs-always-$(CONFIG_X86) += ifdtool
Signature · 1 line
2.54.0 (Apple Git-157)
#2 lore raw

PATCH 2/3 tools: kwboot: Define _is_within_tolerance() only with BOTHER

In reply to Josef Schlehofer

Building kwboot on macOS warns:

warning: unused function '_is_within_tolerance' [-Wunused-function]

The only caller checks the baudrate that BOTHER sets, and macOS has no BOTHER. Define the function under the same #ifdef.

---
 tools/kwboot.c | 2 ++
 1 file changed, 2 insertions(+)
tools/kwboot.c +2 -0
index 6bef4610ff8..c03f0d6d63e 100644
@@ -727,12 +727,14 @@ kwboot_tty_baudrate_to_speed(int baudrate)
 	}
 }
 
+#ifdef BOTHER
 static int
 _is_within_tolerance(int value, int reference, int tolerance)
 {
 	return 100 * value >= reference * (100 - tolerance) &&
 	       100 * value <= reference * (100 + tolerance);
 }
+#endif
 
 static int
 kwboot_tty_change_baudrate(int fd, int baudrate)
Signature · 1 line
2.54.0 (Apple Git-157)
#3 lore raw

PATCH 3/3 lib: crc8: Do not include asm/sections.h in host builds

In reply to Josef Schlehofer

Building all host tools with tools-only_defconfig and HOST_TOOLS_ALL=y on macOS stops at crc8.o:

arch/sandbox/include/asm/sections.h:21:13: error: argument to 'section' attribute is not valid for this target

The tools-only build uses the sandbox asm/sections.h, whose getopt section names are not valid Mach-O sections. crc8.c needs the header only for __rcode, which is empty in host builds anyway. Define __rcode for the host instead, as crc32.c does for __efi_runtime.

Fixes 3b52337c759a ("lib: Mark crc8 as relocation code")
---
 lib/crc8.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/crc8.c +3 -1
index bbb229c3892..635466f688a 100644
@@ -5,8 +5,10 @@
 
 #ifdef USE_HOSTCC
 #include <arpa/inet.h>
-#endif
+#define __rcode
+#else
 #include <asm/sections.h>
+#endif
 #include <u-boot/crc.h>
 
 #define POLY	(0x1070U << 3)
Signature · 1 line
2.54.0 (Apple Git-157)
#4 lore raw
In reply to Josef Schlehofer
Quoted 8 lines · Josef Schlehofer

With HOST_TOOLS_ALL=y, the U-Boot host tools do not build on macOS. crc8.o does not compile and kwboot does not link. The kwboot link error also stops board builds such as turris_omnia.

Patch 1 links kwboot with the system libncurses, patch 2 removes an unused function warning in kwboot, and patch 3 keeps the sandbox asm/sections.h out of the host build of crc8.c.

Quoted 5 lines

Tested on macOS 27.0.1 with Apple clang 21: tools-only with HOST_TOOLS_ALL=y and the host tools of turris_omnia_defconfig now build, and kwboot boots a Turris Omnia over UART. On Linux (Debian trixie, GCC 14.2) the same tools-only build and a full turris_omnia build still pass, and kwboot still links against libtinfo.

Interesting. I guess since our Azure builds are (wow, I need to check if there's newer VMs..) on macos-14, and we do:

$ brew install make ossp-uuid
$ gmake tools-only_config tools-only \
            HOSTCFLAGS="-I/usr/local/opt/[email protected]/include" \
            HOSTLDFLAGS="-L/usr/local/opt/[email protected]/lib"
is why we hadn't hit this?
Signature · 1 line
Tom
#5 lore raw

No, the issue should be there with macos-14 too. You just don't hit it because tools-only_defconfig doesn't build the two things that break:

a) kwboot is only built with CONFIG_ARCH_MVEBU or CONFIG_ARCH_KIRKWOOD, and tools-only_defconfig has neither.

b) The same goes for crc8.c. It's only used by gen_ethaddr_crc, which needs CONFIG_CMD_NET, and that's not enabled in tools-only_defconfig either.

I hit both with HOST_TOOLS_ALL=y, which turns these on.

To be honest, I haven't tried macos-14.

~ Josef

st 28. 10. 2026 v 19:13 odesílatel Tom Rini <[email protected]> napsal:

Quoted 27 lines · Josef Schlehofer
Quoted 9 lines

With HOST_TOOLS_ALL=y, the U-Boot host tools do not build on macOS. crc8.o does not compile and kwboot does not link. The kwboot link error also stops board builds such as turris_omnia.

Patch 1 links kwboot with the system libncurses, patch 2 removes an unused function warning in kwboot, and patch 3 keeps the sandbox asm/sections.h out of the host build of crc8.c.

Quoted 5 lines

Tested on macOS 27.0.1 with Apple clang 21: tools-only with HOST_TOOLS_ALL=y and the host tools of turris_omnia_defconfig now build, and kwboot boots a Turris Omnia over UART. On Linux (Debian trixie, GCC 14.2) the same tools-only build and a full turris_omnia build still pass, and kwboot still links against libtinfo.

Interesting. I guess since our Azure builds are (wow, I need to check if there's newer VMs..) on macos-14, and we do:

$ brew install make ossp-uuid
$ gmake tools-only_config tools-only \
            HOSTCFLAGS="-I/usr/local/opt/[email protected]/include" \
            HOSTLDFLAGS="-L/usr/local/opt/[email protected]/lib"
is why we hadn't hit this?

--
Tom

#6 lore raw
Quoted 6 lines · Josef Schlehofer

No, the issue should be there with macos-14 too. You just don't hit it because tools-only_defconfig doesn't build the two things that break:

a) kwboot is only built with CONFIG_ARCH_MVEBU or CONFIG_ARCH_KIRKWOOD, and tools-only_defconfig has neither.

Quoted 7 lines

b) The same goes for crc8.c. It's only used by gen_ethaddr_crc, which needs CONFIG_CMD_NET, and that's not enabled in tools-only_defconfig either.

I hit both with HOST_TOOLS_ALL=y, which turns these on.

To be honest, I haven't tried macos-14.

Ah, OK. Would you mind testing your series on top of
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
And then a follow-up to your current series to make that test we have build more, so we would have caught this? Thanks!

Signature · 1 line
Tom
#7 lore raw

I got to it sooner than I expected. I tested your patch with my series on GitHub Actions, on the same macOS 26 image as your Azure run. And yes, I could reproduce it there: with HOST_TOOLS_ALL=y it fails at crc8.o and the kwboot link without my series, and passes with it.

So I've sent a patch that adds HOST_TOOLS_ALL=y to the macOS job, so that it catches more:
https://lore.kernel.org/u-boot/[email protected]/

~ Josef

čt 29. 10. 2026 v 18:30 odesílatel Tom Rini <[email protected]> napsal:

Quoted 24 lines · Josef Schlehofer
Quoted 7 lines

No, the issue should be there with macos-14 too. You just don't hit it because tools-only_defconfig doesn't build the two things that break:

a) kwboot is only built with CONFIG_ARCH_MVEBU or CONFIG_ARCH_KIRKWOOD, and tools-only_defconfig has neither.

Quoted 7 lines

b) The same goes for crc8.c. It's only used by gen_ethaddr_crc, which needs CONFIG_CMD_NET, and that's not enabled in tools-only_defconfig either.

I hit both with HOST_TOOLS_ALL=y, which turns these on.

To be honest, I haven't tried macos-14.

Ah, OK. Would you mind testing your series on top of
https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
And then a follow-up to your current series to make that test we have build more, so we would have caught this? Thanks!

--
Tom

#8 lore raw
In reply to Josef Schlehofer
Quoted 9 lines · Josef Schlehofer

With HOST_TOOLS_ALL=y, the U-Boot host tools do not build on macOS. crc8.o does not compile and kwboot does not link. The kwboot link error also stops board builds such as turris_omnia.

Patch 1 links kwboot with the system libncurses, patch 2 removes an unused function warning in kwboot, and patch 3 keeps the sandbox asm/sections.h out of the host build of crc8.c.

[...]

Applied to u-boot/main, thanks!

[1/3] tools: kwboot: Link with libncurses on macOS

      commit: af5ea6f9b0cff8720eff993adc2ff445fc0ef8ac
[2/3] tools: kwboot: Define _is_within_tolerance() only with BOTHER
      commit: de2f8355f9ef1a044bf7b6b03205260efdb1e425
[3/3] lib: crc8: Do not include asm/sections.h in host builds
      commit: 3a310b42b6dd79f409850fe88bc75764cf4765c6
Signature · 1 line
Tom