From e81fef1796ef02bf49916b89ae8b924053603488 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 3 Feb 2017 23:09:31 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294065 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 4 ++++ test/Driver/darwin-ld-pthread.c | 4 ++++ 2 files changed, 8 insertions(+) create mode 100644 test/Driver/darwin-ld-pthread.c diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 910b5106e9..1cefce6848 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -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 index 0000000000..b22b68a6e6 --- /dev/null +++ b/test/Driver/darwin-ld-pthread.c @@ -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' -- 2.40.0