-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can bypass validation of asm!
in a function that is never used via inline(always)
#36718
Comments
This is probably a side effect #36524 (which avoids generating code for |
Can confirm that the |
cc #29722, the tracking issue for |
Good catch, @japaric!
|
OK, it seems that
The question is, how do we want to handle this. I'd very much prefer if translation would always succeed once things pass analysis. On the other hand, before the PR, the compiler also failed as late as translation, so the only difference is that now things can fail in a downstream crate. I bet though that even before the inlining PR, we had exactly the same problem with generic functions, that is, an |
Nominating because I want to discuss if there is anything we can do or if we even want to do something here. The specific question is:
|
marking P-low as noted above, this is another special case instance of code that can end up in an rlib and then cause a compilation failure further downstream. (We cannot really do anything about it without making our own verification of asm, rather than relying on LLVM's) |
I think that this is fundamentally unsolvable in the same way an |
Triage: Also happens with the new inline assembly, but that even accepts this code on x86_64: #![feature(asm)]
unsafe fn bkpt() {
asm!("bkpt aa aaa aa");
} |
asm!
in a function declaration using inline(always)
asm!
in a function that is never used via inline(always)
Confirmed that using the version of We must conclude that either this is intended behavior, or else this needs to block the stabilization of |
I think this is fundamentally unsolvable in the same way that we can't catch linker errors caused by unused inline functions. So I'm going to close this and just say that this is the intended behavior as you suggested. |
STR
NOTE target = x86_64-unknown-linux-gnu in all cases
This is rejected:
But this is accepted:
Don't worry though, because you can't actually use the ARCH specific instruction:
Additional comments
This is a pretty useful bug/feature! You can use it
cargo test
the arch-agnostic parts of a cratedesigned for ARM on x86 without adding a bunch of
cfg
attributes:Without the
inline(always)
trick, you'll have to add acfg(target_arch = "arm")
to thebkpt
function to get this to compile.
I don't think we want people to rely on this though. Specially, if the
inline(always)
trick stopsworking in the future.
Meta
cc @brson I'll let you decide how bad this is.
The text was updated successfully, but these errors were encountered: