From af4b8f8987248e442faaad339261332e05e254b8 Mon Sep 17 00:00:00 2001
Date: Sun, 16 May 2021 12:21:10 -0700
Subject: [PATCH 07/24] Threading: Only call pthread_setname_np() if we have it

---
 llvm/lib/Support/Unix/Threading.inc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index 667d023fc134..8162c60b2cdd 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -193,11 +193,15 @@
   ::pthread_setname_np(::pthread_self(), "%s",
                        const_cast<char *>(NameStr.data()));
 #elif defined(__APPLE__)
+#if HAVE_PTHREAD_SETNAME_NP
   ::pthread_setname_np(NameStr.data());
+#endif
 #else
+#if HAVE_PTHREAD_SETNAME_NP
   ::pthread_setname_np(::pthread_self(), NameStr.data());
 #endif
 #endif
+#endif
 }
 
 void llvm::get_thread_name(SmallVectorImpl<char> &Name) {
