Failed to configure with MLIR_ENABLE_CUDA_RUNNER and libc++ as clang's default stdlib

Hi,

cmake-ing with MLIR_ENABLE_CUDA_RUNNER turned on and setting
CLANG_DEFAULT_CXX_STDLIB="libc++" resulted in the error when checking
nvcc is able to compile a test program. It turns out that -stdlibc=libc++ is passed
to the host compiler (g++ of version 9.4.0) which doesn’t understand the option.
Is this known limitation?

Thanks in advance!

CMake Error at /home/ryuta/packages/cmake/cmake-3.28.0/Modules/CMakeTestCUDACompiler.cmake:59 (message):
  The CUDA compiler

    "/usr/local/cuda-11.4/bin/nvcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/home/ryuta/packages/llvm/build/CMakeFiles/CMakeScratch/TryCompile-qjhF1D'
    
    Run Build Command(s): /usr/bin/ninja -v cmTC_5425b
    [1/2] /usr/local/cuda-11.4/bin/nvcc -forward-unknown-to-host-compiler   -O2 -g -DNDEBUG "--generate-code=arch=compute_87,code=[compute_87,sm_87]" -MD -MT CMakeFiles/cmTC_5425b.dir/main.cu.o -MF CMakeFiles/cmTC_5425b.dir/main.cu.o.d -x cu -c /home/ryuta/packages/llvm/build/CMakeFiles/CMakeScratch/TryCompile-qjhF1D/main.cu -o CMakeFiles/cmTC_5425b.dir/main.cu.o
    [2/2] : && /usr/bin/g++ -stdlib=libc++ -fuse-ld=lld -Wl,--color-diagnostics -flto=thin -Wl,--thinlto-cache-dir=/home/ryuta/packages/llvm/build/lto.cache CMakeFiles/cmTC_5425b.dir/main.cu.o -o cmTC_5425b  -lcudadevrt  -lcudart_static  -lrt  -lpthread  -ldl -L"/usr/local/cuda-11.4/targets/aarch64-linux/lib/stubs" -L"/usr/local/cuda-11.4/targets/aarch64-linux/lib" && :
    FAILED: cmTC_5425b 
    : && /usr/bin/g++ -stdlib=libc++ -fuse-ld=lld -Wl,--color-diagnostics -flto=thin -Wl,--thinlto-cache-dir=/home/ryuta/packages/llvm/build/lto.cache CMakeFiles/cmTC_5425b.dir/main.cu.o -o cmTC_5425b  -lcudadevrt  -lcudart_static  -lrt  -lpthread  -ldl -L"/usr/local/cuda-11.4/targets/aarch64-linux/lib/stubs" -L"/usr/local/cuda-11.4/targets/aarch64-linux/lib" && :
    g++: error: unrecognized command line option ‘-stdlib=libc++’
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  /home/ryuta/packages/llvm/llvm-project/mlir/lib/Dialect/GPU/CMakeLists.txt:121 (enable_language)

Here’s how I configure:

CC=clang \
CXX=clang++ \
LD=ld.lld \
CUDACXX=nvcc \
CUDAARCHS=87 \
$HOME/packages/cmake/build/bin/cmake \
      -G Ninja \
      -B build \
      -S llvm-project/llvm \
      -DBUILD_SHARED_LIBS=ON \
      -DCMAKE_INSTALL_PREFIX=$PWD/local \
      -DCMAKE_BUILD_TYPE="RelWithDebInfo" \
      -DCMAKE_C_COMPILER_LAUNCHER=ccache \
      -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
      -DLLVM_TARGETS_TO_BUILD="AArch64;NVPTX;WebAssembly" \
      -DLLVM_ENABLE_LIBCXX=ON \
      -DLLVM_ENABLE_LLD=ON \
      -DLLVM_ENABLE_LTO="Thin" \
      -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb;mlir;flang" \
      -DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx;compiler-rt;openmp" \
      -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
      -DMLIR_ENABLE_CUDA_RUNNER=ON \
      -DMLIR_ENABLE_NVPTXCOMPILER=ON \
      -DCLANG_DEFAULT_CXX_STDLIB="libc++" \
      -DCLANG_DEFAULT_LINKER="lld" \
      -DCLANG_DEFAULT_RTLIB="compiler-rt" \
      -DCLANG_DEFAULT_UNWINDLIB="libunwind"