Skip to content

[build] F: Pin newlib to _do_start-weak commit#1

Closed
esaurez wants to merge 1 commit into
mainfrom
chore/bump-newlib-for-do_start-weak
Closed

[build] F: Pin newlib to _do_start-weak commit#1
esaurez wants to merge 1 commit into
mainfrom
chore/bump-newlib-for-do_start-weak

Conversation

@esaurez

@esaurez esaurez commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary (DRAFT — do not merge until upstream newlib lands)

Bumps NEWLIB_COMMIT to point at the upstream merge of esaurez/newlib#5 (_do_start weakening), and restores reproducible newlib checkouts.

Why this is filed as a draft

The current NEWLIB_COMMIT value (881840f880350e6fd929629cef9a5a3d1708bbf4) is the fork commit on esaurez/newlib. Before this PR is merged, the SHA must be updated to the upstream merge commit on nanvix/newlib (otherwise git clone https://github.com/nanvix/newlib && git checkout 881840f88 would fail).

Filing now so the diff is reviewable and ready to flip from draft to ready-for-review the moment esaurez/newlib#5 lands at nanvix/newlib.

Changes

  1. Bump NEWLIB_COMMIT to the new newlib SHA.
  2. Restore reproducible newlib checkout — the previous git clone --depth=1 --branch dev step ignored the NEWLIB_COMMIT pin entirely (no git checkout after the shallow clone), so the toolchain was actually built against whatever happened to be at the tip of dev at image-build time. Drop --depth=1 and add an explicit git checkout \.
  3. Add Dockerfile.localpatch-do_start — fast local validation. Reassembles just crt0.S from a patched newlib tree and overlays the resulting crt0.o onto the existing toolchain-gcc:sha-34a3641 image, no full rebuild needed.

Dependency chain

\
esaurez/nanvix#30 (sys-ffi split, removes 36 of 37 duplicate symbols)
esaurez/newlib#5 (.weak _do_start, removes the 37th)
|
v
THIS PR (NEWLIB_COMMIT bump to pick up newlib#5)
|
v
ghcr.io/nanvix/toolchain-gcc:sha- (image republished by CI)
|
v
F: fixup commits on the 6 Tier 0 PRs
esaurez/{posix-tests#4, libxml2#2, libxslt#2, lxml#2, libffi#2, openssl#2}
drop -Wl,--allow-multiple-definition
\\

Validation

Validated locally with Dockerfile.localpatch-do_start overlaid on the current toolchain image:

\
$ docker run --rm local-nanvix/toolchain-gcc:do_start-weak nm /opt/nanvix/i686-nanvix/lib/crt0.o
00000000 W _do_start # was: T _do_start
U _start
\\

posix-tests (18 binaries, 12 integration suites) and libxml2 functional test both built without -Wl,--allow-multiple-definition and ran to PASS, using libnvx_crt0's SSE-aligned _do_start at the entry point.

References

  • Companion newlib change: esaurez/newlib#5
  • Investigation notes: nanvix-todo/newlib-do_start-collision.md
  • Prior cleanup (resolved 36 of 37 duplicate strong symbols): esaurez/nanvix#30

esaurez added a commit to esaurez/posix-tests that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
esaurez added a commit to esaurez/libxml2 that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
esaurez added a commit to esaurez/libxslt that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
esaurez added a commit to esaurez/lxml that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
esaurez added a commit to esaurez/libffi that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
esaurez added a commit to esaurez/openssl that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
esaurez added a commit to esaurez/libffi that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

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

Bumps NEWLIB_COMMIT to incorporate the `_do_start` weakening from
nanvix/newlib#TBD (esaurez/newlib#5) so that consumers linking
Nanvix's libnvx_crt0.a no longer need `-Wl,--allow-multiple-definition`
on their test ELF link lines.

Also restores reproducibility of the newlib checkout: the prior
`git clone --depth=1 --branch dev` step silently used the tip of
`dev` regardless of the declared `NEWLIB_COMMIT` pin, making
toolchain builds non-deterministic.  Removing `--depth=1` and
adding an explicit `git checkout \` restores the
pin.

Companion Dockerfile.localpatch-do_start is added for fast local
validation of the newlib fix without a full toolchain rebuild --
useful for reviewers who want to confirm the symbol topology and
SSE alignment effects before the full image is republished.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@esaurez esaurez force-pushed the chore/bump-newlib-for-do_start-weak branch from 84f7da2 to 08ad1af Compare June 8, 2026 21:34
esaurez added a commit to esaurez/posix-tests that referenced this pull request Jun 8, 2026
The `-Wl,--allow-multiple-definition` flag was added in the previous
commit to silently coalesce 37 duplicate strong symbols that appeared
in 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.  See nanvix/nanvix#TBD (esaurez/nanvix#30).
  * The remaining `_do_start` by declaring newlib's stub `.weak`
    so libnvx_crt0's strong SSE-aligned override wins cleanly.
    See nanvix/newlib#TBD (esaurez/newlib#5).

With those upstream and a toolchain image republished from
nanvix/toolchain-gcc#TBD (esaurez/toolchain-gcc#1) that bundles the
new newlib commit, the link line no longer needs the flag.

Validated end-to-end with the patched toolchain
(`local-nanvix/toolchain-gcc:do_start-weak`):

  * posix-tests: 18 binaries built, 12 integration suites pass
  * libxml2 functional test: PASS
  * `_do_start` at the entry point is libnvx_crt0's SSE-aligned
    variant (`and $0xfffffff0, %esp ; sub $0x8, %esp ; push ; push ;
    call _start`), not newlib's 9-byte unaligned stub.

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

esaurez commented Jun 9, 2026

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR nanvix#14 (draft, depends on nanvix/newlib#17 merging first), which carries the cleaned-up version of this PR. Changes vs the original fork PR: (a) rebased onto current upstream/main; (b) Dockerfile.localpatch-do_start (the local-only validation Dockerfile) is no longer committed to the repo -- its content is included verbatim in the upstream PR description as a code block so reviewers can copy it out and use it for local validation without polluting the repo with non-shippable scaffolding; (c) commit message rewritten to clearly describe the two distinct fixes (SHA bump + reproducibility), with the #TBD placeholder rewritten to point at nanvix/newlib#17; (d) PR description rewritten to clearly separate the two fixes and reference the in-flight nanvix/newlib#17 and the already-upstream nanvix/nanvix#2487 (which addresses the other 36 duplicate strong symbols). Closing this fork PR; tracking continues upstream.

@esaurez esaurez closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant