[clang] [clang] [Driver] Fix respecting libdir when locating flang runtime (PR #127345)

via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 15 12:11:01 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Michał Górny (mgorny)

<details>
<summary>Changes</summary>

Fix `tools::addFortranRuntimeLibraryPath` to use
`CLANG_INSTALL_LIBDIR_BASENAME` rather than hardwired `lib` directory. This fixes flang being unable to find its runtime when installed into nonstandard directory on a system using `lib64` for 64-bit libraries. While technically flang runtime could be installed with a different libdir value than clang, it seems rather unlikely.

---
Full diff: https://github.com/llvm/llvm-project/pull/127345.diff


1 Files Affected:

- (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+1-1) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 2d01943ca1ac4..47e6fd9dbf902 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1367,7 +1367,7 @@ void tools::addFortranRuntimeLibraryPath(const ToolChain &TC,
   // lib64 instead of lib.
   SmallString<256> DefaultLibPath =
       llvm::sys::path::parent_path(TC.getDriver().Dir);
-  llvm::sys::path::append(DefaultLibPath, "lib");
+  llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
   if (TC.getTriple().isKnownWindowsMSVCEnvironment())
     CmdArgs.push_back(Args.MakeArgString("-libpath:" + DefaultLibPath));
   else

``````````

</details>


https://github.com/llvm/llvm-project/pull/127345


More information about the cfe-commits mailing list