forked from OSchip/llvm-project
Fix rewrite of reserved library name in case of -nodefaultlibs
The Driver only checked if nostdlib was set when deciding to add reserved_lib_stdcxx, but as nostdlib is always exactly nodefaultlibs and nostartfiles we should be checking one (clearly nodefaultlibs in the case) as well. This appears to be the only such instance of this in the codebase. Differential Revision: http://reviews.llvm.org/D14935 llvm-svn: 253990
This commit is contained in:
parent
47c1baeb1f
commit
b0bb6142f5
|
@ -209,6 +209,7 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
|
|||
DerivedArgList *DAL = new DerivedArgList(Args);
|
||||
|
||||
bool HasNostdlib = Args.hasArg(options::OPT_nostdlib);
|
||||
bool HasNodefaultlib = Args.hasArg(options::OPT_nodefaultlibs);
|
||||
for (Arg *A : Args) {
|
||||
// Unfortunately, we have to parse some forwarding options (-Xassembler,
|
||||
// -Xlinker, -Xpreprocessor) because we either integrate their functionality
|
||||
|
@ -252,7 +253,7 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
|
|||
StringRef Value = A->getValue();
|
||||
|
||||
// Rewrite unless -nostdlib is present.
|
||||
if (!HasNostdlib && Value == "stdc++") {
|
||||
if (!HasNostdlib && !HasNodefaultlib && Value == "stdc++") {
|
||||
DAL->AddFlagArg(A, Opts->getOption(options::OPT_Z_reserved_lib_stdcxx));
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2> %t
|
||||
// RUN: FileCheck < %t %s
|
||||
//
|
||||
// CHECK-NOT: start-group
|
||||
// CHECK-NOT: "-lgcc"
|
||||
// CHECK-NOT: "-lc"
|
||||
// CHECK: crtbegin
|
||||
// CHECK: crtend
|
||||
// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2>&1 | FileCheck -check-prefix=TEST1 %s
|
||||
// TEST1-NOT: start-group
|
||||
// TEST1-NOT: "-lgcc"
|
||||
// TEST1-NOT: "-lc"
|
||||
// TEST1: crtbegin
|
||||
// TEST1: crtend
|
||||
|
||||
// RUN: %clang -target i686-pc-linux-gnu -stdlib=libc++ -nodefaultlibs -lstdc++ -### %s 2>&1 | FileCheck -check-prefix=TEST2 %s
|
||||
// TEST2-NOT: "-lc++"
|
||||
// TEST2: "-lstdc++"
|
||||
|
|
Loading…
Reference in New Issue