Skip to content

The agent that grows with you

fix(termux): keep apt's libc++ ahead of the payload's on the build linker path

ethernet5d8eafbc8850
diff --git a/scripts/termux/termux_build.sh b/scripts/termux/termux_build.sh
index c0b20bd2136..9c26492129f 100755
--- a/scripts/termux/termux_build.sh
+++ b/scripts/termux/termux_build.sh
@@ -44,7 +44,14 @@ if [ "${1:-}" = "--in-container" ]; then
# (linkerconfig on-device). Inside the container the tree lives at
# $PAYLOAD_ROOT/python$PREFIX, so the dynamic linker needs to be told
# where the payload's libs live before any staged binary runs.
- export LD_LIBRARY_PATH="$PAYLOAD_ROOT/python$PREFIX/lib:$PAYLOAD_ROOT/node$PREFIX/lib:$PAYLOAD_ROOT/runtime-libs/lib:$PREFIX/lib"
+ # $SYSTEM_LIBCXX_DIR leads on purpose. The payload pins libc++ 29, but the toolchain below
+ # needs the libc++ 30 that apt installs, and a library found on LD_LIBRARY_PATH beats the
+ # binary's own RUNPATH. With the payload dir first, apt's cmake cannot start, scikit-build-core
+ # reads that as "no cmake" and compiles one from PyPI source (pillow -> pybind11 -> cmake
+ # bootstrap). The dir holds only that one symlink, made after apt runs, so no other payload
+ # lib is shadowed.
+ SYSTEM_LIBCXX_DIR="$PREFIX/tmp/system-libcxx"
+ export LD_LIBRARY_PATH="$SYSTEM_LIBCXX_DIR:$PAYLOAD_ROOT/python$PREFIX/lib:$PAYLOAD_ROOT/node$PREFIX/lib:$PAYLOAD_ROOT/runtime-libs/lib:$PREFIX/lib"
if [ -n "$PAYLOAD_ROOT" ] && [ -x "$STAGED_PY" ]; then
PY="$STAGED_PY"
log "Using the staged payload Python ($PY)"
@@ -77,6 +84,10 @@ if [ "${1:-}" = "--in-container" ]; then
libyaml openssl readline zlib liblzma libsqlite ncurses \
|| fail "apt install of the build toolchain failed"
fi
+ mkdir -p "$SYSTEM_LIBCXX_DIR"
+ ln -sf "$PREFIX/lib/libc++_shared.so" "$SYSTEM_LIBCXX_DIR/libc++_shared.so"
+ cmake -E capabilities >/dev/null 2>&1 \
+ || fail "container cmake cannot start; the wheel build would compile cmake from source"
# BINARIES, not package names: the rust package provides rustc/cargo
# (there is no `rust` binary).
for tool in clang rustc cargo make git; do