From ca10e542b977b6cae8819edb8feaed55404c82ce Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sun, 27 Sep 2026 10:04:48 +0200 Subject: [PATCH 1/2] examples/nxflat: Build the test modules that do build. The Makefile said "Most of these do no build yet" and built three of the nine. Eight build and convert: errno, hello, longjmp, mutex, pthread, signal, struct and task. What had kept most of them out was read-only data reached PC-relative, which the tree now compiles GOT-relative. BUILD_SUBDIRS was assigned but never read, so mutex, pthread and task stayed out even where the configuration allowed them. The conditionals now append to SUBDIRS, which the recipes walk. hello++ stays out: two of its four modules convert, the third needs R_ARM_TARGET1 from the converter and the fourth needs an iostream. Assisted-by: Claude Opus 5 (1M context) Signed-off-by: Marco Casaroli --- examples/nxflat/tests/Makefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/nxflat/tests/Makefile b/examples/nxflat/tests/Makefile index 0f83f513728..e40f211ebf2 100644 --- a/examples/nxflat/tests/Makefile +++ b/examples/nxflat/tests/Makefile @@ -22,16 +22,17 @@ include $(APPDIR)/Make.defs -# Most of these do no build yet -#SUBDIRS = errno hello hello++ longjmp mutex pthread signal task struct -SUBDIRS = errno hello struct +# hello++ is left out: two of its four modules convert, the third needs +# R_ARM_TARGET1 from the converter and the fourth needs an iostream. + +SUBDIRS = errno hello longjmp signal struct ifneq ($(CONFIG_DISABLE_PTHREAD),y) -BUILD_SUBDIRS += mutex pthread +SUBDIRS += mutex pthread endif ifneq ($(CONFIG_ARCH_ADDRENV),y) -BUILD_SUBDIRS += task +SUBDIRS += task endif NXFLAT_DIR = $(APPDIR)/examples/nxflat From f397be5c62a3cea16ba99c1cde1bccc91c1512b7 Mon Sep 17 00:00:00 2001 From: Marco Casaroli Date: Sun, 27 Sep 2026 10:34:22 +0200 Subject: [PATCH 2/2] examples/nxflat: Install the modules without a GNU extension. install -D is GNU's, and creates the leading directories. The BSD install that macOS carries has no such option and fails the build of every module. mkdir -p does that part, and the mode stays explicit. longjmp is built only where CONFIG_ARCH_SETJMP_H is set. It imports setjmp() and longjmp(), which the firmware exports only when it supplies its own implementation; without the guard the kernel link fails on two undefined references. Verified on lm3s6965-ek:qemu-nxflat with the option off and on. Assisted-by: Claude Opus 5 (1M context) Signed-off-by: Marco Casaroli --- examples/nxflat/tests/Makefile | 9 ++++++++- examples/nxflat/tests/errno/Makefile | 3 ++- examples/nxflat/tests/hello++/Makefile | 12 ++++++++---- examples/nxflat/tests/hello/Makefile | 3 ++- examples/nxflat/tests/longjmp/Makefile | 3 ++- examples/nxflat/tests/mutex/Makefile | 3 ++- examples/nxflat/tests/pthread/Makefile | 3 ++- examples/nxflat/tests/signal/Makefile | 3 ++- examples/nxflat/tests/struct/Makefile | 3 ++- examples/nxflat/tests/task/Makefile | 3 ++- 10 files changed, 32 insertions(+), 13 deletions(-) diff --git a/examples/nxflat/tests/Makefile b/examples/nxflat/tests/Makefile index e40f211ebf2..814eb1801ad 100644 --- a/examples/nxflat/tests/Makefile +++ b/examples/nxflat/tests/Makefile @@ -25,7 +25,14 @@ include $(APPDIR)/Make.defs # hello++ is left out: two of its four modules convert, the third needs # R_ARM_TARGET1 from the converter and the fourth needs an iostream. -SUBDIRS = errno hello longjmp signal struct +SUBDIRS = errno hello signal struct + +# longjmp imports setjmp() and longjmp(), which the symbol table exports only +# where NuttX supplies them itself. + +ifeq ($(CONFIG_ARCH_SETJMP_H),y) +SUBDIRS += longjmp +endif ifneq ($(CONFIG_DISABLE_PTHREAD),y) SUBDIRS += mutex pthread diff --git a/examples/nxflat/tests/errno/Makefile b/examples/nxflat/tests/errno/Makefile index 43ee63d4e9c..d115de73c5b 100644 --- a/examples/nxflat/tests/errno/Makefile +++ b/examples/nxflat/tests/errno/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN) diff --git a/examples/nxflat/tests/hello++/Makefile b/examples/nxflat/tests/hello++/Makefile index 3202dd1b9c0..a0a58a6b087 100644 --- a/examples/nxflat/tests/hello++/Makefile +++ b/examples/nxflat/tests/hello++/Makefile @@ -149,16 +149,20 @@ $(BIN3): $(BIN3).r2 # $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN1): $(BIN1) - $(Q) install -D $(BIN1) $(ROMFS_DIR)/$(BIN1) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN1) $(ROMFS_DIR)/$(BIN1) $(ROMFS_DIR)/$(BIN2): $(BIN2) - $(Q) install -D $(BIN2) $(ROMFS_DIR)/$(BIN2) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN2) $(ROMFS_DIR)/$(BIN2) $(ROMFS_DIR)/$(BIN3): $(BIN3) - $(Q) install -D $(BIN3) $(ROMFS_DIR)/$(BIN3) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN3) $(ROMFS_DIR)/$(BIN3) #$(ROMFS_DIR)/$(BIN4): $(BIN4) -# $(Q) install -D $(BIN4) $(ROMFS_DIR)/$(BIN4) +# $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN4) $(ROMFS_DIR)/$(BIN4) install: $(ROMFS_DIR)/$(BIN1) $(ROMFS_DIR)/$(BIN2) $(ROMFS_DIR)/$(BIN3) diff --git a/examples/nxflat/tests/hello/Makefile b/examples/nxflat/tests/hello/Makefile index c176050953b..96b3c0b275a 100644 --- a/examples/nxflat/tests/hello/Makefile +++ b/examples/nxflat/tests/hello/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN) diff --git a/examples/nxflat/tests/longjmp/Makefile b/examples/nxflat/tests/longjmp/Makefile index d1dfdd6a444..12a7e89dde3 100644 --- a/examples/nxflat/tests/longjmp/Makefile +++ b/examples/nxflat/tests/longjmp/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN) diff --git a/examples/nxflat/tests/mutex/Makefile b/examples/nxflat/tests/mutex/Makefile index afdfc4966e0..0facbb638b6 100644 --- a/examples/nxflat/tests/mutex/Makefile +++ b/examples/nxflat/tests/mutex/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN) diff --git a/examples/nxflat/tests/pthread/Makefile b/examples/nxflat/tests/pthread/Makefile index 34eda9330c0..a699c777a43 100644 --- a/examples/nxflat/tests/pthread/Makefile +++ b/examples/nxflat/tests/pthread/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN) diff --git a/examples/nxflat/tests/signal/Makefile b/examples/nxflat/tests/signal/Makefile index 0fba3386436..0e0248df3c2 100644 --- a/examples/nxflat/tests/signal/Makefile +++ b/examples/nxflat/tests/signal/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN) diff --git a/examples/nxflat/tests/struct/Makefile b/examples/nxflat/tests/struct/Makefile index 463b2c260de..402cf117027 100644 --- a/examples/nxflat/tests/struct/Makefile +++ b/examples/nxflat/tests/struct/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN) diff --git a/examples/nxflat/tests/task/Makefile b/examples/nxflat/tests/task/Makefile index cb3473d6be6..3f6e7b033c7 100644 --- a/examples/nxflat/tests/task/Makefile +++ b/examples/nxflat/tests/task/Makefile @@ -57,7 +57,8 @@ $(BIN): $(BIN).r2 $(Q) $(LDNXFLAT) $(LDNXFLATFLAGS) -o $@ $^ $(ROMFS_DIR)/$(BIN): $(BIN) - $(Q) install -D $(BIN) $(ROMFS_DIR)/$(BIN) + $(Q) mkdir -p $(ROMFS_DIR) + $(Q) install -m 0755 $(BIN) $(ROMFS_DIR)/$(BIN) install: $(ROMFS_DIR)/$(BIN)