feat(toolchain): dimensional ABI compatibility model (fix glibc C-lib under libc++)#178
Merged
Merged
Conversation
… under libc++); v0.0.68
The capability-driven ABI check (added 0.0.54) derived a single `tcAbi`
string in which `stdlibId == "libc++"` short-circuited before the glibc
fallback. So a clang+libc++ toolchain on `x86_64-unknown-linux-gnu` (glibc at
the libc level) was labelled abi=libc++ and wrongly rejected dependencies that
declare `abi:glibc` — even pure C libraries like glfw, which link glibc fine
under libc++. This blocked building glfw (and any glibc C lib) under the llvm
toolchain (e.g. the imgui-m module package, which pins llvm@20.1.7).
Model ABI compatibility as the orthogonal axes it actually is:
libc (glibc/musl/msvcrt/macos) ← target triple
cxxStdlib (libstdc++/libc++/…) ← compiler/stdlibId
arch / os ← target triple
cxxAbi (itanium/msvc) ← compiler
A dependency constrains only the dimension(s) it cares about; unspecified
dimensions are don't-care. Legacy `abi:glibc` maps to the libc dimension only;
a new `abi:<dim>=<val>` form expresses other axes. No descriptor changes
needed.
- new src/toolchain/abi.cppm: AbiProfile + abi_profile() (single derivation),
parse_abi_capability(), abi_check() (per-dim, don't-care).
- prepare.cppm: replace the conflated tcAbi block with the dimensional check;
precise per-dimension diagnostics.
- doctor.cppm: show abi(libc)/cxxstdlib/arch/os instead of one fused string.
- tests/unit/test_abi.cpp: 11 cases incl. the regression (glibc C-lib under
libc++ is compatible; glibc dep under musl still mismatches on libc).
Verified locally: glfw builds under BOTH gcc@16.1.0 and llvm@20.1.7; a musl
target still correctly errors ("requires libc=glibc … provides libc=musl").
Design: .agents/docs/2026-06-27-abi-compat-model-single-pr-design.md
Analysis: .agents/docs/2026-06-27-glfw-abi-glibc-vs-libcxx-conflation-analysis.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The capability-driven ABI check (added in 0.0.54) derives a single
tcAbistring wherestdlibId == "libc++"short-circuits before the glibc fallback:So a
clang+libc++toolchain onx86_64-unknown-linux-gnu— which is glibc at the libc level — is labelledabi=libc++and rejects any dependency declaringabi:glibc, even pure C libraries like glfw (libc++ is a C++ stdlib, not a libc replacement; it links glibc fine). This blocks building glfw, and anything pulling it, under the llvm toolchain (e.g. the imgui-m module package, which pinsllvm@20.1.7).Full root-cause + reproduction:
.agents/docs/2026-06-27-glfw-abi-glibc-vs-libcxx-conflation-analysis.md.Fix — model ABI as the orthogonal axes it is
libccxxStdlibarch,oscxxAbiA dependency constrains only the dimension(s) it cares about; unspecified dimensions are don't-care. Legacy
abi:glibc→ thelibcdimension only (zero descriptor changes); a newabi:<dim>=<val>form expresses other axes.Design (single-PR scope, with the L3 reselection seam):
.agents/docs/2026-06-27-abi-compat-model-single-pr-design.md.Changes
src/toolchain/abi.cppm—AbiProfile+abi_profile()(single derivation site),parse_abi_capability(),abi_check()(per-dimension, don't-care).src/build/prepare.cppm— replace the conflatedtcAbiblock with the dimensional check; precise per-dimension diagnostics.src/doctor.cppm— showabi(libc)/cxxstdlib/arch/osinstead of one fused string.tests/unit/test_abi.cpp— 11 cases incl. the regression lock.Verification (local, fresh 0.0.68)
gcc@16.1.0→Finished(no regression)llvm@20.1.7→Finished✅ (the fix)--target x86_64-linux-musl→ still errors:requires libc=glibc … provides libc=musl(genuine incompatibility, now naming the dimension)mcpp test: 27 unit binaries pass incl. newtest_abidoctor:abi(libc)=glibc cxxstdlib=libc++ arch=x86_64 os=linuxOnce released,
mcpp-indexcan move the glfw/imgui-module GL smokes back into the blocking CI set.