Skip to content

Protect C++ compile options from direct use by NVCC

Benjamin Morgan requested to merge bmorgan/cuda-unknown-to-host into master

Reported by Celeritas developers (thanks Seth Johnson and Paul Romano!). When using VecGeom with CUDA enabled and CUDA 10.1/2, NVCC errors out with:

  • nvcc fatal : Unknown option 'faligned-new'
  • nvcc fatal : 'avx2': expected a number

Traced to CUDA < 11 not providing the -forward-unknown-to-host-compiler flag, which CMake will add automatically if NVCC supports it. Not picked up immediately in CI testing of VecGeom as it still uses the old FindCUDA build methodology. Consumers of VecGeom linking to the CUDA library get a transitive link the VecGeom C++ library and thus have its (C++) compile options applied to CUDA compilations. CMake w/CUDA 11 handles this transparently with the above forwarding flag, but older CUDA versions barf as described.

Limit direct use of C++ compile options to C++ compilation consumers. Wrap C++ compile options in -Xcompiler= flags for CUDA consumers to forward these to the host compiler for both CUDA 10 and newer.

This can be dropped once VecGeom requires CUDA 11 or newer as the minimum version.

Merge request reports