r254535 - Fix the clang driver when "-nostdlib" is present

Sumanth Gundapaneni via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 11:12:42 PST 2015


Author: sgundapa
Date: Wed Dec  2 13:12:41 2015
New Revision: 254535

URL: http://llvm.org/viewvc/llvm-project?rev=254535&view=rev
Log:
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

Modified:
    cfe/trunk/lib/Driver/Tools.cpp
    cfe/trunk/test/Driver/nostdlib.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=254535&r1=254534&r2=254535&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Dec  2 13:12:41 2015
@@ -8694,8 +8694,7 @@ void gnutools::Linker::ConstructJob(Comp
       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));
 }

Modified: cfe/trunk/test/Driver/nostdlib.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/nostdlib.c?rev=254535&r1=254534&r2=254535&view=diff
==============================================================================
--- cfe/trunk/test/Driver/nostdlib.c (original)
+++ cfe/trunk/test/Driver/nostdlib.c Wed Dec  2 13:12:41 2015
@@ -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"




More information about the cfe-commits mailing list