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