r294065 - Driver: Do not warn about unused -pthread when linking on darwin

Matthias Braun via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 3 15:09:32 PST 2017


Author: matze
Date: Fri Feb  3 17:09:31 2017
New Revision: 294065

URL: http://llvm.org/viewvc/llvm-project?rev=294065&view=rev
Log:
Driver: Do not warn about unused -pthread when linking on darwin

While there is nothing to do at link time to get pthreads support on
darwin, specifying the argument is fine and we should not warn about
unused arguments.

Added:
    cfe/trunk/test/Driver/darwin-ld-pthread.c
Modified:
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=294065&r1=294064&r2=294065&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Feb  3 17:09:31 2017
@@ -8696,6 +8696,10 @@ void darwin::Linker::ConstructJob(Compil
 
     // Let the tool chain choose which runtime library to link.
     getMachOToolChain().AddLinkRuntimeLibArgs(Args, CmdArgs);
+
+    // No need to do anything for pthreads. Claim argument to avoid warning.
+    Args.ClaimAllArgs(options::OPT_pthread);
+    Args.ClaimAllArgs(options::OPT_pthreads);
   }
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles)) {

Added: cfe/trunk/test/Driver/darwin-ld-pthread.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld-pthread.c?rev=294065&view=auto
==============================================================================
--- cfe/trunk/test/Driver/darwin-ld-pthread.c (added)
+++ cfe/trunk/test/Driver/darwin-ld-pthread.c Fri Feb  3 17:09:31 2017
@@ -0,0 +1,4 @@
+// RUN: %clang -Wunused-command-line-argument -pthread -target x86_64-apple-darwin -### /dev/null -o /dev/null 2>&1 | FileCheck %s
+
+// There is nothing to do at link time to get pthread support. But do not warn.
+// CHECK-NOT: argument unused during compilation: '-pthread'




More information about the cfe-commits mailing list