-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang] [Driver] Fix respecting libdir when locating flang runtime #127345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
@llvm/pr-subscribers-flang-runtime @llvm/pr-subscribers-clang Author: Michał Górny (mgorny) ChangesFix Full diff: https://github.com/llvm/llvm-project/pull/127345.diff 1 Files Affected:
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
|
CLANG_INSTALL_LIBDIR_BASENAME can be "lib" or "lib64". I think it should only be used for libraries outside of llvm-project, like how cuda/amdgpu libs are installed by system. For llvm-project installed libs, it's much better to stick with a uniform "lib", which is easy to test in clang/test/Driver I am not familiar with offload/cuda/amdgpu. It's possible that CLANG_INSTALL_LIBDIR_BASENAME gets abused (https://reviews.llvm.org/D130586 might be related) in places where it should not be used less. |
But |
…and just to be clear, Flang runtimes are installed into plain system |
Hmm, but thinking about it, it should probably grab the right libdir from some multilib config rather than the hardwired build-time value. |
Sigh, looks like clang's driver is a mess around |
Closed in favor of #134362. |
Fix
tools::addFortranRuntimeLibraryPath
to useCLANG_INSTALL_LIBDIR_BASENAME
rather than hardwiredlib
directory. This fixes flang being unable to find its runtime when installed into nonstandard directory on a system usinglib64
for 64-bit libraries. While technically flang runtime could be installed with a different libdir value than clang, it seems rather unlikely.