From b369a4ddd14beead8710b2d63191807598034b74 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Mon, 29 Dec 2025 23:38:04 +0700 Subject: [PATCH] Fix cross compiling neovim --- recipes/libs/utf8proc/recipe.toml | 19 +----------- recipes/wip/libs/lua/lpeg/recipe.toml | 1 + .../wip/libs/other/tree-sitter/recipe.toml | 1 + recipes/wip/text/neovim/recipe.toml | 31 ++++++++++++++++--- recipes/wip/text/neovim/redox.patch | 27 ---------------- 5 files changed, 30 insertions(+), 49 deletions(-) diff --git a/recipes/libs/utf8proc/recipe.toml b/recipes/libs/utf8proc/recipe.toml index c34c12f19..417c53cdc 100644 --- a/recipes/libs/utf8proc/recipe.toml +++ b/recipes/libs/utf8proc/recipe.toml @@ -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" diff --git a/recipes/wip/libs/lua/lpeg/recipe.toml b/recipes/wip/libs/lua/lpeg/recipe.toml index 484e5b3a5..ef1ad9a32 100644 --- a/recipes/wip/libs/lua/lpeg/recipe.toml +++ b/recipes/wip/libs/lua/lpeg/recipe.toml @@ -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" diff --git a/recipes/wip/libs/other/tree-sitter/recipe.toml b/recipes/wip/libs/other/tree-sitter/recipe.toml index e5507e3e9..8285bd265 100644 --- a/recipes/wip/libs/other/tree-sitter/recipe.toml +++ b/recipes/wip/libs/other/tree-sitter/recipe.toml @@ -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" ] diff --git a/recipes/wip/text/neovim/recipe.toml b/recipes/wip/text/neovim/recipe.toml index 8978c7ed2..1f29bff5f 100644 --- a/recipes/wip/text/neovim/recipe.toml +++ b/recipes/wip/text/neovim/recipe.toml @@ -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 \ diff --git a/recipes/wip/text/neovim/redox.patch b/recipes/wip/text/neovim/redox.patch index 30b3f7229..c8ea25b56 100644 --- a/recipes/wip/text/neovim/redox.patch +++ b/recipes/wip/text/neovim/redox.patch @@ -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