llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

[Cuda] Fails to build anything with error: __float128 is not supported on this target #97866

Closed russeree closed 2 weeks ago

russeree commented 2 months ago

Hey currently I am having difficulty getting the Clang++ Cuda compiler to build anything on my instance of Arch Linux. The primary error being error: __float128 is not supported on this target

System Specs

I have tried multiple versions of Clang and they all have the same behavior.

My Code

https://gist.github.com/russeree/4756646281b36fcf1825eaf28330136b

My Command

clang++ -x cuda --cuda-gpu-arch=sm_61 -I/opt/cuda/lib64 axpy.cu -o axpy -L/opt/cuda/lib32 -lcudart_static -ldl -lrt -pthread

I have tried the other flags such as

 --std=c++17 -D__STRICT_ANSI__ 

These do not help at all

Errors

/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2089:27: error: __float128 is not supported on this target
 2089 |     struct numeric_limits<__float128>
      |                           ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2093:33: error: __float128 is not supported on this target
 2093 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2104:33: error: __float128 is not supported on this target
 2104 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2118:33: error: __float128 is not supported on this target
 2118 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2132:33: error: __float128 is not supported on this target
 2132 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2136:33: error: __float128 is not supported on this target
 2136 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2156:33: error: __float128 is not supported on this target
 2156 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2160:33: error: __float128 is not supported on this target
 2160 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2164:33: error: __float128 is not supported on this target
 2164 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2176:33: error: __float128 is not supported on this target
 2176 |       static _GLIBCXX_CONSTEXPR __float128
      |                                 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2170:28: error: __float128 is not supported on this target

Full log in this gist https://gist.github.com/russeree/b77db6865093ee452f01ff797098a9fe

tukss commented 2 months ago

I've seen the same issue on my system, Fedora with GCC 14 C++ headers and Clang 18.

I could get it to work with --std=c++17 (which sets __STRICT_ANSI__ and thereby removes the references to __float128 in the headers) and using GCC 13 headers with --gcc-install-dir.

The GCC 14 headers introduced another mention of __float128 that is not guarded by __STRICT__ANSI__, which is why we see the error even with --std=c++17.

I think the root cause of the problem is that clang sets __FLOAT128__ on x86(_64) Linux systems even when the CUDA target doesn't support it. We were just lucky in the past that the problematic parts of the GCC C++ headers were guarded by __STRICT_ANSI__.

I think the logic that enables __FLOAT128__ is here. I guess it should be disabled in case we build for CUDA.

Artem-B commented 2 months ago

Should be fixed by https://github.com/llvm/llvm-project/pull/83918

llvmbot commented 2 months ago

@llvm/issue-subscribers-clang-frontend

Author: Portland.HODL (russeree)

Hey currently I am having difficulty getting the Clang++ Cuda compiler to build anything on my instance of Arch Linux. The primary error being ``` error: __float128 is not supported on this target``` ### System Specs - Arch Linux - Up to date - [Cuda 12.5](https://archlinux.org/packages/extra/x86_64/cuda/) - LLVM 14.0.6, 16.0.6, 18.x.x I have tried multiple versions of Clang and they all have the same behavior. ### My Code https://gist.github.com/russeree/4756646281b36fcf1825eaf28330136b ### My Command ``` clang++ -x cuda --cuda-gpu-arch=sm_61 -I/opt/cuda/lib64 axpy.cu -o axpy -L/opt/cuda/lib32 -lcudart_static -ldl -lrt -pthread ``` I have tried the other flags such as ``` --std=c++17 -D__STRICT_ANSI__ ``` These do not help at all ### Errors ``` /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2089:27: error: __float128 is not supported on this target 2089 | struct numeric_limits<__float128> | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2093:33: error: __float128 is not supported on this target 2093 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2104:33: error: __float128 is not supported on this target 2104 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2118:33: error: __float128 is not supported on this target 2118 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2132:33: error: __float128 is not supported on this target 2132 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2136:33: error: __float128 is not supported on this target 2136 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2156:33: error: __float128 is not supported on this target 2156 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2160:33: error: __float128 is not supported on this target 2160 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2164:33: error: __float128 is not supported on this target 2164 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2176:33: error: __float128 is not supported on this target 2176 | static _GLIBCXX_CONSTEXPR __float128 | ^ /usr/lib64/gcc/x86_64-pc-linux-gnu/14.1.1/../../../../include/c++/14.1.1/limits:2170:28: error: __float128 is not supported on this target ``` Full log in this gist https://gist.github.com/russeree/b77db6865093ee452f01ff797098a9fe
Artem-B commented 2 months ago

Works with gcc-15: https://godbolt.org/z/EPYWaeTPW

tukss commented 2 months ago

Thanks for pointing this out. I can confirm the problem went away completely when switching to the current main branch of LLVM. Any chance this fix will be backported for version 18?

Artem-B commented 2 months ago

My guess is that it's unlikely to happen. Post-release changes are usually limited to critical issues (https://llvm.org/docs/HowToReleaseLLVM.html#release-patch-rules) and this is not one of them, in general.

This problem had existed for a very long time, and went largely unnoticed because the libstdc++ headers installed by debian and ubuntu had patches to work around it, so it only affected the users who used pristine libstdc++ headers, and relatively few users did that.

russeree commented 2 months ago

My guess is that it's unlikely to happen. Post-release changes are usually limited to critical issues (https://llvm.org/docs/HowToReleaseLLVM.html#release-patch-rules) and this is not one of them, in general.

This problem had existed for a very long time, and went largely unnoticed because the libstdc++ headers installed by debian and ubuntu had patches to work around it, so it only affected the users who used pristine libstdc++ headers, and relatively few users did that.

switching to main solved this problem completely! Thank you so much!

image

Artem-B commented 2 weeks ago

Closing as fixed.