Skip to content

CUDA: Fail fast if compiler detection using user-specified architectures or host compiler fails

Raul Tambre requested to merge tambre/cmake:cuda_host_compiler_fail into master

If an user specified a host compiler we should fail if we are unable to perform compiler detection with it.
Previously we would try without and likely succeed and continue. Then we'd fail during ABI detection and compiler testing since we'd still try to use it.

This is particularly problematic when crosscompiling since we extract the host linker from the compiler detection link line. This would result in the wrong host linker being used and a linking error due to architecture mismatch during ABI detection where other necessary flags may already be present to make the host compiler work. See #21076 (closed) for an example.

Fix this by adding CMAKE__COMPILER_ID_REQUIRE_SUCCESS to CMakeDetermineCompilerId, which throws a fatal error if executing the compiler results in a non-zero exit code.

Fixes #21120 (closed).

Edited by Raul Tambre

Merge request reports