<div dir="ltr">Hi,<div><br></div><div>I'm on ubuntu 14.04. I've installed CUDA 7.0 and GCC 4.8, 4.9 and 5.x in my system. Sorry for short written terminal output bit it is my clang installation. Here is an output of this:</div><div><div>$:~/workspace/eclipse/TEST/llvm$ clang -v</div><div>clang version 3.8.0 </div><div>Target: x86_64-unknown-linux-gnu</div><div>Thread model: posix</div><div>InstalledDir: /home/workspace/eclipse/llvm-bin/bin</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.0</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0</div><div>Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0</div><div>Candidate multilib: .;@m64</div><div>Candidate multilib: 32;@m32</div><div>Candidate multilib: x32;@mx32</div><div>Selected multilib: .;@m64</div></div><div><br></div><div>As I understand, clang++ what I built can compile C/C++ but when I want to compile CUDA it can't find essential headers. I put verbose compilation log.</div><div><br></div><div><div>$:~/workspace/eclipse/TEST/llvm$ /home/workspace/eclipse/llvm-bin/bin/clang++ <a href="http://axpy.cu">axpy.cu</a> -o axpy -D__CUDA__ -D__CUDACC__ -I/usr/local/cuda-7.0/include -include cuda_runtime.h -I/usr/local/cuda/samples/common/inc/ -I/usr/local/cuda/ -v -L/usr/local/cuda/lib64 <a href="http://axpy.cu">axpy.cu</a> -lcudart_static -lcuda -ldl -lrt</div><div>clang version 3.8.0 (<a href="https://github.com/clang-omp/clang_trunk">https://github.com/clang-omp/clang_trunk</a> d2064b019fac6da21dc76067b2c8c547379ddd07) (<a href="https://github.com/clang-omp/llvm_trunk">https://github.com/clang-omp/llvm_trunk</a> 76a27d9c85691eff5dbe18c5253865eb362c4786)</div><div>Target: x86_64-unknown-linux-gnu</div><div>Thread model: posix</div><div>InstalledDir: /home/workspace/eclipse/llvm-bin/bin</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.4</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.9.2</div><div>Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.1.0</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2</div><div>Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0</div><div>Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.1.0</div><div>Candidate multilib: .;@m64</div><div>Candidate multilib: 32;@m32</div><div>Candidate multilib: x32;@mx32</div><div>Selected multilib: .;@m64</div><div> "/home/workspace/eclipse/llvm-bin/bin/clang-3.8" -cc1 -triple nvptx64-nvidia-cuda -S -disable-free -main-file-name <a href="http://axpy.cu">axpy.cu</a> -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -no-integrated-as -mconstructor-aliases -target-cpu sm_20 -v -dwarf-column-info -resource-dir /home/workspace/eclipse/llvm-bin/bin/../lib/clang/3.8.0 -include cuda_runtime.h -D __CUDA__ -D __CUDACC__ -I /usr/local/cuda-7.0/include -I /usr/local/cuda/samples/common/inc/ -I /usr/local/cuda/ -c-isystem /home/workspace/eclipse/llvm-openmp-build/runtime/src -c-isystem . -cxx-isystem /home/workspace/eclipse/llvm-openmp-build/runtime/src -cxx-isystem . -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/workspace/eclipse/TEST/llvm -ferror-limit 19 -fmessage-length 135 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/axpy-7c49a7.s -x cuda <a href="http://axpy.cu">axpy.cu</a></div><div>clang -cc1 version 3.8.0 based upon LLVM 3.8.0svn default target x86_64-unknown-linux-gnu</div><div>#include "..." search starts here:</div><div>#include <...> search starts here:</div><div> /usr/local/cuda-7.0/include</div><div> /usr/local/cuda/samples/common/inc</div><div> /usr/local/cuda</div><div> /home/workspace/eclipse/llvm-openmp-build/runtime/src</div><div> .</div><div> /usr/local/include</div><div> /home/workspace/eclipse/llvm-bin/bin/../lib/clang/3.8.0/include</div><div> /usr/include</div><div>End of search list.</div><div>In file included from <built-in>:299:</div><div>In file included from <command line>:3:</div><div>In file included from /usr/local/cuda-7.0/include/cuda_runtime.h:104:</div><div>In file included from /usr/local/cuda-7.0/include/common_functions.h:219:</div><div>/usr/local/cuda-7.0/include/math_functions.h:8484:10: fatal error: 'cmath' file not found</div><div>#include <cmath></div></div><div><br></div><div><br></div><div>Best Regards</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-22 23:56 GMT+01:00 Justin Lebar <span dir="ltr"><<a href="mailto:jlebar@google.com" target="_blank">jlebar@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
What platform are you on?  CUDA support currently only works on Linux.<br>
<br>
I built with llvm@r256010 and clang@r255848 and ran<br>
<br>
$ ~/code/llvm/lldb/bin/clang++ -o axpy<br>
-I/usr/local/cuda/samples/common/inc/ -I/usr/local/cuda/<br>
-L/usr/local/cuda/lib64 <a href="http://axpy.cu" rel="noreferrer" target="_blank">axpy.cu</a> -lcudart_static -lcuda -ldl -lrt<br>
-pthread<br>
<br>
This compiled successfully for me on Ubuntu 14.04.  Note that the<br>
command-line arguments here are *not* optional -- I would not expect<br>
the commands from your e-mail to work, because you were not passing<br>
all of the relevant options.  (These are documented at<br>
<a href="http://llvm.org/docs/CompileCudaWithLLVM.html" rel="noreferrer" target="_blank">http://llvm.org/docs/CompileCudaWithLLVM.html</a>.)<br>
<br>
Maybe this is a dumb question, but are you sure that the clang++<br>
you're invoking is the one you just built?  Usually you have to do<br>
path/to/objdir/bin/clang++.<br>
<span class=""><font color="#888888"><br>
-Justin<br>
</font></span><div class=""><div class="h5"><br>
<br>
On Mon, Dec 21, 2015 at 2:54 AM, gry666 <<a href="mailto:gry666@gmail.com">gry666@gmail.com</a>> wrote:<br>
> Hi Justin,<br>
><br>
> I've installed master version from git on two systems. Currently I can<br>
> thoroughly compile C/C++. But I can't compile CUDA. I think I can't show<br>
> headers to clang while I am compiling cuda<br>
><br>
> The error what I got at the first machine<br>
><br>
> ~/LLVM$ clang++ <a href="http://axpy.cu" rel="noreferrer" target="_blank">axpy.cu</a><br>
> In file included from <built-in>:620:<br>
> In file included from <command line>:1:<br>
> In file included from<br>
> /home/Computational/appbin/llvm-git/bin/../lib/clang/3.8.0/include/__clang_cuda_runtime_wrapper.h:47:<br>
> In file included from /usr/include/stdlib.h:24:<br>
> /usr/include/features.h:374:12: fatal error: 'sys/cdefs.h' file not found<br>
> #  include <sys/cdefs.h><br>
>            ^<br>
><br>
> Second machine<br>
> ~/workspace/eclipse/TEST/llvm$ clang++ <a href="http://axpy.cu" rel="noreferrer" target="_blank">axpy.cu</a> /usr/local/cuda-7.0/include/<br>
> -include cuda_runtime_api.h -D__CUDACC__ -m64<br>
> In file included from <a href="http://axpy.cu:8" rel="noreferrer" target="_blank">axpy.cu:8</a>:<br>
> In file included from /usr/include/cuda_runtime.h:76:<br>
> In file included from /usr/include/common_functions.h:167:<br>
> /usr/include/math_functions.h:7563:10: fatal error: 'cmath' file not found<br>
> #include <cmath><br>
>          ^<br>
><br>
> Thank you very much<br>
><br>
><br>
> 2015-12-20 1:43 GMT+01:00 Justin Lebar <<a href="mailto:jlebar@google.com">jlebar@google.com</a>>:<br>
>><br>
>> It would be easier to debug this if we both had the same source code.<br>
>><br>
>> I'm able to compile many of the samples which came with the CUDA SDK<br>
>> *using clang built from head*.  For example:<br>
>><br>
>> $NVIDIA_CUDA-7.5_Samples/0_Simple/matrixMul$<br>
>> ~/code/llvm/release/bin/clang++ -o matrixMulClang -I../../common/inc<br>
>> -L/usr/local/cuda-7.5/lib64 -I/usr/local/cuda-7.5/ matrixMul.cu<br>
>> -lcudart_static -lcuda -ldl -lrt -pthread<br>
>><br>
>> Does this work for you?  If not, what platform are you on?<br>
>><br>
>> Note that the CUDA implementation in Clang is by no means complete.<br>
>> It mostly works, but there are lots of edge-cases (e.g. printf) that<br>
>> we're still working on.<br>
>><br>
>> -Justin<br>
>><br>
>> On Mon, Dec 14, 2015 at 9:57 AM, gry666 via cfe-dev<br>
>> <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
>> > Hi all,<br>
>> ><br>
>> > It's my first trial with clang. so if my question is so simple, i'm<br>
>> > sorry<br>
>> > first of all.<br>
>> ><br>
>> > Basically, I'm trying to compile simple axpy cuda code by using clang,<br>
>> > I'm<br>
>> > following this example <a href="http://llvm.org/docs/CompileCudaWithLLVM.html" rel="noreferrer" target="_blank">http://llvm.org/docs/CompileCudaWithLLVM.html</a>.<br>
>> > However I'm getting this errors<br>
>> ><br>
>> > $ clang++ <a href="http://axpy.cu" rel="noreferrer" target="_blank">axpy.cu</a> -o axpy-clang -I/usr/local/cuda/samples/common/inc<br>
>> > In file included from <a href="http://axpy.cu:1" rel="noreferrer" target="_blank">axpy.cu:1</a>:<br>
>> > In file included from<br>
>> > /usr/local/cuda/samples/common/inc/helper_cuda.h:24:<br>
>> > /usr/local/cuda/samples/common/inc/helper_string.h:18:10: fatal error:<br>
>> > 'fstream' file not found<br>
>> > #include <fstream><br>
>> >          ^<br>
>> > 1 error generated.<br>
>> > axpy.cu:5:1: error: unknown type name '__global__'<br>
>> > __global__ void axpy(float a, float* x, float* y) {<br>
>> > ^<br>
>> > axpy.cu:5:12: error: expected unqualified-id<br>
>> > __global__ void axpy(float a, float* x, float* y) {<br>
>> >            ^<br>
>> > axpy.cu:19:19: error: use of undeclared identifier 'cudaMalloc'<br>
>> >   checkCudaErrors(cudaMalloc(&device_x, kDataLen * sizeof(float)));<br>
>> >                   ^<br>
>> > axpy.cu:20:19: error: use of undeclared identifier 'cudaMalloc'<br>
>> >   checkCudaErrors(cudaMalloc(&device_y, kDataLen * sizeof(float)));<br>
>> >                   ^<br>
>> > axpy.cu:22:30: error: use of undeclared identifier<br>
>> > 'cudaMemcpyHostToDevice'<br>
>> >                              cudaMemcpyHostToDevice));<br>
>> >                              ^<br>
>> > axpy.cu:25:3: error: use of undeclared identifier 'axpy'<br>
>> >   axpy<<<1, kDataLen>>>(a, device_x, device_y);<br>
>> >   ^<br>
>> > axpy.cu:28:19: error: use of undeclared identifier<br>
>> > 'cudaDeviceSynchronize'<br>
>> >   checkCudaErrors(cudaDeviceSynchronize());<br>
>> >                   ^<br>
>> > axpy.cu:30:30: error: use of undeclared identifier<br>
>> > 'cudaMemcpyDeviceToHost'<br>
>> >                              cudaMemcpyDeviceToHost));<br>
>> >                              ^<br>
>> > axpy.cu:37:19: error: use of undeclared identifier 'cudaDeviceReset'<br>
>> >   checkCudaErrors(cudaDeviceReset());<br>
>> >                   ^<br>
>> > 9 errors generated.<br>
>> ><br>
>> > What am I supposed to do?<br>
>> ><br>
>> > Regards<br>
>> > --<br>
>> > sulomen<br>
>> ><br>
>> > _______________________________________________<br>
>> > cfe-dev mailing list<br>
>> > <a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
>> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
>> ><br>
><br>
><br>
><br>
><br>
> --<br>
> Güray Özen<br>
> DEU Computer Engineering Department<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Güray Özen<br>DEU Computer Engineering Department</div>
</div></div>