Skip to content

release/19.x: Fix libFuzzer not building with pthreads on Windows (#109525) #110663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Oct 1, 2024

Backport b4130be

Requested by: @mstorsjo

@llvmbot llvmbot added this to the LLVM 19.X Release milestone Oct 1, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Oct 1, 2024

@mstorsjo What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented Oct 1, 2024

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

Author: None (llvmbot)

Changes

Backport b4130be

Requested by: @mstorsjo


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

1 Files Affected:

  • (modified) compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp (+5)
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index db80eb383885e6..73eea07cf869ff 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 =
@@ -253,6 +257,7 @@ void SetThreadName(std::thread &thread, const std::string &name) {
       }
     }
   }
+#endif
 }
 
 } // namespace fuzzer

@mstorsjo
Copy link
Member

mstorsjo commented Oct 1, 2024

@mstorsjo What do you think about merging this PR to the release branch?

LGTM, the commit has been in main for a couple of weeks, and my nightly builds run fine with it.

@tru tru merged commit bfa99eb into llvm:release/19.x Oct 11, 2024
4 of 6 checks passed
Copy link

@mstorsjo (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

4 participants