[llvm-bugs] [Bug 48440] New: Linker error with static library containing offload instructions
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Dec 8 04:01:27 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=48440
Bug ID: 48440
Summary: Linker error with static library containing offload
instructions
Product: OpenMP
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Clang Compiler Support
Assignee: unassignedclangbugs at nondot.org
Reporter: gcgt96 at durham.ac.uk
CC: llvm-bugs at lists.llvm.org
Created attachment 24248
--> https://bugs.llvm.org/attachment.cgi?id=24248&action=edit
A reproducer with code and compile instructions
Hello,
I would like to report the following finding when working with
clang from llvm11 using cuda10.1 on linux (x86 and ppc64le).
I compile objects using:
clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda -c saxpy.cxx
I create a static library as such:
ar -crs libsaxpy.a saxpy.o
I want to compile an executable that links to the static library:
clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda runsaxpy.cxx -L.
-lsaxpy -o runit
This results in a linker error:
nvlink error : Undefined reference to '_Z5saxpyidPdS_' in
'/tmp/runsaxpy-a03e51.cubin'
The curious thing is that the error vanishes if instead of linking to the
static library, I instruct the compiler to use the object file directly:
clang++ -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda runsaxpy.cxx saxpy.o
-o runit
I can confirm that the code is offloaded to the gpu with nvprof:
==1356356== Profiling result:
Type Time(%) Time Calls Avg Min Max
Name
GPU activities: 96.54% 99.970us 1 99.970us 99.970us 99.970us
__omp_offloading_34_1f13a9_main_l5
1.98% 2.0490us 1 2.0490us 2.0490us 2.0490us
[CUDA memcpy DtoH]
1.48% 1.5360us 1 1.5360us 1.5360us 1.5360us
[CUDA memcpy HtoD]
I do not know if I am building the static library incorrectly of if I am
missing linker flags perhaps.
I attach a reproducer for what I observe.
Thanks a lot!
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201208/3ebb56fb/attachment.html>
More information about the llvm-bugs
mailing list