For NVPTX target, OpenMP provides a static library libomptarget-nvptx
built by NVCC, and another bitcode libomptarget-nvptx-sm_{$sm}.bc generated by
Clang. When compiling an OpenMP program, the .bc file will be fed to clang
in the second run on the program that compiles the target part. Then the generated
PTX file will be fed to ptxas to generate the object file, and finally the driver
invokes nvlink to generate the binary, where the static library will be appened
to nvlink.
One question is, why do we need two libraries? The only difference is, the static
library contains omp_data.cu and the bitcode library doesn't. It's unclear why
they were implemented in this way, but per D94565, there is no issue if we also
include the file into the bitcode library. Therefore, we can safely drop the
static library.
This patch is about the change in OpenMP. The driver will be updated as well if
this patch is accepted.
We should probably rework this logic / failure reporting. Finding a working compiler should be simpler if we build libomptarget via ENABLE_RUNTIMES.