Conversation
|
Some changes occurred in src/doc/rustc/src/platform-support cc @Noratrieb |
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
This fixes the compile errors in libstd but I haven't had a chance to test it on hardware, I'll report back in a few days once I get the chance. Not sure if it's worth marking this as a draft in the meantime? |
|
@lewisfm: Marking as a draft would be good, thanks. I'm not an appropriate reviewer. I think someone more appropriate would be: r? @joboet
@Kobzol: Is this a bug in reviewer allocation? This PR touches multiple files under |
|
|
Scratch the above, I did more investigation and the cause is different. It is simply caused by the fact that the |
Co-authored-by: Tropical <42101043+tropicaaal@users.noreply.github.com>
df2d771 to
3cad50d
Compare
There was a problem hiding this comment.
This seems good, it's kind of precarious that ISRs can't access thread_locals since this makes panicking inside of interrupt context effectively UB (and that's hard to avoid entirely), but this is a necessary stepping stone to adding support for interrupt-aware thread_locals anyways. I'll test this on hardware in a bit.
Also, for whoever ends up reviewing this: it should be noted that the vast majority of users will never have to touch interrupts on this platform, and these changes were done so that we can be singlethread = false and therefore get real atomics (see the zulip discussion linked above). #[no-std] applications on this target have use-cases for having real atomics, despite this platform not having OS threads. Previously, we used the no_threads implementation of std::sync/thread_local while being singlethread = false, but libstd was changed to throw a compile error under those conditions causing this target to no longer build.
Anyways, tl;dr, this change was done because libstd equates supporting atomics with supporting threads, and the best way to work around that was to make std::sync interrupt-aware.
This PR fixes some compilation errors in
std::syncunder VEXos by switching to a simple spinlock-based model that properly handles the "multithreading" provided by this platform through user interrupt handlers and documenting exactly how and how notstd::syncmay be used on this target. Spinlocks are used because they are very simple and the OS on this target is not aware of threading by default and has no documented builtin futex or mutex API we can use. I don't expect this platform to have more than 1 thread blocking on access for a mutex at once (since there is only 1 thread that's allowed to block per the updated target docs).Previously Rust programs running on VEXos were only allowed a single execution context and user ISRs were not allowed to interact with std code whatsoever. After these changes, ISRs are allowed to partially interact with std and
std::synccan be used to synchronize shared resources between the main thread and interrupts.Using stack-switching schedulers on this platform remains unsound; this is now written explicitly in the target documentation.
More context on these changes in this Zulip thread: https://rust-lang.zulipchat.com/#narrow/channel/219381-t-libs/topic/Meaning.20of.20.22singlethread.22.20in.20target.20spec/with/614265573
LLM disclosure: I did not use LLMs to generate any part of this PR. I did use an LLM to help plan and review my changes before submitting them publicly. All code and documentation is written from scratch in my own style.
cc @tropicaaal @Gavin-Niederman