Bug 281009 - editors/neovim doesn't build (with ccache|as non-root)?
Summary: editors/neovim doesn't build (with ccache|as non-root)?
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Adam Weinberger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-23 10:31 UTC by Anton Saietskii
Modified: 2025-12-05 16:04 UTC (History)
5 users (show)

See Also:
bugzilla: maintainer-feedback? (adamw)


Attachments
poudriere build failure log (17.32 KB, application/x-xz)
2024-08-23 10:31 UTC, Anton Saietskii
no flags Details
v0 (apply via `git am`) (2.41 KB, patch)
2024-08-24 15:01 UTC, Anton Saietskii
vsasjason: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Saietskii 2024-08-23 10:31:41 UTC
Created attachment 253035 [details]
poudriere build failure log

For some reason, CMakeTestCCompiler.cmake fails due to /nonexistent dir which obviously doesn't exists. This affects neovim only, ~600 other ports are building totally fine including those using CMake as well.

loading initial cache file /wrkdirs/usr/ports/editors/neovim/work/.build/.deps/build/tmp/treesitter_query-cache-Release.cmake
-- The C compiler identification is Clang 18.1.5
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/local/libexec/ccache/cc
-- Check for working C compiler: /usr/local/libexec/ccache/cc - broken
CMake Error at /usr/local/share/cmake/Modules/CMakeTestCCompiler.cmake:67 (message):
  The C compiler

    "/usr/local/libexec/ccache/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: '/wrkdirs/usr/ports/editors/neovim/work/.build/.deps/build/src/treesitter_query-build/CMakeFiles/CMakeScratch/TryCompile-jEIFhw'
    
    Run Build Command(s): /usr/local/bin/ninja -v cmTC_eb36d
    [1/2] /usr/local/libexec/ccache/cc   -std=gnu99 -fPIE -MD -MT CMakeFiles/cmTC_eb36d.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_eb36d.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_eb36d.dir/testCCompiler.c.o -c /wrkdirs/usr/ports/editors/neovim/work/.build/.deps/build/src/treesitter_query-build/CMakeFiles/CMakeScratch/TryCompile-jEIFhw/testCCompiler.c
    FAILED: CMakeFiles/cmTC_eb36d.dir/testCCompiler.c.o 
    /usr/local/libexec/ccache/cc   -std=gnu99 -fPIE -MD -MT CMakeFiles/cmTC_eb36d.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_eb36d.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_eb36d.dir/testCCompiler.c.o -c /wrkdirs/usr/ports/editors/neovim/work/.build/.deps/build/src/treesitter_query-build/CMakeFiles/CMakeScratch/TryCompile-jEIFhw/testCCompiler.c
    ccache: error: Failed to create directory /nonexistent/.ccache/tmp: Permission denied
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
ninja: build stopped: subcommand failed.

*** Error code 1

Stop.
make: stopped in /usr/ports/editors/neovim
Comment 1 Anton Saietskii 2024-08-23 10:32:20 UTC
$ cat /usr/local/etc/poudriere.conf
#

ZPOOL=zroot
BASEFS=/usr/local/poudriere

BUILD_AS_NON_ROOT=yes
CCACHE_DIR=/var/cache/ccache/poudriere/
CCACHE_DIR_NON_ROOT_SAFE=yes
PORTBUILD_USER=pbuild
PORTBUILD_UID=65529

PARALLEL_JOBS=2
PREPARE_PARALLEL_JOBS=6
#ALLOW_MAKE_JOBS=yes
ALLOW_MAKE_JOBS_PACKAGES="pkg ccache gcc1* llvm1* node2* rust firefox libreoffice telegram-desktop"
MUTUALLY_EXCLUSIVE_BUILD_PACKAGES="gcc1* llvm1* node2* rust firefox libreoffice telegram-desktop"

DISTFILES_CACHE=/usr/ports/distfiles

NOLINUX=yes
USE_PROCFS=no
USE_FDESCFS=no
USE_TMPFS="data localbase wrkdir"
$ ll -dn /var/cache/ccache/poudriere/
drwxr-xr-x  19 65529 0 20 Aug 21 14:45 /var/cache/ccache/poudriere/
Comment 2 Benjamin Takacs 2024-08-23 11:16:02 UTC
that  ccache: error: Failed to create directory /nonexistent/.ccache/tmp: Permission denied  error means, that the buildsystem forgets CCACHE_DIR and HOME (set to somewhere inside workdir by the ports framework (I would argue it should get set to /nonexistent by the framework, to catch problems)) so ccache fallsback on its default location for the cache $HOME/.ccache and fails, as $HOME doesn't exists (which is good, because it identified a broken buildsystem)
Comment 3 Anton Saietskii 2024-08-24 15:01:50 UTC
Created attachment 253059 [details]
v0 (apply via `git am`)

This is an ugliest possible way to make it build. Also, pet portclippy/portfmt.
Comment 4 Adam Weinberger freebsd_committer freebsd_triage 2024-08-24 16:28:42 UTC
(In reply to Anton Saietskii from comment #3)

That will make it build, but the problem is that it builds just fine with ccache as root. As someone who has to rebuild neovim frequently, dropping ccache is my very last resort.

What I'm unclear on is whether the problem lies in neovim or in the ports framework.
Comment 5 Benjamin Takacs 2024-08-24 17:34:09 UTC
(In reply to Adam Weinberger from comment #4)

but does it really build fine or does it just appear to build fine, as the fallback ccache location /root/.ccache/ is writeable by root?

As other ports pass along CCACH_DIR fine to the underlying buildsystem, it would be strange if the port is at fault here, but not impossible
Comment 6 Anton Saietskii 2024-08-24 18:15:32 UTC
(In reply to Adam Weinberger from comment #4)

> What I'm unclear on is whether the problem lies in neovim or in the ports framework.
neovim ofc. As I indicated in comment #1, considerable count of other ports builds fine with non-root ccache.
Comment 7 Benjamin Takacs 2024-08-26 09:10:18 UTC
looking into the build log, it seems like that port builds some of its dependencies (like treesitter) itself and looses some variables there. Could these dependencies made into ports instead?

The way neovim does it also violates the seperation into configure and build phase, as it uses cmake to configure these dependencies in the build phase instead of in the configure phase.
Comment 8 Adam Weinberger freebsd_committer freebsd_triage 2025-12-05 15:30:11 UTC
(In reply to Benjamin Takacs from comment #7)
I just realized that your comment probably identified the actual problem.

Could this be as simple as passing the correct CCACHE_DIR when building the tree-sitter parsers?

And Benjamin: as it is written, it it supposed config the parsers during post-configure, and then build them in post-build. If cmake needs to be called differently, then please show me what it should do instead. There's no value to building them as a separate port. They are required for neovim, they must be built within the neovim source tree, and they require that neovim do-configure: is completed. Creating a separate port means needing to duplicate the same code into another port, and always keeping them 100% in sync.
Comment 9 Adam Weinberger freebsd_committer freebsd_triage 2025-12-05 15:31:54 UTC
Also: I'm fine with adding NO_CCACHE as long as it's behind an OPTION. But really this is a problem with neovim's cmake configuration, and it should be reported upstream.
Comment 10 Benjamin Takacs 2025-12-05 16:04:14 UTC
(In reply to Adam Weinberger from comment #8)
Looking at the port, yes that post-build target forgets to pass along variables, probably changing it to

${SETENVI} ${WRK_ENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} --build ${BUILD_WRKSRC}/.deps

should correct that mistake (inspired by Mk/Uses/cmake.mk)