From 356652733741f2c168dd3876df2d84b9569d832b Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Thu, 1 Jan 2026 10:03:11 -0700 Subject: [PATCH] Allow disabling extra flags with MYPYC_NO_EXTRA_FLAGS env variable We need a way to disable these when cross compiling as these flags will break due to picking up the host rather than the target. --- mypyc/build_setup.py | 3 ++- mypyc/lib-rt/build_setup.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mypyc/build_setup.py b/mypyc/build_setup.py index 2354853b3808..2c2cf56345c0 100644 --- a/mypyc/build_setup.py +++ b/mypyc/build_setup.py @@ -36,6 +36,7 @@ ccompiler.CCompiler.__spawn = ccompiler.CCompiler.spawn # type: ignore[attr-defined] X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64") PYODIDE = "PYODIDE" in os.environ +NO_EXTRA_FLAGS = "MYPYC_NO_EXTRA_FLAGS" in os.environ def spawn(self, cmd, **kwargs) -> None: # type: ignore[no-untyped-def] @@ -46,7 +47,7 @@ def spawn(self, cmd, **kwargs) -> None: # type: ignore[no-untyped-def] continue if "base64/arch/" in str(argument): new_cmd.extend(["-msimd128"]) - else: + elif not NO_EXTRA_FLAGS: compiler_type: str = self.compiler_type extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT.get(compiler_type, None) new_cmd = list(cmd) diff --git a/mypyc/lib-rt/build_setup.py b/mypyc/lib-rt/build_setup.py index 2354853b3808..2c2cf56345c0 100644 --- a/mypyc/lib-rt/build_setup.py +++ b/mypyc/lib-rt/build_setup.py @@ -36,6 +36,7 @@ ccompiler.CCompiler.__spawn = ccompiler.CCompiler.spawn # type: ignore[attr-defined] X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64") PYODIDE = "PYODIDE" in os.environ +NO_EXTRA_FLAGS = "MYPYC_NO_EXTRA_FLAGS" in os.environ def spawn(self, cmd, **kwargs) -> None: # type: ignore[no-untyped-def] @@ -46,7 +47,7 @@ def spawn(self, cmd, **kwargs) -> None: # type: ignore[no-untyped-def] continue if "base64/arch/" in str(argument): new_cmd.extend(["-msimd128"]) - else: + elif not NO_EXTRA_FLAGS: compiler_type: str = self.compiler_type extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT.get(compiler_type, None) new_cmd = list(cmd)