From bfd49c41b9b732f4472cce381609988821b91bf8 Mon Sep 17 00:00:00 2001 From: bopof Date: Tue, 14 Jul 2026 22:07:56 +0200 Subject: [PATCH] Makefile: select $(PYTHON) from the host, not the target triple (#205) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clean/test-c/test-python run python on the build host, but $(PYTHON) was chosen from $(IS_WIN), which is derived from the target triple ($(CC) -dumpmachine). A Linux->mingw cross build (make CC=x86_64-w64-mingw32-gcc ...) therefore sets IS_WIN and picks `python`, which fails on hosts where only `python3` exists (e.g. Debian/Ubuntu) — breaking the cross-compile path #171 added. Key PYTHON off the host instead: $(OS)=Windows_NT (the #129 signal) is set in every Windows shell and empty on Linux/macOS. EXE stays driven by the target triple, as it should. Addresses @rofl0r's host/target note on #171. Co-authored-by: bopof <285767350+bopof@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 --- c/Makefile | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/c/Makefile b/c/Makefile index c9b7fc3..de8313c 100644 --- a/c/Makefile +++ b/c/Makefile @@ -134,10 +134,16 @@ NVCCFLAGS ?= -O3 -std=c++17 -arch=$(CUDA_ARCH) -Xcompiler=-W3 else NVCCFLAGS ?= -O3 -std=c++17 -arch=$(CUDA_ARCH) -Xcompiler=-Wall,-Wextra endif -ifeq ($(IS_WIN),) -PYTHON ?= python3 -else +# PYTHON is a HOST tool (clean/test-c/test-python run it on the build machine), +# so key it off the host, NOT $(IS_WIN) — which is derived from the *target* +# triple ($(CC) -dumpmachine). Otherwise a cross build (make CC=x86_64-w64- +# mingw32-gcc ... on Linux) sets IS_WIN and picks `python`, breaking clean/test +# on hosts where only `python3` exists. $(OS)=Windows_NT in every Windows shell +# (the #129 signal) and is empty on Linux/macOS. +ifeq ($(OS),Windows_NT) PYTHON ?= python +else +PYTHON ?= python3 endif CUDA_OBJ = TEST_BINS = tests/test_json$(EXE) tests/test_st$(EXE) tests/test_tier$(EXE) tests/test_grammar$(EXE) tests/test_schema_gbnf$(EXE) tests/test_decode_batch$(EXE) tests/test_idot$(EXE) tests/test_i4_acc512$(EXE) tests/test_compat_direct$(EXE)