Commit 40215eb
Runtime closure: bake dep runtime_dirs into RUNPATH; default Linux toolchain to glibc (#109)
* Bake dependency runtime library_dirs into binary RUNPATH; default Linux toolchain to glibc
R2: flags.cppm emitted -Wl,-rpath only from toolchain.linkRuntimeDirs, dropping
dependency packages' [runtime] library_dirs (already collected into
plan.runtimeLibraryDirs by plan.cppm). So host-GL passthrough dirs (e.g.
compat.glx-runtime) never reached the binary RUNPATH and dlopen()'d libGL/libGLX
failed at run time (GLX: Failed to load GLX). Iterate plan.runtimeLibraryDirs
(superset) instead.
R1: cli.cppm first-run default on Linux was gcc-musl-static, which cannot link
the glibc world (X11/GL/system libs). Default to platform-native glibc gcc;
musl-static stays opt-in via --target x86_64-linux-musl (Cargo-style).
* docs: runtime closure (rpath) + toolchain default design
* feat: mcpp new --template gui (imgui.app starter) + package-template design
Adds a builtin gui scaffold to `mcpp new` (Tier-0 imgui.app window starter,
deps imgui 0.0.2, no toolchain pin). Verified: new --template gui -> build ->
window renders. Also documents the long-term package-based template model
(mcpp new name --template pkg@ver:tmpl, libraries ship templates/) as TODO.
* feat: mcpp why / resolve --explain + capability-level doctor
mcpp why [toolchain|runtime|deps] (alias: resolve --explain) explains the
resolved toolchain (incl. abi), the runtime library dirs baked into RUNPATH
(surfacing the compat.glx-runtime host-GL closure), and locked deps — so
defaults are inspectable, not magic (I4).
self doctor: add a runtime-capabilities section probing x11/wayland display
and the host GLVND opengl.glx.driver (libGLX + vendor), reporting the
provider — capability-level, not just env health.
* refactor: capability/provider-driven doctor (no platform #ifdef)
Aggregate dependency providers' [runtime] dlopen_libs/capabilities into the
BuildPlan (with capability->provider mapping). doctor now reports each required
host capability + its provider and verifies each provider-declared dlopen
soname against the resolved runtime library_dirs — fully data-driven. Removes
the previous #ifdef __APPLE__/_WIN32 + hardcoded /usr/lib paths: platform
knowledge belongs in provider packages, not in mcpp core. why also surfaces
capability->provider.
* feat: capability-driven ABI enforcement
A dependency may declare an abi:<x> capability (e.g. compat.glfw -> abi:glibc).
prepare_build now verifies the resolved toolchain's ABI satisfies every such
requirement and fails fast with an actionable message on mismatch — turning a
cryptic deep musl build error (libXdmcp arc4random_buf) into an upfront
capability error. Enforces/diagnoses; abi-driven reselection (toolchain is
resolved before the dep graph) is a resolution-ordering follow-up.
* feat: per-build resolution.json manifest artifact
Writes a machine-readable resolution manifest (toolchain/abi, runtime closure
library_dirs, dlopen_libs, capability->provider) next to build outputs — the
serialized capability->plan, same data as `mcpp why`, usable by CI/tooling.
* refactor: resolution.json via mcpp.libs.json (nlohmann), not string concat
Use the existing json module for safe serialization/escaping instead of
hand-built JSON.
* feat: build profiles ([profile.<name>] + --profile)
Adds bundled build settings: built-in release (-O2) / dev (-O0 -g) / dist
(-O3 -flto -s), overridable/extendable via [profile.<name>] (opt/debug/lto/
strip) in mcpp.toml. --profile selects; flags.cppm applies opt/debug/lto to
compile and lto/strip to link. Verified: release/dev/dist emit distinct flags.
* fix: rpath only dependency runtime dirs; update first-run default test
R2 precision: baking ALL of plan.runtimeLibraryDirs into -L/-rpath pulled the
glibc payload dir into musl/static links (undefined _DYNAMIC; broke e2e 28/30).
Split out plan.depRuntimeLibraryDirs (dependency [runtime] library_dirs only,
e.g. compat.glx-runtime) and emit toolchain.linkRuntimeDirs + dep dirs, as
before plus the dep closure. e2e 29 updated for the intentional glibc
first-run default (musl-static is opt-in via --target).
* feat: Cargo-style features ([features] + --features + dep features=[...])
[features] declares feature -> implied-features (with a 'default' set);
long-form dep specs' features=[...] is now stored (was accepted-but-ignored)
and requests features of that dependency. Activation = default ∪ requested,
expanded transitively; each active feature becomes -DMCPP_FEATURE_<NAME> on
that package's compile flags. Root activation via --features a,b.
Verified: default set, --features, and implication closure all observable
via #ifdef. Transitive dep->dep feature propagation is a follow-up.
* feat: backend= dep knob, [runtime.<cap>] provider= override, [package] platforms
- dep spec backend = "<impl>" — sugar for requesting the dependency's
backend-<impl> feature (library backend selection knob; verified the dep
compiles with -DMCPP_FEATURE_BACKEND_<IMPL>).
- [runtime.<capability>] provider = "<pkg>" — explicit provider selection:
prefers the named provider for matching capabilities (surfaced by why/
doctor/resolution.json), warns when the provider isn't in the graph.
- [package] platforms = [...] — declared platform support, surfaced by
mcpp why as the CI matrix hint.
* fix: first-run default toolchain installs sysroot deps (glibc, linux-headers)
The glibc first-run default (R1) needs the sysroot payloads exactly like
`mcpp toolchain install` provides; the old musl-static default was
self-contained, which masked this. Fixes fresh-home e2e 29/31 in CI
(std module precompile: stdlib.h not found).
* fix: first-run gcc default runs the same post-install fixup pipeline
Extract gcc_post_install_fixup (patchelf PT_INTERP/RUNPATH for gcc/binutils +
linker-specs wiring against sandbox glibc) out of `toolchain install` and run
it from the first-run auto-install too. A fresh-sandbox glibc default
previously skipped the fixup and could not find the C library (stdlib.h: No
such file or directory — e2e 29/31 on CI). One shared pipeline, no duplicate.
* fix: ownership guard — never fixup payloads inherited from another home
gcc_post_install_fixup now skips payloads whose canonical path resolves
outside this MCPP_HOME's registry: inherited (symlinked) payloads belong to
their owner home, whose fixup is already valid; patching through the symlink
rewrote the canonical binaries against ephemeral paths and bricked the
owner's toolchain. Verified: fresh-home e2e (26/28/29/31) pass and the
owner toolchain stays intact.
* fix: payload probe falls back to the active home registry
probe_payload_paths found glibc/linux-headers only as compiler SIBLINGS.
With an inherited (symlinked) compiler the binary resolves into its owner
home, so sysroot payloads freshly installed into the ACTIVE home (first-run
default path) were invisible -> std module precompile failed with
stdlib.h not found (CI fresh-home e2e 29/31). Add
paths::active_home_xpkgs()/find_home_tool() and consult them after sibling
search: discovery = compiler siblings ∪ active home registry.
* fix: validate probed sysroot carries C headers; diagnostic std-precompile error
A probed/remapped sysroot that exists but lacks stdlib.h (e.g. a
partially-bootstrapped sandbox subos in a fresh MCPP_HOME) silently shadowed
the payload -isystem fallback in both stdmod and flags, failing deep in the
std module build. probe_sysroot now only returns a sysroot that actually
contains the C headers (glibc usr/include or musl include layout) so all
consumers uniformly fall through to payload paths. std-precompile failures
now include the full compile command for actionable diagnosis.
* fix: payload C headers via -idirafter for GCC (include_next reachability)
Ground truth from CI (command now in the error): -isystem'd payload glibc
include was present yet #include_next <stdlib.h> still failed. GCC's
libstdc++ wraps libc headers with #include_next, which only searches
directories AFTER the current header's dir — gcc's built-in dirs are last,
so -isystem (inserted before them) is unreachable. Use -idirafter (appended
to the very end) for GCC payload headers in both the std-module precompile
and per-TU flags; clang keeps -isystem. Verified with a faithful fresh-home
repro (no subos => invalid sysroot): first-run installs glibc default and
builds clean.
* fix: payload branch wires link-time C runtime (-B/-L glibc lib)
With the sysroot cleared (validation) the linker lost the implicit crt1.o/
crti.o and -lm/-lc locations (CI: 'cannot find crt1.o'). The payload
fallback now passes -B/-L <glibc payload lib> at link, completing the
no-sysroot path end-to-end (compile headers via -idirafter + link runtime
via -B/-L). Verified: fresh-home first-run builds AND runs.
---------
Co-authored-by: sunrisepeak <x.d2learn.org@gmail.com>1 parent 93398f4 commit 40215eb
11 files changed
Lines changed: 815 additions & 78 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
Lines changed: 83 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
176 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
177 | 180 | | |
178 | | - | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
179 | 186 | | |
180 | | - | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
181 | 195 | | |
182 | 196 | | |
183 | 197 | | |
| |||
198 | 212 | | |
199 | 213 | | |
200 | 214 | | |
201 | | - | |
202 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
203 | 223 | | |
204 | 224 | | |
205 | 225 | | |
| |||
256 | 276 | | |
257 | 277 | | |
258 | 278 | | |
| 279 | + | |
259 | 280 | | |
260 | 281 | | |
261 | 282 | | |
262 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
263 | 292 | | |
264 | 293 | | |
265 | 294 | | |
| |||
273 | 302 | | |
274 | 303 | | |
275 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
276 | 309 | | |
277 | | - | |
| 310 | + | |
278 | 311 | | |
279 | | - | |
| 312 | + | |
280 | 313 | | |
281 | | - | |
282 | | - | |
| 314 | + | |
| 315 | + | |
283 | 316 | | |
284 | 317 | | |
285 | 318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
| |||
219 | 230 | | |
220 | 231 | | |
221 | 232 | | |
222 | | - | |
223 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
224 | 245 | | |
225 | 246 | | |
226 | 247 | | |
| |||
0 commit comments