From bfa85605bf6a5f7af5673c5ba84d8e70aec60325 Mon Sep 17 00:00:00 2001 From: Mobin Aydinfar Date: Thu, 25 Dec 2025 15:24:00 +0330 Subject: [PATCH] configure: fix broken cross-compilation detection Assume the build as native if both $CXX and $CXX_FOR_BUILD have the same value. If the compiler for the host and the build machine are the same, it's a native build. There is a chance that the user may set both $CXX and $CXX_FOR_BUILD to the same compiler. For example, cbuild (Chimera Linux package builder) sets both variables regardless of native or cross build and because we use $CXX_FOR_BUILD for detecting cross build, we should unset that variable in this case. Also, GNU autotools detects this case and assumes the build as native. --- configure | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure b/configure index c3ea70b4..4b4ec930 100755 --- a/configure +++ b/configure @@ -450,6 +450,16 @@ for arg in "$@"; do esac done +## Assume the build as native if both $CXX and $CXX_FOR_BUILD have the same value. +# If the compiler for the host and the build machine are the same, it's a native build. There is a +# chance that the user may set both $CXX and $CXX_FOR_BUILD to the same compiler. For example, +# cbuild (Chimera Linux package builder) sets both variables regardless of native or cross build +# and because we use $CXX_FOR_BUILD for detecting cross build, we should unset that variable in +# this case. Also, GNU autotools detects this case and assumes the build as native. +if [ -n "${CXX_FOR_BUILD:-}" ] && [ "$CXX_FOR_BUILD" = "$CXX" ]; then + unset CXX_FOR_BUILD +fi + ## Check platform is specified for a cross-build if [ -n "${CXX_FOR_BUILD:-}" ]; then if [ -z "${PLATFORM:-}" ]; then