From e289561205e844ab403c1c9e6814b2e44fb8d415 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 13 Jan 2022 15:49:19 -0800 Subject: [PATCH] [Driver][Fuchsia] -r: imply -nostdlib like GCC Similar to D116843. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D116844 --- clang/lib/Driver/ToolChains/Fuchsia.cpp | 6 ++++-- clang/test/Driver/fuchsia.c | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp index 0dbe97966801..bd1600d060c8 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 ecf811d9401b..fdf7f4ef3f11 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 \