Skip to content

Commit a64fccc

Browse files
aganeagithub-actions[bot]
authored andcommitted
Automerge: [clang] Ensure --print-runtime-dir path exists (#102834)
Before this PR, `clang --print-runtime-dir` on Windows used to report a non-existent directory if `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF`. We now check if any of the known runtime directories exist before printing any of them on stdout. If none exists, we print `(runtime dir is not present)`.
2 parents faca693 + bff2aa6 commit a64fccc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,10 +2543,14 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
25432543
}
25442544

25452545
if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
2546-
if (std::optional<std::string> RuntimePath = TC.getRuntimePath())
2547-
llvm::outs() << *RuntimePath << '\n';
2548-
else
2549-
llvm::outs() << TC.getCompilerRTPath() << '\n';
2546+
for (auto RuntimePath :
2547+
{TC.getRuntimePath(), std::make_optional(TC.getCompilerRTPath())}) {
2548+
if (RuntimePath && getVFS().exists(*RuntimePath)) {
2549+
llvm::outs() << *RuntimePath << '\n';
2550+
return false;
2551+
}
2552+
}
2553+
llvm::outs() << "(runtime dir is not present)" << '\n';
25502554
return false;
25512555
}
25522556

0 commit comments

Comments
 (0)