Skip to content

Commit 51a904f

Browse files
committed
Fix arm
1 parent 58dfffd commit 51a904f

3 files changed

Lines changed: 37 additions & 9 deletions

File tree

test/distro-qemu/build-and-run.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ set -ex
33

44
# Configuration
55
KERNEL_VERSION="${1:-5.10.217}"
6-
QEMU_ARCH="${QEMU_ARCH:-x86_64}"
6+
# Auto-detect host architecture if QEMU_ARCH not set.
7+
case "$(uname -m)" in
8+
x86_64) _default_arch="x86_64" ;;
9+
aarch64) _default_arch="aarch64" ;;
10+
*) _default_arch="x86_64" ;;
11+
esac
12+
QEMU_ARCH="${QEMU_ARCH:-$_default_arch}"
713
DISTRO="${DISTRO:-ubuntu}" # debian or ubuntu
814
RELEASE="${RELEASE:-jammy}" # jammy/noble for ubuntu (with USDT probes), bullseye for debian
915
ROOTFS_DIR=$(mktemp -d /tmp/distro-qemu-rootfs.XXXXXX)
@@ -24,7 +30,7 @@ cleanup() {
2430
trap cleanup EXIT
2531

2632
# Download parcagpu library
27-
PARCAGPU_DIR="${PARCAGPU_DIR}" ./download-parcagpu.sh
33+
QEMU_ARCH="${QEMU_ARCH}" PARCAGPU_DIR="${PARCAGPU_DIR}" ./download-parcagpu.sh
2834

2935
echo "Building rootfs with $DISTRO $RELEASE..."
3036

@@ -65,14 +71,13 @@ if ! sudo debootstrap --variant=minbase \
6571
--arch="$DEBOOTSTRAP_ARCH" \
6672
--cache-dir="$CACHE_DIR" \
6773
--foreign \
74+
--include=libstdc++6 \
6875
"$RELEASE" "$ROOTFS_DIR" "$MIRROR" ; then
6976
echo "Debootstrap failed, log follows."
7077
cat "$ROOTFS_DIR/debootstrap/debootstrap.log"
7178
exit 1
7279
fi
7380

74-
75-
7681
# Change ownership of rootfs to current user to avoid needing sudo for subsequent operations
7782
sudo chown -R "$(id -u):$(id -g)" "$ROOTFS_DIR"
7883

@@ -124,13 +129,22 @@ fi
124129
cp "${OUTPUT_DIR}"/*.test "$ROOTFS_DIR/"
125130
cp "${PARCAGPU_DIR}/libparcagpucupti.so" "$ROOTFS_DIR/"
126131

127-
# Copy stub libcupti .so next to the .so (for the test's preload logic) and
128-
# into the RUNPATH (/usr/local/cuda/lib64) as a fallback for the dynamic linker.
132+
# Copy stub libcupti .so into the RUNPATH (/usr/local/cuda/lib64) so the
133+
# dynamic linker resolves the DT_NEEDED entry without a real CUDA install.
129134
mkdir -p "$ROOTFS_DIR/usr/local/cuda/lib64"
130135
for stub in "${PARCAGPU_DIR}"/libcupti.so*; do
131-
[ -f "$stub" ] && cp "$stub" "$ROOTFS_DIR/" && cp "$stub" "$ROOTFS_DIR/usr/local/cuda/lib64/"
136+
[ -f "$stub" ] && cp "$stub" "$ROOTFS_DIR/usr/local/cuda/lib64/"
132137
done
133138

139+
# Copy libstdc++ into the RUNPATH so the dynamic linker finds it.
140+
# Cross-arch debootstrap doesn't run ldconfig, leaving ld.so.cache incomplete,
141+
# so multiarch paths like /usr/lib/aarch64-linux-gnu/ aren't searched.
142+
LIBSTDCXX=$(find "$ROOTFS_DIR" -name 'libstdc++.so.6*' -type f | head -1)
143+
if [ -n "$LIBSTDCXX" ]; then
144+
cp "$LIBSTDCXX" "$ROOTFS_DIR/usr/local/cuda/lib64/"
145+
echo "Copied $(basename "$LIBSTDCXX") to RUNPATH"
146+
fi
147+
134148
# List dynamic dependencies for debugging
135149
echo "Test binary dependencies:"
136150
ldd "${OUTPUT_DIR}/rtld.test" || true
@@ -160,6 +174,10 @@ mount -t proc proc /proc 2>/dev/null || true
160174
mount -t sysfs sys /sys 2>/dev/null || true
161175
mount -t debugfs debugfs /sys/kernel/debug 2>/dev/null || true
162176
177+
# Rebuild ld.so cache so the linker finds libraries in multiarch paths
178+
# (e.g. /usr/lib/aarch64-linux-gnu/libstdc++.so.6).
179+
ldconfig 2>/dev/null || true
180+
163181
# Enable debug logging
164182
export DEBUG_TEST=1
165183

test/distro-qemu/download-kernel.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
set -e
33

44
KERNEL_VERSION="${1:-5.10.217}"
5-
QEMU_ARCH="${QEMU_ARCH:-x86_64}"
5+
case "$(uname -m)" in
6+
x86_64) _default_arch="x86_64" ;;
7+
aarch64) _default_arch="aarch64" ;;
8+
*) _default_arch="x86_64" ;;
9+
esac
10+
QEMU_ARCH="${QEMU_ARCH:-$_default_arch}"
611
KERN_DIR="${KERN_DIR:-ci-kernels}"
712

813
# Map QEMU arch to Docker platform

test/distro-qemu/download-parcagpu.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
#!/bin/bash
22
set -e
33

4-
QEMU_ARCH="${QEMU_ARCH:-x86_64}"
4+
case "$(uname -m)" in
5+
x86_64) _default_arch="x86_64" ;;
6+
aarch64) _default_arch="aarch64" ;;
7+
*) _default_arch="x86_64" ;;
8+
esac
9+
QEMU_ARCH="${QEMU_ARCH:-$_default_arch}"
510
PARCAGPU_DIR="${PARCAGPU_DIR:-parcagpu-lib}"
611

712
# Map QEMU arch to Docker platform

0 commit comments

Comments
 (0)