[llvm-branch-commits] [clang] 21f87ad - [Driver][NetBSD] -r: imply -nostdlib like GCC
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Feb 28 16:20:41 PST 2022
Author: Brad Smith
Date: 2022-02-28T16:19:51-08:00
New Revision: 21f87ad9f590df3f016fa6c738b374b9971fb36e
URL: https://github.com/llvm/llvm-project/commit/21f87ad9f590df3f016fa6c738b374b9971fb36e
DIFF: https://github.com/llvm/llvm-project/commit/21f87ad9f590df3f016fa6c738b374b9971fb36e.diff
LOG: [Driver][NetBSD] -r: imply -nostdlib like GCC
Similar to D116843 for Gnu.cpp
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D119655
(cherry picked from commit d241ce0f97e47afa4f01a643ebbb4eafd729b403)
Added:
Modified:
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/test/Driver/netbsd.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 37b1fc5215ff5..d1eda14a51f01 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -236,7 +236,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
assert(Output.isNothing() && "Invalid output.");
}
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+ options::OPT_r)) {
if (!Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back(
Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
@@ -294,7 +295,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+ options::OPT_r)) {
// Use the static OpenMP runtime with -static-openmp
bool StaticOpenMP = Args.hasArg(options::OPT_static_openmp) &&
!Args.hasArg(options::OPT_static);
@@ -330,7 +332,8 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
+ options::OPT_r)) {
if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
CmdArgs.push_back(
Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
diff --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index 812889309a0f7..b549b3cde9b5a 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -467,3 +467,11 @@
// RUN: %clang -target powerpc-unknown-netbsd -### -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=POWERPC-SECUREPLT %s
// POWERPC-SECUREPLT: "-target-feature" "+secure-plt"
+
+// -r suppresses default -l and crt*.o like -nostdlib.
+// RUN: %clang -no-canonical-prefixes -target x86_64-unknown-netbsd -r \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree %s -### 2>&1 \
+// RUN: | FileCheck -check-prefix=RELOCATABLE %s
+// RELOCATABLE: "-r"
+// RELOCATABLE-NOT: "-l
+// RELOCATABLE-NOT: crt{{[^.]+}}.o
More information about the llvm-branch-commits
mailing list