Skip to content

Commit

Permalink
fix(main/neovim): turn nvim into a wrapper to fix dynamic linking
Browse files Browse the repository at this point in the history
This is required to make Android's dlopen() implementation
resolve symbols exported by libluajit.so to Lua modules.

Co-authored-by: Pip Cet <[email protected]>
closes #22328
  • Loading branch information
TomJo2000 committed Nov 21, 2024
1 parent 001deab commit c7881b6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/neovim/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ termux_step_post_make_install() {

# Tree-sitter grammars are packaged separately and installed into TERMUX_PREFIX/lib/tree_sitter.
ln -s "${TERMUX_PREFIX}"/lib/tree_sitter "${TERMUX_PREFIX}"/share/nvim/runtime/parser

# Move the `nvim` binary to $PREFIX/libexec
# and replace it with our LD_PRELOAD shim.
# See: packages/neovim/nvim-shim.sh for details.
mv "${TERMUX_PREFIX}"/bin/nvim "${TERMUX_PREFIX}"/libexec/nvim
install -m755 "$TERMUX_PKG_BUILDER_DIR/nvim-shim.sh" "${TERMUX_PREFIX}/bin/nvim"
}

termux_step_create_debscripts() {
Expand Down
9 changes: 9 additions & 0 deletions packages/neovim/nvim-shim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env sh

# For further details see:
# https://github.com/termux/termux-packages/issues/22328
# https://github.com/termux/termux-packages/wiki/Common-porting-problems#android-dynamic-linker
# https://github.com/android/ndk/issues/201
#
# Shim to properly expose LuaJIT runtime symbols to dynamically linked plugin modules
LD_PRELOAD="$LD_PRELOAD:libluajit.so" exec "$PREFIX/libexec/nvim" "$@"

0 comments on commit c7881b6

Please sign in to comment.