Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

#[exception] should check that the exception exists on the target core #214

Closed
jonas-schievink opened this issue Nov 21, 2019 · 5 comments · Fixed by #308
Closed

#[exception] should check that the exception exists on the target core #214

jonas-schievink opened this issue Nov 21, 2019 · 5 comments · Fixed by #308

Comments

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Nov 21, 2019

In reference to this comment:

// NOTE that at this point we don't check if the exception is available on the target (e.g.
// MemoryManagement is not available on Cortex-M0)

I've lost a lot of time due to not realizing that MemoryManagement does not exist on M0(+) chips (instead, HardFault is invoked). At least in this particular case it should be easy to forbid it since it never exists on thumbv6-based targets.

Exceptions that don't exist on ARMv6:

  • MemoryManagement
  • BusFault
  • UsageFault
  • DebugMonitor

Exceptions that only exist on ARMv8:

  • SecureFault
@jonas-schievink jonas-schievink changed the title #[interrupt] should check that the interrupt exists on the target #[exception] should check that the exception exists on the target core Jan 6, 2020
@jonas-schievink jonas-schievink added this to the 1.0.0 milestone Jan 7, 2020
@jonas-schievink
Copy link
Contributor Author

Looks like this is currently unimplementable: Proc macros have no access to the build target, for some reason (TARGET is unset), and there are no #[cfg] flags we can use to detect a specific ARM version.

@adamgreig
Copy link
Member

I guess the proc macro is being built for the host so it makes some sense there's no target. Could we use cfg flags set from build.rs or are they only visible to the parent crate?

@jonas-schievink
Copy link
Contributor Author

They're only visible to the crate that owns the build script, I think

@adamgreig
Copy link
Member

Could we do a similar trick to interrupts and generate a dummy reference to the named exception from c-m-rt which will error if the variant doesn't exist there?

@jonas-schievink
Copy link
Contributor Author

Yes, I think that should work!

@bors bors bot closed this as completed in 835d9fa Jan 26, 2021
adamgreig pushed a commit to rust-embedded/cortex-m that referenced this issue Jan 12, 2022
308: Check presence of exceptions r=adamgreig a=jonas-schievink

Closes rust-embedded/cortex-m-rt#214

Co-authored-by: Jonas Schievink <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants