CUDA is not compatible with current versions of libc++

It is not possible to compile CUDA code using nvcc and clang as the host compiler with libc++ as the stdlib.
This is how you can reproduce this issue:
OS: Ubuntu 18.04

  1. Install cuda 11.2.1 with samples
  2. Install clang 9 and libc++
    a. sudo apt install clang-9 libc+±9-dev libc++abi-9-dev
  3. Replace the Makefile of the 0_Simple/vectorAdd with the one from this post
  4. Build vectorAdd using the make command
  5. Result: see code block. This issue is reproducible with newer releases of the CUDA toolkit.

I have also attached a Makefile at the end of this post.

Related post: Cuda issues with Clang Compiler

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h(9100): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h(9113): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h(9121): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h(9135): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h(9678): error: namespace "std" has no member "__lazy_enable_if"

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h(9678): error: expected a ";"

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.h(9681): warning: parsing restarts here after previous syntax error

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(375): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(381): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(383): error: cannot overload functions distinguished by return type alone

/usr/local/cuda/bin/../targets/x86_64-linux/include/crt/math_functions.hpp(389): error: cannot overload functions distinguished by return type alone

Makefile

1 Like

Yes, and it’s still a problem with latest version (cuda 11.5.0 and the supposedly supported clang/libcxx 12).

Some functions in math_functions.h and math_functions.hpp do not detect the new libcxx version to apply the same spurious noexcepts.

1 Like