termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.34k stars 3.07k forks source link

Add CMAKE_FIND_USE_INSTALL_PREFIX=OFF to our CMake flags #22315

Open pipcet opened 3 days ago

pipcet commented 3 days ago

TL;DR Can we apply this patch to a test system and see whether it makes things better or worse?

Here's the issue:

  1. start with a fresh docker container; note that it doesn't (and shouldn't) contain a "ccache" binary in the path. (I used sha256:25e51469574b174a940bc7970cba71d8f96ce228c8ddf7a60aedd61f32c87c68)
  2. ./build-package.sh -I ccache
  3. ./build-package.sh -I swiftshader
  4. /bin/sh: 1: ccache: not found

The build process assumes there's a "ccache" binary in the path, even though the only copy of "ccache" is that in the /data directory. The problem is that CMake's find_program searches the install prefix unless CMAKE_FIND_USE_INSTALL_PREFIX is set, even though CMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER is also set and affects the same directory.

Problems:

  1. CMake doesn't document whether find_program is ever validly used to search for target executables rather than host executables. If that is the case, this change might break other packages.
  2. swiftshader is broken. Its CMake code looks like this:
    # Use CCache if available
    find_program(CCACHE_FOUND ccache)
    if(CCACHE_FOUND)
    message(STATUS "Using ccache")
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
    set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
    endif()

    Obviously, it's perfectly possible for ccache to be a findable program but not reside on the PATH, but the code assumes it's always in the cache.

(It's generally a bad idea to automatically enable ccache without an explicit flag, but that's a swiftshader problem, and we have to live with the broken CMakeLists.txt provided by the package maintainer)

This popped up while working on #22305, but is unrelated.

Biswa96 commented 2 days ago

Could you please clarify whether this change might create any issues with the on-device package build?

pipcet commented 2 days ago

Could you please clarify whether this change might create any issues with the on-device package build?

Good point. Maybe we should move this change to the section:

    if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then

@TomJo2000 , does that make sense to you? I don't know anything about on-device termux builds...

TomJo2000 commented 2 days ago

Right I think that's what was nagging at the back of my mind. During on-device builds those are valid for CMake to pick.

TomJo2000 commented 2 days ago

If I could trouble either of you two for some symbol-fu really quick. I'm having a hard time reasoning out why nvim's Lua runtime isn't providing symbols to modules correctly like luajit or lua5.1 do.