<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - Cuda: Relocatable device code doesn't work"
   href="https://llvm.org/bugs/show_bug.cgi?id=26343">26343</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Cuda: Relocatable device code doesn't work
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </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>-New Bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>crtrott@sandia.gov
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15733" name="attach_15733" title="Reproduction code">attachment 15733</a> <a href="attachment.cgi?id=15733&action=edit" title="Reproduction code">[details]</a></span>
Reproduction code

With nvcc one can use the option "-rdc true", to allow device (or device host)
functions to be declared "extern". This means device functions can be compiled
in one compilation unit and called from others. This doesn't work here:

Error:
[crtrott@apollo test_relocatable_device_code]$ ./build_clang 
ptxas fatal   : Unresolved extern function '_Z4calcv'
fatal error: cannot open file '/tmp/main-b2a94f.fatbin': No such file or
directory
1 error generated.
clang-3.9: error: ptxas command failed with exit code 255 (use -v to see
invocation)
clang-3.9: error: no such file or directory: 'main.o'


Code:
extern int __device__ calc();

__global__ void foo(int* a) {
   a[blockIdx.x*blockDim.x+threadIdx.x] = calc();
}</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>