https://github.com/aganea created https://github.com/llvm/llvm-project/pull/102834
Before this PR, `clang --print-runtime-dir` used to report a non-existant directory if `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF`. We now check if any of the known runtime directories exist before printing on stdout. If it doesn't, we print `(runtime dir is not present)`. >From d1d1340b6876d83d48949306e43c723696bf4753 Mon Sep 17 00:00:00 2001 From: Alexandre Ganea <aga...@havenstudios.com> Date: Sun, 11 Aug 2024 19:03:14 -0400 Subject: [PATCH] [clang] Ensure --print-runtime-dir exits Before this PR, `clang --print-runtime-dir` used to report a non-existant directory if LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=OFF. We now check if any of the known runtime directories exist before printing on stdout. --- clang/lib/Driver/Driver.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index f4e909b79389bc..4c8cd36dd118ee 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2230,10 +2230,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 cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits