[llvm-bugs] [Bug 50509] New: CUDA fails to build on Windows with <complex> included due to missing __device__ signbit(long double)

via llvm-bugs llvm-bugs at lists.llvm.org
Thu May 27 10:07:27 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50509

            Bug ID: 50509
           Summary: CUDA fails to build on Windows with <complex> included
                    due to missing __device__ signbit(long double)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: CUDA
          Assignee: unassignedclangbugs at nondot.org
          Reporter: joachim at joameyer.de
                CC: llvm-bugs at lists.llvm.org

Following the libstdc++ 11 issue with <complex>, we added a test for that case
in hipSYCL and discovered another issue with Clang CUDA's complex on Windows.

You can see the failing build here:
https://github.com/illuhad/hipSYCL/runs/2666453501?check_suite_focus=true
The error is:

```
C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include\complex:565:16: error:
call to 'signbit' is ambiguous
        return (_STD signbit)(_Left);
               ^~~~~~~~~~~~~~
D:\a\hipSYCL\hipSYCL\install\lib\clang\11.1.0\include\__clang_cuda_cmath.h:137:17:
note: candidate function
__DEVICE__ bool signbit(float __x) { return ::__signbitf(__x); }
                ^
D:\a\hipSYCL\hipSYCL\install\lib\clang\11.1.0\include\__clang_cuda_cmath.h:138:17:
note: candidate function
__DEVICE__ bool signbit(double __x) { return ::__signbitd(__x); }
```

This was worked around on the hipSYCL side by providing a __device__ bool
std::signbit(long double) overload which just maps to its double counterpart,
as long double on GPUs is pretty non-sensical anyways...
namespace std {
__device__
  inline bool signbit(long double v) {return signbit(static_cast<double>(v));}
}

As I don't see a way to toggle using long double or not in the MS STL, I'd be
open to contributing a similar workaround for the Clang side but would like
some guidance on the correct approach.

Should we just add this overload blindly, add it for Windows only or even
exclusively when using the MS STL? (if so, do you have any idea how to detect
the MS STL is used?)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210527/978d8695/attachment.html>


More information about the llvm-bugs mailing list