Skip to content

fix: resolve size_t ABI mismatch between clang and GCC toolchain#10

Open
ppenna wants to merge 1 commit into
mainfrom
fix-size-t-abi-mismatch
Open

fix: resolve size_t ABI mismatch between clang and GCC toolchain#10
ppenna wants to merge 1 commit into
mainfrom
fix-size-t-abi-mismatch

Conversation

@ppenna

@ppenna ppenna commented May 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the size_t ABI mismatch where clang mangles size_t as unsigned int (j) but the GCC toolchain's libstdc++/libsupc++ uses long unsigned int (m), causing linker failures for any C++ code targeting i686-nanvix.

Approach

Updates LLVM_COMMIT to pick up the upstream fix from nanvix/llvm-project#17 which ships libc++, libc++abi, and libunwind built with clang as stage 1 runtimes. Since these libraries are compiled with clang, their ABI matches clang's size_t definition.

Changes

  • Dockerfile: Bump LLVM_COMMIT to 405181e (includes stage 1 libc++ runtimes); update stage 1 comment; add smoke test verifying libc++.a, libc++abi.a, and libunwind.a are present
  • tests/test_size_t_abi.cpp: New C++ regression test that exercises ::operator new(size_t) — the exact pattern that was broken
  • build.yml: Add CI step to compile and link the C++ test with -stdlib=libc++, then verify ELF output (added to both build and registry smoke test jobs)
  • README.md: Update pinned LLVM commit

Validation

  • LLVM commit 405181e verified to exist and includes the libc++ runtimes fix
  • Dockerfile passes docker build --check (syntax validation)
  • Workflow YAML passes schema validation
  • C++ test specifically targets the operator new(size_t) ABI mismatch from the issue reproduction

Closes #9

Update LLVM_COMMIT to pick up upstream libc++ runtimes (nanvix/llvm-project#17)
which ship libc++, libc++abi, and libunwind built with clang. This ensures
the C++ runtime ABI matches clang's size_t definition (unsigned int) on
i686-nanvix, fixing linker failures for operator new and other STL symbols.

Changes:
- Bump LLVM_COMMIT to 405181e (includes stage 1 libc++ runtimes)
- Add Dockerfile smoke test for libc++ static libraries
- Add C++ ABI regression test (tests/test_size_t_abi.cpp)
- Add CI step to compile and link C++ test with -stdlib=libc++
- Update README pinned LLVM commit

Closes #9

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

size_t ABI mismatch: clang mangles as unsigned int (j), GCC toolchain uses long unsigned int (m)

1 participant