From 886f29e1f6b8184b8221ac620455917595b65088 Mon Sep 17 00:00:00 2001 From: Maksym Shkolnyi Date: Wed, 3 Sep 2025 20:24:17 +0200 Subject: [PATCH] config: Add warning if ARCH environment variable is set If ARCH environment variable is set it can cause the failure of the kernel modules check during the configure step. The resulting error will be confusing, and may looks like this: > checking for kernel config option compatibility... done > checking whether CONFIG_MODULES is defined... no > configure: error: > *** This kernel does not include the required loadable module > *** support! Detect when ARCH is print a warning. Reviewed-by: Brian Behlendorf Signed-off-by: Maksym Shkolnyi Closes #17680 --- config/always-arch.m4 | 17 +++++++++++++++++ config/zfs-build.m4 | 1 + 2 files changed, 18 insertions(+) diff --git a/config/always-arch.m4 b/config/always-arch.m4 index 9f413eedd..1ee6099ca 100644 --- a/config/always-arch.m4 +++ b/config/always-arch.m4 @@ -39,3 +39,20 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_ARCH], [ AM_CONDITIONAL([TARGET_CPU_SPARC64], test $TARGET_CPU = sparc64) AM_CONDITIONAL([TARGET_CPU_ARM], test $TARGET_CPU = arm) ]) +dnl # +dnl # Check for conflicting environment variables +dnl # +dnl # If ARCH env variable is set up, then kernel Makefile in the /usr/src/kernel +dnl # can misbehave during the zfs ./configure test of the module compilation. +AC_DEFUN([ZFS_AC_CONFIG_CHECK_ARCH_VAR], [ + AC_MSG_CHECKING([for conflicting environment variables]) + if test -n "$ARCH"; then + AC_MSG_RESULT([warning]) + AC_MSG_WARN(m4_normalize([ARCH environment variable is set to "$ARCH". + This can cause build kernel modules support check failure. + Please unset it.])) + else + AC_MSG_RESULT([done]) + fi +]) + diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index fd92614f6..adf6576f3 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -266,6 +266,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [ ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD ZFS_AC_CONFIG_ALWAYS_SYSTEM ZFS_AC_CONFIG_ALWAYS_ARCH + ZFS_AC_CONFIG_CHECK_ARCH_VAR ZFS_AC_CONFIG_ALWAYS_PYTHON ZFS_AC_CONFIG_ALWAYS_PYZFS ZFS_AC_CONFIG_ALWAYS_SED