test(cuda): build a .cu without link flags, and through a library
CudaCompile's builds name no CUDA library now, but for the last. The toolkit it names through CUDA_PATH has a lib64 beside its nvcc with the real toolkit's libcudart_static.a, so the executable links only if crafter-build links the runtime, and the recorded link names that archive. Another build puts the .cu in a static library and the C++ unit in an executable built on it, which links only if the library hands the runtime on. That lib64 also holds a libcheckpoint.so and a libm.so that are no libraries, as Arch's lib64 holds a real libcheckpoint.so and a libOpenCL.so: another build links an executable with CUDA sources on a library of the project's named checkpoint, and clang++ adds -lm to every C++ link, so a link that searched the toolkit's lib64 would stop on one of them wherever its -L stood. The last names -L<lib64> -lcudart, as a project with CUDA sources had to, and has that -lcudart ahead of the static archive, so the shared runtime is the one the linker takes. The test skips where the real toolkit's lib64 holds no static runtime, since crafter-build then links none. Before crafter-build linked the runtime, the link failed on an undefined CUDA runtime symbol. ToolchainResolve checks where the runtime is looked for, on staged toolkits, so that it runs in CI: the archive in the lib64 beside nvcc's bin, none where that lib64 holds none, none where it links to itself, which a look that threw would have stopped the test on, and none without an nvcc. CudaCompile is the only check of the runtime link itself, and it skips without such a toolkit, so AGENTS.template.md's note on when to run it names the link as well as the compile, and gives the lookup to ToolchainResolve.
This commit is contained in:
parent
22ea97406d
commit
99653194ba
4 changed files with 179 additions and 18 deletions
|
|
@ -247,6 +247,30 @@ int main() {
|
|||
Check(found.is_absolute() && fs::equivalent(found, cuda / "named/bin/nvcc"), std::format("a relative CUDA_PATH names an absolute nvcc (got '{}')", found.string()));
|
||||
}
|
||||
}
|
||||
{
|
||||
// The static runtime beside the nvcc found: lib64/libcudart_static.a
|
||||
// where it is there, else none, as for a lib64 that holds none or
|
||||
// cannot be looked into, here one that links to itself, which has to
|
||||
// be looked into without throwing.
|
||||
const fs::path kits = scratch / "runtime";
|
||||
Program(kits / "with/bin/nvcc");
|
||||
Touch(kits / "with/lib64/libcudart_static.a");
|
||||
Program(kits / "without/bin/nvcc");
|
||||
fs::create_directories(kits / "without/lib64");
|
||||
Program(kits / "looped/bin/nvcc");
|
||||
fs::create_directory_symlink("lib64", kits / "looped/lib64");
|
||||
ToolchainInputs in;
|
||||
in.env["CUDA_PATH"] = (kits / "with").string();
|
||||
const fs::path found = ResolveToolchain(in).cudaRuntime;
|
||||
std::error_code ec;
|
||||
Check(!found.empty() && fs::equivalent(found, kits / "with/lib64/libcudart_static.a", ec), std::format("the static runtime in the lib64 beside nvcc's bin (got '{}')", found.string()));
|
||||
in.env["CUDA_PATH"] = (kits / "without").string();
|
||||
Check(ResolveToolchain(in).cudaRuntime.empty(), "none where that lib64 holds none");
|
||||
in.env["CUDA_PATH"] = (kits / "looped").string();
|
||||
Check(ResolveToolchain(in).cudaRuntime.empty(), "none where the lib64 cannot be looked into");
|
||||
in.env["CUDA_PATH"] = (kits / "missing").string();
|
||||
Check(ResolveToolchain(in).cudaRuntime.empty(), "and none without an nvcc");
|
||||
}
|
||||
{
|
||||
// Nothing anywhere: the error says where it looked and what to set.
|
||||
ToolchainInputs in;
|
||||
|
|
|
|||
Loading…
Reference in a new issue