From d222472a85ac294a51631ccfbd29f737988a7315 Mon Sep 17 00:00:00 2001 From: Enrique Saurez Date: Tue, 9 Jun 2026 14:27:14 -0700 Subject: [PATCH] [build] E: Link libnvx_crt0.a into test ELF, drop --allow-multiple-definition nanvix/nanvix#2453 moved the `_start` entry point out of `libposix.a` into a new `libnvx_crt0.a`. Add `libnvx_crt0.a` to the test ELF link line so `_start` is found at link time; otherwise the linker silently picks newlib's weak fallback and the test hangs at startup. Also drop `-Wl,--allow-multiple-definition` from the link line. The flag was previously needed to coalesce duplicate strong symbols (`__kcall_*`, `_do_exit_thread`, `_do_start_thread`, `_do_start`) that appeared in both `libnvx_crt0.a` and `libposix.a`. All of those duplicates are now resolved upstream: * nanvix/nanvix#2487 -- sys-ffi crate split that removes the `__kcall_*` / `_do_exit_thread` / `_do_start_thread` duplicates from `libnvx_crt0.a`. * nanvix/newlib#17 -- declares newlib's `_do_start` as `.weak` so libnvx_crt0's strong SSE-aligned override wins cleanly. * nanvix/toolchain-gcc#14 -- pins the new newlib commit and triggers a republish of the toolchain image. This PR depends on all three above having merged AND the toolchain image at `ghcr.io/nanvix/toolchain-gcc` having been republished with the new newlib bundled in. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Makefile.nanvix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.nanvix b/Makefile.nanvix index bd28afada..e4959f7cf 100644 --- a/Makefile.nanvix +++ b/Makefile.nanvix @@ -79,6 +79,7 @@ CC := $(NANVIX_TOOLCHAIN)/bin/i686-nanvix-gcc AR := $(NANVIX_TOOLCHAIN)/bin/i686-nanvix-ar NANVIX_LDFLAGS := -static -L$(SYSROOT_PATH)/lib -T$(SYSROOT_PATH)/lib/user.ld NANVIX_LIBS := -Wl,--start-group \ + $(SYSROOT_PATH)/lib/libnvx_crt0.a \ $(SYSROOT_PATH)/lib/libposix.a \ $(NANVIX_TOOLCHAIN)/i686-nanvix/lib/libc.a \ $(NANVIX_TOOLCHAIN)/i686-nanvix/lib/libm.a \ @@ -138,7 +139,7 @@ build: $(CONFIGURED_MARKER) ffi_test$(EXE): build @printf '#include \n#include \nint main() {\n ffi_cif cif;\n ffi_type *args[1];\n args[0] = &ffi_type_uint;\n if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint, args) == FFI_OK) {\n printf("FFI_TEST: PASS cif_prep\\n");\n } else {\n printf("FFI_TEST: FAIL cif_prep\\n"); return 1;\n }\n return 0;\n}\n' > _ffi_test.c $(CC) -O2 -I$(FFI_INCLUDE) _ffi_test.c $(LIBFFI) \ - $(NANVIX_LDFLAGS) -Wl,--allow-multiple-definition $(NANVIX_LIBS) \ + $(NANVIX_LDFLAGS) $(NANVIX_LIBS) \ -o $@ @rm -f _ffi_test.c @echo " OK: $@ ($$(wc -c < $@) bytes)"