Skip to content

Commit da7f21e

Browse files
committed
[llvm-link] Improve missing file error message
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.
1 parent e50a231 commit da7f21e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

llvm/tools/llvm-link/llvm-link.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,17 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
393393
// Similar to some flags, internalization doesn't apply to the first file.
394394
bool InternalizeLinkedSymbols = false;
395395
for (const auto &File : Files) {
396+
auto ErrOrExpected = MemoryBuffer::getFileOrSTDIN(File);
397+
398+
// When we encounter a missing file, print all missing files to stderr.
399+
if (auto EC = ErrOrExpected.getError())
400+
if (EC == std::errc::no_such_file_or_directory)
401+
for (auto &F : Files)
402+
if (!llvm::sys::fs::exists(F))
403+
errs() << "No such file or directory: '" << F << "'\n";
404+
396405
std::unique_ptr<MemoryBuffer> Buffer =
397-
ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(File)));
406+
ExitOnErr(errorOrToExpected(std::move(ErrOrExpected)));
398407

399408
std::unique_ptr<Module> M =
400409
identify_magic(Buffer->getBuffer()) == file_magic::archive

0 commit comments

Comments
 (0)