Skip to content

Commit a64ff96

Browse files
authored
[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.
1 parent 59e5519 commit a64ff96

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,16 @@ 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 BufferOrErr = MemoryBuffer::getFileOrSTDIN(File);
397+
398+
// When we encounter a missing file, make sure we expose its name.
399+
if (auto EC = BufferOrErr.getError())
400+
if (EC == std::errc::no_such_file_or_directory)
401+
ExitOnErr(createStringError(EC, "No such file or directory: '%s'",
402+
File.c_str()));
403+
396404
std::unique_ptr<MemoryBuffer> Buffer =
397-
ExitOnErr(errorOrToExpected(MemoryBuffer::getFileOrSTDIN(File)));
405+
ExitOnErr(errorOrToExpected(std::move(BufferOrErr)));
398406

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

0 commit comments

Comments
 (0)