[llvm] [Flang-RT] Do not use Apple-specific libdir scheme (PR #151954)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 5 03:58:10 PDT 2025


================
@@ -34,14 +34,8 @@
 function (get_toolchain_library_subdir outvar)
   set(outval "lib")
 
-  if (APPLE)
-    # Required to be "darwin" for MachO toolchain.
-    get_toolchain_os_dirname(os_dirname)
-    set(outval "${outval}/${os_dirname}")
-  else ()
-    get_toolchain_arch_dirname(arch_dirname)
-    set(outval "${outval}/${arch_dirname}")
-  endif ()
+  get_toolchain_arch_dirname(arch_dirname)
+  set(outval "${outval}/${arch_dirname}")
----------------
Meinersbur wrote:

> On my machine, both compiler-rt and flang-rt libraries are installed into `<install_dir>/lib/clang/22/lib/darwin`.

That was the original intention/idea. 


> IIUC, this change would make flang-rt libraries be installed in a new directory, `<install_dir>/lib/clang/22/lib/<target>`, right? Wouldn't it be better to make flang look for its libraries in the same path as compiler-rt?

`ToolChain::addFlangRTLibPath` calls `ToolChain::getArchSpecificLibPaths()` which is overridable by the MachO ToolChain (but not actually overridden). The `x86_64` is added here: 
https://github.com/llvm/llvm-project/blob/852cc9200f7c7cc76bc61ac2aa42712c94793f0d/clang/lib/Driver/ToolChain.cpp#L1041
It felt best to avoid platform-specific exceptions making the problem more managable. 

Turns out `ToolChain::getArchSpecificLibPaths()`  is only used when using RPath.  `ToolChain::addFlangRTLibPath` is called to fill `getFilePaths`. On non-MachO platforms seem that `getRuntimePath()` covers it, but is skipped on MachO:
https://github.com/llvm/llvm-project/blob/852cc9200f7c7cc76bc61ac2aa42712c94793f0d/clang/lib/Driver/ToolChain.cpp#L1010-L1011

Trying another version soon

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


More information about the llvm-commits mailing list