This repository has no description
1diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
2index cb6ebda183..fbbd3a87e6 100644
3--- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
4+++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
5@@ -21,6 +21,7 @@
6 check_function_exists(execle HAVE_EXECLE)
7 check_function_exists(posix_spawn HAVE_POSIX_SPAWN)
8 check_function_exists(posix_spawnp HAVE_POSIX_SPAWNP)
9+check_function_exists(fork HAVE_FORK)
10
11 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
12 include_directories(${CMAKE_CURRENT_BINARY_DIR})
13diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
14index 5ca580fbb5..4a299ef90e 100644
15--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
16+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
17@@ -212,7 +212,7 @@
18 elseif(FUCHSIA OR UNIX)
19 set(LLVM_ON_WIN32 0)
20 set(LLVM_ON_UNIX 1)
21- if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
22+ if(APPLE OR WASM OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
23 set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
24 else()
25 set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
26diff --git a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
27index bba3329e8c..591cce29cc 100644
28--- a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
29+++ b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
30@@ -9,20 +9,32 @@
31 #include "llvm/ExecutionEngine/Orc/MemoryMapper.h"
32
33 #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
34+#include "llvm/Config/config.h"
35 #include "llvm/Support/WindowsError.h"
36
37 #include <algorithm>
38
39 #if defined(LLVM_ON_UNIX) && !defined(__ANDROID__)
40 #include <fcntl.h>
41+#if defined(HAVE_SYS_MMAN_H)
42 #include <sys/mman.h>
43+#endif
44 #if defined(__MVS__)
45 #include "llvm/Support/BLAKE3.h"
46 #include <sys/shm.h>
47 #endif
48 #include <unistd.h>
49+#if defined(HAVE_SYS_MMAN_H) && defined(MAP_SHARED) && defined(PROT_READ) && \
50+ defined(PROT_WRITE) && defined(PROT_EXEC)
51+#define LLVM_SUPPORTS_POSIX_MMAP 1
52+#else
53+#define LLVM_SUPPORTS_POSIX_MMAP 0
54+#endif
55 #elif defined(_WIN32)
56 #include <windows.h>
57+#define LLVM_SUPPORTS_POSIX_MMAP 0
58+#else
59+#define LLVM_SUPPORTS_POSIX_MMAP 0
60 #endif
61
62 namespace llvm {
63@@ -195,16 +207,21 @@
64 // SharedMemoryMapper
65
66 SharedMemoryMapper::SharedMemoryMapper(ExecutorProcessControl &EPC,
67- SymbolAddrs SAs, size_t PageSize)
68+ SymbolAddrs SAs, size_t PageSize)
69 : EPC(EPC), SAs(SAs), PageSize(PageSize) {
70-#if (!defined(LLVM_ON_UNIX) || defined(__ANDROID__)) && !defined(_WIN32)
71+#if !defined(_WIN32) && \
72+ !(defined(LLVM_ON_UNIX) && !defined(__ANDROID__) && \
73+ (defined(__MVS__) || LLVM_SUPPORTS_POSIX_MMAP))
74 llvm_unreachable("SharedMemoryMapper is not supported on this platform yet");
75 #endif
76 }
77
78+
79 Expected<std::unique_ptr<SharedMemoryMapper>>
80 SharedMemoryMapper::Create(ExecutorProcessControl &EPC, SymbolAddrs SAs) {
81-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
82+#if defined(_WIN32) || \
83+ (defined(LLVM_ON_UNIX) && !defined(__ANDROID__) && \
84+ (defined(__MVS__) || LLVM_SUPPORTS_POSIX_MMAP))
85 auto PageSize = sys::Process::getPageSize();
86 if (!PageSize)
87 return PageSize.takeError();
88@@ -218,10 +235,13 @@
89 }
90
91 void SharedMemoryMapper::reserve(size_t NumBytes,
92- OnReservedFunction OnReserved) {
93-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
94+ OnReservedFunction OnReserved) {
95+#if defined(_WIN32) || \
96+ (defined(LLVM_ON_UNIX) && !defined(__ANDROID__) && \
97+ (defined(__MVS__) || LLVM_SUPPORTS_POSIX_MMAP))
98
99 EPC.callSPSWrapperAsync<
100+
101 rt::SPSExecutorSharedMemoryMapperServiceReserveSignature>(
102 SAs.Reserve,
103 [this, NumBytes, OnReserved = std::move(OnReserved)](
104@@ -260,8 +280,9 @@
105 return OnReserved(errorCodeToError(
106 std::error_code(errno, std::generic_category())));
107 }
108-#else
109- int SharedMemoryFile = shm_open(SharedMemoryName.c_str(), O_RDWR, 0700);
110+#elif LLVM_SUPPORTS_POSIX_MMAP
111+ int SharedMemoryFile =
112+ shm_open(SharedMemoryName.c_str(), O_RDWR, 0700);
113 if (SharedMemoryFile < 0) {
114 return OnReserved(errorCodeToError(errnoAsErrorCode()));
115 }
116@@ -276,8 +297,13 @@
117 }
118
119 close(SharedMemoryFile);
120+#else
121+ return OnReserved(make_error<StringError>(
122+ "SharedMemoryMapper requires POSIX mmap support on this platform",
123+ inconvertibleErrorCode()));
124 #endif
125
126+
127 #elif defined(_WIN32)
128
129 std::wstring WideSharedMemoryName(SharedMemoryName.begin(),
130@@ -306,6 +332,10 @@
131 },
132 SAs.Instance, static_cast<uint64_t>(NumBytes));
133
134+#elif defined(LLVM_ON_UNIX) && !defined(__ANDROID__)
135+ OnReserved(make_error<StringError>(
136+ "SharedMemoryMapper requires POSIX mmap support on this platform",
137+ inconvertibleErrorCode()));
138 #else
139 OnReserved(make_error<StringError>(
140 "SharedMemoryMapper is not supported on this platform yet",
141@@ -385,10 +415,13 @@
142 }
143
144 void SharedMemoryMapper::release(ArrayRef<ExecutorAddr> Bases,
145- OnReleasedFunction OnReleased) {
146-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
147+ OnReleasedFunction OnReleased) {
148+#if defined(_WIN32) || \
149+ (defined(LLVM_ON_UNIX) && !defined(__ANDROID__) && \
150+ (defined(__MVS__) || LLVM_SUPPORTS_POSIX_MMAP))
151 Error Err = Error::success();
152
153+
154 {
155 std::lock_guard<std::mutex> Lock(Mutex);
156
157@@ -399,9 +432,15 @@
158 #if defined(__MVS__)
159 if (shmdt(Reservations[Base].LocalAddr) < 0)
160 Err = joinErrors(std::move(Err), errorCodeToError(errnoAsErrorCode()));
161-#else
162+#elif LLVM_SUPPORTS_POSIX_MMAP
163 if (munmap(Reservations[Base].LocalAddr, Reservations[Base].Size) != 0)
164 Err = joinErrors(std::move(Err), errorCodeToError(errnoAsErrorCode()));
165+#else
166+ Err = joinErrors(
167+ std::move(Err),
168+ make_error<StringError>(
169+ "SharedMemoryMapper requires POSIX mmap support on this platform",
170+ inconvertibleErrorCode()));
171 #endif
172
173 #elif defined(_WIN32)
174@@ -430,6 +469,10 @@
175 return OnReleased(joinErrors(std::move(Err), std::move(Result)));
176 },
177 SAs.Instance, Bases);
178+#elif defined(LLVM_ON_UNIX) && !defined(__ANDROID__)
179+ OnReleased(make_error<StringError>(
180+ "SharedMemoryMapper requires POSIX mmap support on this platform",
181+ inconvertibleErrorCode()));
182 #else
183 OnReleased(make_error<StringError>(
184 "SharedMemoryMapper is not supported on this platform yet",
185@@ -445,8 +488,10 @@
186
187 #if defined(__MVS__)
188 shmdt(R.second.LocalAddr);
189-#else
190+#elif LLVM_SUPPORTS_POSIX_MMAP
191 munmap(R.second.LocalAddr, R.second.Size);
192+#else
193+ (void)R;
194 #endif
195
196 #elif defined(_WIN32)
197diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
198index f5118c0f2b..2695cfbbd8 100644
199--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
200+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp
201@@ -9,6 +9,7 @@
202 #include "llvm/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.h"
203
204 #include "llvm/ExecutionEngine/Orc/Shared/OrcRTBridge.h"
205+#include "llvm/Config/config.h"
206 #include "llvm/Support/Process.h"
207 #include "llvm/Support/WindowsError.h"
208
209@@ -17,12 +18,22 @@
210 #if defined(LLVM_ON_UNIX)
211 #include <errno.h>
212 #include <fcntl.h>
213+#ifdef HAVE_SYS_MMAN_H
214 #include <sys/mman.h>
215+#endif
216 #if defined(__MVS__)
217 #include "llvm/Support/BLAKE3.h"
218 #include <sys/shm.h>
219 #endif
220 #include <unistd.h>
221+#if defined(HAVE_SYS_MMAN_H) && defined(MAP_SHARED) && defined(PROT_NONE) && \
222+ defined(PROT_READ) && defined(PROT_WRITE) && defined(PROT_EXEC)
223+#define LLVM_SUPPORTS_POSIX_MMAP 1
224+#else
225+#define LLVM_SUPPORTS_POSIX_MMAP 0
226+#endif
227+#else
228+#define LLVM_SUPPORTS_POSIX_MMAP 0
229 #endif
230
231 namespace llvm {
232@@ -51,7 +62,8 @@
233
234 Expected<std::pair<ExecutorAddr, std::string>>
235 ExecutorSharedMemoryMapperService::reserve(uint64_t Size) {
236-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
237+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__) && LLVM_SUPPORTS_POSIX_MMAP) || \
238+ defined(_WIN32)
239
240 #if defined(LLVM_ON_UNIX)
241
242@@ -131,6 +143,10 @@
243
244 return std::make_pair(ExecutorAddr::fromPtr(Addr),
245 std::move(SharedMemoryName));
246+#elif defined(LLVM_ON_UNIX) && !defined(__ANDROID__)
247+ return make_error<StringError>(
248+ "SharedMemoryMapper requires POSIX mmap support on this platform",
249+ inconvertibleErrorCode());
250 #else
251 return make_error<StringError>(
252 "SharedMemoryMapper is not supported on this platform yet",
253@@ -140,7 +156,8 @@
254
255 Expected<ExecutorAddr> ExecutorSharedMemoryMapperService::initialize(
256 ExecutorAddr Reservation, tpctypes::SharedMemoryFinalizeRequest &FR) {
257-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
258+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__) && LLVM_SUPPORTS_POSIX_MMAP) || \
259+ defined(_WIN32)
260
261 ExecutorAddr MinAddr(~0ULL);
262
263@@ -196,6 +213,10 @@
264
265 return MinAddr;
266
267+#elif defined(LLVM_ON_UNIX) && !defined(__ANDROID__)
268+ return make_error<StringError>(
269+ "SharedMemoryMapper requires POSIX mmap support on this platform",
270+ inconvertibleErrorCode());
271 #else
272 return make_error<StringError>(
273 "SharedMemoryMapper is not supported on this platform yet",
274@@ -234,7 +255,8 @@
275
276 Error ExecutorSharedMemoryMapperService::release(
277 const std::vector<ExecutorAddr> &Bases) {
278-#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32)
279+#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__) && LLVM_SUPPORTS_POSIX_MMAP) || \
280+ defined(_WIN32)
281 Error Err = Error::success();
282
283 for (auto Base : Bases) {
284@@ -289,6 +311,10 @@
285 }
286
287 return Err;
288+#elif defined(LLVM_ON_UNIX) && !defined(__ANDROID__)
289+ return make_error<StringError>(
290+ "SharedMemoryMapper requires POSIX mmap support on this platform",
291+ inconvertibleErrorCode());
292 #else
293 return make_error<StringError>(
294 "SharedMemoryMapper is not supported on this platform yet",
295diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp
296index f7852b0ca6..d6bea8c977 100644
297--- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp
298+++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderPerf.cpp
299@@ -14,6 +14,7 @@
300
301 #include "llvm/ExecutionEngine/Orc/Shared/PerfSharedStructs.h"
302
303+#include "llvm/Config/config.h"
304 #include "llvm/Support/FileSystem.h"
305 #include "llvm/Support/MemoryBuffer.h"
306 #include "llvm/Support/Path.h"
307@@ -23,12 +24,25 @@
308 #include <mutex>
309 #include <optional>
310
311-#ifdef __linux__
312+#if defined(__linux__)
313
314+#ifdef HAVE_SYS_MMAN_H
315 #include <sys/mman.h> // mmap()
316+#endif
317 #include <time.h> // clock_gettime(), time(), localtime_r() */
318 #include <unistd.h> // for read(), close()
319
320+#if defined(HAVE_SYS_MMAN_H) && defined(MAP_PRIVATE) && defined(PROT_READ) && \
321+ defined(PROT_WRITE) && defined(PROT_EXEC) && defined(PROT_NONE)
322+#define LLVM_SUPPORTS_POSIX_MMAP 1
323+#else
324+#define LLVM_SUPPORTS_POSIX_MMAP 0
325+#endif
326+
327+#endif
328+
329+#if defined(__linux__) && LLVM_SUPPORTS_POSIX_MMAP
330+
331 #define DEBUG_TYPE "orc"
332
333 // language identifier (XXX: should we generate something better from debug
334@@ -420,6 +434,42 @@
335 .release();
336 }
337
338+#elif defined(__linux__)
339+
340+using namespace llvm;
341+using namespace llvm::orc;
342+
343+static Error missingMMap() {
344+ using namespace llvm;
345+ return llvm::make_error<StringError>(
346+ "perf JIT support requires POSIX mmap on this platform",
347+ inconvertibleErrorCode());
348+}
349+
350+static Error missingMMapBatch(PerfJITRecordBatch &Batch) {
351+ return missingMMap();
352+}
353+
354+extern "C" llvm::orc::shared::CWrapperFunctionResult
355+llvm_orc_registerJITLoaderPerfImpl(const char *Data, uint64_t Size) {
356+ using namespace shared;
357+ return WrapperFunction<SPSError(SPSPerfJITRecordBatch)>::handle(
358+ Data, Size, missingMMapBatch)
359+ .release();
360+}
361+
362+extern "C" llvm::orc::shared::CWrapperFunctionResult
363+llvm_orc_registerJITLoaderPerfStart(const char *Data, uint64_t Size) {
364+ using namespace shared;
365+ return WrapperFunction<SPSError()>::handle(Data, Size, missingMMap).release();
366+}
367+
368+extern "C" llvm::orc::shared::CWrapperFunctionResult
369+llvm_orc_registerJITLoaderPerfEnd(const char *Data, uint64_t Size) {
370+ using namespace shared;
371+ return WrapperFunction<SPSError()>::handle(Data, Size, missingMMap).release();
372+}
373+
374 #else
375
376 using namespace llvm;
377diff --git a/llvm/lib/Support/Unix/Memory.inc b/llvm/lib/Support/Unix/Memory.inc
378index bac208a7d5..571e777009 100644
379--- a/llvm/lib/Support/Unix/Memory.inc
380+++ b/llvm/lib/Support/Unix/Memory.inc
381@@ -18,10 +18,19 @@
382 #include "llvm/Support/Process.h"
383 #include "llvm/Support/Valgrind.h"
384
385+#include <system_error>
386+
387 #ifdef HAVE_SYS_MMAN_H
388 #include <sys/mman.h>
389 #endif
390
391+#if defined(HAVE_SYS_MMAN_H) && defined(MAP_PRIVATE) && defined(PROT_READ) && \
392+ defined(PROT_WRITE) && defined(PROT_EXEC) && defined(PROT_NONE)
393+#define LLVM_SUPPORTS_POSIX_MMAP 1
394+#else
395+#define LLVM_SUPPORTS_POSIX_MMAP 0
396+#endif
397+
398 #ifdef __APPLE__
399 #include <mach/mach.h>
400 #endif
401@@ -36,6 +45,7 @@
402 extern "C" void __clear_cache(void *, void *);
403 #endif
404
405+#if LLVM_SUPPORTS_POSIX_MMAP
406 static int getPosixProtectionFlags(unsigned Flags) {
407 switch (Flags & llvm::sys::Memory::MF_RWE_MASK) {
408 case llvm::sys::Memory::MF_READ:
409@@ -66,6 +76,7 @@
410 // Provide a default return value as required by some compilers.
411 return PROT_NONE;
412 }
413+#endif
414
415 namespace llvm {
416 namespace sys {
417@@ -77,6 +88,11 @@
418 if (NumBytes == 0)
419 return MemoryBlock();
420
421+#if !LLVM_SUPPORTS_POSIX_MMAP
422+ (void)NearBlock;
423+ EC = std::make_error_code(std::errc::function_not_supported);
424+ return MemoryBlock();
425+#else
426 // On platforms that have it, we can use MAP_ANON to get a memory-mapped
427 // page without file backing, but we need a fallback of opening /dev/zero
428 // for strictly POSIX platforms instead.
429@@ -146,12 +162,16 @@
430 }
431
432 return Result;
433+#endif
434 }
435
436 std::error_code Memory::releaseMappedMemory(MemoryBlock &M) {
437 if (M.Address == nullptr || M.AllocatedSize == 0)
438 return std::error_code();
439
440+#if !LLVM_SUPPORTS_POSIX_MMAP
441+ return std::make_error_code(std::errc::function_not_supported);
442+#else
443 if (0 != ::munmap(M.Address, M.AllocatedSize))
444 return errnoAsErrorCode();
445
446@@ -159,6 +179,7 @@
447 M.AllocatedSize = 0;
448
449 return std::error_code();
450+#endif
451 }
452
453 std::error_code Memory::protectMappedMemory(const MemoryBlock &M,
454@@ -167,6 +188,10 @@
455 if (M.Address == nullptr || M.AllocatedSize == 0)
456 return std::error_code();
457
458+#if !LLVM_SUPPORTS_POSIX_MMAP
459+ (void)Flags;
460+ return std::make_error_code(std::errc::function_not_supported);
461+#else
462 if (!Flags)
463 return std::error_code(EINVAL, std::generic_category());
464
465@@ -202,6 +227,7 @@
466 Memory::InvalidateInstructionCache(M.Address, M.AllocatedSize);
467
468 return std::error_code();
469+#endif
470 }
471
472 /// InvalidateInstructionCache - Before the JIT can run a block of code
473diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
474index cf05db546e..4a806086a3 100644
475--- a/llvm/lib/Support/Unix/Path.inc
476+++ b/llvm/lib/Support/Unix/Path.inc
477@@ -831,6 +831,13 @@
478 mapmode Mode) {
479 assert(Size != 0);
480
481+#if !defined(MAP_SHARED) || !defined(MAP_PRIVATE) || !defined(PROT_READ) || \
482+ !defined(PROT_WRITE)
483+ (void)FD;
484+ (void)Offset;
485+ (void)Mode;
486+ return make_error_code(errc::function_not_supported);
487+#else
488 int flags = (Mode == readwrite) ? MAP_SHARED : MAP_PRIVATE;
489 int prot = (Mode == readonly) ? PROT_READ : (PROT_READ | PROT_WRITE);
490 #if defined(MAP_NORESERVE)
491@@ -860,6 +867,7 @@
492 if (Mapping == MAP_FAILED)
493 return errnoAsErrorCode();
494 return std::error_code();
495+#endif
496 }
497
498 mapped_file_region::mapped_file_region(int fd, mapmode mode, size_t length,
499@@ -872,14 +880,24 @@
500 }
501
502 void mapped_file_region::unmapImpl() {
503+#if !defined(MAP_SHARED) || !defined(MAP_PRIVATE) || !defined(PROT_READ) || \
504+ !defined(PROT_WRITE)
505+ (void)Mapping;
506+ (void)Size;
507+#else
508 if (Mapping)
509 ::munmap(Mapping, Size);
510+#endif
511 }
512
513 void mapped_file_region::dontNeedImpl() {
514 assert(Mode == mapped_file_region::readonly);
515 if (!Mapping)
516 return;
517+#if !defined(POSIX_MADV_DONTNEED) && !defined(MADV_DONTNEED)
518+ (void)Size;
519+ return;
520+#else
521 #if defined(__MVS__) || defined(_AIX)
522 // If we don't have madvise, or it isn't beneficial, treat this as a no-op.
523 #elif defined(POSIX_MADV_DONTNEED)
524@@ -887,6 +905,7 @@
525 #else
526 ::madvise(Mapping, Size, MADV_DONTNEED);
527 #endif
528+#endif
529 }
530
531 int mapped_file_region::alignment() { return Process::getPageSizeEstimate(); }
532diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc
533index 2742734bb1..3ea4758130 100644
534--- a/llvm/lib/Support/Unix/Program.inc
535+++ b/llvm/lib/Support/Unix/Program.inc
536@@ -274,6 +274,17 @@
537 }
538 #endif // HAVE_POSIX_SPAWN
539
540+#if !defined(HAVE_FORK)
541+ (void)Args;
542+ (void)Redirects;
543+ (void)MemoryLimit;
544+ (void)PI;
545+ (void)Env;
546+ (void)DetachProcess;
547+ if (ErrMsg)
548+ *ErrMsg = "fork is not available on this target";
549+ return false;
550+#else
551 // Create a child process.
552 int child = fork();
553 switch (child) {
554@@ -347,6 +358,7 @@
555 PI.Process = child;
556
557 return true;
558+#endif
559 }
560
561 namespace llvm {
562diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
563index 25f43a4bb6..d6ad7f5229 100644
564--- a/llvm/tools/lli/lli.cpp
565+++ b/llvm/tools/lli/lli.cpp
566@@ -1206,7 +1206,7 @@
567 }
568
569 Expected<std::unique_ptr<orc::ExecutorProcessControl>> launchRemote() {
570-#ifndef LLVM_ON_UNIX
571+#if !defined(LLVM_ON_UNIX) || defined(__wasm__)
572 llvm_unreachable("launchRemote not supported on non-Unix platforms");
573 #else
574 int PipeFD[2][2];
575diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
576index bff05b9ca4..4bb40e1a8e 100644
577--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
578+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
579@@ -737,7 +737,7 @@
580 }
581
582 static Expected<std::unique_ptr<ExecutorProcessControl>> launchExecutor() {
583-#ifndef LLVM_ON_UNIX
584+#if !defined(LLVM_ON_UNIX) || defined(__wasm__)
585 // FIXME: Add support for Windows.
586 return make_error<StringError>("-" + OutOfProcessExecutor.ArgStr +
587 " not supported on non-unix platforms",