Skip to content
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

feat: configurable link section attribute for irqs #718

Merged

Conversation

sethp
Copy link
Contributor

@sethp sethp commented May 19, 2023

This change introduces a new config field that allows svd2rust to target which linker sections get assigned to the __INTERRUPTS static, with reasonable defaults.

Previously on RISC-V, the choice was always left up to the compiler, and it seemed to always pick .rodata. Unfortunately, in my context, that meant placing the LUT in a memory range that had a lot of highly variable latency, which cost not just time but predictability in servicing interrupts.

With this change in place, I'm able to target a particular section (e.g. .data, or .trap.rodata) for the placement of the static, which grants more granular control over the ultimate loaded memory address.

For the full details about the problem, please see: esp-rs/esp-hal@e29f3d5

sethp added 2 commits May 18, 2023 21:53
This change introduces a new config field that allows `svd2rust`
to target which linker sections get assigned to the `__INTERRUPTS`
static, with reasonable defaults.

Previously on RISC-V, the choice was always left up to the compiler, and
it seemed to always pick `.rodata`. Unfortunately, in my context, that
meant placing the LUT in a memory range that had a lot of highly
variable latency, which cost not just time but predictability in
servicing interrupts.

With this change in place, I'm able to target a particular section
(e.g. `.data`, or `.trap.rodata`) for the placement of the static, which
grants more granular control over the ultimate loaded memory address.

For the full details about the problem, please see: esp-rs/esp-hal@e29f3d5
@sethp sethp requested a review from a team as a code owner May 19, 2023 04:54
sethp added a commit to rustbox/esp-pacs that referenced this pull request May 19, 2023
This commit premptively adopts the change proposed to [svd2rust] to
expose the link section as a config parameter.

[svd2rust]: rust-embedded/svd2rust#718
sethp added a commit to rustbox/esp-pacs that referenced this pull request May 19, 2023
This commit preemptively adopts the change proposed to [svd2rust] to
expose the link section as a config parameter.

[svd2rust]: rust-embedded/svd2rust#718
src/generate/interrupt.rs Outdated Show resolved Hide resolved
@burrbull
Copy link
Member

I hope this is backward compatible?

burrbull
burrbull previously approved these changes May 19, 2023
@sethp
Copy link
Contributor Author

sethp commented May 19, 2023

Oh, great point: the code generator changes are in the sense that passing None for that parameter (or not setting a value, which should default to None) doesn't change the generated code.

Using the new parameter may not be backwards compatible, depending on what link section is being set: as long as the new section gets output in some part of the resulting binary it sure could be, but it's somewhat easy to rely on a particular layout, either accidentally or on purpose.

@burrbull
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented May 19, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit e6a6d15 into rust-embedded:master May 19, 2023
jessebraham pushed a commit to esp-rs/esp-pacs that referenced this pull request May 22, 2023
* feat: place __INTERRUPTS vector in `.trap.rodata`

This commit preemptively adopts the change proposed to [svd2rust] to
expose the link section as a config parameter.

[svd2rust]: rust-embedded/svd2rust#718

* chore: update generated files

via:

```
(cd xtask; cargo run -- --generate-only)
```

* fix: quiet rust-analyzer's noisy complaints

Rust-analyzer's "all targets" default mode runs afoul of `#[no_std]`
crates that don't have a test harness. This change tells cargo (and
indirectly, rust-analyzer) that we have no expectation for that to work.

The CI changes don't have any effect currently, since none of these
crates have any `bin`s or `example`s, but it does check that the
rust-analzyzer complaints won't crop back up in the future.

* chore: point at post-merge-queue commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants