@@ -290,16 +290,13 @@ static void saveThinArchiveToRepro(ArchiveFile const *file) {
290
290
}
291
291
292
292
struct DeferredFile {
293
- #if LLVM_ENABLE_THREADS
294
293
StringRef path;
295
294
bool isLazy;
296
295
MemoryBufferRef buffer;
297
- #endif
298
296
};
299
297
using DeferredFiles = std::vector<DeferredFile>;
300
298
301
- #if LLVM_ENABLE_THREADS
302
- class SerialBackgroundQueue {
299
+ class SerialBackgroundWorkQueue {
303
300
std::deque<std::function<void ()>> queue;
304
301
std::thread *running;
305
302
std::mutex mutex;
@@ -339,7 +336,7 @@ class SerialBackgroundQueue {
339
336
}
340
337
};
341
338
342
- static SerialBackgroundQueue pageInQueue;
339
+ static SerialBackgroundWorkQueue pageInQueue;
343
340
344
341
// Most input files have been mapped but not yet paged in.
345
342
// This code forces the page-ins on multiple threads so
@@ -376,7 +373,7 @@ void multiThreadedPageInBackground(DeferredFiles &deferred) {
376
373
#endif
377
374
};
378
375
379
- { // Create scope for waiting for the taskGroup
376
+ if ( llvm_is_multithreaded ()) { // Create scope for waiting for the taskGroup
380
377
std::atomic_size_t index = 0 ;
381
378
llvm::parallel::TaskGroup taskGroup;
382
379
for (int w = 0 ; w < config->readWorkers ; w++)
@@ -403,7 +400,6 @@ static void multiThreadedPageIn(const DeferredFiles &deferred) {
403
400
multiThreadedPageInBackground (files);
404
401
});
405
402
}
406
- #endif
407
403
408
404
static InputFile *processFile (std::optional<MemoryBufferRef> buffer,
409
405
DeferredFiles *archiveContents, StringRef path,
@@ -503,10 +499,8 @@ static InputFile *processFile(std::optional<MemoryBufferRef> buffer,
503
499
continue ;
504
500
}
505
501
506
- #if LLVM_ENABLE_THREADS
507
- if (archiveContents)
502
+ if (config->readWorkers && archiveContents)
508
503
archiveContents->push_back ({path, isLazy, *mb});
509
- #endif
510
504
if (!hasObjCSection (*mb))
511
505
continue ;
512
506
if (Error e = file->fetch (c, " -ObjC" ))
@@ -582,11 +576,9 @@ static void deferFile(StringRef path, bool isLazy, DeferredFiles &deferred) {
582
576
std::optional<MemoryBufferRef> buffer = readFile (path);
583
577
if (!buffer)
584
578
return ;
585
- #if LLVM_ENABLE_THREADS
586
579
if (config->readWorkers )
587
580
deferred.push_back ({path, isLazy, *buffer});
588
581
else
589
- #endif
590
582
processFile (buffer, nullptr , path, LoadType::CommandLine, isLazy);
591
583
}
592
584
@@ -1448,7 +1440,6 @@ static void createFiles(const InputArgList &args) {
1448
1440
}
1449
1441
}
1450
1442
1451
- #if LLVM_ENABLE_THREADS
1452
1443
if (config->readWorkers ) {
1453
1444
multiThreadedPageIn (deferredFiles);
1454
1445
@@ -1468,7 +1459,6 @@ static void createFiles(const InputArgList &args) {
1468
1459
1469
1460
pageInQueue.stopAllWork = true ;
1470
1461
}
1471
- #endif
1472
1462
}
1473
1463
1474
1464
static void gatherInputSections () {
@@ -1856,17 +1846,16 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
1856
1846
}
1857
1847
1858
1848
if (auto *arg = args.getLastArg (OPT_read_workers)) {
1859
- #if LLVM_ENABLE_THREADS
1860
- StringRef v (arg->getValue ());
1861
- unsigned workers = 0 ;
1862
- if (!llvm::to_integer (v, workers, 0 ))
1863
- error (arg->getSpelling () +
1864
- " : expected a non-negative integer, but got '" + arg->getValue () +
1865
- " '" );
1866
- config->readWorkers = workers;
1867
- #else
1868
- error (arg->getSpelling () + " : option unavailable" );
1869
- #endif
1849
+ if (llvm_is_multithreaded ()) {
1850
+ StringRef v (arg->getValue ());
1851
+ unsigned workers = 0 ;
1852
+ if (!llvm::to_integer (v, workers, 0 ))
1853
+ error (arg->getSpelling () +
1854
+ " : expected a non-negative integer, but got '" + arg->getValue () +
1855
+ " '" );
1856
+ config->readWorkers = workers;
1857
+ } else
1858
+ error (arg->getSpelling () + " : option unavailable" );
1870
1859
}
1871
1860
if (auto *arg = args.getLastArg (OPT_threads_eq)) {
1872
1861
StringRef v (arg->getValue ());
0 commit comments