Skip to content
This repository was archived by the owner on Jun 24, 2026. It is now read-only.

[build] E: Link libnvx_crt0.a into test ELFs#178

Closed
esaurez wants to merge 1 commit into
mainfrom
feat/add-libnvx_crt0-for-PR11b-compat
Closed

[build] E: Link libnvx_crt0.a into test ELFs#178
esaurez wants to merge 1 commit into
mainfrom
feat/add-libnvx_crt0-for-PR11b-compat

Conversation

@esaurez

@esaurez esaurez commented Jun 9, 2026

Copy link
Copy Markdown

Summary

nanvix/nanvix#2453 (already upstream) moved the _start entry point out of libposix.a into a new libnvx_crt0.a. Add libnvx_crt0.a to both the LIBRARIES and LIBRARIES_CXX link wrappers in src/Makefile so every posix-tests test ELF gets _start at link time. Without this the linker silently picks newlib's weak default _start and the test hangs at startup with no diagnostic output.

Dependencies

This PR assumes the following have already merged and the toolchain image has been republished:

  • nanvix/nanvix#2487sys-ffi crate split that removes the duplicate __kcall_* / _do_exit_thread / _do_start_thread strong symbols from libnvx_crt0.a.
  • nanvix/newlib#17 — declares newlib's _do_start as .weak so libnvx_crt0's strong SSE-aligned override wins cleanly without -Wl,--allow-multiple-definition.
  • nanvix/toolchain-gcc#14 — pins the new newlib commit and triggers a republish of ghcr.io/nanvix/toolchain-gcc.

If those have not landed, the link line will fail with multiple definition of __kcall_* errors against the unpatched toolchain image.

What changes

A new LIBNVX_CRT0 variable is exported alongside LIBPOSIX and LIBC, and added inside the existing --start-group ahead of LIBPOSIX in both LIBRARIES and LIBRARIES_CXX so every test ELF gets _start resolved from libnvx_crt0's strong symbol.

@esaurez esaurez requested a review from ppenna as a code owner June 9, 2026 20:14
@esaurez esaurez changed the title [build] E: Link libnvx_crt0.a into test ELFs for PR-11b compatibility [build] E: Link libnvx_crt0.a into test ELFs to keep _start resolution working Jun 9, 2026
@esaurez esaurez force-pushed the feat/add-libnvx_crt0-for-PR11b-compat branch from 980ad7d to d1821b9 Compare June 9, 2026 21:29
@esaurez esaurez changed the title [build] E: Link libnvx_crt0.a into test ELFs to keep _start resolution working [build] E: Link libnvx_crt0.a into test ELFs Jun 9, 2026
@esaurez esaurez changed the base branch from feat/dlfcn-diamond-needed to main June 9, 2026 21:30
nanvix/nanvix#2453 moved the `_start` entry point out of
`libposix.a` into a new `libnvx_crt0.a`.  Add `libnvx_crt0.a` to
both the `LIBRARIES` and `LIBRARIES_CXX` link wrappers so every
posix-tests test ELF gets `_start` at link time; otherwise the
linker silently picks newlib's weak fallback and the test hangs
at startup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 9, 2026 21:31
@esaurez esaurez force-pushed the feat/add-libnvx_crt0-for-PR11b-compat branch from d1821b9 to 975898c Compare June 9, 2026 21:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the POSIX tests build system to explicitly link Nanvix’s new libnvx_crt0.a into every test ELF so the correct strong _start entry point is resolved at link time (preventing silent fallback to newlib’s weak _start and subsequent test hangs).

Changes:

  • Export a new LIBNVX_CRT0 pointing at $(NANVIX_SYSROOT)/lib/libnvx_crt0.a.
  • Prepend $(LIBNVX_CRT0) to both LIBRARIES and LIBRARIES_CXX within the existing --start-group/--end-group link wrapper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ppenna added a commit that referenced this pull request Jun 11, 2026
Since Nanvix 0.16.19, process startup (_start / __nanvix_main) was moved
out of libposix.a into libnvx_crt0.a. After pinning nanvix to 0.16.32,
linking only libposix.a left __nanvix_main undefined and the test ELFs
failed to link (ld returned 1).

Link libnvx_crt0.a first in both the C and C++ library groups so its
strong symbols win, and add -Wl,--allow-multiple-definition to resolve
the kcall objects (_start, environ, Rust allocator shims) shared between
libnvx_crt0.a and libposix.a.

Combines the nanvix 0.16.32 bump with the crt0 startup fix (supersedes
the standalone crt0 PR #178).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ppenna

ppenna commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Superseded by #180, which combines the nanvix v0.16.32 bump with this crt0 link fix and adds -Wl,--allow-multiple-definition to resolve the symbol overlap (_start, environ, Rust allocator shims) that caused this PR's multiple-definition link errors. #180 is green.

@ppenna ppenna closed this Jun 11, 2026
@ppenna ppenna deleted the feat/add-libnvx_crt0-for-PR11b-compat branch June 11, 2026 08:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants