Audit Hackage foreign import calling conventions
Unlike most other calling conventions, the AArch64/Darwin ABI depends crucially on width of arguments, particularly when arguments are passed via the stack. Unfortunately, this is the first platform that GHC supports for which this is the case. Consequently, there are numerous latent bugs hiding in Hackage packages which can manifest as undefined behavior at runtime (e.g. see https://github.com/biegunka/terminal-size/pull/16). We should make an attempt at finding such erroneous code and pushing patches upstream when necessary. The safest option is to port all foreign import
s of system functions to use the foreign import capi
mechanism as this is robust against this sort of failure mode.
Note that the problem with ioctl
is not the argument count but rather the fact that it's a varargs function.