From 92557dc756fe8464399d73033d77953edfaba270 Mon Sep 17 00:00:00 2001 From: esaurez Date: Mon, 8 Jun 2026 13:38:30 -0700 Subject: [PATCH] [build] F: Drop -Wl,--allow-multiple-definition (no longer needed)The `-Wl,--allow-multiple-definition` flag was added in the previouscommit to silently coalesce 37 duplicate strong symbols that appearedin BOTH `libnvx_crt0.a` and `libposix.a`: * 34 `__kcall_*` FFI wrappers (`__kcall_lock_mutex`, `__kcall_signal_cond`, `__kcall_send`, ...) * `_do_exit_thread` (thread-exit handler) * `_do_start_thread` (asm thread-bootstrap stub) * `_do_start` (process-entry stub)These have now been resolved structurally upstream: * 36 of 37 by the `sys-ffi` crate split that moves the `#[no_mangle]` FFI exports out of `sys` into a dedicated crate that only `libposix.a` links: nanvix/nanvix#2487. * The remaining `_do_start` by declaring newlib's stub `.weak` so libnvx_crt0's strong SSE-aligned override wins cleanly: nanvix/newlib#17, plus the toolchain image republish in nanvix/toolchain-gcc#14.Once all three of the above have merged and the toolchain image isrepublished with the new newlib commit, the link line no longerneeds `--allow-multiple-definition`.MERGE ORDER: do NOT merge this PR until ALL of the following havelanded: 1. nanvix/nanvix#2487 (sys-ffi crate split) -- already filed. 2. nanvix/newlib#17 (.weak _do_start) -- already filed. 3. nanvix/toolchain-gcc#14 (republish image with new newlib) -- already filed; draft until newlib#17 merges. 4. The toolchain image at ghcr.io/nanvix/toolchain-gcc has been republished from #14 with the new newlib commit. 5. The parent E: PR adding the libnvx_crt0.a wildcard link entry, which this PR is stacked on top of.If merged early, the .so / test ELF link step will fail with"multiple definition of __kcall_*" errors.Validated end-to-end against a locally-rebuilt toolchain imagecarrying the newlib #17 change: the resulting ELF's `_do_start`entry point is libnvx_crt0's SSE-aligned variant (`and $0xfffffff0,%esp ; sub $0x8, %esp ; push ; push ; call _start`) -- the latentSSE-alignment bug present in shipping binaries today is fixed.Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Makefile.nanvix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.nanvix b/Makefile.nanvix index 7abb9c941..3f5e834df 100644 --- a/Makefile.nanvix +++ b/Makefile.nanvix @@ -138,7 +138,7 @@ $(SHAREDLIB): $(LIBFFI) 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_LDFLAGS) \ $(wildcard $(SYSROOT_PATH)/lib/libnvx_crt0.a) \ $(NANVIX_LIBS) \ -o $@