[compiler-rt] Fix libFuzzer not building with pthreads on Windows (PR #109525)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 02:14:42 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: None (Zentrik)

<details>
<summary>Changes</summary>

Fixes https://github.com/llvm/llvm-project/issues/106871

---
Full diff: https://github.com/llvm/llvm-project/pull/109525.diff


1 Files Affected:

- (modified) compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp (+4) 


``````````diff
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index e0210aa0ac3651..ca0a2a9f958caa 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -239,6 +239,9 @@ size_t PageSize() {
 }
 
 void SetThreadName(std::thread &thread, const std::string &name) {
+#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) || defined(_GLIBCXX_GCC_GTHR_POSIX_H)
+  (void)pthread_setname_np(thread.native_handle(), name.c_str());
+#else
   typedef HRESULT(WINAPI * proc)(HANDLE, PCWSTR);
   HMODULE kbase = GetModuleHandleA("KernelBase.dll");
   proc ThreadNameProc = reinterpret_cast<proc>(
@@ -253,6 +256,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
       }
     }
   }
+#endif
 }
 
 } // namespace fuzzer

``````````

</details>


https://github.com/llvm/llvm-project/pull/109525


More information about the llvm-commits mailing list