agbcc
agbcc copied to clipboard
Refactor all uses of GEN_FCN to use locals
An intermediate local value (cast to the appropriate signature) for lookups in the instruction generation jump table works around a code generation bug in macOS ARM64 clang that would cause their parameters to be pushed on the stack instead of passed in registers.
(addresses #43)
I've had feedback on the pret Discord server that this works and people are able to build projects such as pokefirered
on M1 Macs.
Further research indicates that both vanilla Clang and gcc are also affected, so this might be a more general ABI problem. Either way, the issue is fixed by these changes; it's a matter of if they're acceptable to merge given the extent of them.
I've recently found some documentation indicating these may be consequences of deliberate changes made to the ARM64 ABI on Apple platforms: https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Update-Code-that-Passes-Arguments-to-Variadic-Functions
@holmesmr
If you use Fixes #43
or similar on the first comment of a PR, it'll make that PR so it'll close the issue once it's merged.
Also works with Resolves #43
and Closes #43
This may also fix #46 and #38 (even though #38 already has a fix in #39)