Skip to content

Commit 704aee6

Browse files
Allow disabling extra flags with MYPYC_NO_EXTRA_FLAGS env variable (#20507)
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. Should fix: ``` /home/buildroot/buildroot/output/per-package/python-librt/host/bin/aarch64-linux-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g0 -D_FORTIFY_SOURCE=1 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -I. -Ibase64 -I/home/buildroot/buildroot/output/build/python3-3.13.11/Include -I/home/buildroot/buildroot/output/build/python3-3.13.11 -c base64/arch/avx/codec.c -o build/temp.linux-aarch64-cpython-313/base64/arch/avx/codec.o -O3 -Wno-unused-function -mavx aarch64-linux-gcc.br_real: error: unrecognized command-line option ‘-mavx’ error: command '/home/buildroot/buildroot/output/per-package/python-librt/host/bin/aarch64-linux-gcc' failed with exit code 1 ```
1 parent c5c12fa commit 704aee6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mypyc/build_setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
ccompiler.CCompiler.__spawn = ccompiler.CCompiler.spawn # type: ignore[attr-defined]
3737
X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64")
3838
PYODIDE = "PYODIDE" in os.environ
39+
NO_EXTRA_FLAGS = "MYPYC_NO_EXTRA_FLAGS" in os.environ
3940

4041

4142
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]
4647
continue
4748
if "base64/arch/" in str(argument):
4849
new_cmd.extend(["-msimd128"])
49-
else:
50+
elif not NO_EXTRA_FLAGS:
5051
compiler_type: str = self.compiler_type
5152
extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT.get(compiler_type, None)
5253
new_cmd = list(cmd)

mypyc/lib-rt/build_setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
ccompiler.CCompiler.__spawn = ccompiler.CCompiler.spawn # type: ignore[attr-defined]
3737
X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64")
3838
PYODIDE = "PYODIDE" in os.environ
39+
NO_EXTRA_FLAGS = "MYPYC_NO_EXTRA_FLAGS" in os.environ
3940

4041

4142
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]
4647
continue
4748
if "base64/arch/" in str(argument):
4849
new_cmd.extend(["-msimd128"])
49-
else:
50+
elif not NO_EXTRA_FLAGS:
5051
compiler_type: str = self.compiler_type
5152
extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT.get(compiler_type, None)
5253
new_cmd = list(cmd)

0 commit comments

Comments
 (0)