[clang] 57e43eb - [Driver][Gnu] Don't passs --dynamic-linker in -r mode
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 18 23:13:24 PDT 2022
Author: Fangrui Song
Date: 2022-06-18T23:13:19-07:00
New Revision: 57e43ebc42d4e572cab1e84532115c364d5db92a
URL: https://github.com/llvm/llvm-project/commit/57e43ebc42d4e572cab1e84532115c364d5db92a
DIFF: https://github.com/llvm/llvm-project/commit/57e43ebc42d4e572cab1e84532115c364d5db92a.diff
LOG: [Driver][Gnu] Don't passs --dynamic-linker in -r mode
No behavior change as GNU ld/gold/ld.lld ignore --dynamic-linker in -r mode.
This change makes the intention clearer as we already suppress --dynamic-linker
for -shared, -static, and -static-pie.
Added:
Modified:
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/linux-cross.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 9a9ac600fc4d..d09f41136895 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -477,7 +477,8 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_rdynamic))
CmdArgs.push_back("-export-dynamic");
- if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE) {
+ if (!Args.hasArg(options::OPT_shared) && !IsStaticPIE &&
+ !Args.hasArg(options::OPT_r)) {
CmdArgs.push_back("-dynamic-linker");
CmdArgs.push_back(Args.MakeArgString(Twine(D.DyldPrefix) +
ToolChain.getDynamicLinker(Args)));
diff --git a/clang/test/Driver/linux-cross.cpp b/clang/test/Driver/linux-cross.cpp
index c989ca80938d..e218e8d93ed0 100644
--- a/clang/test/Driver/linux-cross.cpp
+++ b/clang/test/Driver/linux-cross.cpp
@@ -211,10 +211,11 @@
// RUN: --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s --check-prefix=MUSL_X32
// MUSL_X32: "-dynamic-linker" "/lib/ld-musl-x32.so.1"
-/// -r suppresses default -l and crt*.o like -nostdlib.
+/// -r suppresses -dynamic-linker, default -l, and crt*.o like -nostdlib.
// RUN: %clang -### %s --target=x86_64-linux-gnu --sysroot=%S/Inputs/debian_multiarch_tree \
// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin -resource-dir=%S/Inputs/resource_dir \
// RUN: --stdlib=platform --rtlib=platform -r 2>&1 | FileCheck %s --check-prefix=RELOCATABLE
+// RELOCATABLE-NOT: "-dynamic-linker"
// RELOCATABLE: "-internal-isystem"
// RELOCATABLE-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10"
// RELOCATABLE: "-L
More information about the cfe-commits
mailing list