<div dir="ltr"><div class="gmail_quote">Message: 2<br>
Date: Tue, 5 Nov 2019 02:54:05 +0000<br>
From: "Doerfert, Johannes via Openmp-dev" <<a href="mailto:openmp-dev@lists.llvm.org" target="_blank">openmp-dev@lists.llvm.org</a>><br>
To: Shilei Tian <<a href="mailto:tianshilei1992@gmail.com" target="_blank">tianshilei1992@gmail.com</a>><br>Subject: Re: [Openmp-dev] nvlink reported undefined reference when<br>
        building OpenMP offloading program<br><br>
<br>
I think Jon (CCed) is aware and working on it:<br>
  <a href="https://reviews.llvm.org/rG764c8420e4b8fc11a9fa94d00f4ee617aa754cb2" rel="noreferrer" target="_blank">https://reviews.llvm.org/rG764c8420e4b8fc1libomptarget1a9fa94d00f4ee617aa754cb2</a><br>
<br>
On 11/04, Shilei Tian via Openmp-dev wrote:<br>
> Hi,<br>
> <br>
> I was trying to build an OpenMP offloading program. nvlink always reported following error:<br>
> <br><div>> nvlink error   : Undefined reference to '_Z25GetLogicalThreadIdInBlockb' in '/tmp/main-02fcf5.cubin'</div><div><br></div><div>Hi Shilei,</div><div><br></div><div>Thanks for the comprehensive report. I am indeed looking into this.</div><div><br></div><div>That you're building for X86 means the problem isn't isolated to POWER8, which means I can stop looking at cross compilation. I'll update the discussion. Thanks!</div><div><br></div><div>OpenMP still works for me. My nvptx build is a bit precarious though because trunk conflicts with libstdc++, so the corresponding invocation is:</div><div><br></div><div>~/llvm-install/bin/clang --cuda-gpu-arch=sm_50 -fopenmp -fopenmp-targets=nvptx64 <a href="http://test.cu">test.cu</a>  -nocudainc -L~/llvm-install/lib </div><div>LD_LIBRARY_PATH=~/llvm-build/lib ./a.out</div><div><br></div><div>Looking at symbols in the cuda runtime libraries suggests all is well, at least on my machine.</div><div><br></div><div>I believe replacing INLINE with DEVICE in openmp/libomptarget/deviceRTL/nvptx/src/<a href="http://support.cu">support.cu</a> will unblock people. I don't want to propose that as a patch until I can reproduce locally.</div><div><br></div><div>Alternatively, using clang instead of nvcc would probably resolve this.</div><div>-DCUDA_HOST_COMPILER=`which clang`</div><div><br></div><div>Regards,</div><div><br></div><div>Jon</div></div></div>