<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 - _FORTIFY_SOURCE and optimization(like -O1, -O2, etc.) prevents CUDA compilation"
   href="https://bugs.llvm.org/show_bug.cgi?id=41390">41390</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>_FORTIFY_SOURCE  and optimization(like -O1, -O2, etc.) prevents CUDA compilation
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </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>CUDA
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>kazukuro0824@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>#include <stdio.h>
int main()
{
    printf("test\n");
}

This code can't be compiled when you run Clang like below:
$ clang -x cuda -O2 -D_FORTIFY_SOURCE=1 -c test.cu.cc

That's because string_fortified.h, included from string.h, tries to re-declare
some built-in functions. (See also
<a href="https://sourceware.org/git/?p=glibc.git;a=blob;f=string/string.h;h=c38eea971f4396c678598f51602082318ec5349d;hb=HEAD#l494">https://sourceware.org/git/?p=glibc.git;a=blob;f=string/string.h;h=c38eea971f4396c678598f51602082318ec5349d;hb=HEAD#l494</a>)
So, I think __clang_cuda_runtime_wrapper.h:216 should be reconsidered. 

For example:

#include <string.h>

to

#if defined(__fortify_function)
#define __tmp_value __fortify_function
#undef __fortify_function
#include <string.h>
#define __fortify_function __tmp_value
#undef __tmp_value
#else
#include <string.h>
#endif</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>