[Clang] Introduce clang-offload-packager tool to bundle device files
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 6 May 2022 17:56:42 +0000 (13:56 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Wed, 11 May 2022 13:39:13 +0000 (09:39 -0400)
commit26eb04268f4c9c0e2d4ff5bc53ae90cbb7f6c731
tree1ca439d3b7e3e40c0d3e8310acfe967909b51605
parent75bb815231f6967bd5f4e24143141b9fe69d01f8
[Clang] Introduce clang-offload-packager tool to bundle device files

In order to do offloading compilation we need to embed files into the
host and create fatbainaries. Clang uses a special binary format to
bundle several files along with their metadata into a single binary
image. This is currently performed using the `-fembed-offload-binary`
option. However this is not very extensibile since it requires changing
the command flag every time we want to add something and makes optional
arguments difficult. This patch introduces a new tool called
`clang-offload-packager` that behaves similarly to CUDA's `fatbinary`.
This tool takes several input files with metadata and embeds it into a
single image that can then be embedded in the host.

Reviewed By: tra

Differential Revision: https://reviews.llvm.org/D125165
23 files changed:
clang/docs/ClangOffloadPackager.rst [new file with mode: 0644]
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/Action.h
clang/include/clang/Driver/ToolChain.h
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/Action.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Clang.h
clang/test/Driver/amdgpu-openmp-toolchain-new.c
clang/test/Driver/cuda-openmp-driver.cu
clang/test/Driver/cuda-phases.cu
clang/test/Driver/linker-wrapper-image.c
clang/test/Driver/linker-wrapper.c
clang/test/Driver/openmp-offload-gpu-new.c
clang/test/Driver/openmp-offload-infer.c
clang/test/Frontend/embed-object.c
clang/test/Frontend/embed-object.ll
clang/test/lit.cfg.py
clang/tools/CMakeLists.txt
clang/tools/clang-offload-packager/CMakeLists.txt [new file with mode: 0644]
clang/tools/clang-offload-packager/ClangOffloadPackager.cpp [new file with mode: 0644]