[BUG]: c.parallel unit tests link c2h (with THRUST_DEVICE_SYSTEM=CUDA) but compile without a CUDA compiler
- Dominant language
- C++
- Stars
- 2.5k
- Forks
- 486
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 295
Description
### Is this a duplicate?
- [x] I confirmed there appear to be no [duplicate issues](https://github.com/NVIDIA/cccl/issues) for this bug and that I agree to the [Code of Conduct](CODE_OF_CONDUCT.md)
### Type of Bug
Compile-time Error
### Component
Not sure
### Describe the bug
In #5154, I extend c2h with a new printing routine for Catch2. This causes additional code paths of `thrust::device_vector` to be instantiated and fail compilation, because the CUDA device system is active (per CMake configuration of cccl.c) but no CUDA compiler is used, since the cccl.c tests are translated by a non-CUDA compiler (.cpp files).
Error:
```
[100%] Building CXX object c/parallel/test/CMakeFiles/cccl.c.parallel.test.for.cpp.dir/test_for.cpp.o
In file included from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/memory.h:35,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/allocator/temporary_allocator.h:31,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/temporary_array.h:46,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/internal/copy_cross_system.h:47,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/system/cuda/detail/copy.h:79,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/system/detail/adl/copy.h:50,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/copy.inl:29,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/copy.h:72,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/system/detail/sequential/merge.inl:28,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/system/detail/sequential/merge.h:81,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/system/cpp/detail/merge.h:30,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/system/cpp/execution_policy.h:59,
from /home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/execution_policy.h:40,
from /home/bgruber/dev/cccl/c2h/include/c2h/device_policy.h:30,
from /home/bgruber/dev/cccl/c2h/include/c2h/catch2_test_helper.h:20,
from /home/bgruber/dev/cccl/c/parallel/test/test_util.h:29,
from /home/bgruber/dev/cccl/c/parallel/test/algorithm_execution.h:19,
from /home/bgruber/dev/cccl/c/parallel/test/test_for.cpp:19:
/home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/reference.h: In instantiation of ‘thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::reference::value_type thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::reference::strip_const_get_value(const System&) const [with System = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::cuda_cub::tag; Element = const char; Pointer = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::device_ptr; Derived = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::device_reference; value_type = char]’:
/home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/reference.h:328:33: required from ‘thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::reference::value_type thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::reference::convert_to_value_type(System*) const [with System = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::cuda_cub::tag; Element = const char; Pointer = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::device_ptr; Derived = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::device_reference; value_type = char]’
/home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/reference.h:179:33: required from ‘thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::reference::operator value_type() const [with Element = const char; Pointer = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::device_ptr; Derived = thrust::THRUST_300100_SM___CUDA_ARCH_LIST___NS::device_reference; value_type = char]’
/home/bgruber/dev/cccl/c2h/include/c2h/vector.h:89:1: required from here
/home/bgruber/dev/cccl/lib/cmake/thrust/../../../thrust/thrust/detail/reference.h:337:21: error: void value not ignored as it ought to be
337 | return get_value(thrust::detail::derived_cast(non_const_system), ptr);
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
This error is caused because in:
```
template
_CCCL_HOST_DEVICE value_type strip_const_get_value(System const& system) const
{
System& non_const_system = const_cast(system);
using thrust::system::detail::generic::get_value;
return get_value(thrust::detail::derived_cast(non_const_system), ptr);
}
```
`generic::get_value` returns `void` and `cuda_cub::get_value` is not visible (but included!) because the compiler is not a CUDA compiler.
### How to Reproduce
Git clone #5154.
Configure CCCL C tests and build target `cccl.c.parallel.test.for.cpp`.
### Expected behavior
Successful compilation.
### Reproduction link
_No response_
### Operating System
_No response_
### nvidia-smi output
_No response_
### NVCC version
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.