Skip to content

Conversation

Meinersbur
Copy link
Member

@Meinersbur Meinersbur commented Aug 4, 2025

The clang/flang driver has two separate systems for find the location of clang_rt (simplified):

  • getCompilerRTPath(), e.g. ../lib/clang/22/lib/windows, used when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0
  • getRuntimePath(), e.g. ../lib/clang/22/lib/x86_64-pc-windows-msvc, used when LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1

To simplify the search path, Flang-RT normally assumes only getRuntimePath(), i.e. ignoring LLVM_ENABLE_PER_TARGET_RUNTIME_DIR and always using the LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1 mechanism. There is an exception for Apple Darwin triples where getRuntimePath() returns nothing. The flang-rt/compiler-rt CMake code for library location also ignores LLVM_ENABLE_PER_TARGET_RUNTIME_DIR but uses the LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0 path instead. Since only getRuntimePath() is automatically added to the linker command line, this patch explicitly adds getCompilerRTPath() to the search path when linking flang_rt.

Fixes #151031

Comment on lines 37 to 38
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.

@klausler
Copy link
Contributor

klausler commented Aug 4, 2025

This patch didn't change the behavior for me, unfortunately.

@PHHargrove
Copy link

This did not resolve the problem because the new location is not in the linker's search path.
I will add the linker command from flang -v output to issue #151031

@Meinersbur Meinersbur changed the title [Flang-RT] Do not use Apple-specific libdir scheme [Flang] Search flang_rt in clang_rt path Aug 5, 2025
@Meinersbur
Copy link
Member Author

Meinersbur commented Aug 5, 2025

For reference. compiler-rt special Apple code:

if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)

flang-rt special Apple code:

Copy link
Contributor

@klausler klausler left a comment

Choose a reason for hiding this comment

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

Works for me; thanks!

Copy link
Contributor

@luporl luporl left a comment

Choose a reason for hiding this comment

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

LGTM, works on my machine.
Thanks for digging deeper into the cause of the problem.

Copy link
Collaborator

@kkwli kkwli left a comment

Choose a reason for hiding this comment

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

It works. Thanks.

@PHHargrove
Copy link

Testing with the two new commits still fails to locate libflang_rt.runtime.a and adds a warning about a non-existent directory in the library search path.

$ /opt/llvm/bin/flang  ~/Hello/hello.f
ld: warning: search path '/opt/llvm/lib/clang/22/lib/darwin' not found
ld: library 'flang_rt.runtime' not found
flang-22: error: linker command failed with exit code 1 (use -v to see invocation)

Again with -v to show the link command and confirm the hash of the commit tested:

$ /opt/llvm/bin/flang -v ~/Hello/hello.f
flang version 22.0.0git (git@github.com:llvm/llvm-project 3a61f7935c5331d1dbcb64cac1e06b3062012bfe)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /opt/llvm/bin
 "/opt/llvm/bin/flang" -fc1 -triple arm64-apple-macosx14.0.0 -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu apple-m1 -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +ccpp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -resource-dir /opt/llvm/lib/clang/22 -mframe-pointer=non-leaf -o /var/folders/dt/tfds1s310vgbwph7tvcvqwlm0000gp/T/hello-c1467d.o -x f95 /Users/phhargrove/Hello/hello.f
 "/usr/bin/ld" -demangle -lto_library /opt/llvm/lib/libLTO.dylib -no_deduplicate -dynamic -arch arm64 -platform_version macos 14.0.0 14.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mllvm -enable-linkonceodr-outlining -o a.out /var/folders/dt/tfds1s310vgbwph7tvcvqwlm0000gp/T/hello-c1467d.o -L/opt/llvm/lib/clang/22/lib/darwin -L/opt/llvm/lib -lflang_rt.runtime -lSystem
ld: warning: search path '/opt/llvm/lib/clang/22/lib/darwin' not found
ld: library 'flang_rt.runtime' not found
flang-22: error: linker command failed with exit code 1 (use -v to see invocation)

FWIW:

$ ls -R /opt/llvm/lib/clang/22/lib
arm64-apple-darwin23.6.0

/opt/llvm/lib/clang/22/lib/arm64-apple-darwin23.6.0:
libflang_rt.runtime.a

@Meinersbur
Copy link
Member Author

Meinersbur commented Aug 6, 2025

