test(sysroot): cover the std module source choice for a sysroot build
SysrootStdModule runs over staged layouts that need no compiler: a sysroot with its own module source, one on a point release of the toolchain's libc++, one on the next major release with a shipped source, one nothing was shipped for, one without libc++ at all, and the two cases where a release cannot be read. The last block drives Build() against a sysroot claiming libc++ 99 and expects the one-line explanation back instead of compiler output, which is the failure the fix replaces. ToolchainResolve additionally checks that the release is read from the libc++ the module source comes from (the prefix's, an explicit libc++ install's, the system's) and where the shipped sources are looked up. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
e15cd3c14d
commit
cbf2b94f06
3 changed files with 167 additions and 1 deletions
|
|
@ -40,9 +40,11 @@ int main() {
|
|||
// A prefix with everything crafter-build looks for beside the compiler,
|
||||
// and one with the compiler alone.
|
||||
const fs::path full = scratch / "full";
|
||||
for (const char* rel : {"bin/clang++", "bin/clang", "bin/llvm-ar", "lib/libclang.so", "include/clang-c/Index.h", "share/libc++/v1/std.cppm", "share/wasi-sysroot/include/.keep"}) {
|
||||
for (const char* rel : {"bin/clang++", "bin/clang", "bin/llvm-ar", "lib/libclang.so", "include/clang-c/Index.h", "include/c++/v1/__config", "share/libc++/v1/std.cppm", "share/wasi-sysroot/include/.keep"}) {
|
||||
Touch(full / rel);
|
||||
}
|
||||
// The prefix's libc++ headers state its release.
|
||||
std::ofstream(full / "include/c++/v1/__config") << "# define _LIBCPP_VERSION 230102\n";
|
||||
const fs::path bare = scratch / "bare";
|
||||
Touch(bare / "bin/clang++");
|
||||
|
||||
|
|
@ -56,6 +58,8 @@ int main() {
|
|||
Check(!tc.libclang.has_value(), "the PATH fallback searches libclang by name");
|
||||
Check(tc.llvmIncludeDir.empty(), "the PATH fallback adds no include dir");
|
||||
Check(tc.stdCppm == "/usr/share/libc++/v1/std.cppm", "the system std module source is the default");
|
||||
Check(tc.libcxxVersion == LibcxxVersion("/usr/include/c++/v1"), "the system libc++ headers state the release of the system module source");
|
||||
Check(tc.stdModulesDir.empty(), "no crafter-build prefix, no shipped module sources");
|
||||
Check(tc.wasiSysroot == "/usr/share/wasi-sysroot", "the system wasi sysroot is the default");
|
||||
Check(tc.mingwSysroot == "/usr/x86_64-w64-mingw32" && !tc.mingwSysrootExplicit, "the default mingw dir is not passed as --sysroot");
|
||||
Check(tc.LibcxxCompileFlags().empty() && tc.LibcxxLinkFlags().empty(), "the PATH fallback adds no libc++ flags");
|
||||
|
|
@ -71,6 +75,8 @@ int main() {
|
|||
Check(tc.libclang == full / "lib/libclang.so", "libclang beside the compiler is pinned");
|
||||
Check(tc.llvmIncludeDir == full / "include", "clang-c headers beside the compiler are added to the include path");
|
||||
Check(tc.stdCppm == full / "share/libc++/v1/std.cppm", "the prefix's std module source is used");
|
||||
Check(tc.libcxxVersion == 230102, "the prefix's libc++ headers state its release");
|
||||
Check(tc.stdModulesDir == full / "share/crafter-build/libc++-modules", "module sources for other releases are looked up in crafter-build's own share directory");
|
||||
Check(tc.wasiSysroot == full / "share/wasi-sysroot", "the prefix's wasi sysroot is used");
|
||||
Check(tc.LibcxxCompileFlags().empty(), "the compiler finds its own libc++ headers without flags");
|
||||
Check(Contains(tc.LibcxxLinkFlags(), std::format("-L{}", (full / "lib").string())) && Contains(tc.LibcxxLinkFlags(), std::format("-Wl,-rpath,{}", (full / "lib").string())), "binaries get -L and an rpath for the prefix's lib dir");
|
||||
|
|
@ -120,12 +126,15 @@ int main() {
|
|||
// An explicit libc++ install: headers, library and std module all
|
||||
// come from it, whatever the compiler would have used.
|
||||
const fs::path libcxx = scratch / "libcxx";
|
||||
fs::create_directories(libcxx / "include/c++/v1");
|
||||
std::ofstream(libcxx / "include/c++/v1/__config") << "# define _LIBCPP_VERSION 210108\n";
|
||||
ToolchainInputs in;
|
||||
in.crafterPrefix = full;
|
||||
in.env["CRAFTER_BUILD_LIBCXX_DIR"] = libcxx.string();
|
||||
Toolchain tc = ResolveToolchain(in);
|
||||
Check(tc.libcxxDir == libcxx, "CRAFTER_BUILD_LIBCXX_DIR is recorded");
|
||||
Check(tc.stdCppm == libcxx / "share/libc++/v1/std.cppm", "the std module source follows the explicit libc++");
|
||||
Check(tc.libcxxVersion == 210108, "the release is read from the explicit libc++, not the compiler's");
|
||||
Check(Contains(tc.LibcxxCompileFlags(), std::format("-nostdinc++ -isystem {}", (libcxx / "include/c++/v1").string())), "compiles use the explicit libc++ headers");
|
||||
Check(Contains(tc.LibcxxLinkFlags(), std::format("-L{}", (libcxx / "lib").string())) && Contains(tc.LibcxxLinkFlags(), std::format("-Wl,-rpath,{}", (libcxx / "lib").string())), "links use the explicit libc++ library dir, with an rpath");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue