summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumanth Gundapaneni <sgundapa@codeaurora.org>2015-12-02 19:12:41 +0000
committerSumanth Gundapaneni <sgundapa@codeaurora.org>2015-12-02 19:12:41 +0000
commitb79fdff9e26511bf298163067a9feaf71b48d5b4 (patch)
tree0d01ae9ae60300cf739a0179afa203cb785cdcc3
parent7cc447763765f96b8d525e3074e44af7f6922879 (diff)
downloadbcm5719-llvm-b79fdff9e26511bf298163067a9feaf71b48d5b4.tar.gz
bcm5719-llvm-b79fdff9e26511bf298163067a9feaf71b48d5b4.zip
Fix the clang driver when "-nostdlib" is present
This patch is a fix to r252901 which changed the behavior of clang driver. In the presence of "-nostdlib" none of the standard libraries should be passed to link line. Differential Revision: http://reviews.llvm.org/D15130 llvm-svn: 254535
-rw-r--r--clang/lib/Driver/Tools.cpp3
-rw-r--r--clang/test/Driver/nostdlib.c16
2 files changed, 17 insertions, 2 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 484737b2bcc..2015e3b821d 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -8694,8 +8694,7 @@ void gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!isAndroid)
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
}
- } else if (Args.hasArg(options::OPT_rtlib_EQ))
- AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
+ }
C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));
}
diff --git a/clang/test/Driver/nostdlib.c b/clang/test/Driver/nostdlib.c
index e6891f870d6..47c6f8bacd4 100644
--- a/clang/test/Driver/nostdlib.c
+++ b/clang/test/Driver/nostdlib.c
@@ -9,3 +9,19 @@
// RUN: %clang -### -nostartfiles -nostdlib -target i386-apple-darwin %s \
// RUN: 2>&1 | FileCheck %s -check-prefix=ARGSCLAIMED
// ARGSCLAIMED-NOT: warning:
+
+// In the presence of -nostdlib, the standard libraries should not be
+// passed down to link line
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu -nostdlib --rtlib=compiler-rt \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target i686-pc-linux-gnu --rtlib=compiler-rt -nostdlib \
+// RUN: -resource-dir=%S/Inputs/resource_dir -lclang_rt.builtins-i686 \
+// RUN: | FileCheck --check-prefix=CHECK-LINUX-NOSTDLIB %s
+//
+// CHECK-LINUX-NOSTDLIB: warning: argument unused during compilation: '--rtlib=compiler-rt'
+// CHECK-LINUX-NOSTDLIB: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
+// CHECK-LINUX-NOSTDLIB-NOT: "{{.*}}/Inputs/resource_dir{{/|\\\\}}lib{{/|\\\\}}linux{{/|\\\\}}libclang_rt.builtins-i686.a"
OpenPOWER on IntegriCloud