Skip to content

Commit 692b069

Browse files
aganeackoparkar
authored andcommitted
[clang] Ensure --print-runtime-dir path exists (llvm#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)`.
1 parent a3d0488 commit 692b069

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
@@ -2540,10 +2540,14 @@ bool Driver::HandleImmediateArgs(Compilation &C) {
25402540
}
25412541

25422542
if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
2543-
if (std::optional<std::string> RuntimePath = TC.getRuntimePath())
2544-
llvm::outs() << *RuntimePath << '\n';
2545-
else
2546-
llvm::outs() << TC.getCompilerRTPath() << '\n';
2543+
for (auto RuntimePath :
2544+
{TC.getRuntimePath(), std::make_optional(TC.getCompilerRTPath())}) {
2545+
if (RuntimePath && getVFS().exists(*RuntimePath)) {
2546+
llvm::outs() << *RuntimePath << '\n';
2547+
return false;
2548+
}
2549+
}
2550+
llvm::outs() << "(runtime dir is not present)" << '\n';
25472551
return false;
25482552
}
25492553

0 commit comments

Comments
 (0)