-
Notifications
You must be signed in to change notification settings - Fork 150
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
Hardfault trampoline is now optional #476
Hardfault trampoline is now optional #476
Conversation
I think it should be some argument to the macro, instead of a Cargo feature. Something like The problem with Cargo features is that one crate might do Also, are the current trampoline and
|
This could be done technically. Though that would pull some code from the crate into the macro. Not very nice for readability and maintainability.
Since there can only be one handler anyways, only the crate that implements the handler cares about the feature being enabled. So I don't think this'll be a problem in practice.
I don't know how people use it. I do know that removing it would be a breaking change. |
Ok, so after the weekly meeting we decided to look more into the direction that Dario proposed. I'll describe how that is supposed to work. So, the goal is to be backwards compatible so we can avoid bumping the major version. This should still compile: #[exception]
fn HardFault(e: ExceptionFrame) {
// ...
} It will turn into: #[exception(trampoline = true)]
fn HardFault(e: ExceptionFrame) {
// ...
} This way we can set the trampoline to false if we don't want a trampoline to be generated. For the next major version we could consider making false the default. In principle we could extend the ExceptionFrame to all registers in a minor release, but that's better suited for a different PR. But what does this mean for the code?
All in all it isn't that much. |
Yeah I'm leaning to making it explicit too. Just wanted to mention the possibility. |
Ok, the trampoline generation is done in the macro now. |
Thanks, looks good! I was trying to follow through how the trampoline works now and I'm not sure when Should the asm routine actually be called |
Oh I think you may be right. I'll investigate and fix |
Ok, it passes again! It should all check out now. And I've confirmed it by looking at the exception frame values, they are very similar to what I get in the last release. I've added a dummy function to improve diagnostics. Otherwise when you have two hardfaults, of which one uses the trampoline and one doesn't, you'd get a horribly long error about assembly code. The only real cost here is that the diagnostics now talk about If naked functions were stabilized yet, then I could've used that and get rid of |
Thanks for updating that! I've reviewed the changes and run some tests and the generated output all seems good. The docs need updating in a couple of places and then I'm happy to merge this:
|
@adamgreig Good catch! I've changed and added to the docs in the last commit. I think that should cover everything and it's technically more correct than the old docs. |
thank you! |
And thank you 😄 |
Fixes #406
This was less work than I thought! (So please check if I didn't miss anything haha)
Basically, anything that works with the hardfault trampoline is cfg'ed behind the new feature flag.
I've opted to make the flag default to avoid breaking changes... (unless somebody has
default-features = false
in their Cargo.toml). So technically it's still a breaking change I think?Also, we probably want to have a test for this all. There seems to be a test for the trampoline version.
But I don't really know how testing in this repo is set up.