This is an archive of the discontinued LLVM Phabricator instance.

[clang-offload-bundler] Library-ize ClangOffloadBundler
ClosedPublic

Authored by lamb-j on Jul 15 2022, 9:09 AM.

Details

Summary

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.

Diff Detail

Event Timeline

lamb-j created this revision.Jul 15 2022, 9:09 AM
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: mgorny. · View Herald Transcript
lamb-j requested review of this revision.Jul 15 2022, 9:09 AM
Herald added a project: Restricted Project. · View Herald Transcript
lamb-j updated this revision to Diff 445863.Jul 19 2022, 10:13 AM

Moving classes into clang namespace, more specific name for config class

lamb-j updated this revision to Diff 446945.Jul 22 2022, 12:34 PM

Switching pointers to references, adding namespace comment

lamb-j updated this revision to Diff 446946.Jul 22 2022, 12:36 PM

Fixing header typo

lamb-j updated this revision to Diff 447531.Jul 25 2022, 5:59 PM

Removing trailing whitespace

yaxunl accepted this revision.Jul 26 2022, 6:56 AM

LGTM. Thanks.

This revision is now accepted and ready to land.Jul 26 2022, 6:56 AM
This revision was landed with ongoing or failed builds.Jul 26 2022, 10:06 AM
This revision was automatically updated to reflect the committed changes.
lamb-j reopened this revision.Jul 26 2022, 5:12 PM
This revision is now accepted and ready to land.Jul 26 2022, 5:12 PM
lamb-j updated this revision to Diff 447894.Jul 26 2022, 5:12 PM

Updating driver cmake to correctly build shared library

This revision was landed with ongoing or failed builds.Jul 27 2022, 12:03 PM
This revision was automatically updated to reflect the committed changes.