From 2d41b061729e3c7e7c8af3cf1ba89ba9170e4c50 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 31 Jul 2023 18:51:26 +0000 Subject: [PATCH 1/2] [Support] Include Support/thread.h before api implementations This header was included after the implementations to work around an issue with FreeBSD, however, this causes some issues when dllexport\explicit visibility attributes will be added to the headers on Windows, since the definitions need to see the declarations for the attributes to apply. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on windows. --- llvm/lib/Support/Unix/Threading.inc | 8 ++++++++ llvm/lib/Support/Windows/Threading.inc | 1 + 2 files changed, 9 insertions(+) diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc index a354984cabb1e..ca855eb1160c7 100644 --- a/llvm/lib/Support/Unix/Threading.inc +++ b/llvm/lib/Support/Unix/Threading.inc @@ -33,6 +33,14 @@ #include // For pthread_getthreadid_np() / pthread_set_name_np() #endif + +// Must be included after Threading.inc to provide definition for llvm::thread +// because FreeBSD's condvar.h (included by user.h) misuses the "thread" +// keyword. +#ifndef __FreeBSD__ +#include "llvm/Support/thread.h" +#endif + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include #include diff --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc index 4baf8b8cb82ae..d862dbd7f71c9 100644 --- a/llvm/lib/Support/Windows/Threading.inc +++ b/llvm/lib/Support/Windows/Threading.inc @@ -12,6 +12,7 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/thread.h" #include "llvm/Support/Windows/WindowsSupport.h" #include From 0fd042ac4dfbcf0cad26dbf52081a86d7b4f98ca Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Sat, 5 Oct 2024 08:11:08 +0100 Subject: [PATCH 2/2] Fix formatting --- llvm/lib/Support/Unix/Threading.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc index ca855eb1160c7..c7b4c7af3b9f3 100644 --- a/llvm/lib/Support/Unix/Threading.inc +++ b/llvm/lib/Support/Unix/Threading.inc @@ -33,7 +33,6 @@ #include // For pthread_getthreadid_np() / pthread_set_name_np() #endif - // Must be included after Threading.inc to provide definition for llvm::thread // because FreeBSD's condvar.h (included by user.h) misuses the "thread" // keyword.