[llvm] 9093ba9 - [Support] Include Support/thread.h before api implementations (#111175)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 21:45:32 PDT 2024


Author: Thomas Fransham
Date: 2024-10-10T07:45:29+03:00
New Revision: 9093ba9f7ee58ccf62e58487a5028707a248c0b7

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

LOG: [Support] Include Support/thread.h before api implementations (#111175)

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.

---------

Co-authored-by: Tom Stellard <tstellar at redhat.com>

Added: 
    

Modified: 
    llvm/lib/Support/Unix/Threading.inc
    llvm/lib/Support/Windows/Threading.inc

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc
index a354984cabb1ef..c7b4c7af3b9f33 100644
--- a/llvm/lib/Support/Unix/Threading.inc
+++ b/llvm/lib/Support/Unix/Threading.inc
@@ -33,6 +33,13 @@
 #include <pthread_np.h> // 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 <errno.h>
 #include <sys/cpuset.h>

diff  --git a/llvm/lib/Support/Windows/Threading.inc b/llvm/lib/Support/Windows/Threading.inc
index 4baf8b8cb82aed..d862dbd7f71c9d 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 <process.h>


        


More information about the llvm-commits mailing list