problem on compiling cuda program with clang++

Hi all,

I compiled the llvm3.9 source code on the Nvidia TX1 board. And now I am following the document in the docs/CompileCudaWithLLVM.rst to compile cuda program with clang++.

However, when I compile [axpy.cu](http://axpy.cu) using nvcc, nvcc can generate the correct the binary;

while compiling [axpy.cu](http://axpy.cu) using clang++, the detailed command is clang++ [axpy.cu](http://axpy.cu) -o axpy --cuda-gpu-arch=sm_53 -L/usr/local/cuda/lib64 -lcudart_static -ldl -lrt -pthread, clang++ generate the following error:`/usr/include/features.h:367:12: fatal error: ‘sys/cdefs.h’ file not found

include <sys/cdefs.h>`.

And I find that ‘sys/cdefs.h’ is included in the directory /usr/include/aarch64-linux-gnu/sys.

Anybody ever came accross the same problems? Thanks!

Hi, it looks like you're compiling CUDA for an ARM host? This is not
a configuration we have tested, nor is it something we have the
capability of testing at the moment.

You may be able to make it work by providing the appropriate -isystem
flags to clang so that it can find your headers, but who knows, it may
be more complicated than that.

Regards,
-Justin

(+llvm-dev)

My question was whether your host machine, the one which is running
the compiler, is ARM (as opposed to x86 or POWER). The header you
pointed to was in "aarch64-linux-gnu", which made me think you might
be on an ARM system.

If you are not running linux x86, it is not likely to work.

If you are running linux x86, we will need much more details about
your system in order to be able to assist you. (For example, what
Linux distribution are you running, and what version?) We will also
need the output of running your command with "clang -v" and the
preprocessor output, clang -E.

-Justin

Hi, it looks like you're compiling CUDA for an ARM host? This is not
a configuration we have tested, nor is it something we have the
capability of testing at the moment.

Hi Justin,

NVidia TX1 is the AArch64 Jetson board with proper GPU (we use those).

You may be able to make it work by providing the appropriate -isystem
flags to clang so that it can find your headers, but who knows, it may
be more complicated than that.

We don't use them for their GPU, so I don't know, but those kits are
meant to be CUDA development boxes.

The board setup process has an installer (JetPack) which gets all the
drivers, headers and libraires for CUDA development. It should be just
a matter of finding them and using with -isystem.

cheers,
--renato

NVidia TX1 is the AArch64 Jetson board with proper GPU (we use those).

Sure, I believe that others use this configuration. I was saying,
"we", being, myself and those whom I work closely with, do not. Sorry
if that wasn't precise.

It is still not clear to me if the original poster is compiling for
ARM or not. But it sounds like you're going to help them get this
working, which is great, because I have no experience with this setup.

It should be just a matter of finding them and using with -isystem.

As I originally suggested. :slight_smile:

-Justin

  1. Yes, you both are right. My platform is Jetson TX1, AArch64.

  2. And I obtain all the necessary files for TX1 by JetPack from the host(X86) and so nvcc can work rightly.

  3. Althrough I can compile LLVM3.9 on TX1, I can not compile the CUDA program using clang tools. The error is “sys/cedfs.h no such file”.

Sure, I believe that others use this configuration. I was saying,
"we", being, myself and those whom I work closely with, do not. Sorry
if that wasn't precise.

It was clear. :slight_smile:

It is still not clear to me if the original poster is compiling for
ARM or not. But it sounds like you're going to help them get this
working, which is great, because I have no experience with this setup.

I think so. On ARM to ARM.

--renato

I'm assuming you compiled LLVM and you're using Clang on the Jetson board?

I don't know much about CUDA, but I think that if you left all the
check-boxes checked, JetPack installs *all* dependencies, drivers and
libraries on the user home directory (something like
/home/ubuntu/...).

If that's true, than finding the header you need is just a matter of running:

$ find $HOME -name cedfs.h

Once you find the directory where that file is (.../sys/cedfs.h), then
add it (without /sys/cedfs.h) to the compiler flags:

$ clang ... cuda options ... -isystem {the directory you found above}

This should at least get you over this problem.

cheers,
--renato