[clang] 066043c - [Driver][Minix] -r: imply -nostdlib like GCC
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 25 13:18:20 PDT 2022
Author: Brad Smith
Date: 2022-06-25T16:16:38-04:00
New Revision: 066043c84fdb0ee0d719fd80b0ff9e0f853850d0
URL: https://github.com/llvm/llvm-project/commit/066043c84fdb0ee0d719fd80b0ff9e0f853850d0
DIFF: https://github.com/llvm/llvm-project/commit/066043c84fdb0ee0d719fd80b0ff9e0f853850d0.diff
LOG: [Driver][Minix] -r: imply -nostdlib like GCC
Similar to D116843 for Gnu.cpp
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D128554
Added:
clang/test/Driver/minix.c
Modified:
clang/lib/Driver/ToolChains/Minix.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Minix.cpp b/clang/lib/Driver/ToolChains/Minix.cpp
index 5bceb9aba3e96..4b8670a79012e 100644
--- a/clang/lib/Driver/ToolChains/Minix.cpp
+++ b/clang/lib/Driver/ToolChains/Minix.cpp
@@ -56,7 +56,8 @@ void tools::minix::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)) {
CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crt1.o")));
CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crti.o")));
CmdArgs.push_back(
@@ -71,7 +72,8 @@ void tools::minix::Linker::ConstructJob(Compilation &C, const JobAction &JA,
getToolChain().addProfileRTLibs(Args, CmdArgs);
- if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
+ if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
+ options::OPT_r)) {
if (D.CCCIsCXX()) {
if (getToolChain().ShouldLinkCXXStdlib(Args))
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
@@ -79,7 +81,8 @@ void tools::minix::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_pthread))
CmdArgs.push_back("-lpthread");
CmdArgs.push_back("-lc");
diff --git a/clang/test/Driver/minix.c b/clang/test/Driver/minix.c
new file mode 100644
index 0000000000000..54f261d53809d
--- /dev/null
+++ b/clang/test/Driver/minix.c
@@ -0,0 +1,6 @@
+// -r suppresses default -l and crt*.o like -nostdlib.
+// RUN: %clang -### %s --target=i386-unknown-minix -r 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-RELOCATABLE
+// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
More information about the cfe-commits
mailing list