[clang] e289561 - [Driver][Fuchsia] -r: imply -nostdlib like GCC
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 13 15:49:24 PST 2022
Author: Fangrui Song
Date: 2022-01-13T15:49:19-08:00
New Revision: e289561205e844ab403c1c9e6814b2e44fb8d415
URL: https://github.com/llvm/llvm-project/commit/e289561205e844ab403c1c9e6814b2e44fb8d415
DIFF: https://github.com/llvm/llvm-project/commit/e289561205e844ab403c1c9e6814b2e44fb8d415.diff
LOG: [Driver][Fuchsia] -r: imply -nostdlib like GCC
Similar to D116843.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D116844
Added:
Modified:
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 0dbe979668018..bd1600d060c87 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -109,7 +109,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-o");
CmdArgs.push_back(Output.getFilename());
- 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("Scrt1.o")));
}
@@ -131,7 +132,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
ToolChain.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 (Args.hasArg(options::OPT_static))
CmdArgs.push_back("-Bdynamic");
diff --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index ecf811d9401ba..fdf7f4ef3f11b 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -72,6 +72,8 @@
// CHECK-RELOCATABLE-NOT: "-pie"
// CHECK-RELOCATABLE-NOT: "--build-id"
// CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-l
+// CHECK-RELOCATABLE-NOT: crt{{[^.]+}}.o
// RUN: %clang %s -### --target=x86_64-unknown-fuchsia -nodefaultlibs -fuse-ld=lld 2>&1 \
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
More information about the cfe-commits
mailing list