[clang] [flang] [flang][Driver] When linking with the Fortran runtime, the `addArchSpecificRPath()` should be called too (PR #114837)

Paul Osmialowski via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 09:26:06 PST 2024


https://github.com/pawosm-arm created https://github.com/llvm/llvm-project/pull/114837

When linking with other runtimes (OpenMP, sanitizers), the addArchSpecificRPath() is being called. The same thing should happen when linking with the Fortran runtime, this will improve user experience massively.

>From 5f6614172bd634e871c5e2c837e4310a0de7f98f Mon Sep 17 00:00:00 2001
From: Paul Osmialowski <pawel.osmialowski at arm.com>
Date: Mon, 4 Nov 2024 11:50:57 +0000
Subject: [PATCH] [flang][Driver] When linking with the Fortran runtime, the
 addArchSpecificRPath() should be called too

When linking with other runtimes (OpenMP, sanitizers),
the addArchSpecificRPath() is being called. The same thing should
happen when linking with the Fortran runtime, this will improve
user experience massively.
---
 clang/lib/Driver/ToolChains/CommonArgs.cpp       | 1 +
 flang/test/Driver/arch-specific-libdir-rpath.f95 | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1c3c8c816594e5..ca06fb115dfa11 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1293,6 +1293,7 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
     }
     CmdArgs.push_back("-lFortranRuntime");
     CmdArgs.push_back("-lFortranDecimal");
+    addArchSpecificRPath(TC, Args, CmdArgs);
   }
 
   // libomp needs libatomic for atomic operations if using libgcc
diff --git a/flang/test/Driver/arch-specific-libdir-rpath.f95 b/flang/test/Driver/arch-specific-libdir-rpath.f95
index cc09938f7d1e28..23fb52abfbd574 100644
--- a/flang/test/Driver/arch-specific-libdir-rpath.f95
+++ b/flang/test/Driver/arch-specific-libdir-rpath.f95
@@ -16,6 +16,13 @@
 !
 ! Test that -rpath is added
 !
+! Add LIBPATH, RPATH
+!
+! RUN: %flang %s -### --target=x86_64-linux \
+! RUN:     -resource-dir=%S/../../../clang/test/Driver/Inputs/resource_dir_with_arch_subdir \
+! RUN:     -frtlib-add-rpath 2>&1 \
+! RUN:   | FileCheck --check-prefixes=RESDIR,LIBPATH-X86_64,RPATH-X86_64 %s
+!
 ! Add LIBPATH, RPATH for OpenMP
 !
 ! RUN: %flang %s -### --target=x86_64-linux -fopenmp \



More information about the cfe-commits mailing list