[Concept,13/18] ulib: Enable building the ulib test program

Message ID 20250904130459.848794-14-sjg@u-boot.org
State New
Headers
Series ulib: Introduce building U-Boot as a shared library |

Commit Message

Simon Glass Sept. 4, 2025, 1:04 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Now that the required pieces are in place, add the test program into the
build. Provide the linker script too.

The library requires CONFIG_CMDLINE, at least initially, so don't
attempt to build it when there is no command line.

For clang, an error is produced, so disable it in that case too:

   test/ulib/ulib_test.o: file not recognized: file format not recognized

For now the program just crashes on startup, due to mon_len being larger
than available RAM.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 Makefile | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
  

Patch

diff --git a/Makefile b/Makefile
index a0a9ce3196b..b43e028a06e 100644
--- a/Makefile
+++ b/Makefile
@@ -1043,7 +1043,11 @@  INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \
 	$(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \
 	$(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin)
 
-INPUTS-$(CONFIG_ULIB) += libu-boot.so
+ifdef CONFIG_CMDLINE
+ifneq ($(cc-name),clang)
+INPUTS-$(CONFIG_ULIB) += libu-boot.so test/ulib/ulib_test
+endif
+endif
 
 LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 
@@ -1852,6 +1856,7 @@  endif
 # Build U-Boot as a shared library
 quiet_cmd_libu-boot.so = LD      $@
       cmd_libu-boot.so = $(CC) -shared -o $@ -Wl,--build-id=none \
+	-Wl,-T,$(srctree)/arch/sandbox/cpu/u-boot-lib.lds \
 	$(u-boot-init) \
 	$(KBUILD_LDFLAGS:%=-Wl,%) $(SANITIZERS) $(LTO_FINAL_LDFLAGS) \
 	-Wl,--whole-archive \