[cfe-dev] [llvm-dev] Clang driver for OpenMP target offloading

Jonas Hahnfeld via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 27 01:10:09 PST 2017


Hi Simone,

you are more likely to get answers to frontend questions asking on 
cfe-dev. However, your output shows that you are using clang-ykt which 
isn't supported upstream so this is not the right place for your 
questions. Nevertheless, I'll answer some because the same "problem" 
will arise with (upstream) trunk.

Am 2017-12-26 23:37, schrieb Simone Atzeni via llvm-dev:
> Hi,
> 
> I am having some trouble to understand how the clang driver works for
> OpenMP offloading.
> 
> For example, if I run the following command (with the -v flag):
> 
> clang -v -g -fopenmp offloading_success.c -o offloading_success
> 
> I can see the invocations that clang does and if I run those command
> one by one I can successfully compile my program.

Just to clarify: This will compile but will fallback to run on the host 
because the arguments don't specify which device to compile for.

> Now, if I do the same but with the offloading option, as in the
> following command:
> 
> clang -v -g -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
> offloading_success.c -o offloading_success
> 
> the command works, compiles correctly, and when I run the program, it
> successfully run on the device.

(which would not be the case for upstream trunk yet...)

> However, if I show the invocations with "-v" and try to run the
> commands one by one it does not work and in particular I get an error
> with the last command which is the linking part with "ld".
> The error i get is the following:
> 
> /usr/bin/ld: cannot open linker script file
> /tmp/offloading_success-2b4739.lk [1]: No such file or directory
> 
> Where is this ".lk" file generated? Is there a missing commands in the
> invocations?

The linker script is generated by Clang's driver (both in clang-ykt and 
trunk) and is deleted after its usage which is the default for temporary 
files. If you want to inspect the intermediate files, I suggest adding 
--save-temps which will dump a bunch of files to the current directory. 
(AFAIK this will result in more files than generated by default so that 
developers have more intermediate steps to look at.)

Cheers,
Jonas



More information about the cfe-dev mailing list