tstellar / rpms / clang

Forked from rpms/clang 6 years ago
Clone
Blob Blame History Raw
From 9a9ab6e33a2309d82194f4196d700ff3e91616c0 Mon Sep 17 00:00:00 2001
From: Fangrui Song <i@maskray.me>
Date: Thu, 9 Mar 2023 21:52:52 -0800
Subject: [PATCH 2/2] [Driver] Default to -fno-openmp-implicit-rpath

D118493 added -fno-openmp-implicit-rpath and made it the default, with an
argument that it convenients systems installing the toolchain at a non-standard
location.

I'd argue that such systems should specify `-Wl,-rpath` explicitly or in a Clang
configuration file. libc++, libc++abi, libunwind, and compiler-rt don't add the
extra DT_RUNPATH, it's weird for openmp to diverge. Some build systems want to
handle DT_RUNPATH themselves (e.g. CMAKE_INSTALL_RPATH). Some distributions
(e.g. Fedora) have policies against `DT_RUNPATH` and this change is causing
trouble.

No test: the test was removed by d14897c7dad8c05c003bada019c0b573ace63a1a.

Differential Revision: https://reviews.llvm.org/D143306
---
 clang/include/clang/Driver/Options.td      | 2 +-
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 6f9ef66808a1..629fc471d5b2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4264,7 +4264,7 @@ def no_offload_add_rpath: Flag<["--"], "no-offload-add-rpath">, Flags<[NoArgumen
   Alias<frtlib_add_rpath>;
 defm openmp_implicit_rpath: BoolFOption<"openmp-implicit-rpath",
   LangOpts<"OpenMP">,
-  DefaultTrue,
+  DefaultFalse,
   PosFlag<SetTrue, [], "Set rpath on OpenMP executables">,
   NegFlag<SetFalse>,
   BothFlags<[NoArgumentUnused]>>;
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index dc46b625bb67..2b48a13d2b19 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -800,7 +800,7 @@ void tools::addOpenMPRuntimeSpecificRPath(const ToolChain &TC,
                                           ArgStringList &CmdArgs) {
 
   if (Args.hasFlag(options::OPT_fopenmp_implicit_rpath,
-                   options::OPT_fno_openmp_implicit_rpath, true)) {
+                   options::OPT_fno_openmp_implicit_rpath, false)) {
     // Default to clang lib / lib64 folder, i.e. the same location as device
     // runtime
     SmallString<256> DefaultLibPath =
-- 
2.31.1