[cfe-dev] libtooling/libclang cannot find "__clang_cuda_runtime_wrapper.h"
Franklin He via cfe-dev
cfe-dev at lists.llvm.org
Sat Nov 10 16:22:33 PST 2018
Thanks for the help Artem.
After a bit of fumbling around, adding the resource directory results in the same error as directly including the clang directory via -I
I was hoping to use libclang as libTooling is restricted to either host or device code in a single pass from my understanding. In the meantime, I'll proceed with libTooling.
-- Franklin
Error message attached below:
$ ./cuda_libclang_sa /tmp/test.cu -v --cuda-gpu-arch=sm_35 -resource-dir=/home/n0mad/code_libs/llvm_trunk/lib/clang/8.0.0
clang version 8.0.0 (http://llvm.org/git/clang.git 3129a82102a7de23d44f02c0df89c1d6a535f7a7) (http://llvm.org/git/llvm.git 00233291cf25baa54e5d058610e8a985deaac9e4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/n0mad/CLionProjects/cudadadadadadadadadada/cmake-build-debug/libclang
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/8
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda-10.0, version 10.0
ignoring nonexistent directory "/include"
ignoring nonexistent directory "/include"
ignoring duplicate directory "/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8"
ignoring duplicate directory "/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux"
ignoring duplicate directory "/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/home/n0mad/code_libs/llvm_trunk/lib/clang/8.0.0/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/home/n0mad/code_libs/llvm_trunk/lib/clang/8.0.0/include/cuda_wrappers
/usr/local/cuda-10.0/include
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux
/usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward
/usr/local/include
/home/n0mad/code_libs/llvm_trunk/lib/clang/8.0.0/include
/usr/include
End of search list.
/home/n0mad/code_libs/llvm_trunk/lib/clang/8.0.0/include/__clang_cuda_builtin_vars.h:67:27: error: use of undeclared identifier '__nvvm_read_ptx_sreg_tid_x'
/home/n0mad/code_libs/llvm_trunk/lib/clang/8.0.0/include/__clang_cuda_builtin_vars.h:68:27: error: use of undeclared identifier '__nvvm_read_ptx_sreg_tid_y'
/home/n0mad/code_libs/llvm_trunk/lib/clang/8.0.0/include/__clang_cuda_builtin_vars.h:69:27: error: use of undeclared identifier '__nvvm_read_ptx_sreg_tid_z'
________________________________
From: Artem Belevich <tra at google.com>
Sent: Sunday, 11 November 2018 12:29 PM
To: He_Franklin at hotmail.com
Cc: cfe-dev
Subject: Re: [cfe-dev] libtooling/libclang cannot find "__clang_cuda_runtime_wrapper.h"
It looks like -resource-dir is missing in case of libclang tool.
Try passing -Xclang -resource-dir=/path/to/clang/installation/root
You can get resouce dir with 'clang -print-resource-dir'
--Artem
On Sat, Nov 10, 2018 at 2:25 PM Franklin He <He_Franklin at hotmail.com<mailto:He_Franklin at hotmail.com>> wrote:
I did some more testing and the problem does not occur if I put the libTooling-based executable in the $LLVM_INSTALL_DIR/bin directory. I originally did an out of source build which would have put the executable not in tree with the rest of the LLVM library.
The libclang-based tool still exhibit the same issue no matter where I put the final executable.
I've attached the terminal output using the -v flag with tools I've made using libtooling, libclang, and also the output if I compile a test CUDA file using Clang. For some reason they all check different include directories.....
I've also attached what would happen if you force the include of the CUDA wrappers using the -I flag, in short: A lot of weird errors.
-- Franklin
________________________________
From: Artem Belevich <tra at google.com<mailto:tra at google.com>>
Sent: Thursday, 8 November 2018 12:19 PM
To: He_Franklin at hotmail.com<mailto:He_Franklin at hotmail.com>
Cc: cfe-dev
Subject: Re: [cfe-dev] libtooling/libclang cannot find "__clang_cuda_runtime_wrapper.h"
It would help a lot if you could figure out what compiler options we end up using when the file is handled by libtooling or libclang. The fact that you've got the error means that the file *is* treated as a CUDA file (good news) but we either didn't add include path to clang headers, or the headers are not where they should be.
I don't know if there's an easy way to do it libtooling or libclang. In the past I dug these options out with debugger. You can try passing '-v' and see if you get back the usual printout of header search path.
--Artem
On Sun, Oct 14, 2018 at 2:13 AM Franklin He via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:
Hello
I am attempting to write a static analyzer for CUDA using the Clang infrastructure.
After writing a simple tool, and giving it the example CUDA file in https://llvm.org/docs/CompileCudaWithLLVM.html , I get the following error:
fatal error: '__clang_cuda_runtime_wrapper.h' file not found
so far this happens with both libtooling and libclang. I have tried using clang to compile the same CUDA file and it works.
I am currently linking against clang sources from the trunk, but this also happens with Clang version 6.
I currently have CUDA 10 installed on this computer.
Any help would be appreciated.
Regards
Franklin
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
--
--Artem Belevich
--
--Artem Belevich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181111/a542ae4d/attachment.html>
More information about the cfe-dev
mailing list