Merge branch 'neovim-deps' into 'master'

Port neovim

See merge request redox-os/cookbook!605
This commit is contained in:
Jeremy Soller 2025-09-16 06:31:37 -06:00
commit 052ecbb54c
10 changed files with 377 additions and 47 deletions

View File

@ -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-07-22 01:48:56.591286953 +0700
+++ source-new/CMakeLists.txt 2025-09-16 14:15:31.813140608 +0700
@@ -1,3 +1,4 @@
+set (CMAKE_CXX_STANDARD 99)
cmake_minimum_required(VERSION 3.4)
if(POLICY CMP0091)
@@ -312,6 +313,17 @@
@@ -312,6 +313,18 @@
src/unix/hurd.c)
endif()
@ -18,6 +18,7 @@ diff -ruwN source/CMakeLists.txt source-new/CMakeLists.txt
+ src/unix/proctitle.c
+ src/unix/posix-hrtime.c
+ src/unix/posix-poll.c
+ src/unix/redox.c
+ )
+endif()
+
@ -26,7 +27,7 @@ diff -ruwN source/CMakeLists.txt source-new/CMakeLists.txt
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-07-22 01:53:54.941276543 +0700
+++ source-new/include/uv/unix.h 2025-09-16 11:42:40.882554686 +0700
@@ -66,6 +66,7 @@
defined(__MSYS__) || \
defined(__HAIKU__) || \
@ -37,7 +38,7 @@ diff -ruwN source/include/uv/unix.h source-new/include/uv/unix.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-07-21 22:55:16.826444959 +0700
+++ source-new/src/unix/core.c 2025-09-16 11:42:40.882554686 +0700
@@ -97,6 +97,10 @@
# include <sanitizer/linux_syscall_hooks.h>
#endif
@ -61,7 +62,7 @@ diff -ruwN source/src/unix/core.c source-new/src/unix/core.c
if (rc == -1)
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-07-21 22:55:16.826444959 +0700
+++ source-new/src/unix/fs.c 2025-09-16 11:42:40.882554686 +0700
@@ -87,7 +87,8 @@
defined(__MVS__) || \
defined(__NetBSD__) || \
@ -100,7 +101,7 @@ diff -ruwN source/src/unix/fs.c source-new/src/unix/fs.c
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-07-22 02:10:12.760625178 +0700
+++ source-new/src/unix/proctitle.c 2025-09-16 11:42:40.882554686 +0700
@@ -30,7 +30,13 @@
size_t cap; /* Maximum capacity. Computed once in uv_setup_args(). */
};
@ -115,9 +116,115 @@ diff -ruwN source/src/unix/proctitle.c source-new/src/unix/proctitle.c
static uv_mutex_t process_title_mutex;
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
@@ -0,0 +1,102 @@
+/* Copyright libuv contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "uv.h"
+#include "internal.h"
+
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+
+static void
+get_mem_info(uint64_t* totalmem, uint64_t* freemem) {
+ *totalmem = 0;
+ *freemem = 0;
+}
+
+
+void uv_loadavg(double avg[3]) {
+ avg[0] = 0.0;
+ avg[1] = 0.0;
+ avg[2] = 0.0;
+}
+
+
+int uv_exepath(char* buffer, size_t* size) {
+ if (buffer == NULL || size == NULL || *size == 0) {
+ return UV_EINVAL;
+ }
+ FILE* fp = fopen("/scheme/sys/exe", "r");
+ if (fp == NULL) {
+ return -errno;
+ }
+ if (fgets(buffer, *size, fp) == NULL) {
+ fclose(fp);
+ return UV_EIO;
+ }
+ fclose(fp);
+ buffer[strcspn(buffer, "\r\n")] = '\0';
+ *size = strlen(buffer);
+ return 0;
+}
+
+int uv_interface_addresses(uv_interface_address_t** addresses, int* count) {
+ return 0;
+}
+
+
+uint64_t uv_get_free_memory(void) {
+ return 0;
+}
+
+
+uint64_t uv_get_total_memory(void) {
+ return 0;
+}
+
+
+uint64_t uv_get_constrained_memory(void) {
+ return 0;
+}
+
+
+uint64_t uv_get_available_memory(void) {
+ return uv_get_free_memory();
+}
+
+
+int uv_resident_set_memory(size_t* rss) {
+ return 0;
+}
+
+
+int uv_uptime(double* uptime) {
+ return 0;
+}
+
+
+int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) {
+ return 0;
+}
+
+void uv_free_interface_addresses(uv_interface_address_t* addresses,
+ 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-07-21 22:55:16.826444959 +0700
+++ source-new/src/unix/stream.c 2025-09-16 11:42:40.883554697 +0700
@@ -29,7 +29,14 @@
#include <errno.h>
@ -151,7 +258,7 @@ diff -ruwN source/src/unix/stream.c source-new/src/unix/stream.c
struct cmsghdr hdr;
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-07-21 22:55:16.826444959 +0700
+++ source-new/src/unix/udp.c 2025-09-16 11:42:40.883554697 +0700
@@ -31,6 +31,12 @@
#include <xti.h>
#endif

View File

@ -3,25 +3,15 @@ git = "https://github.com/luvit/luv.git"
[build]
template = "custom"
dependencies = [
"lua54",
"libuv",
"lua-compat-53"
"luajit"
]
script = """
COOKBOOK_CONFIGURE="cmake"
COOKBOOK_CONFIGURE_FLAGS=(
-DBUILD_MODULE=OFF
-DBUILD_STATIC_LIBS=ON
-DWITH_SHARED_LIBUV=ON
-DWITH_LUA_ENGINE=Lua
DYNAMIC_INIT
COOKBOOK_CMAKE_FLAGS+=(
-DWITH_LUA_ENGINE=Luajit
-DLUA_BUILD_TYPE=System
-DLUA_COMPAT53_DIR="${COOKBOOK_SYSROOT}/bin"
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DLIBUV_LIBRARIES="${COOKBOOK_SYSROOT}/usr/lib/libuv.a"
-DLIBUV_INCLUDE_DIR="${COOKBOOK_SYSROOT}/usr/include"
-DLUA_INCLUDE_DIR="${COOKBOOK_SYSROOT}/include"
-DLUV_INCLUDE_DIR="${COOKBOOK_SYSROOT}/include"
"${COOKBOOK_SOURCE}"
-DWITH_SHARED_LIBUV=On
)
cookbook_configure
cookbook_cmake
"""

View File

@ -0,0 +1,15 @@
[source]
tar = "https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.1.0.tar.gz"
[build]
template = "custom"
dependencies = [
"luajit",
]
script = """
rsync -av --delete "${COOKBOOK_SOURCE}/" ./
make linux CC="${CC} -I${COOKBOOK_SYSROOT}/include/luajit-2.1"
mkdir -p ${COOKBOOK_STAGE}/usr/lib/pkgconfig
cp lpeg.so ${COOKBOOK_STAGE}/usr/lib/liblpeg.so.1
ln -s "liblpeg.so.1" ${COOKBOOK_STAGE}/usr/lib/liblpeg.so
"""

View File

@ -1,5 +1,15 @@
#TODO missing script for building, see https://github.com/leonerd/libtickit
[source]
tar = "https://www.leonerd.org.uk/code/libtickit/libtickit-0.4.3.tar.gz"
tar = "https://www.leonerd.org.uk/code/libtickit/libtickit-0.4.5.tar.gz"
[build]
template = "custom"
dependencies = [
"ncursesw"
]
script = """
DYNAMIC_INIT
rsync -av --delete "${COOKBOOK_SOURCE}/" ./
"${COOKBOOK_MAKE}" -j "${COOKBOOK_MAKE_JOBS}"
"${COOKBOOK_MAKE}" install-inc install-lib DESTDIR="${COOKBOOK_STAGE}"
"""

View File

@ -2,4 +2,12 @@
[source]
tar = "https://launchpad.net/libvterm/trunk/v0.3/+download/libvterm-0.3.3.tar.gz"
[build]
template = "configure"
template = "custom"
script = """
DYNAMIC_INIT
rsync -av --delete "${COOKBOOK_SOURCE}/" ./
${COOKBOOK_MAKE} -j ${COOKBOOK_MAKE_JOBS} install \
PREFIX="${COOKBOOK_STAGE}"
"""

View File

@ -8,4 +8,4 @@ COOKBOOK_CONFIGURE_FLAGS+=(
--prefix="${COOKBOOK_STAGE}/usr"
)
cookbook_configure
"""
"""

View File

@ -0,0 +1,13 @@
[source]
tar = "https://github.com/tree-sitter/tree-sitter/archive/refs/tags/v0.25.8.tar.gz"
patches = [
"redox.patch"
]
[build]
template = "custom"
script = """
DYNAMIC_INIT
PACKAGE_PATH=cli cookbook_cargo
cookbook_cmake "${COOKBOOK_SOURCE}"/lib
"""

View File

@ -0,0 +1,45 @@
diff --color -ruwN source/Cargo.toml source-new/Cargo.toml
--- source/Cargo.toml 2025-07-14 01:32:42.000000000 +0700
+++ source-new/Cargo.toml 2025-09-16 11:37:28.820646655 +0700
@@ -118,7 +118,7 @@
dialoguer = { version = "0.11.0", features = ["fuzzy-select"] }
etcetera = "0.8.0"
filetime = "0.2.25"
-fs4 = "0.12.0"
+fs4 = { git = "https://github.com/al8n/fs4-rs" } # for redox support, still not published yet
git2 = "0.20.0"
glob = "0.3.2"
heck = "0.5.0"
@@ -151,7 +151,7 @@
url = { version = "2.5.4", features = ["serde"] }
walkdir = "2.5.0"
wasmparser = "0.224.0"
-webbrowser = "1.0.3"
+webbrowser = "1.0.5"
tree-sitter = { version = "0.25.1", path = "./lib" }
tree-sitter-generate = { version = "0.25.1", path = "./cli/generate" }
diff --color -ruwN source/cli/src/fuzz/allocations.rs source-new/cli/src/fuzz/allocations.rs
--- source/cli/src/fuzz/allocations.rs 2025-07-14 01:32:42.000000000 +0700
+++ source-new/cli/src/fuzz/allocations.rs 2025-09-16 11:39:56.112458323 +0700
@@ -7,6 +7,7 @@
},
};
+#[cfg(not(target_os = "redox"))]
#[ctor::ctor]
unsafe fn initialize_allocation_recording() {
tree_sitter::set_allocator(
diff --color -ruwN source/lib/src/portable/endian.h source-new/lib/src/portable/endian.h
--- source/lib/src/portable/endian.h 2025-07-14 01:32:42.000000000 +0700
+++ source-new/lib/src/portable/endian.h 2025-09-16 11:27:12.315211556 +0700
@@ -24,7 +24,8 @@
defined(__CYGWIN__) || \
defined(__MSYS__) || \
defined(__EMSCRIPTEN__) || \
- defined(__wasi__)
+ defined(__wasi__) || \
+ defined(__redox__)
#if defined(__NetBSD__)
#define _NETBSD_SOURCE 1

View File

@ -1,29 +1,30 @@
#TODO probably wrong script, see https://github.com/neovim/neovim/wiki/Installing-Neovim#install-from-source
#TODO mostly work, kinda slow, can't quit (signal issues?)
[source]
git = "https://github.com/neovim/neovim"
rev = "d772f697a281ce9c58bf933997b87c7f27428a60"
tar = "https://github.com/neovim/neovim/archive/refs/tags/v0.11.3.tar.gz"
patches = [
"redox.patch"
]
[build]
template = "custom"
dependencies = [
"luajit",
"gettext",
"less",
"libiconv",
"libuv",
"libvterm",
"libtickit",
"luv",
"lpeg",
"tree-sitter",
"gettext",
"unibilium",
"utf8proc",
]
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 \
-DLUA_GEN_PRG=luajit
# Lpeg is absolute path https://github.com/neovim/neovim/issues/23395
patchelf --replace-needed \
"${COOKBOOK_SYSROOT}/usr/lib/liblpeg.so" \
'liblpeg.so.1' ${COOKBOOK_STAGE}/usr/bin/nvim
"""

View File

@ -0,0 +1,141 @@
diff -ruwN source/runtime/CMakeLists.txt source-new/runtime/CMakeLists.txt
--- source/runtime/CMakeLists.txt 2025-07-13 01:34:12.000000000 +0700
+++ source-new/runtime/CMakeLists.txt 2025-09-16 14:46:20.134790482 +0700
@@ -24,37 +24,6 @@
file(GLOB PACKAGES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*)
-set(GENERATED_PACKAGE_TAGS)
-foreach(PACKAGE ${PACKAGES})
- get_filename_component(PACKNAME ${PACKAGE} NAME)
- file(GLOB "${PACKNAME}_DOC_FILES" CONFIGURE_DEPENDS ${PACKAGE}/doc/*.txt)
- if(${PACKNAME}_DOC_FILES)
- file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME})
- add_custom_command(OUTPUT "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags"
- COMMAND ${CMAKE_COMMAND} -E copy_directory
- ${PACKAGE} ${GENERATED_PACKAGE_DIR}/${PACKNAME}
- COMMAND $<TARGET_FILE:nvim_bin>
- -u NONE -i NONE -e --headless -c "helptags doc" -c quit
- DEPENDS
- nvim_bin
- nvim_runtime_deps
- WORKING_DIRECTORY "${GENERATED_PACKAGE_DIR}/${PACKNAME}"
- )
-
- set("${PACKNAME}_DOC_NAMES")
- foreach(DF "${${PACKNAME}_DOC_FILES}")
- get_filename_component(F ${DF} NAME)
- list(APPEND "${PACKNAME}_DOC_NAMES" ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/${F})
- endforeach()
-
- install_helper(
- FILES ${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags "${${PACKNAME}_DOC_NAMES}"
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/pack/dist/opt/${PACKNAME}/doc)
-
- list(APPEND GENERATED_PACKAGE_TAGS "${GENERATED_PACKAGE_DIR}/${PACKNAME}/doc/tags")
- endif()
-endforeach()
-
set(BUILDDOCFILES)
foreach(DF ${DOCFILES})
get_filename_component(F ${DF} NAME)
@@ -65,8 +34,6 @@
COMMAND ${CMAKE_COMMAND} -E remove_directory doc
COMMAND ${CMAKE_COMMAND} -E copy_directory
${PROJECT_SOURCE_DIR}/runtime/doc doc
- COMMAND $<TARGET_FILE:nvim_bin>
- -u NONE -i NONE -e --headless -c "helptags ++t doc" -c quit
DEPENDS
nvim_bin
nvim_runtime_deps
@@ -78,7 +45,6 @@
DEPENDS
${GENERATED_SYN_VIM}
${GENERATED_HELP_TAGS}
- ${GENERATED_PACKAGE_TAGS}
)
# CMake is painful here. It will create the destination using the user's
@@ -88,10 +54,6 @@
# If it's preexisting, leave it alone.
install_helper(
- FILES ${GENERATED_HELP_TAGS} ${BUILDDOCFILES}
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/doc)
-
-install_helper(
FILES ${GENERATED_SYN_VIM}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim/runtime/syntax/vim)
diff -ruwN source/src/nvim/channel.c source-new/src/nvim/channel.c
--- source/src/nvim/channel.c 2025-07-13 01:34:12.000000000 +0700
+++ source-new/src/nvim/channel.c 2025-09-16 13:41:27.109978099 +0700
@@ -547,8 +547,23 @@
// Redirect stdout/stdin (the UI channel) to stderr. Use fnctl(F_DUPFD_CLOEXEC) instead of dup()
// to prevent child processes from inheriting the file descriptors, which are used by UIs to
// detect when Nvim exits.
+ #ifdef __redox__
+ int new_stdin_fd = dup(STDIN_FILENO);
+ if (new_stdin_fd >= 0) {
+ fcntl(new_stdin_fd, F_SETFD, FD_CLOEXEC);
+ }
+ stdin_dup_fd = new_stdin_fd;
+
+ // 2. Duplicate STDOUT and set CLOEXEC flag
+ int new_stdout_fd = dup(STDOUT_FILENO);
+ if (new_stdout_fd >= 0) {
+ fcntl(new_stdout_fd, F_SETFD, FD_CLOEXEC);
+ }
+ stdout_dup_fd = new_stdout_fd;
+ #else
stdin_dup_fd = fcntl(STDIN_FILENO, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
stdout_dup_fd = fcntl(STDOUT_FILENO, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
+ #endif // __redox__
dup2(STDERR_FILENO, STDOUT_FILENO);
dup2(STDERR_FILENO, STDIN_FILENO);
}
diff -ruwN source/src/nvim/CMakeLists.txt source-new/src/nvim/CMakeLists.txt
--- source/src/nvim/CMakeLists.txt 2025-07-13 01:34:12.000000000 +0700
+++ source-new/src/nvim/CMakeLists.txt 2025-09-16 16:07:40.327319085 +0700
@@ -93,19 +93,6 @@
endif()
# -fstack-protector breaks Mingw-w64 builds
-if(NOT MINGW)
- check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG_FLAG)
- if(HAS_FSTACK_PROTECTOR_STRONG_FLAG)
- target_compile_options(main_lib INTERFACE -fstack-protector-strong)
- target_link_libraries(main_lib INTERFACE -fstack-protector-strong)
- else()
- check_c_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR_FLAG)
- if(HAS_FSTACK_PROTECTOR_FLAG)
- target_compile_options(main_lib INTERFACE -fstack-protector --param ssp-buffer-size=4)
- target_link_libraries(main_lib INTERFACE -fstack-protector --param ssp-buffer-size=4)
- endif()
- endif()
-endif()
# Compiler specific options
if(MSVC)
@@ -145,9 +132,6 @@
# Platform specific options
if(UNIX)
target_link_libraries(main_lib INTERFACE m)
- if (NOT CMAKE_SYSTEM_NAME STREQUAL "SunOS")
- target_link_libraries(main_lib INTERFACE util)
- endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
diff -ruwN source/src/nvim/os/os_defs.h source-new/src/nvim/os/os_defs.h
--- source/src/nvim/os/os_defs.h 2025-07-13 01:34:12.000000000 +0700
+++ source-new/src/nvim/os/os_defs.h 2025-09-16 13:45:00.379142388 +0700
@@ -28,6 +28,8 @@
#if !defined(NAME_MAX) && defined(_XOPEN_NAME_MAX)
# define NAME_MAX _XOPEN_NAME_MAX
+#elif !defined(NAME_MAX)
+# define NAME_MAX 255
#endif
#define BASENAMELEN (NAME_MAX - 5)