Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions flang-rt/cmake/modules/GetToolchainDirs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Copy link
Contributor

@luporl luporl Aug 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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?

Copy link
Member Author

@Meinersbur Meinersbur Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

AddPath({getOSLibName(), llvm::Triple::getArchTypeName(getArch())});

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 MachO1:

if (Triple.isOSDarwin())
return {};

Trying another version soon

Footnotes

  1. Was this meant to return std::string(P) at some point? The bail out in the middle of the function is strange.
    EDIT: The root cause turns out to be #87866. Again.


set(${outvar} "${outval}" PARENT_SCOPE)
endfunction ()
Expand Down
Loading