Author: Alexandre Ganea Date: 2025-11-01T16:54:46Z New Revision: bff2aa63624766b1111be0ffec9645c952fc8e38
URL: https://github.com/llvm/llvm-project/commit/bff2aa63624766b1111be0ffec9645c952fc8e38 DIFF: https://github.com/llvm/llvm-project/commit/bff2aa63624766b1111be0ffec9645c952fc8e38.diff LOG: [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)`. Added: Modified: clang/lib/Driver/Driver.cpp Removed: ################################################################################ diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 71c52807091ba..51618d17a4180 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2540,10 +2540,14 @@ bool Driver::HandleImmediateArgs(Compilation &C) { } if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) { - if (std::optional<std::string> RuntimePath = TC.getRuntimePath()) - llvm::outs() << *RuntimePath << '\n'; - else - llvm::outs() << TC.getCompilerRTPath() << '\n'; + for (auto RuntimePath : + {TC.getRuntimePath(), std::make_optional(TC.getCompilerRTPath())}) { + if (RuntimePath && getVFS().exists(*RuntimePath)) { + llvm::outs() << *RuntimePath << '\n'; + return false; + } + } + llvm::outs() << "(runtime dir is not present)" << '\n'; return false; } _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
