<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Incompatible C++ headers when compiling with -fopenmp-targets=nvptx64-nvidia-cuda"
   href="https://bugs.llvm.org/show_bug.cgi?id=40239">40239</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Incompatible C++ headers when compiling with -fopenmp-targets=nvptx64-nvidia-cuda
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>OpenMP
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Clang Compiler Support
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>csdaley@lbl.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The iostream and algorithm header files cause compilation errors when compiled
with -fopenmp-targets=nvptx64-nvidia-cuda. This happens on Intel Haswell but
not on IBM Power 8.


$ cat hello.cxx 
#include <iostream>
#include <algorithm>

int main()
{
  std::cout << "hello" << std::endl;
  return 0;
}


The following works:
$ clang++ hello.cxx -fopenmp -o hello && ./hello
hello

The following fails:
$ clang++ hello.cxx -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -o hello &&
./hello
In file included from hello.cxx:1:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/iostream:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ostream:38:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/ios:40:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/char_traits.h:39:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_algobase.h:64:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_pair.h:59:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/move.h:57:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/type_traits:269:39:
error: __float128 is not supported
      on this target
    struct __is_floating_point_helper<__float128>
                                      ^
In file included from hello.cxx:2:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/algorithm:62:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_algo.h:65:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/random:51:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/opt_random.h:33:
In file included from
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/x86intrin.h:29:
In file included from
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/immintrin.h:427:
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/pconfigintrin.h:42:14:
error: invalid output
      constraint '=a' in asm
           : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
             ^
In file included from hello.cxx:2:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/algorithm:62:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/stl_algo.h:65:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/random:51:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/x86_64-redhat-linux/bits/opt_random.h:33:
In file included from
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/x86intrin.h:29:
In file included from
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/immintrin.h:431:
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/sgxintrin.h:40:14:
error: invalid output
      constraint '=a' in asm
           : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
             ^
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/sgxintrin.h:51:14:
error: invalid output
      constraint '=a' in asm
           : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
             ^
/home/chrisdaley/software/llvm/8.0.0-git_20190105/lib/clang/8.0.0/include/sgxintrin.h:62:14:
error: invalid output
      constraint '=a' in asm
           : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2])
             ^
5 errors generated.



I can avoid the error from the iostream header file by compiling against the
2011 ISO C++ standard using -std=c++11, but the error from the algorithm header
file remains. I can avoid both errors by using a different GCC toolchain, but I
don't know if this is advised:

$ clang++ -std=c++11
--gcc-toolchain=/home/chrisdaley/software/gcc/8.2.0-offload hello.cxx -fopenmp
-fopenmp-targets=nvptx64-nvidia-cuda -o hello && ./hello
hello

Finally, I can also avoid both errors by compiling against the 1998 ISO C++
standard. Although unfortunately I need to use C++11 in my real code.

$ clang++ -std=c++98 hello.cxx -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -o
hello && ./hello
hello

$ clang++ -v
clang version 8.0.0 (<a href="https://github.com/llvm-mirror/clang">https://github.com/llvm-mirror/clang</a>
53e3c74f8e4c55f5122bdd1cab090fd21daa9ce2) (<a href="https://github.com/llvm-mirror/llvm">https://github.com/llvm-mirror/llvm</a>
bfaf433903bc707a4320b02b34e0c39da1fcfc85)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/chrisdaley/software/llvm/8.0.0-git_20190105/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /cm/extra/apps/CUDA.linux86-64/9.2.88.1_396.26,
version 9.2


Thanks,
Chris</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>