fix: remove subos sysroot override, use payload paths for toolchain sysroot#62
Open
Sunrisepeak wants to merge 4 commits into
Open
fix: remove subos sysroot override, use payload paths for toolchain sysroot#62Sunrisepeak wants to merge 4 commits into
Sunrisepeak wants to merge 4 commits into
Conversation
…ysroot (#62) Remove M5.5 logic that forced tc->sysroot to mcpp's xlings subos (~/.mcpp/registry/subos/default). The subos created by `xlings self init` lacks linux kernel headers (linux/limits.h, asm/, asm-generic/), causing std module precompilation to fail on user machines. Root cause: commit 063fb6f changed MCPP_HOME to ~/.mcpp/, where the subos exists but is incomplete. M5.5 only checked exists(usr/include) and overwrote the toolchain's correct sysroot. CI never caught this because its subos is fully populated by `xlings self install`. Design principle: mcpp uses xlings only as a package index + download tool. Sysroot comes from the toolchain payload itself, not from subos. Changes: - cli.cppm: delete M5.5 subos sysroot override entirely - probe.cppm: parse clang++.cfg --sysroot= when -print-sysroot fails (Clang doesn't support -print-sysroot), so tc->sysroot reflects the payload's actual configuration - stdmod.cppm: generalize --no-default-config from macOS-only to all Clang toolchains with a cfg file (cfg paths become stale after mcpp copies the payload to its sandbox) - flags.cppm: sync the same --no-default-config logic for regular compilation flags
GCC bakes the build-time sysroot into the binary via --with-sysroot. For xlings-built GCC this is a path like <buildhost>/.xlings/subos/default that doesn't exist on the user's machine. When -print-sysroot returns such a non-existent path ending in subos/default, remap it to the equivalent sysroot relative to the compiler's own xpkgs directory. This is payload-derived (from the compiler binary's location in the registry), not a config-level dependency on subos.
When bypassing clang++.cfg with --no-default-config, we must provide both libc++ include paths that the cfg originally supplied: -isystem <llvmRoot>/include/c++/v1 -isystem <llvmRoot>/include/<triple>/c++/v1 The target-specific path contains __config_site which is required by __config. Without it, std module precompilation fails with '__config_site' file not found.
On Linux, clang++.cfg contains essential linker flags (-fuse-ld=lld, --rtlib=compiler-rt, --unwindlib=libunwind). Using --no-default-config strips these, causing "cannot find crtbeginS.o" link failures because clang falls back to system GNU ld looking for GCC runtime objects. On Linux, let the cfg apply normally. The cfg's --sysroot points to the xlings subos which is valid and complete. Pass --sysroot explicitly only when needed (to override a stale cfg value), leveraging the fact that command-line --sysroot takes precedence over the cfg's value. Keep --no-default-config for macOS only, where the cfg-baked paths genuinely become stale (pointing to CommandLineTools SDK when Xcode SDK is active).
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.
Summary
tc->sysrootto mcpp's subos (~/.mcpp/registry/subos/default), which lacks linux kernel headers (linux/limits.h) on user machinesclang++.cfgfor--sysroot=when-print-sysrootfails (Clang doesn't support it), sotc->sysrootreflects the payload's actual configuration--no-default-configfrom macOS-only to all Clang toolchains with a cfg file (cfg paths become stale after mcpp copies the payload)Root cause
Commit 063fb6f changed MCPP_HOME to
~/.mcpp/, where the subos skeleton exists but is incomplete (nolinux/,asm/,asm-generic/headers). M5.5 only checkedexists(usr/include)and overwrote the toolchain's correct sysroot. CI never caught this because its subos is fully populated byxlings self install.Design principle
mcpp uses xlings only as a package index + download tool. The toolchain sysroot comes from the payload itself (GCC
-print-sysroot, Clangclang++.cfg), not from xlings subos.Test plan