diff --git a/mcpp.toml b/mcpp.toml index 8cc3558..7ca1959 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -10,6 +10,7 @@ members = [ "tests/examples/archive", "tests/examples/asio", + "tests/examples/asm-macos-spike", "tests/examples/asio-module", "tests/examples/build-mcpp", "tests/examples/cjson", diff --git a/tests/examples/asm-macos-spike/asm/add_arm64.S b/tests/examples/asm-macos-spike/asm/add_arm64.S new file mode 100644 index 0000000..301784c --- /dev/null +++ b/tests/examples/asm-macos-spike/asm/add_arm64.S @@ -0,0 +1,9 @@ +// R2 spike: minimal aarch64 GAS .S — proves mcpp assembles + links a GAS .S TU +// on macos-15 (the #1 macOS unknown; FFmpeg/OpenCV SIMD on arm64 is GAS .S). +// macOS arm64 ABI: w0=arg0, w1=arg1, result in w0; C symbol `asm_add` -> `_asm_add`. +.text +.p2align 2 +.globl _asm_add +_asm_add: + add w0, w0, w1 + ret diff --git a/tests/examples/asm-macos-spike/mcpp.toml b/tests/examples/asm-macos-spike/mcpp.toml new file mode 100644 index 0000000..4724bb8 --- /dev/null +++ b/tests/examples/asm-macos-spike/mcpp.toml @@ -0,0 +1,9 @@ +# R2 spike (TEMP — remove after the macOS .S path is proven): compile one +# aarch64 GAS .S unit on macos-15 and link it into a test. cfg(macos)-gated so +# the aarch64 asm is only assembled on macOS; a no-op main elsewhere. +[package] +name = "asm-macos-spike-tests" +version = "0.1.0" + +[target.'cfg(macos)'.build] +sources = ["asm/add_arm64.S"] diff --git a/tests/examples/asm-macos-spike/tests/spike.cpp b/tests/examples/asm-macos-spike/tests/spike.cpp new file mode 100644 index 0000000..27bc58f --- /dev/null +++ b/tests/examples/asm-macos-spike/tests/spike.cpp @@ -0,0 +1,11 @@ +#ifdef __APPLE__ +import std; +extern "C" int asm_add(int, int); // defined in asm/add_arm64.S +int main() { + int r = asm_add(2, 3); + std::println("asm-macos-spike: aarch64 .S linked OK, asm_add(2,3)={}", r); + return r == 5 ? 0 : 1; +} +#else +int main() { return 0; } +#endif