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

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 13:34:00 PDT 2024


Author: Zentrik
Date: 2024-09-24T23:33:57+03:00
New Revision: b4130bee6bfd34d8045f02fc9f951bcb5db9d85c

URL: https://github.com/llvm/llvm-project/commit/b4130bee6bfd34d8045f02fc9f951bcb5db9d85c
DIFF: https://github.com/llvm/llvm-project/commit/b4130bee6bfd34d8045f02fc9f951bcb5db9d85c.diff

LOG: Fix libFuzzer not building with pthreads on Windows (#109525)

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

Added: 
    

Modified: 
    compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index e0210aa0ac3651..37aecae7237ae9 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -239,6 +239,10 @@ 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 +257,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
       }
     }
   }
+#endif
 }
 
 } // namespace fuzzer


        


More information about the llvm-commits mailing list