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

Unable to build on platforms without atomic types #3

Closed
alistair23 opened this issue Sep 14, 2020 · 9 comments · Fixed by #4
Closed

Unable to build on platforms without atomic types #3

alistair23 opened this issue Sep 14, 2020 · 9 comments · Fixed by #4
Assignees

Comments

@alistair23
Copy link

Some platforms (such as RV32IMC) don't have the atomic types. When trying to build radium for those platforms this error is seen:

error[E0432]: unresolved imports `core::sync::atomic::AtomicBool`, `core::sync::atomic::AtomicI16`, `core::sync::atomic::AtomicI32`, `core::sync::atomic::AtomicI8`, `core::sync::atomic::AtomicIsize`, `core::sync::atomic::AtomicPtr`, `core::sync::atomic::AtomicU16`, `core::sync::atomic::AtomicU32`, `core::sync::atomic::AtomicU8`, `core::sync::atomic::AtomicUsize`
  --> /home/alistair/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/radium-0.3.0/src/lib.rs:29:11
   |
29 |     self, AtomicBool, AtomicI16, AtomicI32, AtomicI8, AtomicIsize, AtomicPtr, AtomicU16, AtomicU32,
   |           ^^^^^^^^^^  ^^^^^^^^^  ^^^^^^^^^  ^^^^^^^^  ^^^^^^^^^^^  ^^^^^^^^^  ^^^^^^^^^  ^^^^^^^^^ no `AtomicU32` in `sync::atomic`
   |           |           |          |          |         |            |          |
   |           |           |          |          |         |            |          no `AtomicU16` in `sync::atomic`
   |           |           |          |          |         |            no `AtomicPtr` in `sync::atomic`
   |           |           |          |          |         no `AtomicIsize` in `sync::atomic`
   |           |           |          |          no `AtomicI8` in `sync::atomic`
   |           |           |          no `AtomicI32` in `sync::atomic`
   |           |           no `AtomicI16` in `sync::atomic`
   |           no `AtomicBool` in `sync::atomic`
30 |     AtomicU8, AtomicUsize, Ordering,
   |     ^^^^^^^^  ^^^^^^^^^^^ no `AtomicUsize` in `sync::atomic`
   |     |
   |     no `AtomicU8` in `sync::atomic`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0432`.
error: could not compile `radium`.

To learn more, run the command again with --verbose.
make: *** [Makefile:141: flash-opentitan] Error 101

Something like this: rust-embedded/heapless#123 should hopefully fix the problem.

@myrrlyn
Copy link
Collaborator

myrrlyn commented Sep 15, 2020

The WIP branch to resolve this is feature/3. I have just pushed commit 1fd54d1, which adds a build script to detect the target architecture and set our own equivalents of the Rust-internal cfg(target_has_atomic) gates.

Please patch your manifest to use

[dependencies.radium]
git = "https://github.com/mystor/radium
rev = "feature/3"

and test your project. The expected results are for radium to successfully compile, and for bitvec to fail.

You can sidestep the bitvec failure temporarily by setting

[dependencies.bitvec]
default-features = false

If these patches work, I will release a new radium that uses the build script, and a new bitvec that uses the new radium, and let you know when they are available.

Thank you for this issue.

@alistair23
Copy link
Author

Hey, thanks so much for this. I just checked the feature/3 branch and it builds for riscv32imc. I haven't had a chance to test it in my project as it's a few dependency levels deep. This at least allows it to build so that's a great start.

@tarcieri
Copy link

@alistair23 you should be able to test it by adding:

[patch.crates-io]
radium = { git = "https://github.com/mystor/radium.git", branch = "feature/3" }

...directive in your toplevel Cargo.toml

@alistair23
Copy link
Author

Ah awesome.

Radium builds, bitvec doesn't though:

error[E0277]: the trait bound `core::cell::Cell<u8>: radium::Radium<u8>` is not satisfied
   --> /home/alistair/.cargo/registry/src/github.jparrowsec.cn-1ecc6299db9ec823/bitvec-0.18.3/src/store.rs:128:8
    |
85  |   pub trait BitStore: seal::Sealed + Sized + Debug {
    |             -------- required by a bound in this
...
105 |           + Radium<<Self::Alias as BitStore>::Mem>;
    |             -------------------------------------- required by this bound in `store::BitStore`
...
128 |           impl BitStore for $t {
    |                ^^^^^^^^ the trait `radium::Radium<u8>` is not implemented for `core::cell::Cell<u8>`
...
179 | / bitstore!(
180 | |     u8 => atomic::AtomicU8,
181 | |     u16 => atomic::AtomicU16,
182 | |     u32 => atomic::AtomicU32,
183 | |     usize => atomic::AtomicUsize,
184 | | );
    | |__- in this macro invocation
    |
    = help: the following implementations were found:
              <core::cell::Cell<*mut T> as radium::Radium<*mut T>>
              <core::cell::Cell<bool> as radium::Radium<bool>>
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

@myrrlyn
Copy link
Collaborator

myrrlyn commented Sep 15, 2020

I forgot how our codegen macros worked, and accidentally disabled Radium production entirely. Pushed the fix.

@alistair23
Copy link
Author

Perfect! It works now!

@myrrlyn myrrlyn linked a pull request Sep 16, 2020 that will close this issue
@myrrlyn
Copy link
Collaborator

myrrlyn commented Sep 19, 2020

mystor/4 is now merged, and published as radium 0.4, closing this issue. bitvec 0.19.1 is now published to depend on it.

@myrrlyn
Copy link
Collaborator

myrrlyn commented Sep 19, 2020

This is already covered by building with --no-default-features, as riscv32imc-unknown-none-elf does not have std, but you must not enable --features atomic on this target, or the compilation will fail. This is a problem that I will fix when the compiler makes it convenient.

@alistair23
Copy link
Author

Thanks!

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 a pull request may close this issue.

3 participants