@PHHargrove Thanks for the details. There is something weird about your setup.

  1. libflang_rt.runtime.a in arm64-apple-darwin23.6.0/. As long as CMake detects APPLE, the install directory will be CMAKE_SYSTEM_NAME (lower case). I have no explanation for this.
  2. The native target is arm64-apple-darwin23.6.0, but you are compiling for arm64-apple-macosx14.0.0, probably because you compiled LLVM with an LLVM_DEFAULT_TARGET_TRIPLE option, or you updated your OS since you first configured LLVM. This has elements of cross-compilation which is still unsupported for Flang. Consider deleting your build directory a running cmake from scratch.

@Meinersbur Meinersbur marked this pull request as ready for review August 6, 2025 10:19
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Aug 6, 2025
@llvmbot
Copy link
Member

llvmbot commented Aug 6, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Michael Kruse (Meinersbur)

Changes

clang_rt has two separate systems for find its location (simplified):

  • getRuntimePath(), e.g. ../lib/clang/22/lib/x86_64-pc-windows-msvc, used with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1
  • getCompilerRTPath(), e.g. ../lib/clang/22/lib/windows, used with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0

To simplify the search path, Flang-RT normally assumes only getRuntimePath(), i.e. ignoring LLVM_ENABLE_PER_TARGET_RUNTIME_DIR. There is an exception for Apple Darwin where getRuntimePath() returns nothing. We fall back to getCompilerRTPath() instead since LLVM_ENABLE_PER_TARGET_RUNTIME_DIR is also ignored in the flang-rt/compiler-rt CMake code. Since only getRuntimePath() is automatically added to the linker command line, we add the path explicitly when linking flang_rt.

Fixes #151031


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

