Cross-posted from StackOverflow:
I’m having some trouble compiling a simple test program with NVCC using Clang-9 as a host compiler and libc++ as the STL implementation.
System:
- Ubuntu 18.04-LTS
- NVCC 11.0.194
- Clang-9 installed from the LLVM APT packages
- LLVM Libc+±9
I have the following test program, main.cu
:
#include <string>
#include <cstring>
#include <iostream>
std::string device_description() {
int device_count = 0;
cudaError err = cudaGetDeviceCount(&device_count);
for ( int i = 0; i < device_count; ++i) {
cudaDeviceProp props;
err = cudaGetDeviceProperties(&props, i);
if (!err) {
return std::string(props.name, std::strlen(props.name));
}
}
return "no device";
}
int main() {
std::cout << device_description() << std::endl;
return 0;
}
It compiles and runs successfully with NVCC and clang as follows:
nvcc --std c++17 -ccbin /usr/bin/clang++-9 main.cu -o test
However, if I attempt to compile with libc++
nvcc --std c++17 -forward-unknown-to-host-compiler -ccbin /usr/bin/clang++-9 -stdlib=libc++ main.cu -o test
I get the following output:
/usr/lib/llvm-9/bin/../include/c++/v1/type_traits(559): error: type name is not allowed
/usr/lib/llvm-9/bin/../include/c++/v1/type_traits(559): error: type name is not allowed
/usr/lib/llvm-9/bin/../include/c++/v1/type_traits(559): error: identifier "__is_same" is undefined
...etc...
21 errors detected in the compilation of "main.cu".
Am I missing something?