ARM 的 variadic function calling convention 跟 x86 不一樣What About ... ?所以有些 x86 下意外會動的 FFI 程式碼到 Mac M1 可能會 segfault
Addressing Architectural Differences in Your macOS C...> The x86_64 and arm64 architectures have different calling conventions for variadic functions—functions with a variable number of parameters. On x86_64, the compiler treats fixed and variadic parameters the same, placing parameters in registers first and only using the stack when no more registers are available.
> On arm64, the compiler always places variadic parameters on the stack, regardless of whether registers are available. If you implement a function with fixed parameters, but redeclare it with variadic parameters, the mismatch causes unexpected behavior at runtime.
立即下載
所以程式碼裡面原本 segfault, 加了個 printf 後可能就不會 segfault, 只是會變處理垃圾參數 XDDD