]> granicus.if.org Git - clang/commitdiff
Driver: Do not warn about unused -pthread when linking on darwin
authorMatthias Braun <matze@braunis.de>
Fri, 3 Feb 2017 23:09:31 +0000 (23:09 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 3 Feb 2017 23:09:31 +0000 (23:09 +0000)
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.

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

lib/Driver/Tools.cpp
test/Driver/darwin-ld-pthread.c [new file with mode: 0644]

index 910b5106e988ccb2126b0ecb1b91063d2e3c6c7d..1cefce6848c41ddb19531b3e43b94d12ac819adb 100644 (file)
@@ -8696,6 +8696,10 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
     // 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)) {
diff --git a/test/Driver/darwin-ld-pthread.c b/test/Driver/darwin-ld-pthread.c
new file mode 100644 (file)
index 0000000..b22b68a
--- /dev/null
@@ -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'