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
14 changes: 9 additions & 5 deletions spy/build/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
"-DSPY_GC_NONE",
]

# WASM-specific CFLAGS shared by wasi and emscripten
_WASM_CFLAGS: list[str] = [
# WASM ABI/codegen flags shared by wasi and emscripten. They must be passed BOTH when
# compiling and when linking.
_WASM_ABI_FLAGS: list[str] = [
"-mmultivalue",
"-Xclang",
"-target-abi",
Expand All @@ -44,11 +45,11 @@
"wasi": [
"-DSPY_TARGET_WASI",
"--target=wasm32-wasi-musl",
*_WASM_CFLAGS,
*_WASM_ABI_FLAGS,
],
"emscripten": [
"-DSPY_TARGET_EMSCRIPTEN",
*_WASM_CFLAGS,
*_WASM_ABI_FLAGS,
],
"native": [
"-DSPY_TARGET_NATIVE",
Expand All @@ -62,8 +63,11 @@
_TARGET_LDFLAGS: dict[str, list[str]] = {
"wasi": [
"--target=wasm32-wasi-musl",
*_WASM_ABI_FLAGS,
],
"emscripten": [
*_WASM_ABI_FLAGS,
],
"emscripten": [],
"native": [],
"native-static": [
"--target=native-native-musl",
Expand Down
11 changes: 11 additions & 0 deletions spy/tests/compiler/test_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,3 +455,14 @@ def foo() -> i64:
("integer literal out of range", "2147483648"),
)
self.compile_raises(src, "foo", errors)

def test_i64_mul_multi_object_build(self):
# A tuple return type pulls in more modules, so the C backend builds
# several .o files and links them in a separate step.
src = """
def mul(a: i64, b: i64) -> tuple[i64, i64]:
return a * b, a
"""
mod = self.compile(src)
assert mod.mul(6, 7) == (42, 6)
assert mod.mul(-6, 7) == (-42, -6)
Loading