forked from OSchip/llvm-project
[Driver][Ananas] -r: imply -nostdlib like GCC
Similar to D116843 for Gnu.cpp Reviewed By: zhmu, MaskRay Differential Revision: https://reviews.llvm.org/D124729
This commit is contained in:
parent
6cfcfbdc95
commit
a132e527f2
|
@ -85,7 +85,8 @@ void ananas::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
assert(Output.isNothing() && "Invalid output.");
|
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)) {
|
if (!Args.hasArg(options::OPT_shared)) {
|
||||||
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
|
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crt0.o")));
|
||||||
}
|
}
|
||||||
|
@ -111,12 +112,15 @@ void ananas::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
|
|
||||||
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
|
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
|
||||||
|
|
||||||
|
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
|
||||||
|
options::OPT_r)) {
|
||||||
if (ToolChain.ShouldLinkCXXStdlib(Args))
|
if (ToolChain.ShouldLinkCXXStdlib(Args))
|
||||||
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
|
ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);
|
||||||
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
|
|
||||||
CmdArgs.push_back("-lc");
|
CmdArgs.push_back("-lc");
|
||||||
|
}
|
||||||
|
|
||||||
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))
|
if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))
|
||||||
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
|
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,3 +15,10 @@
|
||||||
// CHECK-SHARED: crtbeginS.o
|
// CHECK-SHARED: crtbeginS.o
|
||||||
// CHECK-SHARED: crtendS.o
|
// CHECK-SHARED: crtendS.o
|
||||||
// CHECK-SHARED: crtn.o
|
// CHECK-SHARED: crtn.o
|
||||||
|
|
||||||
|
// -r suppresses default -l and crt*.o like -nostdlib.
|
||||||
|
// RUN: %clang %s -### -o %t.o --target=x86_64-unknown-ananas -r 2>&1 \
|
||||||
|
// RUN: | FileCheck %s --check-prefix=CHECK-RELOCATABLE
|
||||||
|
// CHECK-RELOCATABLE: "-r"
|
||||||
|
// CHECK-RELOCATABLE-NOT: "-l
|
||||||
|
// CHECK-RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
|
||||||
|
|
Loading…
Reference in New Issue