Skip to content

Commit 277fc81

Browse files
vargazJo Shields
authored andcommitted
Ifdef out more code with LLVM_ENABLE_THREADS, mxe doesn't include definitions of std::mutex etc.
1 parent 299a099 commit 277fc81

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

llvm/include/llvm/Support/ThreadPool.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ThreadPool {
4848
/// Blocking destructor: the pool will wait for all the threads to complete.
4949
~ThreadPool();
5050

51+
#if LLVM_ENABLE_THREADS
5152
/// Asynchronous submission of a task to the pool. The returned future can be
5253
/// used to wait for the task to finish and is *non-blocking* on destruction.
5354
template <typename Function, typename... Args>
@@ -63,6 +64,15 @@ class ThreadPool {
6364
inline std::shared_future<void> async(Function &&F) {
6465
return asyncImpl(std::forward<Function>(F));
6566
}
67+
#else
68+
template <typename Function, typename... Args>
69+
inline void async(Function &&F, Args &&... ArgList) {
70+
}
71+
72+
template <typename Function>
73+
inline void async(Function &&F) {
74+
}
75+
#endif
6676

6777
/// Blocking wait for all the threads to complete and the queue to be empty.
6878
/// It is an error to try to add new tasks while blocking on this call.
@@ -79,13 +89,15 @@ class ThreadPool {
7989
/// Tasks waiting for execution in the pool.
8090
std::queue<PackagedTaskTy> Tasks;
8191

92+
#if LLVM_ENABLE_THREADS
8293
/// Locking and signaling for accessing the Tasks queue.
8394
std::mutex QueueLock;
8495
std::condition_variable QueueCondition;
8596

8697
/// Locking and signaling for job completion
8798
std::mutex CompletionLock;
8899
std::condition_variable CompletionCondition;
100+
#endif
89101

90102
/// Keep track of the number of thread actually busy
91103
std::atomic<unsigned> ActiveThreads;

llvm/lib/LTO/LTO.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,9 @@ class InProcessThinBackend : public ThinBackendProc {
859859
std::set<GlobalValue::GUID> CfiFunctionDecls;
860860

861861
Optional<Error> Err;
862+
#if LLVM_ENABLE_THREADS
862863
std::mutex ErrMu;
864+
#endif
863865

864866
public:
865867
InProcessThinBackend(
@@ -946,7 +948,9 @@ class InProcessThinBackend : public ThinBackendProc {
946948
AddStream, Cache, Task, BM, CombinedIndex, ImportList, ExportList,
947949
ResolvedODR, DefinedGlobals, ModuleMap, TypeIdSummariesByGuid);
948950
if (E) {
951+
#if LLVM_ENABLE_THREADS
949952
std::unique_lock<std::mutex> L(ErrMu);
953+
#endif
950954
if (Err)
951955
Err = joinErrors(std::move(*Err), std::move(E));
952956
else

llvm/lib/Support/ThreadPool.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
//
1212
//===----------------------------------------------------------------------===//
1313

14-
#include "llvm/Support/ThreadPool.h"
15-
1614
#include "llvm/Config/llvm-config.h"
1715
#include "llvm/Support/Threading.h"
1816
#include "llvm/Support/raw_ostream.h"
@@ -21,6 +19,8 @@ using namespace llvm;
2119

2220
#if LLVM_ENABLE_THREADS
2321

22+
#include "llvm/Support/ThreadPool.h"
23+
2424
// Default to hardware_concurrency
2525
ThreadPool::ThreadPool() : ThreadPool(hardware_concurrency()) {}
2626

@@ -109,6 +109,8 @@ ThreadPool::~ThreadPool() {
109109

110110
#else // LLVM_ENABLE_THREADS Disabled
111111

112+
#if 0
113+
112114
ThreadPool::ThreadPool() : ThreadPool(0) {}
113115

114116
// No threads are launched, issue a warning if ThreadCount is not 0
@@ -144,3 +146,5 @@ ThreadPool::~ThreadPool() {
144146
}
145147

146148
#endif
149+
150+
#endif

0 commit comments

Comments
 (0)