This is an archive of the discontinued LLVM Phabricator instance.

[libc] Ensure that the required clang tools are up-to-date for libc GPU
ClosedPublic

Authored by jhuber6 on Apr 4 2023, 4:21 PM.

Details

Summary

The clang-offload-packager. nvptx-arch, and amdgpu-arch tools are
required for building the GPU target of libc. This patch ensures that
we build this tool when directly building libc via ninja libc or similar.

Diff Detail

Event Timeline

jhuber6 created this revision.Apr 4 2023, 4:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2023, 4:21 PM
jhuber6 requested review of this revision.Apr 4 2023, 4:21 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 4 2023, 4:21 PM
jhuber6 updated this revision to Diff 510960.Apr 4 2023, 4:22 PM

Adding nvptx-arch and amdgpu-arch as well.

jhuber6 retitled this revision from [libc] Ensure that the `clang-offload-packager` is up-to-date for libc GPU to [libc] Ensure that the required clang tools are up-to-date for libc GPU.Apr 4 2023, 4:23 PM
jhuber6 edited the summary of this revision. (Show Details)
tra added inline comments.Apr 4 2023, 4:44 PM
llvm/runtimes/CMakeLists.txt
403

Do these tools depend on something that may not be present on a build machine w/o GPU?

I think nvptx-arch currently links with libcuda.so, which means that it will not build on machine w/o a NVIDIA GPU. Ideally the app needs to dlopen(libcuda.so.1) and gracefully fail if it's not found.

I think the dependency on nvptx-arch tools may need to be conditional on whether its build prerequisites are found.

jhuber6 added inline comments.Apr 4 2023, 5:00 PM
llvm/runtimes/CMakeLists.txt
403

Yes, nvptx-arch will attempt to dynamically open CUDA if it wasn't found beforehand. Otherwise they just depend on ClangBasic and other LLVM libraries that should be supported.

tra accepted this revision.Apr 4 2023, 5:09 PM
tra added inline comments.
llvm/runtimes/CMakeLists.txt
403

If we already can dlopen it, then we should always do it. Linking with it explicitly just makes the binary unusable on machines w/o GPUs. E.g. you can just pack and ship it with the release build of clang. That a matter for a separate patch though.

This revision is now accepted and ready to land.Apr 4 2023, 5:09 PM
jhuber6 added inline comments.Apr 4 2023, 5:11 PM
llvm/runtimes/CMakeLists.txt
403

So right now it just dlopens if it's not found on the machine. Honestly it probably would be best if we just always dlopened it since it would guarantee any build configuration would work somewhat. Honestly the only reason I haven't done that is because linking it directly makes it easier to use within an IDE since it has access to the header files.

This revision was landed with ongoing or failed builds.Apr 4 2023, 5:51 PM
This revision was automatically updated to reflect the committed changes.