From 83c484119032e9987779bdfa3cd4a4aff6bd2ab0 Mon Sep 17 00:00:00 2001 From: Jookia Date: Fri, 26 Jun 2026 23:57:14 +1000 Subject: [PATCH] Patch Python 3.13 and newer CPUID use --- module/prepare_source.py | 4 ++++ patch/python/mimalloc-cpuid-check.patch | 14 ++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 patch/python/mimalloc-cpuid-check.patch diff --git a/module/prepare_source.py b/module/prepare_source.py index 44bd1ae..967af29 100644 --- a/module/prepare_source.py +++ b/module/prepare_source.py @@ -450,6 +450,10 @@ def _python(ver: BranchProfile, paths: ProjectPaths, download_only: bool): patch(paths.src_dir.python, paths.patch_dir / 'python/fix-mingw-build_3.12.patch') shutil.copy(paths.patch_dir / 'python/python-config.sh', paths.src_dir.python / 'python-config.sh') + # Fix CPUID use + if v >= Version('3.13'): + patch(paths.src_dir.python, paths.patch_dir / 'python/mimalloc-cpuid-check.patch') + patch_done(paths.src_dir.python) def _setuptools(ver: BranchProfile, paths: ProjectPaths, download_only: bool): diff --git a/patch/python/mimalloc-cpuid-check.patch b/patch/python/mimalloc-cpuid-check.patch new file mode 100644 index 0000000..87f0309 --- /dev/null +++ b/patch/python/mimalloc-cpuid-check.patch @@ -0,0 +1,14 @@ +--- a/Objects/mimalloc/init.c 2026-06-27 03:20:13.530317083 +1000 ++++ b/Objects/mimalloc/init.c 2026-06-27 03:22:47.593182651 +1000 +@@ -529,8 +529,9 @@ + + static void mi_detect_cpu_features(void) { + // FSRM for fast rep movsb support (AMD Zen3+ (~2020) or Intel Ice Lake+ (~2017)) +- int32_t cpu_info[4]; +- __cpuid(cpu_info, 7); ++ int32_t cpu_info[4] = {0}; ++ if (__get_cpuid_max(0, NULL) > 0) ++ __cpuid(cpu_info, 7); + _mi_cpu_has_fsrm = ((cpu_info[3] & (1 << 4)) != 0); // bit 4 of EDX : see + } + #else