You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the following code compiles fine when targetting x86_64.
pubextern"aapcs"fnfoo(){}
This code is non-sensical because AAPCS calling convention is only defined for ARM. An example of non-sensical ABI being disallowed is
pubextern"fastcall"fnfoo(){}
when compiling with --target=armv7-unknown-linux-gnueabihf which fails with:
error[E0570]: The ABI `"fastcall"` is not supported for the current target
--> <source>:6:1
|
6 | / extern "fastcall" fn foo() {
7 | | }
| |_^
Targets should be reviewed for such nonsensical ABIs and their blacklists updated. I feel that to avoid this issue in the future we should rather prefer a whitelist of ABIs, rather than a blacklist, and by default put no ABIs, so that the compilation fails until the ABI list is properly populated for the target.
One thing that I mentioned there, that is not mentioned here, is that because these errors can happen on stable safe Rust code, this is actually a soundness bug (safe Rust code has UB). Note also that for some ABIs, like stdcall, we don't error on tier-1 targets.
I feel that to avoid this issue in the future we should rather prefer a whitelist of ABIs, rather than a blacklist, and by default put no ABIs, so that the compilation fails until the ABI list is properly populated for the target.
I agree. There are some ABIs that the reference says are available on all targets (e.g. "C", "system", "Rust", etc.) but except for those, each target should have a white-list that explicitly allows using an ABI on the target.
Activity
nagisa commentedon Dec 28, 2018
Compiling
extern "aapcs"on aarch64 will explode in LLVM withLLVM ERROR: Unsupported calling convention..gnzlbg commentedon Oct 16, 2019
I ran into these same issues in #65443 .
One thing that I mentioned there, that is not mentioned here, is that because these errors can happen on stable safe Rust code, this is actually a soundness bug (safe Rust code has UB). Note also that for some ABIs, like
stdcall, we don't error on tier-1 targets.I agree. There are some ABIs that the reference says are available on all targets (e.g.
"C","system","Rust", etc.) but except for those, each target should have a white-list that explicitly allows using an ABI on the target.Replace per-target ABI denylist with an allowlist
Auto merge of rust-lang#86231 - nagisa:nagisa/abi-allowlist, r=petroc…