Commit 3073341
authored
fix: resolve LLVM toolchain install failure on Linux (#61)
* fix: resolve LLVM toolchain install failure on Linux
Three fixes for `mcpp toolchain install llvm` failing with
"xpkg payload missing":
1. install_with_progress(): use direct `xlings install -y` command
on ALL platforms (not just Windows). The direct command avoids
stdin closure (</dev/null) that breaks xlings subprocess
coordination for large packages like LLVM (~800MB). Falls back
to NDJSON interface path if direct install fails.
2. package_fetcher.cppm: extend the global xlings directory fallback
from Windows-only to all platforms. If xlings installs a package
to ~/.xlings/ instead of the mcpp sandbox, detect and copy it.
3. ci.yml: add "Toolchain install smoke test" step that exercises
`mcpp toolchain install llvm` + build with it. This core user
flow was previously untested in CI.
* fix: add missing import mcpp.platform in package_fetcher.cppm
Also replace raw WIFEXITED/WEXITSTATUS with
platform::process::extract_exit_code() in xlings.cppm.
* fix(ci): use 'toolchain default' instead of non-existent --toolchain flag
* fix: remove import mcpp.platform from package_fetcher.cppm
The added import changed the module dependency graph fingerprint,
invalidating BMI cache on macOS CI and exposing a pre-existing
Xcode 16.4 SDK incompatibility during std module precompilation.
Use #if defined(_WIN32) instead of if constexpr for the USERPROFILE
check to avoid changing the module import set.
* fix(ci-macos): add MCPP_HOME env and MCPP_VENDORED_XLINGS for test step
macOS CI was missing the MCPP_HOME job-level env var that Linux CI
has. The freshly-built mcpp resolved to a fresh ~/.mcpp/ sandbox,
triggering a clean std module precompile that exposed a pre-existing
Xcode 16.4 + LLVM 20.1.7 sysroot incompatibility.
Fix: set MCPP_HOME=/Users/runner/.mcpp (consistent with Linux CI)
and export MCPP_VENDORED_XLINGS in the test step so the sandbox
reuses the pre-installed xlings binary.
* fix: don't use xcrun SDK as sysroot for xlings LLVM on macOS
Root cause: probe_sysroot() falls back to xcrun --show-sdk-path on
macOS when the compiler doesn't report a sysroot via -print-sysroot.
For xlings-installed LLVM 20.1.7, this sets --sysroot to the Xcode
SDK path. Combined with -nostdinc++ from clang++.cfg, this breaks
C runtime header resolution — macOS SDK headers reference internal
macros (_CTYPE_A, etc.) that are only defined via default include
paths which --sysroot overrides.
Fix: remove the xcrun SDK fallback in probe_sysroot(). If the
compiler itself doesn't report a sysroot, none should be used.
The xcrun fallback was designed for Apple's system clang, not for
standalone xlings LLVM which provides its own libc++ headers.
Also revert the ci-macos.yml MCPP_HOME workaround — the real bug
is fixed, no workaround needed.
* fix: prefer xcrun SDK over cfg-baked sysroot on macOS
probe_sysroot() called -print-sysroot first, which on macOS with
xlings LLVM just echoed back the --sysroot from clang++.cfg. That
cfg-baked path points to CommandLineTools SDK, which may differ from
the active Xcode SDK. When the two SDKs have different header
versions, std module precompilation fails with undeclared _CTYPE_A
and related C runtime macro errors.
Fix: on macOS, probe xcrun --show-sdk-path FIRST (always returns the
active SDK), then fall back to -print-sysroot for non-macOS. The
xcrun sysroot passed on the command line overrides the cfg-baked one.
* fix: skip --sysroot for std module precompile on macOS
Root cause: on macOS, xlings LLVM's clang++.cfg already contains a
--sysroot for the macOS SDK. When mcpp additionally passes --sysroot
on the command line during std module precompilation, it changes the
C header include ordering. The macOS SDK's ___wctype.h references
_CTYPE_A (defined in _ctype.h), but the duplicate --sysroot flag
prevents _ctype.h from being included transitively during module
purview compilation, causing "undeclared identifier '_CTYPE_A'" errors.
Fix: detect apple/darwin target triple in stdmod.cppm and skip the
--sysroot flag for std module precompile. The cfg's own --sysroot
handles macOS SDK discovery correctly for this compilation mode.
Regular compilation (flags.cppm) and linking still use the probed
sysroot as before.
Also restore probe_sysroot() to its original logic (xcrun fallback)
since the issue was in stdmod.cppm passing sysroot, not in probing it.
* fix: override stale cfg sysroot with xcrun SDK for macOS std precompile
The previous fix skipped --sysroot entirely on macOS, but xlings
LLVM's clang++.cfg still applies its own --sysroot pointing to
CommandLineTools SDK. When the active SDK is Xcode (different path),
the cfg's stale sysroot causes _CTYPE_A undeclared errors.
Fix: on macOS, always probe xcrun and pass the active SDK as
--sysroot to OVERRIDE the cfg-baked stale path. This ensures the
std module precompile uses the correct SDK regardless of what was
baked into clang++.cfg at LLVM install time.
* fix: skip --sysroot entirely for macOS std module precompile
CI step 9 proves that clang++ WITHOUT explicit --sysroot precompiles
std.cppm correctly on macOS — the clang++.cfg's built-in --sysroot
and -isystem flags handle SDK header resolution properly.
When mcpp passes an explicit --sysroot (even the identical value),
it changes Clang's internal header search order, breaking the
transitive inclusion of _ctype.h before ___wctype.h. The macOS SDK's
___wctype.h references _CTYPE_A which is only defined via the
default cfg-driven include chain.
Fix: detect apple/darwin target and skip --sysroot for std module
precompile, letting clang++.cfg handle it. Non-macOS platforms
(Linux, Windows) continue to use the probed sysroot as before.
* fix: bypass stale clang++.cfg for macOS std module precompile
When xlings copies LLVM to mcpp's sandbox, clang++.cfg retains
hardcoded absolute paths from the original install (--sysroot and
-isystem pointing to ~/.xlings/... instead of ~/.mcpp/...). These
stale paths cause _CTYPE_A undeclared errors during std module
precompilation.
Fix: on macOS Clang, pass --no-default-config to ignore the stale
cfg, then explicitly provide the correct -isystem (libc++ headers
from the sandbox LLVM root) and --sysroot (active SDK from xcrun).
This produces the same header search behavior as a fresh clang++
invocation with the correct paths.
* fix: apply --no-default-config for all macOS Clang compilation
The stale clang++.cfg issue affects not just std module precompile
but also regular compilation via ninja. flags.cppm now applies the
same --no-default-config + correct -isystem + xcrun --sysroot fix
for all macOS Clang compilation, bypassing the cfg's stale paths.1 parent 20bf41d commit 3073341
7 files changed
Lines changed: 214 additions & 25 deletions
File tree
- .agents/docs
- .github/workflows
- src
- build
- pm
- toolchain
| 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 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
137 | 154 | | |
138 | 155 | | |
139 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
92 | 96 | | |
93 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
94 | 109 | | |
95 | 110 | | |
96 | 111 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
613 | 614 | | |
614 | | - | |
615 | | - | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
616 | 619 | | |
617 | 620 | | |
618 | 621 | | |
| |||
635 | 638 | | |
636 | 639 | | |
637 | 640 | | |
638 | | - | |
639 | 641 | | |
640 | 642 | | |
641 | 643 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
265 | | - | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
266 | 269 | | |
267 | 270 | | |
268 | 271 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
95 | 103 | | |
96 | | - | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
97 | 115 | | |
98 | 116 | | |
99 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
623 | 627 | | |
624 | 628 | | |
| 629 | + | |
| 630 | + | |
625 | 631 | | |
626 | 632 | | |
627 | | - | |
628 | 633 | | |
629 | | - | |
| 634 | + | |
630 | 635 | | |
631 | 636 | | |
632 | 637 | | |
| |||
0 commit comments