Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions mypyc/build_setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import platform
import sys

Expand Down Expand Up @@ -30,32 +31,41 @@

ccompiler.CCompiler.__spawn = ccompiler.CCompiler.spawn # type: ignore[attr-defined]
X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64")
PYODIDE = "PYODIDE" in os.environ


def spawn(self, cmd, **kwargs) -> None: # type: ignore[no-untyped-def]
compiler_type: str = self.compiler_type
extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT[compiler_type]
new_cmd = list(cmd)
if X86_64 and extra_options is not None:
# filenames are closer to the end of command line
if PYODIDE:
new_cmd = list(cmd)
for argument in reversed(new_cmd):
# Check if the matching argument contains a source filename.
if not str(argument).endswith(".c"):
continue
if "base64/arch/" in str(argument):
new_cmd.extend(["-msimd128"])
else:
compiler_type: str = self.compiler_type
extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT[compiler_type]
new_cmd = list(cmd)
if X86_64 and extra_options is not None:
# filenames are closer to the end of command line
for argument in reversed(new_cmd):
# Check if the matching argument contains a source filename.
if not str(argument).endswith(".c"):
continue

for path in extra_options.keys():
if path in str(argument):
if compiler_type == "bcpp":
compiler = new_cmd.pop()
# Borland accepts a source file name at the end,
# insert the options before it
new_cmd.extend(extra_options[path])
new_cmd.append(compiler)
else:
new_cmd.extend(extra_options[path])

# path component is found, no need to search any further
break
for path in extra_options.keys():
if path in str(argument):
if compiler_type == "bcpp":
compiler = new_cmd.pop()
# Borland accepts a source file name at the end,
# insert the options before it
new_cmd.extend(extra_options[path])
new_cmd.append(compiler)
else:
new_cmd.extend(extra_options[path])

# path component is found, no need to search any further
break
self.__spawn(new_cmd, **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion mypyc/lib-rt/base64/arch/neon64/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <arm_neon.h>

// Only enable inline assembly on supported compilers.
#if defined(__GNUC__) || defined(__clang__)
#if !defined(__wasm__) && (defined(__GNUC__) || defined(__clang__))
#define BASE64_NEON64_USE_ASM
#endif

Expand Down
2 changes: 1 addition & 1 deletion mypyc/lib-rt/base64/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define BASE64_WITH_NEON32 0
#define HAVE_NEON32 BASE64_WITH_NEON32

#if defined(__APPLE__) && defined(__aarch64__)
#if (defined(__APPLE__) && defined(__aarch64__)) || (defined(__wasm__) && defined(__wasm_simd128__))
#define BASE64_WITH_NEON64 1
#else
#define BASE64_WITH_NEON64 0
Expand Down
49 changes: 29 additions & 20 deletions mypyc/lib-rt/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,41 @@

ccompiler.CCompiler.__spawn = ccompiler.CCompiler.spawn # type: ignore[attr-defined]
X86_64 = platform.machine() in ("x86_64", "AMD64", "amd64")
PYODIDE = "PYODIDE" in os.environ


def spawn(self, cmd, **kwargs) -> None: # type: ignore[no-untyped-def]
compiler_type: str = self.compiler_type
extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT[compiler_type]
new_cmd = list(cmd)
if X86_64 and extra_options is not None:
# filenames are closer to the end of command line
if PYODIDE:
new_cmd = list(cmd)
for argument in reversed(new_cmd):
# Check if the matching argument contains a source filename.
if not str(argument).endswith(".c"):
continue

for path in extra_options.keys():
if path in str(argument):
if compiler_type == "bcpp":
compiler = new_cmd.pop()
# Borland accepts a source file name at the end,
# insert the options before it
new_cmd.extend(extra_options[path])
new_cmd.append(compiler)
else:
new_cmd.extend(extra_options[path])

# path component is found, no need to search any further
break
if "base64/arch/" in str(argument):
new_cmd.extend(["-msimd128"])
else:
compiler_type: str = self.compiler_type
extra_options = EXTRA_FLAGS_PER_COMPILER_TYPE_PER_PATH_COMPONENT[compiler_type]
new_cmd = list(cmd)
if X86_64 and extra_options is not None:
# filenames are closer to the end of command line
for argument in reversed(new_cmd):
# Check if the matching argument contains a source filename.
if not str(argument).endswith(".c"):
continue

for path in extra_options.keys():
if path in str(argument):
if compiler_type == "bcpp":
compiler = new_cmd.pop()
# Borland accepts a source file name at the end,
# insert the options before it
new_cmd.extend(extra_options[path])
new_cmd.append(compiler)
else:
new_cmd.extend(extra_options[path])

# path component is found, no need to search any further
break
self.__spawn(new_cmd, **kwargs)


Expand Down