[clang-offload-bundler] Library-ize ClangOffloadBundler
authorJacob Lambert <jacob.lambert@amd.com>
Fri, 15 Jul 2022 00:00:26 +0000 (17:00 -0700)
committerJacob Lambert <jacob.lambert@amd.com>
Tue, 26 Jul 2022 17:05:22 +0000 (10:05 -0700)
commit8348c4095600ec2c0beee293267832799d2ebee3
treead14a88d146709771f2eafaa5cc46742be2c24cc
parent1ea7b9c6ee6420dd6e87489534f44b92e1b6f220
[clang-offload-bundler] Library-ize ClangOffloadBundler

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API. This will allow online and JIT compilers to
bundle and unbundle files without spawning a new process.

This patch lifts the classes and functions used to implement
the clang-offload-bundler into a separate OffloadBundler.cpp,
and defines three top-level API functions in OfflaodBundler.h.
        BundleFiles()
        UnbundleFiles()
        UnbundleArchives()

This patch also introduces a Config class that locally stores the
previously global cl::opt options and arrays to allow users to call
the APIs in a multi-threaded context, and introduces an
OffloadBundler class to encapsulate the top-level API functions.

We also  lift the BundlerExecutable variable, which is specific
to the clang-offload-bundler tool, from the API, and replace
its use with an ObjcopyPath variable. This variable must be set
in order to internally call llvm-objcopy.

Finally, we move the API files from
clang/tools/clang-offload-bundler into clang/lib/Driver and
clang/include/clang/Driver.

Differential Revision: https://reviews.llvm.org/D129873
clang/include/clang/Driver/OffloadBundler.h [new file with mode: 0644]
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/OffloadBundler.cpp [new file with mode: 0644]
clang/tools/clang-offload-bundler/CMakeLists.txt
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp