|
| 1 | +import os |
1 | 2 | import platform |
2 | 3 | import sys |
3 | 4 |
|
|
30 | 31 |
|
31 | 32 | ccompiler.CCompiler.__spawn = ccompiler.CCompiler.spawn # type: ignore[attr-defined] |
32 | 33 | X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64") |
| 34 | +PYODIDE = "PYODIDE" in os.environ |
33 | 35 |
|
34 | 36 |
|
35 | 37 | def spawn(self, cmd, **kwargs) -> None: # type: ignore[no-untyped-def] |
36 | | - compiler_type: str = self.compiler_type |
37 | | - extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT[compiler_type] |
38 | | - new_cmd = list(cmd) |
39 | | - if X86_64 and extra_options is not None: |
40 | | - # filenames are closer to the end of command line |
| 38 | + if PYODIDE: |
| 39 | + new_cmd = list(cmd) |
41 | 40 | for argument in reversed(new_cmd): |
42 | | - # Check if the matching argument contains a source filename. |
43 | 41 | if not str(argument).endswith(".c"): |
44 | 42 | continue |
| 43 | + if "base64/arch/" in str(argument): |
| 44 | + new_cmd.extend(["-msimd128"]) |
| 45 | + else: |
| 46 | + compiler_type: str = self.compiler_type |
| 47 | + extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT[compiler_type] |
| 48 | + new_cmd = list(cmd) |
| 49 | + if X86_64 and extra_options is not None: |
| 50 | + # filenames are closer to the end of command line |
| 51 | + for argument in reversed(new_cmd): |
| 52 | + # Check if the matching argument contains a source filename. |
| 53 | + if not str(argument).endswith(".c"): |
| 54 | + continue |
45 | 55 |
|
46 | | - for path in extra_options.keys(): |
47 | | - if path in str(argument): |
48 | | - if compiler_type == "bcpp": |
49 | | - compiler = new_cmd.pop() |
50 | | - # Borland accepts a source file name at the end, |
51 | | - # insert the options before it |
52 | | - new_cmd.extend(extra_options[path]) |
53 | | - new_cmd.append(compiler) |
54 | | - else: |
55 | | - new_cmd.extend(extra_options[path]) |
56 | | - |
57 | | - # path component is found, no need to search any further |
58 | | - break |
| 56 | + for path in extra_options.keys(): |
| 57 | + if path in str(argument): |
| 58 | + if compiler_type == "bcpp": |
| 59 | + compiler = new_cmd.pop() |
| 60 | + # Borland accepts a source file name at the end, |
| 61 | + # insert the options before it |
| 62 | + new_cmd.extend(extra_options[path]) |
| 63 | + new_cmd.append(compiler) |
| 64 | + else: |
| 65 | + new_cmd.extend(extra_options[path]) |
| 66 | + |
| 67 | + # path component is found, no need to search any further |
| 68 | + break |
59 | 69 | self.__spawn(new_cmd, **kwargs) |
60 | 70 |
|
61 | 71 |
|
|
0 commit comments