From ba06b454f38d3ad3a8d8801f21c9dc9891584c82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sat, 19 Sep 2026 10:45:03 -0600 Subject: [PATCH] loongarch64 cross build: don't assume an x86-64 host The GL stub generation in b.sh and setup-loongarch64-cross.sh harvested symbols from hardcoded /usr/lib/x86_64-linux-gnu paths. On any other host those simply don't exist, and neither script treats that as an error - so the stub silently fell back to the handful of GLX symbols listed inline, which isn't enough for GLEW's static archive to link against. Ask the host compiler for its multiarch triplet instead. Co-Authored-By: Claude Opus 5 (1M context) --- b.sh | 7 ++++--- cmake/scripts/setup-loongarch64-cross.sh | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/b.sh b/b.sh index a7683d0fb0..2cae01608b 100755 --- a/b.sh +++ b/b.sh @@ -133,10 +133,11 @@ if [ ! -z "$LOONGARCH64_BUILD" ]; then STUB_C=$(mktemp /tmp/gl_stub_XXXXXX.c) echo "/* Loongarch64 GL/GLX stub - cross-compilation only */" > "$STUB_C" # Collect all T (exported) symbols from GL/GLX libs, deduplicate, emit stubs + HOST_MULTIARCH=$(gcc -print-multiarch 2>/dev/null || dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null) { - for lib in /usr/lib/x86_64-linux-gnu/libGL.so.1 \ - /usr/lib/x86_64-linux-gnu/libGLX.so.0 \ - /usr/lib/x86_64-linux-gnu/libGLdispatch.so.0; do + for lib in /usr/lib/$HOST_MULTIARCH/libGL.so.1 \ + /usr/lib/$HOST_MULTIARCH/libGLX.so.0 \ + /usr/lib/$HOST_MULTIARCH/libGLdispatch.so.0; do [ -f "$lib" ] && nm -D "$lib" 2>/dev/null | awk '/^[0-9a-f]+ T /{ print $3 }' done # Always include the minimal GLX symbols GLEW directly references diff --git a/cmake/scripts/setup-loongarch64-cross.sh b/cmake/scripts/setup-loongarch64-cross.sh index 978dbcebc1..e6a6323dd6 100755 --- a/cmake/scripts/setup-loongarch64-cross.sh +++ b/cmake/scripts/setup-loongarch64-cross.sh @@ -32,10 +32,12 @@ done # B26 branch to address 0 would overflow on LoongArch). echo "Generating libGL.so stub..." +HOST_MULTIARCH=$(gcc -print-multiarch 2>/dev/null || dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null) + HOST_GL="" for candidate in \ - /usr/lib/x86_64-linux-gnu/libGL.so.1 \ - /usr/lib/x86_64-linux-gnu/libGL.so \ + /usr/lib/$HOST_MULTIARCH/libGL.so.1 \ + /usr/lib/$HOST_MULTIARCH/libGL.so \ /usr/lib/libGL.so.1 ; do [ -f "$candidate" ] && HOST_GL="$candidate" && break done