This is an archive of the discontinued LLVM Phabricator instance.

[libomptarget][nfc] Add hook to easily disable building amdgcn bclib
ClosedPublic

Authored by JonChesterfield on May 11 2021, 4:15 AM.

Details

Summary

[libomptarget][nfc] Add hook to easily disable building amdgcn bclib

This is useful when building LLVM with a toolchain that can't emit code
for amdgcn, e.g. because it overrides the include search path with headers
from another architecture, or the clang compiler is missing builtins.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.May 11 2021, 4:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2021, 4:15 AM
This revision is now accepted and ready to land.May 11 2021, 8:03 AM

It seems like a change in this patch introduced a dependency issue for fresh builds.

openmp/libomptarget/deviceRTLs/amdgcn/CMakeLists.txt
158

When I build openmp as LLVM runtime (-DLLVM_ENABLE_RUNTIMES=openmp) in a fresh build directory, opt is not ready when this target should get built. I usually build massively parallel(-j48), so dependency issues will pop up from time to time.
I don't know why this did not happen before, but now this target misses a dependency to the OPT_TOOL built in the outer build process.
I find these lines in my build log:

[101/206] Generating libomptarget-amdgcn-gfx701.bc
FAILED: openmp/libomptarget/deviceRTLs/amdgcn/libomptarget-amdgcn-gfx701.bc 
cd build-main/runtimes/runtimes-bins/openmp/libomptarget/deviceRTLs/amdgcn && build-main/bin/llvm-link linkout.cuda.gfx701.bc | build-main/bin/opt --always-inline -o build-main/runtimes/runtimes-bins/openmp/libomptarget/libomptarget-amdgcn-gfx701.bc
/bin/sh: build-main/bin/opt: permission denied
...
[5987/5995] Linking CXX executable bin/opt

When I revert this patch, I don't see the line about linking bin/opt at all. I have no idea, how this patch impacts the use of opt ?!?

That is interesting. The cmake does require opt (and llvm-link), and the only reason it does not specify a dependency on those is I do not know how to spell that in cmake.

This patch doesn't change the dependency on opt, but maybe changes the order in which cmake does things, exposing that race condition more frequently.

Does anyone know how to tell cmake not to run this until after op, llvm-link, possibly clang exist?