2024-04-09 13:39:29 +00:00
|
|
|
From 5c209e4632cb6acdda3be01ae7d83c31ba956979 Mon Sep 17 00:00:00 2001
|
2023-10-12 09:15:14 +00:00
|
|
|
From: Tom Stellard <tstellar@redhat.com>
|
|
|
|
Date: Thu, 9 Mar 2023 21:52:41 -0800
|
2024-04-09 13:39:29 +00:00
|
|
|
Subject: [PATCH] Restore -fopenmp-implicit-rpath, disabled by default
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
Used by redhat-rpm-config on older Fedora versions.
|
|
|
|
---
|
2024-04-09 13:39:29 +00:00
|
|
|
clang/include/clang/Driver/Options.td | 6 ++++++
|
|
|
|
clang/lib/Driver/ToolChains/CommonArgs.cpp | 19 +++++++++++++++++++
|
|
|
|
clang/lib/Driver/ToolChains/CommonArgs.h | 3 +++
|
2023-10-12 09:15:14 +00:00
|
|
|
clang/test/OpenMP/Inputs/libomp.a | 1 +
|
2024-04-09 13:39:29 +00:00
|
|
|
4 files changed, 29 insertions(+)
|
2023-10-12 09:15:14 +00:00
|
|
|
create mode 100644 clang/test/OpenMP/Inputs/libomp.a
|
|
|
|
|
|
|
|
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
|
2024-04-09 13:39:29 +00:00
|
|
|
index f745e573eb26..6289c1af9ada 100644
|
2023-10-12 09:15:14 +00:00
|
|
|
--- a/clang/include/clang/Driver/Options.td
|
|
|
|
+++ b/clang/include/clang/Driver/Options.td
|
2024-04-09 13:39:29 +00:00
|
|
|
@@ -5484,6 +5484,12 @@ def offload_add_rpath: Flag<["--"], "offload-add-rpath">,
|
2023-10-12 09:15:14 +00:00
|
|
|
def no_offload_add_rpath: Flag<["--"], "no-offload-add-rpath">,
|
|
|
|
Flags<[NoArgumentUnused]>,
|
|
|
|
Alias<frtlib_add_rpath>;
|
|
|
|
+defm openmp_implicit_rpath: BoolFOption<"openmp-implicit-rpath",
|
|
|
|
+ LangOpts<"OpenMP">,
|
|
|
|
+ DefaultFalse,
|
|
|
|
+ PosFlag<SetTrue, [], [ClangOption], "Set rpath on OpenMP executables">,
|
|
|
|
+ NegFlag<SetFalse>,
|
|
|
|
+ BothFlags<[NoArgumentUnused]>>;
|
|
|
|
def r : Flag<["-"], "r">, Flags<[LinkerInput, NoArgumentUnused]>,
|
|
|
|
Group<Link_Group>;
|
|
|
|
def regcall4 : Flag<["-"], "regcall4">, Group<m_Group>,
|
|
|
|
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
|
2024-04-09 13:39:29 +00:00
|
|
|
index 62a53b85ce09..c51766250983 100644
|
2023-10-12 09:15:14 +00:00
|
|
|
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
|
|
|
|
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
|
2024-04-09 13:39:29 +00:00
|
|
|
@@ -1109,6 +1109,23 @@ static void addOpenMPDeviceLibC(const Compilation &C, const ArgList &Args,
|
|
|
|
}
|
2023-10-12 09:15:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
|
|
|
|
+ const ArgList &Args,
|
|
|
|
+ ArgStringList &CmdArgs) {
|
|
|
|
+
|
|
|
|
+ if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
|
|
|
|
+ options::OPT_fno_openmp_implicit_rpath, false)) {
|
|
|
|
+ // Default to clang lib / lib64 folder, i.e. the same location as device
|
|
|
|
+ // runtime
|
|
|
|
+ SmallString<256> DefaultLibPath =
|
|
|
|
+ llvm::sys::path::parent_path(TC.getDriver().Dir);
|
|
|
|
+ llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
|
|
|
|
+ CmdArgs.push_back("-rpath");
|
|
|
|
+ CmdArgs.push_back(Args.MakeArgString(DefaultLibPath));
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,
|
|
|
|
const ArgList &Args,
|
|
|
|
ArgStringList &CmdArgs) {
|
2024-04-09 13:39:29 +00:00
|
|
|
@@ -1185,6 +1202,8 @@ bool tools::addOpenMPRuntime(const Compilation &C, ArgStringList &CmdArgs,
|
|
|
|
addOpenMPDeviceLibC(C, Args, CmdArgs);
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
addArchSpecificRPath(TC, Args, CmdArgs);
|
|
|
|
+ if (RTKind == Driver::OMPRT_OMP)
|
|
|
|
+ addOpenMPRuntimeSpecificRPath(TC, Args, CmdArgs);
|
|
|
|
addOpenMPRuntimeLibraryPath(TC, Args, CmdArgs);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h b/clang/lib/Driver/ToolChains/CommonArgs.h
|
2024-04-09 13:39:29 +00:00
|
|
|
index 5581905db311..3360eb0c6a37 100644
|
2023-10-12 09:15:14 +00:00
|
|
|
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
|
|
|
|
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
|
|
|
|
@@ -105,6 +105,9 @@ void AddAssemblerKPIC(const ToolChain &ToolChain,
|
|
|
|
const llvm::opt::ArgList &Args,
|
|
|
|
llvm::opt::ArgStringList &CmdArgs);
|
|
|
|
|
|
|
|
+void addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
|
|
|
|
+ const llvm::opt::ArgList &Args,
|
|
|
|
+ llvm::opt::ArgStringList &CmdArgs);
|
|
|
|
void addArchSpecificRPath(const ToolChain &TC, const llvm::opt::ArgList &Args,
|
|
|
|
llvm::opt::ArgStringList &CmdArgs);
|
|
|
|
void addOpenMPRuntimeLibraryPath(const ToolChain &TC,
|
|
|
|
diff --git a/clang/test/OpenMP/Inputs/libomp.a b/clang/test/OpenMP/Inputs/libomp.a
|
|
|
|
new file mode 100644
|
|
|
|
index 000000000000..8b277f0dd5dc
|
|
|
|
--- /dev/null
|
|
|
|
+++ b/clang/test/OpenMP/Inputs/libomp.a
|
|
|
|
@@ -0,0 +1 @@
|
|
|
|
+!<arch>
|
|
|
|
--
|
2024-04-09 13:39:29 +00:00
|
|
|
2.42.0
|
2023-10-12 09:15:14 +00:00
|
|
|
|