Closed cr1901 closed 3 years ago
Good catch! I think the right solution here would be to add cfg(target_has_atomic_usize) or some other built-in cfg like that. Would you be up to sending a PR? If not, I’ll try to get to this tomorrow.
Oh, how unfortunate: the cfg attribute I am thinking about is unstable: https://github.com/rust-lang/rust/issues/32976#issuecomment-716787769
I guess, we need to add a race
feature than, but keep it default.
Also, this is not the first time I am bitten in the back by “compiles on my machine”. I wish the language had better sorry here.
I guess, we need to add a race feature than, but keep it default.
Is this considered a backwards-compat change according to semver? Also, FWIW, msp430
is stuck on nightly for various reasons1 and will continue to be so for a while. Though I agree a general solution would be better.
Anyways, I could try to do the PR myself.
compiles on my machine
I'm abusing the fact that cargo check --target
needs very minimal setup. So I have a CI which checks that things at least compile on many „weird“ platforms:
https://github.com/vorner/signal-hook/blob/master/.github/workflows/test.yaml#L183
Not sure if it would help here, but feel free to borrow any part of that.
Is this considered a backwards-compat change according to semver?
I think its' backward-compatible enough :) This is a new API addition, so I wouldn't mind breaking it in edge cases.
@vorner I like your idea, and tried incorporating it into GHA myself.
Unfortunately, I literally just started learning GHA yesterday, and I ran into two (related) snags, that make me unsure how to add msp430-none-elf
or other weird platforms as a test:
msp430-none-elf
is not an upstream target that can be added via rustup component add
. It probably could be at this point, but there are other things that upstream needs to figure out before msp430 can really be stabilized, so it's not been on my radar.
Therefore, instead of the following:
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.toolchain }}
profile: minimal
default: true
target: ${{ matrix.target }}
for MSP430 and other bare-metal targets, you'd use something like (along with passing -Zbuild-std=core
to cargo
:
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
components: rust-src
I'm not sure how to switch how the toolchain is downloaded based on the capabilities of the target.
MSP430 doesn't (and never will :)) have libstd
, so passing --tests
to cargo check
will fail, even with cross
. cargo check
catches the error though, so I think that may be enough for now?
Anyways, I added a minimal fix for now.
As of
v1.6.0
, therace
module became stable. I've been usingonce_cell
in my msp430 code sincev1.2.0
without issue. Unfortunately, since the release ofv1.6.0
, I've been unable to compile the module:Is it possible to gate the
race
module behind a feature so than I can continue to useonce_cell
on a target without atomics, or would this be considered a semver breaking change?