Skip to content

enhance(main/neovim{,-nightly},main/vim,x11/vim-gtk): document has('termux') feature flag#28681

Closed
TomJo2000 wants to merge 3 commits intotermux:masterfrom
TomJo2000:nvim-has-termux-docs
Closed

enhance(main/neovim{,-nightly},main/vim,x11/vim-gtk): document has('termux') feature flag#28681
TomJo2000 wants to merge 3 commits intotermux:masterfrom
TomJo2000:nvim-has-termux-docs

Conversation

@TomJo2000
Copy link
Copy Markdown
Member

@TomJo2000 TomJo2000 commented Mar 4, 2026

This PR replaces the src-nvim-eval-funcs.c.patch for the neovim/neovim-nightly packages with a more comprehensive version, has-termux.patch.

The renamed and expanded patch adds documentation of the has('termux') and has('android') feature flags added by the original patch.
In addition the added documentation also makes available the :h termux and :h android help tags, pointing to the additional information about the feature flags.

The syntax and style guide for the vimdoc documentation format are documented in:

The formatting on the help file is a bit wonky in the patch, however I have confirmed manually that it is indented identically to the rest of the section.

image

(Contrast of indentation guides enhanced manually for visual clarity.)

@TomJo2000 TomJo2000 force-pushed the nvim-has-termux-docs branch 2 times, most recently from 52b92df to 50e987f Compare March 4, 2026 01:11
@TomJo2000
Copy link
Copy Markdown
Member Author

The build currently seems to die on this right here.

