[clang] d5b2055 - [OpenMP] Add verbose output for linker wrapper
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 28 10:28:47 PST 2022
Author: Joseph Huber
Date: 2022-02-28T13:28:19-05:00
New Revision: d5b2055769f40386a818e9df0a173eafa0e7dc5f
URL: https://github.com/llvm/llvm-project/commit/d5b2055769f40386a818e9df0a173eafa0e7dc5f
DIFF: https://github.com/llvm/llvm-project/commit/d5b2055769f40386a818e9df0a173eafa0e7dc5f.diff
LOG: [OpenMP] Add verbose output for linker wrapper
Summary;
This path adds printing support for the linker wrapper. When the user
passes `-v` it will not print the commands used by the linker wrapper to
indicate to the user what is happening during the linking.
Added:
Modified:
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Removed:
################################################################################
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 2d73e0e574cbb..d183c8b09c997 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -164,6 +164,15 @@ Expected<Optional<std::string>>
extractFromBuffer(std::unique_ptr<MemoryBuffer> Buffer,
SmallVectorImpl<DeviceFile> &DeviceFiles);
+void printCommands(ArrayRef<StringRef> CmdArgs) {
+ if (CmdArgs.empty())
+ return;
+
+ llvm::errs() << " \"" << CmdArgs.front() << "\" ";
+ for (auto IC = CmdArgs.begin() + 1, IE = CmdArgs.end(); IC != IE; ++IC)
+ llvm::errs() << *IC << (IC + 1 != IE ? " " : "\n");
+}
+
static StringRef getDeviceFileExtension(StringRef DeviceTriple,
bool IsBitcode = false) {
Triple TheTriple(DeviceTriple);
@@ -210,6 +219,9 @@ Error runLinker(std::string &LinkerPath, SmallVectorImpl<std::string> &Args) {
for (auto &Arg : Args)
LinkerArgs.push_back(Arg);
+ if (Verbose)
+ printCommands(LinkerArgs);
+
if (sys::ExecuteAndWait(LinkerPath, LinkerArgs))
return createStringError(inconvertibleErrorCode(), "'linker' failed");
return Error::success();
@@ -338,6 +350,9 @@ extractFromBinary(const ObjectFile &Obj,
StripArgs.push_back("-o");
StripArgs.push_back(TempFile);
+ if (Verbose)
+ printCommands(StripArgs);
+
if (sys::ExecuteAndWait(*StripPath, StripArgs))
return createStringError(inconvertibleErrorCode(), "'llvm-strip' failed");
@@ -560,6 +575,9 @@ Expected<std::string> assemble(StringRef InputFile, Triple TheTriple,
CmdArgs.push_back(InputFile);
+ if (Verbose)
+ printCommands(CmdArgs);
+
if (sys::ExecuteAndWait(*PtxasPath, CmdArgs))
return createStringError(inconvertibleErrorCode(), "'ptxas' failed");
@@ -601,6 +619,9 @@ Expected<std::string> link(ArrayRef<std::string> InputFiles, Triple TheTriple,
for (StringRef Input : InputFiles)
CmdArgs.push_back(Input);
+ if (Verbose)
+ printCommands(CmdArgs);
+
if (sys::ExecuteAndWait(*NvlinkPath, CmdArgs))
return createStringError(inconvertibleErrorCode(), "'nvlink' failed");
@@ -639,6 +660,9 @@ Expected<std::string> link(ArrayRef<std::string> InputFiles, Triple TheTriple,
for (StringRef Input : InputFiles)
CmdArgs.push_back(Input);
+ if (Verbose)
+ printCommands(CmdArgs);
+
if (sys::ExecuteAndWait(*LLDPath, CmdArgs))
return createStringError(inconvertibleErrorCode(), "'lld' failed");
@@ -716,6 +740,9 @@ Expected<std::string> link(ArrayRef<std::string> InputFiles, Triple TheTriple,
for (StringRef Input : InputFiles)
CmdArgs.push_back(Input);
+ if (Verbose)
+ printCommands(CmdArgs);
+
if (sys::ExecuteAndWait(LinkerUserPath, CmdArgs))
return createStringError(inconvertibleErrorCode(), "'linker' failed");
More information about the cfe-commits
mailing list