diff --git a/iso/builder/build-nvidia-module.sh b/iso/builder/build-nvidia-module.sh index c54f77c..8c06f9a 100644 --- a/iso/builder/build-nvidia-module.sh +++ b/iso/builder/build-nvidia-module.sh @@ -23,17 +23,24 @@ DEBIAN_KERNEL_ABI="$3" [ -n "$DEBIAN_KERNEL_ABI" ] || { echo "usage: $0 "; exit 1; } KVER="${DEBIAN_KERNEL_ABI}-amd64" -KDIR="/usr/src/linux-headers-${KVER}" +# On Debian, kernel headers are split into two packages: +# linux-headers- — arch-specific (generated, Makefile) +# linux-headers--common — common source headers (linux/, asm-generic/, etc.) +# NVIDIA conftest needs SYSSRC pointing to common (for source headers like linux/mm.h) +# and SYSOUT pointing to amd64 (for generated headers like autoconf.h, asm/). +KDIR_ARCH="/usr/src/linux-headers-${KVER}" +KDIR_COMMON="/usr/src/linux-headers-${DEBIAN_KERNEL_ABI}-common" echo "=== NVIDIA ${NVIDIA_VERSION} (proprietary) for kernel ${KVER} ===" -if [ ! -d "$KDIR" ]; then +if [ ! -d "$KDIR_ARCH" ] || [ ! -d "$KDIR_COMMON" ]; then echo "=== installing linux-headers-${KVER} ===" DEBIAN_FRONTEND=noninteractive apt-get install -y \ "linux-headers-${KVER}" \ gcc make perl fi -echo "kernel headers: $KDIR" +echo "kernel headers (arch): $KDIR_ARCH" +echo "kernel headers (common): $KDIR_COMMON" CACHE_DIR="${DIST_DIR}/nvidia-${NVIDIA_VERSION}-${KVER}" if [ -d "$CACHE_DIR/modules" ] && [ -f "$CACHE_DIR/bin/nvidia-smi" ]; then @@ -86,12 +93,16 @@ echo "kernel source: $KERNEL_SRC" # Build kernel modules # CFLAGS_MODULE: add GCC include dir so NVIDIA's nv_stdarg.h can find stdarg.h. # Kernel build uses -nostdinc which strips GCC's own includes; we restore it here. -GCC_INCLUDES=$(gcc --print-file-name=include 2>/dev/null || echo "") echo "=== building kernel modules ($(nproc) cores) ===" cd "$KERNEL_SRC" +# SYSSRC=common: conftest finds real kernel headers (linux/mm.h etc.) +# SYSOUT=amd64: generated headers (autoconf.h, asm/) from arch package +# Without this split, conftest uses amd64/include/ which is nearly empty, +# all compile-tests fail silently, and NVIDIA assumes all APIs present → link errors. make -j$(nproc) \ - KERNEL_UNAME="$KVER" SYSSRC="$KDIR" \ - CFLAGS_MODULE="${GCC_INCLUDES:+-I${GCC_INCLUDES}} -Wno-error" \ + KERNEL_UNAME="$KVER" \ + SYSSRC="$KDIR_COMMON" \ + SYSOUT="$KDIR_ARCH" \ modules 2>&1 | tail -10 # Collect outputs