rust-embedded / cortex-m

Low level access to Cortex-M processors
Apache License 2.0
835 stars 152 forks source link

panic-semihosting, panic-itm: Move `#![no_std]` above `#![cfg(target...)]` #528

Closed zachs18 closed 5 months ago

zachs18 commented 7 months ago

... so that the crates are always no_std, even on unsupported platforms.

For dependent binaries, this will cause either:

  1. No change, when compiling for all(target_arch = "arm", target_os = "none").
  2. No change, for binaries which aren't #[no_std], already provide a different #[panic_handler], or already pull in std via another dependency.
  3. New compilation error because #[panic_handler] is not defined and is now not pulled in from std as it was before.

cc https://github.com/rust-lang/miri/issues/3498#issuecomment-2088590212

RalfJung commented 7 months ago

I don't think this will help, cfg-attributes apply to everything independent of their place in the attribute list. At least I think I had trouble with that in the past...

... but then, with your godbolt link it seems like this does help. So maybe I misremember, or things got changed, or no_std is different.