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) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-09-19 11:52:16 -06:00
1 parent af929f8e45
commit ba06b454f3
2 files changed
+8 -5

No files matched your search

+4 -3
View File
@@ -133,10 +133,11 @@ if [ ! -z "$LOONGARCH64_BUILD" ]; then
STUB_C=$(mktemp /tmp/gl_stub_XXXXXX.c) STUB_C=$(mktemp /tmp/gl_stub_XXXXXX.c)
echo "/* Loongarch64 GL/GLX stub - cross-compilation only */" > "$STUB_C" echo "/* Loongarch64 GL/GLX stub - cross-compilation only */" > "$STUB_C"
# Collect all T (exported) symbols from GL/GLX libs, deduplicate, emit stubs # 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 \ for lib in /usr/lib/$HOST_MULTIARCH/libGL.so.1 \
/usr/lib/x86_64-linux-gnu/libGLX.so.0 \ /usr/lib/$HOST_MULTIARCH/libGLX.so.0 \
/usr/lib/x86_64-linux-gnu/libGLdispatch.so.0; do /usr/lib/$HOST_MULTIARCH/libGLdispatch.so.0; do
[ -f "$lib" ] && nm -D "$lib" 2>/dev/null | awk '/^[0-9a-f]+ T /{ print $3 }' [ -f "$lib" ] && nm -D "$lib" 2>/dev/null | awk '/^[0-9a-f]+ T /{ print $3 }'
done done
# Always include the minimal GLX symbols GLEW directly references # Always include the minimal GLX symbols GLEW directly references
+4 -2
View File
@@ -32,10 +32,12 @@ done
# B26 branch to address 0 would overflow on LoongArch). # B26 branch to address 0 would overflow on LoongArch).
echo "Generating libGL.so stub..." echo "Generating libGL.so stub..."
HOST_MULTIARCH=$(gcc -print-multiarch 2>/dev/null || dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null)
HOST_GL="" HOST_GL=""
for candidate in \ for candidate in \
/usr/lib/x86_64-linux-gnu/libGL.so.1 \ /usr/lib/$HOST_MULTIARCH/libGL.so.1 \
/usr/lib/x86_64-linux-gnu/libGL.so \ /usr/lib/$HOST_MULTIARCH/libGL.so \
/usr/lib/libGL.so.1 ; do /usr/lib/libGL.so.1 ; do
[ -f "$candidate" ] && HOST_GL="$candidate" && break [ -f "$candidate" ] && HOST_GL="$candidate" && break
done done