1 Files Affected:

  • (modified) clang/lib/Driver/ToolChain.cpp (+21-8)
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 25c6b5a486fd5..7667dbddb0ca2 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -855,17 +855,30 @@ void ToolChain::addFortranRuntimeLibs(const ArgList &Args,
 
 void ToolChain::addFortranRuntimeLibraryPath(const llvm::opt::ArgList &Args,
                                              ArgStringList &CmdArgs) const {
-  // Default to the <driver-path>/../lib directory. This works fine on the
-  // platforms that we have tested so far. We will probably have to re-fine
-  // this in the future. In particular, on some platforms, we may need to use
-  // lib64 instead of lib.
+  auto AddLibSearchPathIfExists = [&](const Twine &Path) {
+    // Linker may emit warnings about non-existing directories
+    if (!llvm::sys::fs::is_directory(Path))
+      return;
+
+    if (getTriple().isKnownWindowsMSVCEnvironment())
+      CmdArgs.push_back(Args.MakeArgString("-libpath:" + Path));
+    else
+      CmdArgs.push_back(Args.MakeArgString("-L" + Path));
+  };
+
+  // Search for flang_rt.* at the same location as clang_rt.* with
+  // LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0. On most platforms, flang_rt is
+  // located at the path returned by getRuntimePath() which is already added to
+  // the library search path. This exception is for Apple-Darwin.
+  AddLibSearchPathIfExists(getCompilerRTPath());
+
+  // Fall back to the non-resource directory <driver-path>/../lib. We will
+  // probably have to refine this in the future. In particular, on some
+  // platforms, we may need to use lib64 instead of lib.
   SmallString<256> DefaultLibPath =
       llvm::sys::path::parent_path(getDriver().Dir);
   llvm::sys::path::append(DefaultLibPath, "lib");
-  if (getTriple().isKnownWindowsMSVCEnvironment())
-    CmdArgs.push_back(Args.MakeArgString("-libpath:" + DefaultLibPath));
-  else
-    CmdArgs.push_back(Args.MakeArgString("-L" + DefaultLibPath));
+  AddLibSearchPathIfExists(DefaultLibPath);
 }
 
 void ToolChain::addFlangRTLibPath(const ArgList &Args,

@Meinersbur Meinersbur merged commit 8de4819 into llvm:main Aug 6, 2025
13 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Aug 6, 2025

LLVM Buildbot has detected a new failure on builder lldb-aarch64-ubuntu running on linaro-lldb-aarch64-ubuntu while building clang at step 6 "test".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/22209

Here is the relevant piece of the build log for the reference
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: commands/platform/basic/TestPlatformPython.py (190 of 2304)
PASS: lldb-api :: commands/memory/write/TestMemoryWrite.py (191 of 2304)
PASS: lldb-api :: commands/platform/basic/TestPlatformCommand.py (192 of 2304)
PASS: lldb-api :: commands/platform/file/close/TestPlatformFileClose.py (193 of 2304)
PASS: lldb-api :: commands/platform/file/read/TestPlatformFileRead.py (194 of 2304)
PASS: lldb-api :: commands/memory/read/TestMemoryRead.py (195 of 2304)
UNSUPPORTED: lldb-api :: commands/platform/sdk/TestPlatformSDK.py (196 of 2304)
PASS: lldb-api :: commands/platform/connect/TestPlatformConnect.py (197 of 2304)
PASS: lldb-api :: commands/plugin/TestPlugin.py (198 of 2304)
UNRESOLVED: lldb-api :: commands/gui/spawn-threads/TestGuiSpawnThreads.py (199 of 2304)
******************** TEST 'lldb-api :: commands/gui/spawn-threads/TestGuiSpawnThreads.py' FAILED ********************
Script:
--
/usr/bin/python3.10 /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py -u CXXFLAGS -u CFLAGS --env LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include --env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --arch aarch64 --build-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex --lldb-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api --clang-module-cache-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb --compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang --dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil --make /usr/bin/gmake --llvm-tools-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --cmake-build-type Release /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/commands/gui/spawn-threads -p TestGuiSpawnThreads.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 22.0.0git (https://github.com/llvm/llvm-project.git revision 8de481913353a1e37264687d5cc73db0de19e6cc)
  clang revision 8de481913353a1e37264687d5cc73db0de19e6cc
  llvm revision 8de481913353a1e37264687d5cc73db0de19e6cc
Skipping the following test categories: ['libc++', 'msvcstl', 'dsym', 'gmodules', 'debugserver', 'objc']

--
Command Output (stderr):
--
FAIL: LLDB (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: test_gui (TestGuiSpawnThreads.TestGuiSpawnThreadsTest)
======================================================================
ERROR: test_gui (TestGuiSpawnThreads.TestGuiSpawnThreadsTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py", line 151, in wrapper
    return func(*args, **kwargs)
  File "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/commands/gui/spawn-threads/TestGuiSpawnThreads.py", line 44, in test_gui
    self.child.expect_exact(f"thread #{i + 2}: tid =")
  File "/usr/local/lib/python3.10/dist-packages/pexpect/spawnbase.py", line 432, in expect_exact
    return exp.expect_loop(timeout)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/expect.py", line 179, in expect_loop
    return self.eof(e)
  File "/usr/local/lib/python3.10/dist-packages/pexpect/expect.py", line 122, in eof
    raise exc
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
<pexpect.pty_spawn.spawn object at 0xec5950186050>
command: /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb
args: ['/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb', '--no-lldbinit', '--no-use-colors', '-O', 'settings clear --all', '-O', 'settings set symbols.enable-external-lookup false', '-O', 'settings set target.inherit-tcc true', '-O', 'settings set target.disable-aslr false', '-O', 'settings set target.detach-on-error false', '-O', 'settings set target.auto-apply-fixits false', '-O', 'settings set plugin.process.gdb-remote.packet-timeout 60', '-O', 'settings set symbols.clang-modules-cache-path "/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api"', '-O', 'settings set use-color false', '-O', 'settings set show-statusline false', '--file', '/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/commands/gui/spawn-threads/TestGuiSpawnThreads.test_gui/a.out']
buffer (last 100 chars): b''
before (last 100 chars): b'3 0x0000acb978375030 _start (/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/lldb+0x45030)\n'
after: <class 'pexpect.exceptions.EOF'>

@PHHargrove
Copy link

@PHHargrove Thanks for the details. There is something weird about your setup.

  1. libflang_rt.runtime.a in arm64-apple-darwin23.6.0/. As long as CMake detects APPLE, the install directory will be CMAKE_SYSTEM_NAME (lower case). I have no explanation for this.
  2. The native target is arm64-apple-darwin23.6.0, but you are compiling for arm64-apple-macosx14.0.0, probably because you compiled LLVM with an LLVM_DEFAULT_TARGET_TRIPLE option, or you updated your OS since you first configured LLVM. This has elements of cross-compilation which is still unsupported for Flang. Consider deleting your build directory a running cmake from scratch.

Regarding item 2: -triple arm64-apple-macosx14.0.0 does not match the reported Target: arm64-apple-darwin23.6.0.

My cmake command (given below, for completeness) does not include any LLVM_DEFAULT_TARGET_TRIPLE option.
I have not updated my system recently, and certainly not since since running cmake.

I cannot account for the difference, but have determined that Homebrew's flang and Apple's clang both display the same "discrepancy" between the native target reported by the driver and the -triple it passes to the compiler.
So, I am going to assume this is the expected behavior despite @Meinersbur's assertion that it is not.

Regarding item 1: unexpected library directory.

I removed both the build and installation directories, checked out the merge commit which closed this PR (8de4819), reran cmake in a new build directory, and proceeded to make -j8 all install.

The flang runtime is installed in $prefix/lib/clang/22/lib/darwin which is included in the -L options the driver passes to the linker (directly addressing the defect reported in @ktras's #151031)

TL;DR:

I cannot account for either of the "something weird" items, but with a fresh build I no longer reproduce #151031.
So, It is working for me now. 👍


cmake commoand:

cmake ../llvm \
    -DDEFAULT_SYSROOT="$(xcrun --show-sdk-path)" \
    -DCMAKE_INSTALL_PREFIX=/opt/llvm \
    -DCMAKE_BUILD_TYPE=Release \
    -DLLVM_PARALLEL_LINK_JOBS=1 \
    -DLLVM_ENABLE_PROJECTS="flang;mlir" \
    -DLLVM_INCLUDE_BENCHMARKS=OFF \
    -DLLVM_INCLUDE_EXAMPLES=OFF \
    -DLLVM_INCLUDE_TESTS=OFF \
    -DLLVM_TARGETS_TO_BUILD=host

Verbose compile and run:

$ /opt/llvm/bin/flang -v ~/Hello/hello.f && ./a.out
flang version 22.0.0git (git@github.com:llvm/llvm-project 8de481913353a1e37264687d5cc73db0de19e6cc)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /opt/llvm/bin
 "/opt/llvm/bin/flang" -fc1 -triple arm64-apple-macosx14.0.0 -emit-obj -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -target-cpu apple-m1 -target-feature +v8.4a -target-feature +aes -target-feature +altnzcv -target-feature +ccdp -target-feature +ccpp -target-feature +complxnum -target-feature +crc -target-feature +dotprod -target-feature +flagm -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +fptoint -target-feature +fullfp16 -target-feature +jsconv -target-feature +lse -target-feature +neon -target-feature +pauth -target-feature +perfmon -target-feature +predres -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sb -target-feature +sha2 -target-feature +sha3 -target-feature +specrestrict -target-feature +ssbs -resource-dir /opt/llvm/lib/clang/22 -mframe-pointer=non-leaf -o /var/folders/dt/tfds1s310vgbwph7tvcvqwlm0000gp/T/hello-12a9a2.o -x f95 /Users/phhargrove/Hello/hello.f
 "/usr/bin/ld" -demangle -lto_library /opt/llvm/lib/libLTO.dylib -no_deduplicate -dynamic -arch arm64 -platform_version macos 14.0.0 14.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mllvm -enable-linkonceodr-outlining -o a.out /var/folders/dt/tfds1s310vgbwph7tvcvqwlm0000gp/T/hello-12a9a2.o -L/opt/llvm/lib/clang/22/lib/darwin -L/opt/llvm/lib -lflang_rt.runtime -lSystem
  Hello, world!
Fortran STOP

@Meinersbur
Copy link
Member Author

Meinersbur commented Aug 7, 2025

/cherry-pick 8de4819

@llvmbot
Copy link
Member

llvmbot commented Aug 7, 2025

/cherry-pick 8de4819

Error: Command failed due to missing milestone.

@llvmbot
Copy link
Member

llvmbot commented Aug 7, 2025

/pull-request #152458

@llvmbot llvmbot moved this from Needs Triage to Done in LLVM Release Status Aug 7, 2025
tru pushed a commit to llvmbot/llvm-project that referenced this pull request Aug 8, 2025
The clang/flang driver has two separate systems for find the location of
clang_rt (simplified):

* `getCompilerRTPath()`, e.g. `../lib/clang/22/lib/windows`,
   used when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0`
* `getRuntimePath()`, e.g. `../lib/clang/22/lib/x86_64-pc-windows-msvc`,
   used when `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1`

To simplify the search path, Flang-RT normally assumes only
`getRuntimePath()`, i.e. ignoring `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR`
and always using the `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=1` mechanism.
There is an exception for Apple Darwin triples where `getRuntimePath()`
returns nothing. The flang-rt/compiler-rt CMake code for library
location also ignores `LLVM_ENABLE_PER_TARGET_RUNTIME_DIR` but uses the
`LLVM_ENABLE_PER_TARGET_RUNTIME_DIR=0` path instead. Since only
`getRuntimePath()` is automatically added to the linker command line,
this patch explicitly adds `getCompilerRTPath()` to the path when
linking flang_rt.

Fixes llvm#151031

(cherry picked from commit 8de4819)
@Meinersbur Meinersbur deleted the flangrt_darwin-libpath branch August 19, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
Development

Successfully merging this pull request may close these issues.

[flang] Building flang on Macs requires manually passing a flag with path to runtime libraries
9 participants