Merge branch 'neovim-cross' into 'master'

Fix cross compiling neovim

See merge request redox-os/redox!1794
This commit is contained in:
Jeremy Soller 2025-12-29 09:42:12 -07:00
commit 34e306cc76
5 changed files with 30 additions and 49 deletions

View File

@ -3,21 +3,4 @@ tar = "https://github.com/JuliaStrings/utf8proc/archive/refs/tags/v2.10.0.tar.gz
blake3 = "6f675db5d1ae55ad0825351ba9c58a5b5c24c862f559cc7bfed1cb63c1185594"
[build]
template = "custom"
script = """
DYNAMIC_INIT
COOKBOOK_CONFIGURE="cmake"
COOKBOOK_CONFIGURE_FLAGS=(
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_CROSSCOMPILING=True
-DCMAKE_CXX_COMPILER="${TARGET}-g++"
-DCMAKE_C_COMPILER="${TARGET}-gcc"
-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
"""
template = "cmake"

View File

@ -1,5 +1,6 @@
[source]
tar = "https://www.inf.puc-rio.br/~roberto/lpeg/lpeg-1.1.0.tar.gz"
blake3 = "69fc6eaa1a1749937b7216e3d655cf47a7802ffe407f8f857664e999a7b7377b"
[build]
template = "custom"

View File

@ -1,5 +1,6 @@
[source]
tar = "https://github.com/tree-sitter/tree-sitter/archive/refs/tags/v0.25.8.tar.gz"
blake3 = "a9bce1e3c610441dc9d7dcc3d7d38e6a74e0b06d6b7d40e22982d927006dbfc4"
patches = [
"redox.patch"
]

View File

@ -1,6 +1,8 @@
#TODO mostly work, kinda slow, can't quit (signal issues?)
[source]
tar = "https://github.com/neovim/neovim/archive/refs/tags/v0.11.3.tar.gz"
git = "https://github.com/neovim/neovim"
rev = "v0.11.5"
shallow_clone = true
patches = [
"redox.patch"
]
@ -8,7 +10,6 @@ patches = [
[build]
template = "custom"
dependencies = [
"luajit",
"libiconv",
"libuv",
"luv",
@ -18,10 +19,32 @@ dependencies = [
"unibilium",
"utf8proc",
]
dev-dependencies = [
"host:luajit",
"host:neovim",
]
script = """
DYNAMIC_INIT
cookbook_cmake \
-DLUA_GEN_PRG=luajit
# the only official way to cross compile in future is via zig
# https://github.com/neovim/neovim/issues/19579
# the code path below is very hacky, and our zig support is poor yet
COOKBOOK_CMAKE_FLAGS+=(-DLUA_GEN_PRG=luajit)
export DEPS_BUILD_DIR=$COOKBOOK_SYSROOT/usr
if [ "$TARGET" = "$COOKBOOK_HOST_TARGET" ]; then
cookbook_cmake
# needed to workaround bootstrapping process
cp ./lib/libnlua0.so ${COOKBOOK_STAGE}/usr/lib/nvim/
else
# this is a very ugly workaround
cookbook_cmake || true
cp ${COOKBOOK_TOOLCHAIN}/usr/lib/nvim/libnlua0.so ./lib/libnlua0.so
cookbook_cmake
fi
# Lpeg is absolute path https://github.com/neovim/neovim/issues/23395
patchelf --replace-needed \

View File

@ -67,33 +67,6 @@ diff -ruwN source/runtime/CMakeLists.txt source-new/runtime/CMakeLists.txt
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