]> granicus.if.org Git - clang/commitdiff
Fix the clang driver when "-nostdlib" is present
authorSumanth Gundapaneni <sgundapa@codeaurora.org>
Wed, 2 Dec 2015 19:12:41 +0000 (19:12 +0000)
committerSumanth Gundapaneni <sgundapa@codeaurora.org>
Wed, 2 Dec 2015 19:12:41 +0000 (19:12 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@254535 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Tools.cpp
test/Driver/nostdlib.c

index 484737b2bcc7fc26020f94453e2f7cae2c4d0a57..2015e3b821d3239be38c2764575ab6f8c5e64ca6 100644 (file)
@@ -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));
 }
index e6891f870d61453c7d3dda25b2a03c5b78b46676..47c6f8bacd4644f221bd11bbe0c23588541cc9ee 100644 (file)
@@ -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"