summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Halkenhäuser <MichaelGerald.Halkenhauser@amd.com>2024-02-23 20:17:32 +0100
committerGitHub <noreply@github.com>2024-02-23 13:17:32 -0600
commita64ff9630ccd305a63fca3ea9cc4bc4b49098495 (patch)
tree794cd5d8a3b599b5c9184df9c508f26e19426531
parent59e5519c81c57a66424d657864ce69cb0efdc7d8 (diff)
[llvm-link] Improve missing file error message (#82514)
Add error messages showing the missing filenames. Currently, we only get 'No such file or directory' without any(!) further info. This patch will (only upon ENOENT error) iterate over all requested files and print which ones are actually missing.
-rw-r--r--llvm/tools/llvm-link/llvm-link.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index e6c219a8cd7e..9e7f2c3ebac4 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -393,8 +393,16 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
// Similar to some flags, internalization doesn't apply to the first file.
bool InternalizeLinkedSymbols = false;
for (const auto &File : Files) {
+ auto BufferOrErr = MemoryBuffer::getFileOrSTDIN(File);
+
+ // When we encounter a missing file, make sure we expose its name.
+ if (auto EC = BufferOrErr.getError())
+ if (EC == std::errc::no_such_file_or_directory)
+ ExitOnErr(createStringError(EC, "No such file or directory: '%s'",
+ File.c_str()));
+
std::unique_ptr<MemoryBuffer> Buffer =
- ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(File)));
+ ExitOnErr(errorOrToExpected(std::move(BufferOrErr)));
std::unique_ptr<Module> M =
identify_magic(Buffer->getBuffer()) == file_magic::archive