From a83264396b18d0d7162d856dc5bd4a9bf6eb1deb Mon Sep 17 00:00:00 2001 From: Wildan Mubarok Date: Fri, 10 Oct 2025 23:39:23 +0000 Subject: [PATCH] Port nodejs --- recipes/libs/libuv/recipe.toml | 4 +- recipes/libs/libuv/redox.patch | 123 +++- recipes/wip/dev/lang/nodejs-21/recipe.toml | 49 ++ recipes/wip/dev/lang/nodejs-21/redox.patch | 540 ++++++++++++++++++ .../lang/{nodejs => nodejs-24}/01_redox.patch | 0 .../lang/{nodejs => nodejs-24}/recipe.toml | 25 +- recipes/wip/dev/lang/nodejs-lts/recipe.toml | 5 - recipes/wip/libs/net/c-ares/recipe.toml | 6 + recipes/wip/libs/net/nghttp3/recipe.toml | 6 + recipes/wip/libs/net/ngtcp2/recipe.toml | 14 + recipes/wip/libs/other/simdjson/recipe.toml | 18 +- recipes/wip/libs/other/simdutf/recipe.toml | 9 + 12 files changed, 748 insertions(+), 51 deletions(-) create mode 100644 recipes/wip/dev/lang/nodejs-21/recipe.toml create mode 100644 recipes/wip/dev/lang/nodejs-21/redox.patch rename recipes/wip/dev/lang/{nodejs => nodejs-24}/01_redox.patch (100%) rename recipes/wip/dev/lang/{nodejs => nodejs-24}/recipe.toml (60%) delete mode 100644 recipes/wip/dev/lang/nodejs-lts/recipe.toml create mode 100644 recipes/wip/libs/net/c-ares/recipe.toml create mode 100644 recipes/wip/libs/net/nghttp3/recipe.toml create mode 100644 recipes/wip/libs/net/ngtcp2/recipe.toml create mode 100644 recipes/wip/libs/other/simdutf/recipe.toml diff --git a/recipes/libs/libuv/recipe.toml b/recipes/libs/libuv/recipe.toml index d6b4f9579..23b563c32 100644 --- a/recipes/libs/libuv/recipe.toml +++ b/recipes/libs/libuv/recipe.toml @@ -1,6 +1,6 @@ [source] -tar = "https://dist.libuv.org/dist/v1.45.0/libuv-v1.45.0.tar.gz" -blake3 = "b78eaba37bfa5fea75accc6d70c67358a4d0b6bb2dfb79b9bb17cb5478cdf797" +tar = "https://dist.libuv.org/dist/v1.51.0/libuv-v1.51.0.tar.gz" +blake3 = "e8b5e68bc2d0776ac4ea67df59d694fca58d5cc570c103443a2284e723d01fc2" patches = ["redox.patch"] [build] diff --git a/recipes/libs/libuv/redox.patch b/recipes/libs/libuv/redox.patch index d5405adf2..a99c1c54e 100644 --- a/recipes/libs/libuv/redox.patch +++ b/recipes/libs/libuv/redox.patch @@ -1,12 +1,12 @@ diff -ruwN source/CMakeLists.txt source-new/CMakeLists.txt ---- source/CMakeLists.txt 2023-05-19 18:21:01.000000000 +0700 -+++ source-new/CMakeLists.txt 2025-09-16 14:15:31.813140608 +0700 +--- source/CMakeLists.txt 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/CMakeLists.txt 2025-10-10 11:19:40.329762962 +0700 @@ -1,3 +1,4 @@ +set (CMAKE_CXX_STANDARD 99) - cmake_minimum_required(VERSION 3.4) + cmake_minimum_required(VERSION 3.10) if(POLICY CMP0091) -@@ -312,6 +313,18 @@ +@@ -323,6 +324,18 @@ src/unix/hurd.c) endif() @@ -26,8 +26,8 @@ diff -ruwN source/CMakeLists.txt source-new/CMakeLists.txt list(APPEND uv_defines _GNU_SOURCE _POSIX_C_SOURCE=200112) list(APPEND uv_libraries dl rt) diff -ruwN source/include/uv/unix.h source-new/include/uv/unix.h ---- source/include/uv/unix.h 2023-05-19 18:21:01.000000000 +0700 -+++ source-new/include/uv/unix.h 2025-09-16 11:42:40.882554686 +0700 +--- source/include/uv/unix.h 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/include/uv/unix.h 2025-10-10 11:18:29.024386515 +0700 @@ -66,6 +66,7 @@ defined(__MSYS__) || \ defined(__HAIKU__) || \ @@ -37,9 +37,9 @@ diff -ruwN source/include/uv/unix.h source-new/include/uv/unix.h # include "uv/posix.h" #endif diff -ruwN source/src/unix/core.c source-new/src/unix/core.c ---- source/src/unix/core.c 2023-05-19 18:21:01.000000000 +0700 -+++ source-new/src/unix/core.c 2025-09-16 11:42:40.882554686 +0700 -@@ -97,6 +97,10 @@ +--- source/src/unix/core.c 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/src/unix/core.c 2025-10-10 11:23:22.143824390 +0700 +@@ -110,6 +110,10 @@ # include #endif @@ -50,7 +50,7 @@ diff -ruwN source/src/unix/core.c source-new/src/unix/core.c static void uv__run_pending(uv_loop_t* loop); /* Verify that uv_buf_t is ABI-compatible with struct iovec. */ -@@ -709,7 +713,8 @@ +@@ -722,7 +726,8 @@ defined(__FreeBSD__) || \ defined(__NetBSD__) || \ defined(__OpenBSD__) || \ @@ -60,10 +60,39 @@ diff -ruwN source/src/unix/core.c source-new/src/unix/core.c ssize_t rc; rc = recvmsg(fd, msg, flags | MSG_CMSG_CLOEXEC); if (rc == -1) +@@ -1644,6 +1649,11 @@ + * So the output parameter priority is actually the nice value. + */ + int uv_thread_getpriority(uv_thread_t tid, int* priority) { ++#ifdef __redox__ ++ if (priority == NULL) ++ return UV_EINVAL; ++ *priority = 0; ++#else + int r; + int policy; + struct sched_param param; +@@ -1670,6 +1680,7 @@ + #endif + + *priority = param.sched_priority; ++#endif + return 0; + } + +@@ -1695,7 +1706,7 @@ + * If the function fails, the return value is non-zero. + */ + int uv_thread_setpriority(uv_thread_t tid, int priority) { +-#if !defined(__GNU__) ++#if !defined(__GNU__) && !defined(__redox__) + int r; + int min; + int max; diff -ruwN source/src/unix/fs.c source-new/src/unix/fs.c ---- source/src/unix/fs.c 2023-05-19 18:21:01.000000000 +0700 -+++ source-new/src/unix/fs.c 2025-09-16 11:42:40.882554686 +0700 -@@ -87,7 +87,8 @@ +--- source/src/unix/fs.c 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/src/unix/fs.c 2025-10-10 11:18:29.024993834 +0700 +@@ -77,7 +77,8 @@ defined(__MVS__) || \ defined(__NetBSD__) || \ defined(__HAIKU__) || \ @@ -73,7 +102,7 @@ diff -ruwN source/src/unix/fs.c source-new/src/unix/fs.c # include #else # include -@@ -648,13 +649,13 @@ +@@ -683,13 +684,13 @@ defined(__MVS__) || \ defined(__NetBSD__) || \ defined(__HAIKU__) || \ @@ -89,7 +118,7 @@ diff -ruwN source/src/unix/fs.c source-new/src/unix/fs.c if (0 != statfs(req->path, &buf)) #endif /* defined(__sun) */ return -1; -@@ -670,7 +671,8 @@ +@@ -705,7 +706,8 @@ defined(__OpenBSD__) || \ defined(__NetBSD__) || \ defined(__HAIKU__) || \ @@ -100,8 +129,8 @@ diff -ruwN source/src/unix/fs.c source-new/src/unix/fs.c #else stat_fs->f_type = buf.f_type; diff -ruwN source/src/unix/proctitle.c source-new/src/unix/proctitle.c ---- source/src/unix/proctitle.c 2023-05-19 18:21:01.000000000 +0700 -+++ source-new/src/unix/proctitle.c 2025-09-16 11:42:40.882554686 +0700 +--- source/src/unix/proctitle.c 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/src/unix/proctitle.c 2025-10-10 11:18:29.025229760 +0700 @@ -30,7 +30,13 @@ size_t cap; /* Maximum capacity. Computed once in uv_setup_args(). */ }; @@ -118,7 +147,7 @@ diff -ruwN source/src/unix/proctitle.c source-new/src/unix/proctitle.c static uv_once_t process_title_mutex_once = UV_ONCE_INIT; diff -ruwN source/src/unix/redox.c source-new/src/unix/redox.c --- source/src/unix/redox.c 1970-01-01 07:00:00.000000000 +0700 -+++ source-new/src/unix/redox.c 2025-09-16 14:28:29.209614311 +0700 ++++ source-new/src/unix/redox.c 2025-10-10 11:18:29.028345924 +0700 @@ -0,0 +1,102 @@ +/* Copyright libuv contributors. All rights reserved. + * @@ -223,8 +252,8 @@ diff -ruwN source/src/unix/redox.c source-new/src/unix/redox.c + int count) { +} diff -ruwN source/src/unix/stream.c source-new/src/unix/stream.c ---- source/src/unix/stream.c 2023-05-19 18:21:01.000000000 +0700 -+++ source-new/src/unix/stream.c 2025-09-16 11:42:40.883554697 +0700 +--- source/src/unix/stream.c 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/src/unix/stream.c 2025-10-10 11:18:29.028522718 +0700 @@ -29,7 +29,14 @@ #include @@ -256,9 +285,59 @@ diff -ruwN source/src/unix/stream.c source-new/src/unix/stream.c union uv__cmsg { struct cmsghdr hdr; +diff -ruwN source/src/unix/tcp.c source-new/src/unix/tcp.c +--- source/src/unix/tcp.c 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/src/unix/tcp.c 2025-10-10 11:26:03.504101758 +0700 +@@ -31,7 +31,7 @@ + #include + + /* ifaddrs is not implemented on AIX and IBM i PASE */ +-#if !defined(_AIX) ++#if !defined(_AIX) && !defined(__redox__) + #include + #endif + +@@ -228,7 +228,7 @@ + static int uv__ipv6_link_local_scope_id(void) { + struct sockaddr_in6* a6; + int rv; +-#if defined(_AIX) ++#if defined(_AIX) || defined(__redox__) + /* AIX & IBM i do not have ifaddrs + * so fallback to use uv_interface_addresses */ + uv_interface_address_t* interfaces; +@@ -268,7 +268,7 @@ + } + + freeifaddrs(ifa); +-#endif /* defined(_AIX) */ ++#endif /* defined(_AIX) || defined(__redox__) */ + + return rv; + } +diff -ruwN source/src/unix/thread.c source-new/src/unix/thread.c +--- source/src/unix/thread.c 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/src/unix/thread.c 2025-10-10 11:25:10.712328011 +0700 +@@ -897,7 +897,7 @@ + abort(); + } + +-#if defined(_AIX) || defined(__MVS__) || defined(__PASE__) ++#if defined(_AIX) || defined(__redox__) || defined(__MVS__) || defined(__PASE__) + int uv__thread_setname(const char* name) { + return UV_ENOSYS; + } +@@ -937,6 +937,7 @@ + + #if (defined(__ANDROID_API__) && __ANDROID_API__ < 26) || \ + defined(_AIX) || \ ++ defined(__redox__) || \ + defined(__MVS__) || \ + defined(__PASE__) + int uv__thread_getname(uv_thread_t* tid, char* name, size_t size) { diff -ruwN source/src/unix/udp.c source-new/src/unix/udp.c ---- source/src/unix/udp.c 2023-05-19 18:21:01.000000000 +0700 -+++ source-new/src/unix/udp.c 2025-09-16 11:42:40.883554697 +0700 +--- source/src/unix/udp.c 2025-04-25 16:50:27.000000000 +0700 ++++ source-new/src/unix/udp.c 2025-10-10 11:18:29.028778883 +0700 @@ -31,6 +31,12 @@ #include #endif diff --git a/recipes/wip/dev/lang/nodejs-21/recipe.toml b/recipes/wip/dev/lang/nodejs-21/recipe.toml new file mode 100644 index 000000000..7b5d1d6d8 --- /dev/null +++ b/recipes/wip/dev/lang/nodejs-21/recipe.toml @@ -0,0 +1,49 @@ +#TODO page fault +[source] +tar = "https://nodejs.org/dist/v21.7.3/node-v21.7.3.tar.xz" +blake3 = "95a56db4f9729b2f8384ab58ccb2ec0c41da05991f7400ef97bd76748d77870b" +patches = ["redox.patch"] + +[build] +template = "custom" +dependencies = [ + "libbrotli", + "c-ares", + "libuv", + "ngtcp2", + "nghttp2", + "nghttp3", + "openssl3", + "sqlite3", + "zlib", + "zstd", +] +script = """ +DYNAMIC_INIT +export PYTHONDONTWRITEBYTECODE=1 +export CC_host="$CC_WRAPPER gcc" CXX_host="$CC_WRAPPER g++" + +rsync -av --delete "${COOKBOOK_SOURCE}/" ./ + +case "${TARGET}" in + x86-unknown-redox) export NODE_CPU=x32;; + x86_64-unknown-redox) export NODE_CPU=x64;; + aarch64-unknown-redox) export NODE_CPU=arm64;; +esac + +COOKBOOK_CONFIGURE_FLAGS=( + --prefix=/usr + --dest-cpu=${NODE_CPU} + --dest-os=redox + --shared-cares + --shared-libuv + --shared-ngtcp2 + --shared-nghttp2 + --shared-nghttp3 + --shared-openssl + --shared-zlib + --cross-compiling +) +COOKBOOK_CONFIGURE="./configure" +cookbook_configure +""" diff --git a/recipes/wip/dev/lang/nodejs-21/redox.patch b/recipes/wip/dev/lang/nodejs-21/redox.patch new file mode 100644 index 000000000..3a665e904 --- /dev/null +++ b/recipes/wip/dev/lang/nodejs-21/redox.patch @@ -0,0 +1,540 @@ +diff -ruwN source/configure.py source-new/configure.py +--- source/configure.py 2024-04-10 19:46:11.000000000 +0700 ++++ source-new/configure.py 2025-10-10 13:46:04.244040340 +0700 +@@ -46,7 +46,7 @@ + parser = argparse.ArgumentParser() + + valid_os = ('win', 'mac', 'solaris', 'freebsd', 'openbsd', 'linux', +- 'android', 'aix', 'cloudabi', 'os400', 'ios') ++ 'android', 'aix', 'cloudabi', 'os400', 'ios', 'redox') + valid_arch = ('arm', 'arm64', 'ia32', 'mips', 'mipsel', 'mips64el', 'ppc', + 'ppc64', 'x64', 'x86', 'x86_64', 's390x', 'riscv64', 'loong64') + valid_arm_float_abi = ('soft', 'softfp', 'hard') +diff -ruwN source/deps/v8/bazel/config/BUILD.bazel source-new/deps/v8/bazel/config/BUILD.bazel +--- source/deps/v8/bazel/config/BUILD.bazel 2024-04-10 19:46:12.000000000 +0700 ++++ source-new/deps/v8/bazel/config/BUILD.bazel 2025-10-10 15:52:40.317126983 +0700 +@@ -144,6 +144,11 @@ + ) + + config_setting( ++ name = "is_redox", ++ constraint_values = ["@platforms//os:redox"], ++) ++ ++config_setting( + name = "is_linux", + constraint_values = ["@platforms//os:linux"], + ) +@@ -204,6 +209,7 @@ + selects.config_setting_group( + name = "is_non_android_posix", + match_any = [ ++ ":is_redox", + ":is_linux", + ":is_macos", + ], +diff -ruwN source/deps/v8/BUILD.bazel source-new/deps/v8/BUILD.bazel +--- source/deps/v8/BUILD.bazel 2024-04-10 19:46:12.000000000 +0700 ++++ source-new/deps/v8/BUILD.bazel 2025-10-10 16:05:33.775461039 +0700 +@@ -758,6 +758,11 @@ + "src/base/debug/stack_trace_posix.cc", + "src/base/platform/platform-darwin.cc", + ], ++ "@v8//bazel/config:is_redox": [ ++ "src/base/debug/stack_trace_posix.cc", ++ "src/base/platform/platform-redox.cc", ++ "src/base/platform/platform-redox.h", ++ ], + "@v8//bazel/config:is_windows": [ + "src/base/debug/stack_trace_win.cc", + "src/base/platform/platform-win32.cc", +diff -ruwN source/deps/v8/BUILD.gn source-new/deps/v8/BUILD.gn +--- source/deps/v8/BUILD.gn 2024-04-10 19:46:12.000000000 +0700 ++++ source-new/deps/v8/BUILD.gn 2025-10-10 21:27:40.939874152 +0700 +@@ -5538,8 +5538,9 @@ + if (v8_enable_webassembly) { + # iOS Xcode simulator builds run on an x64 target. iOS and macOS are both + # based on Darwin and thus POSIX-compliant to a similar degree. +- if (is_linux || is_chromeos || is_mac || is_ios || ++ if (is_linux || is_redox || is_chromeos || is_mac || is_ios || + target_os == "freebsd") { ++ assert(false, "gatchs") + sources += [ + "src/trap-handler/handler-inside-posix.cc", + "src/trap-handler/handler-outside-posix.cc", +@@ -5590,8 +5591,8 @@ + if (v8_enable_webassembly) { + # Trap handling is enabled on arm64 Mac and Linux and in simulators on + # x64 on Linux, Mac, and Windows. +- if ((current_cpu == "arm64" && (is_linux || is_chromeos || is_apple)) || +- (current_cpu == "x64" && (is_linux || is_chromeos || is_mac))) { ++ if ((current_cpu == "arm64" && (is_linux || is_redox || is_chromeos || is_apple)) || ++ (current_cpu == "x64" && (is_linux || is_redox || is_chromeos || is_mac))) { + sources += [ + "src/trap-handler/handler-inside-posix.cc", + "src/trap-handler/handler-outside-posix.cc", +@@ -6174,6 +6175,11 @@ + "src/base/debug/stack_trace_posix.cc", + "src/base/platform/platform-darwin.cc", + ] ++ } else if (is_redox) { ++ sources += [ ++ "src/base/debug/stack_trace_posix.cc", ++ "src/base/platform/platform-redox.cc", ++ ] + } else if (is_ios) { + sources += [ + "src/base/debug/stack_trace_posix.cc", +diff -ruwN source/deps/v8/include/v8config.h source-new/deps/v8/include/v8config.h +--- source/deps/v8/include/v8config.h 2024-04-10 19:46:12.000000000 +0700 ++++ source-new/deps/v8/include/v8config.h 2025-10-10 22:03:04.057821844 +0700 +@@ -159,6 +159,11 @@ + # define V8_OS_QNX 1 + # define V8_OS_STRING "qnx" + ++#elif defined(__redox__) ++# define V8_OS_POSIX 1 ++# define V8_OS_REDOX 1 ++# define V8_OS_STRING "redox" ++ + #elif defined(_WIN32) + # define V8_OS_WIN 1 + # define V8_OS_STRING "windows" +@@ -185,6 +190,7 @@ + && !defined(V8_TARGET_OS_IOS) \ + && !defined(V8_TARGET_OS_LINUX) \ + && !defined(V8_TARGET_OS_MACOS) \ ++ && !defined(V8_TARGET_OS_REDOX) \ + && !defined(V8_TARGET_OS_WIN) \ + && !defined(V8_TARGET_OS_CHROMEOS) + # error No known target OS defined. +@@ -197,6 +203,7 @@ + || defined(V8_TARGET_OS_IOS) \ + || defined(V8_TARGET_OS_LINUX) \ + || defined(V8_TARGET_OS_MACOS) \ ++ || defined(V8_TARGET_OS_REDOX) \ + || defined(V8_TARGET_OS_WIN) \ + || defined(V8_TARGET_OS_CHROMEOS) + # error A target OS is defined but V8_HAVE_TARGET_OS is unset. +@@ -223,6 +230,10 @@ + # define V8_TARGET_OS_MACOS + #endif + ++#ifdef V8_OS_REDOX ++# define V8_TARGET_OS_REDOX ++#endif ++ + #ifdef V8_OS_WIN + # define V8_TARGET_OS_WIN + #endif +@@ -239,6 +250,8 @@ + # define V8_TARGET_OS_STRING "linux" + #elif defined(V8_TARGET_OS_MACOS) + # define V8_TARGET_OS_STRING "macos" ++#elif defined(V8_TARGET_OS_REDOX) ++# define V8_TARGET_OS_STRING "redox" + #elif defined(V8_TARGET_OS_WINDOWS) + # define V8_TARGET_OS_STRING "windows" + #else +diff -ruwN source/deps/v8/src/base/platform/memory.h source-new/deps/v8/src/base/platform/memory.h +--- source/deps/v8/src/base/platform/memory.h 2024-04-10 19:46:12.000000000 +0700 ++++ source-new/deps/v8/src/base/platform/memory.h 2025-10-10 13:46:04.297422792 +0700 +@@ -23,9 +23,9 @@ + #include + #endif // !V8_OS_DARWIN + +-#if (V8_OS_POSIX && !V8_OS_AIX && !V8_OS_SOLARIS) || V8_OS_WIN ++#if (V8_OS_POSIX && !V8_OS_AIX && !V8_OS_SOLARIS && !V8_OS_REDOX) || V8_OS_WIN + #define V8_HAS_MALLOC_USABLE_SIZE 1 +-#endif // (V8_OS_POSIX && !V8_OS_AIX && !V8_OS_SOLARIS) || V8_OS_WIN ++#endif // (V8_OS_POSIX && !V8_OS_AIX && !V8_OS_SOLARIS && !V8_OS_REDOX) || V8_OS_WIN + + namespace v8::base { + +diff -ruwN source/deps/v8/src/base/platform/platform-posix.cc source-new/deps/v8/src/base/platform/platform-posix.cc +--- source/deps/v8/src/base/platform/platform-posix.cc 2024-04-10 19:46:12.000000000 +0700 ++++ source-new/deps/v8/src/base/platform/platform-posix.cc 2025-10-10 13:46:04.416447015 +0700 +@@ -28,6 +28,10 @@ + #include // for sysctl + #endif + ++#if defined(__redox__) ++ #define PTHREAD_STACK_MIN 4096 ++#endif ++ + #if defined(ANDROID) && !defined(V8_ANDROID_LOG_STDOUT) + #define LOG_TAG "v8" + #include +@@ -69,7 +73,7 @@ + #include + #endif + +-#if !defined(_AIX) && !defined(V8_OS_FUCHSIA) ++#if !defined(_AIX) && !defined(V8_OS_FUCHSIA) && !defined(V8_OS_REDOX) + #include + #endif + +@@ -135,7 +139,7 @@ + int flags = MAP_ANONYMOUS; + flags |= (page_type == PageType::kShared) ? MAP_SHARED : MAP_PRIVATE; + if (access == OS::MemoryPermission::kNoAccess) { +-#if !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX ++#if !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX && !V8_OS_REDOX + flags |= MAP_NORESERVE; + #endif // !V8_OS_AIX && !V8_OS_FREEBSD && !V8_OS_QNX + #if V8_OS_QNX +diff -ruwN source/deps/v8/src/base/platform/platform-redox.cc source-new/deps/v8/src/base/platform/platform-redox.cc +--- source/deps/v8/src/base/platform/platform-redox.cc 1970-01-01 07:00:00.000000000 +0700 ++++ source-new/deps/v8/src/base/platform/platform-redox.cc 2025-10-10 15:23:18.233737033 +0700 +@@ -0,0 +1,63 @@ ++// Copyright 2014 the V8 project authors. All rights reserved. ++// Use of this source code is governed by a BSD-style license that can be ++// found in the LICENSE file. ++ ++// Platform specific code for Redox goes here. For the POSIX comaptible parts ++// the implementation is in platform-posix.cc. ++ ++#include ++#include ++#include ++#include ++ ++#include ++ ++#undef MAP_TYPE ++ ++#include "src/base/macros.h" ++#include "src/base/platform/platform-posix-time.h" ++#include "src/base/platform/platform-posix.h" ++#include "src/base/platform/platform.h" ++ ++namespace v8 { ++namespace base { ++ ++ ++int64_t get_gmt_offset(const tm& localtm) { ++ // replacement for tm->tm_gmtoff field in glibc ++ // returns seconds east of UTC, taking DST into account ++ struct timeval tv; ++ struct timezone tz; ++ int ret_code = gettimeofday(&tv, &tz); ++ // 0 = success, -1 = failure ++ DCHECK_NE(ret_code, -1); ++ if (ret_code == -1) { ++ return 0; ++ } ++ return (-tz.tz_minuteswest * 60) + (localtm.tm_isdst > 0 ? 3600 : 0); ++} ++ ++TimezoneCache* OS::CreateTimezoneCache() { ++ return new PosixDefaultTimezoneCache(); ++} ++ ++static unsigned StringToLong(char* buffer) { ++ return static_cast(strtol(buffer, nullptr, 16)); ++} ++ ++std::vector OS::GetSharedLibraryAddresses() { ++ UNREACHABLE(); ++} ++ ++void OS::SignalCodeMovingGC() {} ++ ++void OS::AdjustSchedulingParams() {} ++ ++std::vector OS::GetFreeMemoryRangesWithin( ++ OS::Address boundary_start, OS::Address boundary_end, size_t minimum_size, ++ size_t alignment) { ++ return {}; ++} ++ ++} // namespace base ++} // namespace v8 +diff -ruwN source/deps/v8/src/libsampler/sampler.cc source-new/deps/v8/src/libsampler/sampler.cc +--- source/deps/v8/src/libsampler/sampler.cc 2024-04-10 19:46:13.000000000 +0700 ++++ source-new/deps/v8/src/libsampler/sampler.cc 2025-10-10 13:46:04.417193700 +0700 +@@ -16,11 +16,11 @@ + #include + #include + +-#if !V8_OS_QNX && !V8_OS_AIX ++#if !V8_OS_QNX && !V8_OS_AIX && !V8_OS_REDOX + #include + #endif + +-#if V8_OS_AIX || V8_TARGET_ARCH_S390X ++#if V8_OS_AIX || V8_OS_REDOX || V8_TARGET_ARCH_S390X + + #include "src/base/platform/time.h" + +diff -ruwN source/deps/v8/src/trap-handler/handler-inside-posix.cc source-new/deps/v8/src/trap-handler/handler-inside-posix.cc +--- source/deps/v8/src/trap-handler/handler-inside-posix.cc 2024-04-10 19:46:13.000000000 +0700 ++++ source-new/deps/v8/src/trap-handler/handler-inside-posix.cc 2025-10-11 12:32:56.074858844 +0700 +@@ -23,6 +23,7 @@ + // context. Some additional code is used both inside and outside the signal + // handler. This code can be found in handler-shared.cc. + ++#ifndef __redox__ + #include "src/trap-handler/handler-inside-posix.h" + + #include +@@ -102,7 +103,6 @@ + asm("v8_simulator_probe_memory_continuation"); + #endif + #endif // V8_TRAP_HANDLER_VIA_SIMULATOR +- + bool TryHandleSignal(int signum, siginfo_t* info, void* context) { + // Ensure the faulting thread was actually running Wasm code. This should be + // the first check in the trap handler to guarantee that the +@@ -197,3 +197,5 @@ + } // namespace trap_handler + } // namespace internal + } // namespace v8 ++ ++#endif +diff -ruwN source/deps/v8/src/trap-handler/handler-inside-posix.h source-new/deps/v8/src/trap-handler/handler-inside-posix.h +--- source/deps/v8/src/trap-handler/handler-inside-posix.h 2024-04-10 19:46:13.000000000 +0700 ++++ source-new/deps/v8/src/trap-handler/handler-inside-posix.h 2025-10-10 21:44:55.221873295 +0700 +@@ -4,7 +4,7 @@ + + #ifndef V8_TRAP_HANDLER_HANDLER_INSIDE_POSIX_H_ + #define V8_TRAP_HANDLER_HANDLER_INSIDE_POSIX_H_ +- ++#ifndef __redox__ + #include + + #include "include/v8config.h" +@@ -28,5 +28,5 @@ + } // namespace trap_handler + } // namespace internal + } // namespace v8 +- ++#endif + #endif // V8_TRAP_HANDLER_HANDLER_INSIDE_POSIX_H_ +diff -ruwN source/deps/v8/src/wasm/std-object-sizes.h source-new/deps/v8/src/wasm/std-object-sizes.h +--- source/deps/v8/src/wasm/std-object-sizes.h 2024-04-10 19:46:13.000000000 +0700 ++++ source-new/deps/v8/src/wasm/std-object-sizes.h 2025-10-10 13:46:04.591737114 +0700 +@@ -54,24 +54,7 @@ + return raw * 4 / 3; + } + +-// To make it less likely for size estimation functions to become outdated +-// when the classes they're responsible for change, we insert static asserts +-// about the respective class's size into them to at least catch some possible +-// future modifications. Since object sizes are toolchain specific, we define +-// restrictions here under which we enable these checks. +-// When one of these checks fails, that probably means you've added fields to +-// a class guarded by it. Update the respective EstimateCurrentMemoryConsumption +-// function accordingly, and then update the check's expected size. +-#if V8_TARGET_ARCH_X64 && defined(__clang__) && V8_TARGET_OS_LINUX && \ +- !V8_USE_ADDRESS_SANITIZER && !V8_USE_MEMORY_SANITIZER && defined(DEBUG) && \ +- V8_COMPRESS_POINTERS && !defined(V8_GC_MOLE) && defined(_LIBCPP_VERSION) +-#define UPDATE_WHEN_CLASS_CHANGES(classname, size) \ +- static_assert(sizeof(classname) == size, \ +- "Update {EstimateCurrentMemoryConsumption} when adding " \ +- "fields to " #classname) +-#else + #define UPDATE_WHEN_CLASS_CHANGES(classname, size) (void)0 +-#endif + + } // namespace v8::internal::wasm + +diff -ruwN source/src/debug_utils.cc source-new/src/debug_utils.cc +--- source/src/debug_utils.cc 2024-04-10 19:46:14.000000000 +0700 ++++ source-new/src/debug_utils.cc 2025-10-10 13:46:04.755669055 +0700 +@@ -14,7 +14,7 @@ + + #if defined(__linux__) && !defined(__GLIBC__) || \ + defined(__UCLIBC__) || \ +- defined(_AIX) ++ defined(_AIX) || defined(__redox__) + #define HAVE_EXECINFO_H 0 + #else + #define HAVE_EXECINFO_H 1 +diff -ruwN source/src/node_credentials.cc source-new/src/node_credentials.cc +--- source/src/node_credentials.cc 2024-04-10 19:46:14.000000000 +0700 ++++ source-new/src/node_credentials.cc 2025-10-10 13:46:04.816900208 +0700 +@@ -182,7 +182,7 @@ + + static uid_t uid_by_name(Isolate* isolate, Local value) { + if (value->IsUint32()) { +- static_assert(std::is_same::value); ++ // static_assert(std::is_same::value); + return value.As()->Value(); + } else { + Utf8Value name(isolate, value); +@@ -192,7 +192,7 @@ + + static gid_t gid_by_name(Isolate* isolate, Local value) { + if (value->IsUint32()) { +- static_assert(std::is_same::value); ++ // static_assert(std::is_same::value); + return value.As()->Value(); + } else { + Utf8Value name(isolate, value); +diff -ruwN source/src/node_report.cc source-new/src/node_report.cc +--- source/src/node_report.cc 2024-04-10 19:46:14.000000000 +0700 ++++ source-new/src/node_report.cc 2025-10-10 13:46:05.190512964 +0700 +@@ -524,7 +524,7 @@ + while (line != -1) { + l = ss.substr(0, line); + l.erase(l.begin(), std::find_if(l.begin(), l.end(), [](int ch) { +- return !std::iswspace(ch); ++ return !std::isspace(ch); + })); + writer->json_element(l); + ss = ss.substr(line + 1); +diff -ruwN source/tools/gyp/pylib/gyp/common.py source-new/tools/gyp/pylib/gyp/common.py +--- source/tools/gyp/pylib/gyp/common.py 2024-04-10 19:46:15.000000000 +0700 ++++ source-new/tools/gyp/pylib/gyp/common.py 2025-10-10 21:36:23.972976264 +0700 +@@ -445,6 +445,8 @@ + return "netbsd" + if sys.platform.startswith("aix"): + return "aix" ++ if sys.platform.startswith("redox"): ++ return "redox" + if sys.platform.startswith(("os390", "zos")): + return "zos" + if sys.platform == "os400": +diff -ruwN source/tools/gyp/pylib/gyp/generator/make.py source-new/tools/gyp/pylib/gyp/generator/make.py +--- source/tools/gyp/pylib/gyp/generator/make.py 2024-04-10 19:46:15.000000000 +0700 ++++ source-new/tools/gyp/pylib/gyp/generator/make.py 2025-10-10 14:27:51.496602771 +0700 +@@ -1868,7 +1868,7 @@ + self.flavor not in ("mac", "openbsd", "netbsd", "win") + and not self.is_standalone_static_library + ): +- if self.flavor in ("linux", "android"): ++ if self.flavor in ("linux", "android", "redox"): + self.WriteMakeRule( + [self.output_binary], + link_deps, +@@ -1883,7 +1883,7 @@ + postbuilds=postbuilds, + ) + else: +- if self.flavor in ("linux", "android"): ++ if self.flavor in ("linux", "android", "redox"): + self.WriteMakeRule( + [self.output_binary], + link_deps, +diff -ruwN source/tools/v8_gypfiles/d8.gyp source-new/tools/v8_gypfiles/d8.gyp +--- source/tools/v8_gypfiles/d8.gyp 2024-04-10 19:46:15.000000000 +0700 ++++ source-new/tools/v8_gypfiles/d8.gyp 2025-10-10 21:34:47.141291162 +0700 +@@ -47,7 +47,7 @@ + }], + ['(OS=="linux" or OS=="mac" or OS=="freebsd" or OS=="netbsd" \ + or OS=="openbsd" or OS=="solaris" or OS=="android" \ +- or OS=="qnx" or OS=="aix" or OS=="os400")', { ++ or OS=="qnx" or OS=="aix" or OS=="redox" or OS=="os400")', { + 'sources': [ '<(V8_ROOT)/src/d8/d8-posix.cc', ] + }], + [ 'OS=="win"', { +diff -ruwN source/tools/v8_gypfiles/toolchain.gypi source-new/tools/v8_gypfiles/toolchain.gypi +--- source/tools/v8_gypfiles/toolchain.gypi 2024-04-10 19:46:15.000000000 +0700 ++++ source-new/tools/v8_gypfiles/toolchain.gypi 2025-10-10 21:57:05.129575573 +0700 +@@ -575,6 +575,12 @@ + 'V8_TARGET_OS_MACOS', + ] + }], ++ ['OS=="redox"', { ++ 'defines': [ ++ 'V8_HAVE_TARGET_OS', ++ 'V8_TARGET_OS_REDOX', ++ ] ++ }], + ['OS=="win"', { + 'defines': [ + 'V8_HAVE_TARGET_OS', +@@ -661,7 +667,7 @@ + ], + }], + ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \ +- or OS=="netbsd" or OS=="qnx" or OS=="aix" or OS=="os400"', { ++ or OS=="netbsd" or OS=="qnx" or OS=="aix" or OS=="redox" or OS=="os400"', { + 'conditions': [ + [ 'v8_no_strict_aliasing==1', { + 'cflags': [ '-fno-strict-aliasing' ], +diff -ruwN source/tools/v8_gypfiles/v8.gyp source-new/tools/v8_gypfiles/v8.gyp +--- source/tools/v8_gypfiles/v8.gyp 2024-04-10 19:46:15.000000000 +0700 ++++ source-new/tools/v8_gypfiles/v8.gyp 2025-10-11 12:14:17.137386469 +0700 +@@ -606,7 +606,7 @@ + }], + ['v8_enable_webassembly==1', { + 'conditions': [ +- ['OS=="linux" or OS=="mac" or OS=="ios" or OS=="freebsd"', { ++ ['OS=="linux" or OS=="redox" or OS=="mac" or OS=="ios" or OS=="freebsd"', { + 'sources': [ + '<(V8_ROOT)/src/trap-handler/handler-inside-posix.h', + ], +@@ -637,7 +637,7 @@ + }], + ['v8_enable_webassembly==1', { + 'conditions': [ +- ['((_toolset=="host" and host_arch=="arm64" or _toolset=="target" and target_arch=="arm64") and (OS=="linux" or OS=="mac")) or ((_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS=="linux" or OS=="mac"))', { ++ ['((_toolset=="host" and host_arch=="arm64" or _toolset=="target" and target_arch=="arm64") and (OS=="linux" or OS=="mac")) or ((_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS=="linux" or OS=="redox" or OS=="mac"))', { + 'sources': [ + '<(V8_ROOT)/src/trap-handler/handler-inside-posix.h', + ], +@@ -941,7 +941,7 @@ + }], + ['v8_enable_webassembly==1', { + 'conditions': [ +- ['OS=="linux" or OS=="mac" or OS=="ios" or OS=="freebsd"', { ++ ['OS=="linux" or OS=="redox" or OS=="mac" or OS=="ios" or OS=="freebsd"', { + 'sources': [ + '<(V8_ROOT)/src/trap-handler/handler-inside-posix.cc', + '<(V8_ROOT)/src/trap-handler/handler-outside-posix.cc', +@@ -969,7 +969,7 @@ + 'conditions': [ + ['v8_enable_webassembly==1', { + 'conditions': [ +- ['((_toolset=="host" and host_arch=="arm64" or _toolset=="target" and target_arch=="arm64") and (OS=="linux" or OS=="mac" or OS=="ios")) or ((_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS=="linux" or OS=="mac"))', { ++ ['((_toolset=="host" and host_arch=="arm64" or _toolset=="target" and target_arch=="arm64") and (OS=="linux" or OS=="redox" or OS=="mac" or OS=="ios")) or ((_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS=="linux" or OS=="redox" or OS=="mac"))', { + 'sources': [ + '<(V8_ROOT)/src/trap-handler/handler-inside-posix.cc', + '<(V8_ROOT)/src/trap-handler/handler-outside-posix.cc', +@@ -981,7 +981,7 @@ + '<(V8_ROOT)/src/trap-handler/handler-outside-win.cc', + ], + }], +- ['(_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS=="linux" or OS=="mac" or OS=="win")', { ++ ['(_toolset=="host" and host_arch=="x64" or _toolset=="target" and target_arch=="x64") and (OS=="linux" or OS=="redox" or OS=="mac" or OS=="win")', { + 'sources': [ + '<(V8_ROOT)/src/trap-handler/handler-outside-simulator.cc', + ], +@@ -1323,6 +1323,35 @@ + # end of conditions from 'BUILD.gn' + + # Node.js validated ++ ['OS=="redox"', { ++ 'link_settings': { ++ 'target_conditions': [ ++ ['_toolset=="host"', { ++ 'libraries': [ ++ '-ldl' ++ ], ++ }], ++ ], ++ }, ++ 'sources': [ ++ '<(V8_ROOT)/src/base/platform/platform-posix.cc', ++ '<(V8_ROOT)/src/base/platform/platform-posix.h', ++ '<(V8_ROOT)/src/base/platform/platform-posix-time.cc', ++ '<(V8_ROOT)/src/base/platform/platform-posix-time.h', ++ '<(V8_ROOT)/src/base/debug/stack_trace_posix.cc', ++ ], ++ 'target_conditions': [ ++ ['_toolset=="host"', { ++ 'sources': [ ++ '<(V8_ROOT)/src/base/platform/platform-linux.cc', ++ ], ++ }, { ++ 'sources': [ ++ '<(V8_ROOT)/src/base/platform/platform-redox.cc', ++ ], ++ }], ++ ], ++ }], + ['OS=="solaris"', { + 'link_settings': { + 'libraries': [ diff --git a/recipes/wip/dev/lang/nodejs/01_redox.patch b/recipes/wip/dev/lang/nodejs-24/01_redox.patch similarity index 100% rename from recipes/wip/dev/lang/nodejs/01_redox.patch rename to recipes/wip/dev/lang/nodejs-24/01_redox.patch diff --git a/recipes/wip/dev/lang/nodejs/recipe.toml b/recipes/wip/dev/lang/nodejs-24/recipe.toml similarity index 60% rename from recipes/wip/dev/lang/nodejs/recipe.toml rename to recipes/wip/dev/lang/nodejs-24/recipe.toml index fbc91fb97..cfd29f13d 100644 --- a/recipes/wip/dev/lang/nodejs/recipe.toml +++ b/recipes/wip/dev/lang/nodejs-24/recipe.toml @@ -1,22 +1,23 @@ -#TODO depedencies needed +#TODO requires stdc++20 [source] -tar = "https://nodejs.org/dist/v24.5.0/node-v24.5.0.tar.gz" +tar = "https://nodejs.org/dist/v24.5.0/node-v24.9.0.tar.xz" +blake3 = "c710713c9144dc2dfadaef1d180b295d85edd9945513017fc700af68eb08a251" patches = ["01_redox.patch"] [build] template = "custom" -depedencies = [ +dependencies = [ # "ada", "libbrotli", -# "cares", + "c-ares", "libuv", -# "ngtcp2", + "ngtcp2", "nghttp2", # "http-parser", -# "nghttp3", + "nghttp3", "openssl1", "simdjson", -# "simdutf", + "simdutf", "sqlite3", # "uvwasi", "zlib", @@ -24,6 +25,7 @@ depedencies = [ ] script = """ DYNAMIC_INIT +rsync -av --delete "${COOKBOOK_SOURCE}/" ./ case "${TARGET}" in x86-unknown-redox) @@ -41,12 +43,21 @@ COOKBOOK_CONFIGURE_FLAGS=( --prefix=${COOKBOOK_STAGE} --dest-cpu=${NODE_CPU} --dest-os=redox + --shared-cares --shared-libuv + --shared-ngtcp2 --shared-nghttp2 + --shared-nghttp3 --shared-openssl + --shared-simdjson + --shared-simdutf --shared-zlib --shared-zstd --cross-compiling + --without-sqlite + --without-inspector + --without-intl ) +COOKBOOK_CONFIGURE="./configure" cookbook_configure """ diff --git a/recipes/wip/dev/lang/nodejs-lts/recipe.toml b/recipes/wip/dev/lang/nodejs-lts/recipe.toml deleted file mode 100644 index 233365de1..000000000 --- a/recipes/wip/dev/lang/nodejs-lts/recipe.toml +++ /dev/null @@ -1,5 +0,0 @@ -#TODO can't find the Redox target -[source] -tar = "https://nodejs.org/dist/v18.17.1/node-v18.17.1.tar.gz" -[build] -template = "configure" diff --git a/recipes/wip/libs/net/c-ares/recipe.toml b/recipes/wip/libs/net/c-ares/recipe.toml new file mode 100644 index 000000000..299898dc3 --- /dev/null +++ b/recipes/wip/libs/net/c-ares/recipe.toml @@ -0,0 +1,6 @@ +[source] +git = "https://github.com/c-ares/c-ares" +rev = "d3a507e920e7af18a5efb7f9f1d8044ed4750013" # 1.34.5 + +[build] +template = "cmake" diff --git a/recipes/wip/libs/net/nghttp3/recipe.toml b/recipes/wip/libs/net/nghttp3/recipe.toml new file mode 100644 index 000000000..1a4e01f10 --- /dev/null +++ b/recipes/wip/libs/net/nghttp3/recipe.toml @@ -0,0 +1,6 @@ +[source] +git = "https://github.com/ngtcp2/nghttp3" +rev = "f3eb315feda478cdb4919720a7961c0321e1bd89" # 1.14.0 + +[build] +template = "cmake" diff --git a/recipes/wip/libs/net/ngtcp2/recipe.toml b/recipes/wip/libs/net/ngtcp2/recipe.toml new file mode 100644 index 000000000..bc31da496 --- /dev/null +++ b/recipes/wip/libs/net/ngtcp2/recipe.toml @@ -0,0 +1,14 @@ +#TODO Maybe need openssl 1.1.1 +[source] +git = "https://github.com/ngtcp2/ngtcp2" +rev = "e9fe10e0e8b3ce646fa88b4217864f29b4e013d9" # 1.14.0 + +[build] +template = "custom" +script = """ +DYNAMIC_INIT +COOKBOOK_CMAKE_FLAGS+=( + -DENABLE_OPENSSL=OFF +) +cookbook_cmake +""" diff --git a/recipes/wip/libs/other/simdjson/recipe.toml b/recipes/wip/libs/other/simdjson/recipe.toml index 08031f96a..5f162af51 100644 --- a/recipes/wip/libs/other/simdjson/recipe.toml +++ b/recipes/wip/libs/other/simdjson/recipe.toml @@ -1,21 +1,9 @@ -#TODO maybe incomplete script, see https://github.com/simdjson/simdjson/blob/master/HACKING.md#usage-cmake-on-64-bit-platforms-like-linux-freebsd-or-macos [source] git = "https://github.com/simdjson/simdjson" -rev = "6060be2fdf62edf4a8f51a8b0883d57d09397b30" +rev = "0c0ce1bd48baa0677dc7c0945ea7cd1e8b52b297" # 3.13.0 [build] template = "custom" script = """ -COOKBOOK_CONFIGURE="cmake" -COOKBOOK_CONFIGURE_FLAGS=( - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CROSSCOMPILING=True - -DCMAKE_EXE_LINKER_FLAGS="-static" - -DCMAKE_INSTALL_PREFIX="/" - -DCMAKE_PREFIX_PATH="${COOKBOOK_SYSROOT}" - -DCMAKE_SYSTEM_NAME=Generic - -DCMAKE_SYSTEM_PROCESSOR="$(echo "${TARGET}" | cut -d - -f1)" - -DCMAKE_VERBOSE_MAKEFILE=On -"${COOKBOOK_SOURCE}" -) -cookbook_configure +DYNAMIC_INIT +cookbook_cmake """ diff --git a/recipes/wip/libs/other/simdutf/recipe.toml b/recipes/wip/libs/other/simdutf/recipe.toml new file mode 100644 index 000000000..faf1c2465 --- /dev/null +++ b/recipes/wip/libs/other/simdutf/recipe.toml @@ -0,0 +1,9 @@ +[source] +git = "https://github.com/simdutf/simdutf" +rev = "df8bfed3256cf5ca29969a9dd1db677e835b2c6c" # 7.3.5 +[build] +template = "custom" +script = """ +DYNAMIC_INIT +cookbook_cmake +"""