diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -503,6 +503,9 @@ if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") append("-Wa,-mbig-obj" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) endif() +elseif(SERENITYOS) + # SerenityOS sets a very low default stack size value, so increase it to 4MB manually. + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=4194304") endif() option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON) diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h @@ -28,7 +28,8 @@ #endif #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \ - defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__OpenBSD__) + defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__OpenBSD__) || \ + defined(__serenity__) #include #elif defined(_AIX) #include diff --git a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp --- a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp +++ b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp @@ -215,7 +215,8 @@ void SharedMemoryMapper::reserve(size_t NumBytes, OnReservedFunction OnReserved) { -#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32) +#if (defined(LLVM_ON_UNIX) && !(defined(__ANDROID__) || defined(__serenity__))) \ + || defined(_WIN32) EPC.callSPSWrapperAsync< rt::SPSExecutorSharedMemoryMapperServiceReserveSignature>( diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/ExecutorSharedMemoryMapperService.cpp @@ -47,7 +47,8 @@ Expected> ExecutorSharedMemoryMapperService::reserve(uint64_t Size) { -#if (defined(LLVM_ON_UNIX) && !defined(__ANDROID__)) || defined(_WIN32) +#if (defined(LLVM_ON_UNIX) && !(defined(__ANDROID__) || defined(__serenity__))) \ + || defined(_WIN32) #if defined(LLVM_ON_UNIX) diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -112,7 +112,7 @@ #endif #if defined(__NetBSD__) || defined(__DragonFly__) || defined(__GNU__) || \ - defined(__MVS__) + defined(__MVS__) || defined(__serenity__) #define STATVFS_F_FLAG(vfs) (vfs).f_flag #else #define STATVFS_F_FLAG(vfs) (vfs).f_flags @@ -511,6 +511,9 @@ #elif defined(__HAIKU__) // Haiku doesn't expose this information. return false; +#elif defined(__serenity__) + // Serenity doesn't yet support remote filesystem mounts. + return false; #elif defined(__sun) // statvfs::f_basetype contains a null-terminated FSType name of the mounted // target diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -342,7 +342,7 @@ #if defined(_AIX) static pid_t(wait4)(pid_t pid, int *status, int options, struct rusage *usage); -#elif !defined(__Fuchsia__) +#elif !defined(__Fuchsia__) && !defined(__serenity__) using ::wait4; #endif @@ -383,6 +383,13 @@ } #endif +#ifdef __serenity__ +pid_t (llvm::sys::wait4)(pid_t pid, int *status, int options, + struct rusage*) { + return ::waitpid(pid, status, options); +} +#endif + ProcessInfo llvm::sys::Wait(const ProcessInfo &PI, std::optional SecondsToWait, std::string *ErrMsg,