for (( i=0; i < ${#PACKAGE_LIST[@]}; i++ )); do
# Following commands must be executed under lock to prevent running
# multiple instances of "./build-package.sh".
#
# To provide a sane environment for each package,
# builds are done in an explicit subshell for each.
# shellcheck disable=SC2031
(
if [[ "$TERMUX_BUILD_IGNORE_LOCK" != "true" ]]; then
flock -n 5 || termux_error_exit "Another build is already running within same environment."
fi

Which would indicate that the flock is not being properly released in this instance.
I can replicate the issue locally so this is probably not directly related to AppArmor.

@TomJo2000
Copy link
Copy Markdown
Member Author

I have a feeling we accidentally disallowed the container from using the flock() syscall, or a related one that's required here.

That would have been introduced by 221ce1f#diff-6f419dc9863f442f8b508a38b040ec549d82031311653f4b372243adc3653987, but I don't know how I could test that to verify.

More eyes would be appreciated on this.
CC: @thunder-coding @robertkirkman

@robertkirkman
Copy link
Copy Markdown
Member

I don't have apparmor so I'm not sure if I will be a lot of help in this case, but thunder-coding does and will be able to locally troubleshoot this.

@robertkirkman
Copy link
Copy Markdown
Member

I can replicate the issue locally so this is probably not directly related to AppArmor.

You are running apparmor locally as well, though, aren't you?

@TomJo2000
Copy link
Copy Markdown
Member Author

You are running apparmor locally as well, though, aren't you?

Nope.
No AppArmor locally, hence why I didn't think it was directly AppArmor related.

@thunder-coding thunder-coding self-assigned this Mar 4, 2026
@robertkirkman
Copy link
Copy Markdown
Member

Oh, I misunderstood and I thought you had AppArmor. I'll try to reproduce this

@robertkirkman
Copy link
Copy Markdown
Member

robertkirkman commented Mar 4, 2026

I wasn't able to reproduce this when just using scripts/run-docker.sh ./build-package.sh -I -f neovim neovim-nightly in an up-to-date repository folder

@TomJo2000
Copy link
Copy Markdown
Member Author

I wasn't able to reproduce this when just using scripts/run-docker.sh ./build-package.sh -I -f neovim neovim-nightly in an up-to-date repository folder

Is your docker container up to date?

@thunder-coding
Copy link
Copy Markdown
Member

Which would indicate that the flock is not being properly released in this instance.
I can replicate the issue locally so this is probably not directly related to AppArmor.

I was able to replicate this locally in some instances, but during later testing they went away, so I thought it was just some weird codepath that didn't trigger when I completed my PR. And this is affecting CI as well now. So will try digging into after python rebuilds are complete

@robertkirkman
Copy link
Copy Markdown
Member

I wasn't able to reproduce this when just using scripts/run-docker.sh ./build-package.sh -I -f neovim neovim-nightly in an up-to-date repository folder

Is your docker container up to date?

Yes

@licy183
Copy link
Copy Markdown
Member

licy183 commented Mar 4, 2026

It may not be related to flock, maybe just because that fuse-overlayfs has not stopped running.

@thunder-coding
Copy link
Copy Markdown
Member

4fd4e48 should fix this

@TomJo2000 TomJo2000 force-pushed the nvim-has-termux-docs branch from 50e987f to e91addb Compare March 4, 2026 20:21
@TomJo2000
Copy link
Copy Markdown
Member Author

Just checked the DEBs.

image

Seeing a distinct lack of Termux in that documentation.
Will need to look into why it's not getting generated properly.

@TomJo2000
Copy link
Copy Markdown
Member Author

We need to explicitly run the make doc target.
The docs are usually pre-generated as part of the release process.

@TomJo2000 TomJo2000 force-pushed the nvim-has-termux-docs branch from e91addb to fd88be6 Compare March 5, 2026 04:47
@TomJo2000
Copy link
Copy Markdown
Member Author

TomJo2000 commented Mar 5, 2026

/home/builder/.termux-build/neovim/src/.deps/build/src/libuv/src/unix/linux.c:2331:36: error: use of undeclared identifier 'LLONG_MAX'
 2331 |     constraint->quota_per_period = LLONG_MAX;
      |                                    ^
1 error generated.
gmake[6]: *** [CMakeFiles/uv_a.dir/build.make:513: CMakeFiles/uv_a.dir/src/unix/linux.c.o] Error 1
gmake[6]: Leaving directory '/home/builder/.termux-build/neovim/src/.deps/build/src/libuv-build'
gmake[5]: *** [CMakeFiles/Makefile2:87: CMakeFiles/uv_a.dir/all] Error 2
gmake[5]: Leaving directory '/home/builder/.termux-build/neovim/src/.deps/build/src/libuv-build'
gmake[4]: *** [Makefile:136: all] Error 2
gmake[4]: Leaving directory '/home/builder/.termux-build/neovim/src/.deps/build/src/libuv-build'
gmake[3]: *** [CMakeFiles/libuv.dir/build.make:86: build/src/libuv-stamp/libuv-build] Error 2
gmake[3]: Leaving directory '/home/builder/.termux-build/neovim/src/.deps'
gmake[2]: *** [CMakeFiles/Makefile2:158: CMakeFiles/libuv.dir/all] Error 2
gmake[2]: Leaving directory '/home/builder/.termux-build/neovim/src/.deps'
gmake[1]: *** [Makefile:91: all] Error 2
gmake[1]: Leaving directory '/home/builder/.termux-build/neovim/src/.deps'
make: *** [Makefile:108: deps] Error 2

Yeah I got nothing...
No idea how running make doc causes that to suddenly fail.

@TomJo2000
Copy link
Copy Markdown
Member Author

Moving it to termux_step_post_configure() makes it fail on Luajit instead.

Apparently running make doc causes all sorts of unexplained havoc.

@TomJo2000 TomJo2000 force-pushed the nvim-has-termux-docs branch 2 times, most recently from dc5c67a to 760c3e8 Compare March 6, 2026 17:36
@TomJo2000
Copy link
Copy Markdown
Member Author

Moving the make doc to termux_step_host_build() was also unsuccessful.

We can just patch the pre-generated docs in the tarball, it's fine.
It's not what I'd prefer, but it should be equally resilient against patch drift.

@TomJo2000 TomJo2000 force-pushed the nvim-has-termux-docs branch 3 times, most recently from 27f4b8e to 978717b Compare March 9, 2026 16:26
Comment on lines +33 to +34
+--- android Alias for has('termux')
+--- termux Termux environment (The *termux* and *android*
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not an objection, just curious: does vim.uv.os_uname() return enough info to achieve this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's gonna be terribly useful unfortunately.

-- package version: neovim 0.11.6-2
-- nvim --clean
{
  machine = "aarch64",
  release = "5.4.274-qgki-g6ef38bd89f5c",
  sysname = "Linux",
  version = "#1 SMP PREEMPT Wed Jan 28 16:01:13 CST 2026"
}

I get the same result with neovim-nightly (0.12.0~dev-2508+g61f166ec40)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything else come to mind that could be a useful proxy?
For compile time Android checking we usually use #ifdef __ANDROID__ and/or __TERMUX__.

We should be able to apply that to the src/nvim/eval/funcs.c part of this patch at least.
Which is taken from this prior original patch
https://github.com/termux/termux-packages/blob/994dcc0/packages/neovim/src-nvim-eval-funcs.c.patch

An equivalent patch also exists for our vim/vim-gtk package, so I should at least update that patch to include documentation of the feature flags as well.

I'm not sure how we could cleanly extrapolate the presence of those definitions from the C preprocessor to the doc generation,
or if we can use an equivalent proxy for that.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a build flag so that has('foo') works for an arbitrary build-time value, but yeah the docs are less obvious.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on updating the vim patch right now,
but yeah I'm still drawing a blank for making that conditional for the docs.

Copy link
Copy Markdown

@justinmk justinmk Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, we can just update the docs directly upstream. PR would be appreciated

mention this issue/PR so we have a reference

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess I'm making a PR to Vim and Neovim then.
I just finished reworking the vim patch as well.

I'm guessing specific wording can be worked out there, what I have here is just the first things that came to mind.

With the C pre-proc macro checks this also decouples the termux and android feature flags.
So if some other project wants to compile Vim/Neovim on Android they wouldn't necessarily inherit the termux feature, since the __TERMUX__ macro is added as part of out Android NDK patches.

--- ./usr/include/sys/cdefs.h.orig 2021-08-16 11:52:08.128876161 +0200
+++ ./usr/include/sys/cdefs.h 2021-08-16 11:52:08.555542676 +0200
@@ -372,3 +372,6 @@
#if __has_include(<android/ndk-version.h>)
#include <android/ndk-version.h>
#endif
+#define __TERMUX__ 1
+#define __TERMUX_PREFIX__ "@TERMUX_PREFIX@"
+

@TomJo2000 TomJo2000 force-pushed the nvim-has-termux-docs branch from 978717b to b356259 Compare March 9, 2026 22:39
@TomJo2000 TomJo2000 changed the title enhance(main/neovim{,-nightly}): document has('termux') feature flag enhance(main/neovim{,-nightly},main/vim,x11/vim-gtk): document has('termux') feature flag Mar 9, 2026
@TomJo2000 TomJo2000 closed this Mar 18, 2026
@TomJo2000 TomJo2000 deleted the nvim-has-termux-docs branch March 18, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

5 participants