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

            Bug ID: 41390
           Summary: _FORTIFY_SOURCE  and optimization(like -O1, -O2, etc.)
                    prevents CUDA compilation
           Product: clang
           Version: trunk
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: CUDA
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

#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
https://sourceware.org/git/?p=glibc.git;a=blob;f=string/string.h;h=c38eea971f4396c678598f51602082318ec5349d;hb=HEAD#l494)
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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to