Before this patch, libomptarget assumed that if the host compiler is clang, then it is also suitable for compile CUDA to LLVM-IR. The intention was that if libomptarget is compiled using LLVM_ENABLE_RUMTIMES=openmp, the host compiler will be clang from the same propository.
However, the host compiler may also be clang when compiling as a LLVM_ENABLE_PROJECTS=openmp or standalone build if the user explicitly set the tool chain or, clang is the system's default compiler (MacOS, most BSDs). Various vendor compilers such as Apple's clang, Intel's dpcpp/icx, IBM's xlclang, etc. may be identified as 'clang' by CMake. However, these potentially use an incompatible IR, or stripped CUDA support, with unpredictable results.
Fix by explicitly set LIBOMPTARGET_NVPTX_CUDA_COMPILER (and LIBOMPTARGET_NVPTX_BC_LINKER) when using LLVM_ENABLE_RUMTIMES=openmp and do not try to use the host compiler.
Implementation of discussion in D101265. Compilation result: http://meinersbur.de:8011/#/builders/143/builds/375
I don't think it's a good idea to "pollute" LLVM CMake files for this purpose. There are plenty of ways to tell whether OpenMP is built via LLVM_ENABLE_RUNTIMES. I'd set the two CMake variables in OpenMP by checking whether we're in LLVM_ENABLE_RUNTIMES.