diff options
author | Chris Bieneman <chris.bieneman@me.com> | 2022-06-06 04:25:55 +0000 |
---|---|---|
committer | Alex Brachet <abrachet@google.com> | 2022-06-06 04:27:32 +0000 |
commit | f06abbb393800b0d466c88e283c06f75561c432c (patch) | |
tree | 4ff07e40ad34b1a4564c80f7868d73cc478b7c2b /llvm/lib/Support/Path.cpp | |
parent | c2d27c89593e92f8e557f27ec02f083760eeab2d (diff) | |
download | llvm-f06abbb393800b0d466c88e283c06f75561c432c.zip llvm-f06abbb393800b0d466c88e283c06f75561c432c.tar.gz llvm-f06abbb393800b0d466c88e283c06f75561c432c.tar.bz2 |
LLVM Driver Multicall tool
This patch adds an llvm-driver multicall tool that can combine multiple
LLVM-based tools. The build infrastructure is enabled for a tool by
adding the GENERATE_DRIVER option to the add_llvm_executable CMake
call, and changing the tool's main function to a canonicalized
tool_name_main format (i.e. llvm_ar_main, clang_main, etc...).
As currently implemented llvm-driver contains dsymutil, llvm-ar,
llvm-cxxfilt, llvm-objcopy, and clang (if clang is included in the
build).
llvm-driver can be enabled from builds by setting
LLVM_TOOL_LLVM_DRIVER_BUILD=On.
There are several limitations in the current implementation, which can
be addressed in subsequent patches:
(1) the multicall binary cannot currently properly handle
multi-dispatch tools. This means symlinking llvm-ranlib to llvm-driver
will not properly result in llvm-ar's main being called.
(2) the multicall binary cannot be comprised of tools containing
conflicting cl::opt options as the global cl::opt option list cannot
contain duplicates.
These limitations can be addressed in subsequent patches.
Differential revision: https://reviews.llvm.org/D109977
Diffstat (limited to 'llvm/lib/Support/Path.cpp')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 9575e34..283dc70 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -1202,9 +1202,18 @@ Error readNativeFileToEOF(file_t FileHandle, SmallVectorImpl<char> &Buffer, #include "Windows/Path.inc" #endif +bool IsLLVMDriver = false; + namespace llvm { namespace sys { namespace fs { + +std::string getMainExecutable(const char *Argv0, void *MainAddr) { + if (IsLLVMDriver) + return sys::path::stem(Argv0).str(); + return getMainExecutableImpl(Argv0, MainAddr); +} + TempFile::TempFile(StringRef Name, int FD) : TmpName(std::string(Name)), FD(FD) {} TempFile::TempFile(TempFile &&Other) { *this = std::move(Other); } |