<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 - Compiling with -fopenmp-targets=nvptx64-nvida-cuda generates fatal error: 'gnu/stubs-32.h' file not found"
   href="https://bugs.llvm.org/show_bug.cgi?id=33043">33043</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiling with -fopenmp-targets=nvptx64-nvida-cuda generates fatal error: 'gnu/stubs-32.h' file not found
          </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>sergiop@udel.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=18444" name="attach_18444" title="Verbose error">attachment 18444</a> <a href="attachment.cgi?id=18444&action=edit" title="Verbose error">[details]</a></span>
Verbose error

Dear All,

I'm getting the following error when compiling with triple nvptx64-nvida-cuda.
I'm trying to compile manually one of the test cases in libomptarget
(openmp/libomptarget/test/offloading/offloading_success.c).

clang -fopenmp -fopenmp-targets=nvptx64-nvida-cuda offloading_success.c

But I'm getting the following compilation error during the compilation of the
ptx code. For some reason the compiler is trying to use the gnu/stubs-32.h
header (it is using the macro __WORDSIZE == 32 rather than 64). I'm attaching
the verbose output of the compiler.

--- 
In file included from offloading_success.c:6:
In file included from /usr/include/stdio.h:28:
In file included from /usr/include/features.h:385:
/usr/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
          ^~~~~~~~~~~~~~~~
1 error generated.
---

I tested this in two 64 bit systems, thus I don't understand why It wants to
use a 32 bit header: 
- CentOS release 6.7 x86_64 + Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz +
NVIDIA Tesla K80 GPU + gcc 6.2.0
- CentOS release 7 + IBM POWER8 + NVIDIA Tesla P100 GPU + gcc/6.2.1-20161129.

------Setup
I compiled llvm/clang/OpenMP from the master branch. LLVM/clang compiles
correctly and OpenMP compiles with LIBOMPTARGET: Building CUDA offloading
plugin.

Clang commit: 84f57d869ba15eb9b12abc57014d530647a00e01
LLVM commit: 34ad4ae9219da7d2e14b14d0eefd10515d5ac526
OpenMP commit: 1eb73292d2baee506f5dcd1584fca768c849313b

I used cmake + ninja.

1. LLVM + clang: 
cmake /home/1678/Code/ornl/llvm -G Ninja -DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++
-DCMAKE_INSTALL_PREFIX=/home/1678/Code/ornl/llvm-install

2. OpenMP as an out-of-the-tree project: 
cmake /home/1678/Code/ornl/llvm-out-of-tree/openmp -G Ninja
-DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=/home/1678/Code/ornl/llvm-oot-install
-DLIBOMP_LLVM_LIT_EXECUTABLE=/home/1678/Code/ornl/llvm-build/bin/llvm-lit
-DLIBOMPTARGET_FILECHECK_EXECUTABLE=/home/1678/Code/ornl/llvm-build/bin/FileCheck
-DLIBOMPTARGET_LLVM_LIT_EXECUTABLE=/home/1678/Code/ornl/llvm-build/bin/llvm-lit
-DLIBOOMPTARGET_OPENMP_HEADER_FOLDER=/home/1678/Code/ornl/llvm-oot-install/include
-DLIBOMPTARGET_OPENMP_HOST_RTL_FOLDER=/home/1678/Code/ornl/llvm-oot-install/lib

Best,</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>