From 40c1c5e52d123eba4d539057b0f6fac4dd985288 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Sat, 21 Sep 2024 10:10:29 +0100 Subject: [PATCH 1/2] Fix libFuzzer not building with pthreads on Windows Fixes https://github.com/llvm/llvm-project/issues/106871 --- compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp index db80eb383885e..dfa5a8450e57d 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 = @@ -253,6 +256,7 @@ void SetThreadName(std::thread &thread, const std::string &name) { } } } +#endif } } // namespace fuzzer From a937e949d34bfada17fdb7a402de8a2b5e835138 Mon Sep 17 00:00:00 2001 From: Zentrik Date: Sat, 21 Sep 2024 10:22:12 +0100 Subject: [PATCH 2/2] Format --- compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp index dfa5a8450e57d..73eea07cf869f 100644 --- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp +++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp @@ -239,7 +239,8 @@ 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) +#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);