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

Support issue for target "riscv32imc-unknown-none-elf" #10

Closed
haijd opened this issue Dec 6, 2023 · 3 comments
Closed

Support issue for target "riscv32imc-unknown-none-elf" #10

haijd opened this issue Dec 6, 2023 · 3 comments

Comments

@haijd
Copy link

haijd commented Dec 6, 2023

When I was developing for my ESP-C3 chip, I used the "static_cell" crate, which uses "portable-atomic" for atomic support starting from version "1.3.0". Starting from this version, my project gets the following error when compiling:

error[E0433]: failed to resolve: could not find `AtomicU8` in `imp`
   --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:659:14
    |
659 |         imp::AtomicU8::is_lock_free()
    |              ^^^^^^^^ could not find `AtomicU8` in `imp`
    |
help: a struct with a similar name exists
    |
659 |         imp::AtomicU128::is_lock_free()
    |              ~~~~~~~~~~
help: consider importing this struct
    |
472 + use core::sync::atomic::AtomicU8;
    |
help: if you import `AtomicU8`, refer to it directly
    |
659 -         imp::AtomicU8::is_lock_free()
659 +         AtomicU8::is_lock_free()
    |

error[E0433]: failed to resolve: could not find `AtomicU8` in `imp`
   --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:681:14
    |
681 |         imp::AtomicU8::is_always_lock_free()
    |              ^^^^^^^^ could not find `AtomicU8` in `imp`
    |
help: a struct with a similar name exists
    |
681 |         imp::AtomicU128::is_always_lock_free()
    |              ~~~~~~~~~~
help: consider importing this struct
    |
472 + use core::sync::atomic::AtomicU8;
    |
help: if you import `AtomicU8`, refer to it directly
    |
681 -         imp::AtomicU8::is_always_lock_free()
681 +         AtomicU8::is_always_lock_free()
    |

error[E0412]: cannot find type `AtomicU8` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1384:37
     |
1384 |     fn as_atomic_u8(&self) -> &imp::AtomicU8 {
     |                                     ^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicU128` defined here
     |
help: a struct with a similar name exists
     |
1384 |     fn as_atomic_u8(&self) -> &imp::AtomicU128 {
     |                                     ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicU8;
     |
help: if you import `AtomicU8`, refer to it directly
     |
1384 -     fn as_atomic_u8(&self) -> &imp::AtomicU8 {
1384 +     fn as_atomic_u8(&self) -> &AtomicU8 {
     |

error[E0412]: cannot find type `AtomicU8` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1387:56
     |
1387 |         unsafe { &*(self as *const Self as *const imp::AtomicU8) }
     |                                                        ^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicU128` defined here
     |
help: a struct with a similar name exists
     |
1387 |         unsafe { &*(self as *const Self as *const imp::AtomicU128) }
     |                                                        ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicU8;
     |
help: if you import `AtomicU8`, refer to it directly
     |
1387 -         unsafe { &*(self as *const Self as *const imp::AtomicU8) }
1387 +         unsafe { &*(self as *const Self as *const AtomicU8) }
     |

error[E0412]: cannot find type `AtomicPtr` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1409:17
     |
1409 |     inner: imp::AtomicPtr<T>,
     |                 ^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicI64` defined here
     |
note: found an item that was configured out
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/mod.rs:269:60
     |
269  | pub(crate) use self::core_atomic::{AtomicI64, AtomicIsize, AtomicPtr, AtomicU64, AtomicUsize};
     |                                                            ^^^^^^^^^
help: a struct with a similar name exists
     |
1409 |     inner: imp::AtomicI64<T>,
     |                 ~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicPtr;
     |
help: if you import `AtomicPtr`, refer to it directly
     |
1409 -     inner: imp::AtomicPtr<T>,
1409 +     inner: AtomicPtr<T>,
     |

error[E0433]: failed to resolve: could not find `AtomicPtr` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1464:28
     |
1464 |         Self { inner: imp::AtomicPtr::new(p) }
     |                            ^^^^^^^^^ could not find `AtomicPtr` in `imp`
     |
help: a struct with a similar name exists
     |
1464 |         Self { inner: imp::AtomicI64::new(p) }
     |                            ~~~~~~~~~
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicPtr;
     |
472  + use crate::AtomicPtr;
     |
help: if you import `AtomicPtr`, refer to it directly
     |
1464 -         Self { inner: imp::AtomicPtr::new(p) }
1464 +         Self { inner: AtomicPtr::new(p) }
     |

error[E0412]: cannot find type `AtomicPtr` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1516:15
     |
1516 |         <imp::AtomicPtr<T>>::is_lock_free()
     |               ^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicI64` defined here
     |
note: found an item that was configured out
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/mod.rs:269:60
     |
269  | pub(crate) use self::core_atomic::{AtomicI64, AtomicIsize, AtomicPtr, AtomicU64, AtomicUsize};
     |                                                            ^^^^^^^^^
help: a struct with a similar name exists
     |
1516 |         <imp::AtomicI64<T>>::is_lock_free()
     |               ~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicPtr;
     |
help: if you import `AtomicPtr`, refer to it directly
     |
1516 -         <imp::AtomicPtr<T>>::is_lock_free()
1516 +         <AtomicPtr<T>>::is_lock_free()
     |

error[E0412]: cannot find type `AtomicPtr` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1538:15
     |
1538 |         <imp::AtomicPtr<T>>::is_always_lock_free()
     |               ^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicI64` defined here
     |
note: found an item that was configured out
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/mod.rs:269:60
     |
269  | pub(crate) use self::core_atomic::{AtomicI64, AtomicIsize, AtomicPtr, AtomicU64, AtomicUsize};
     |                                                            ^^^^^^^^^
help: a struct with a similar name exists
     |
1538 |         <imp::AtomicI64<T>>::is_always_lock_free()
     |               ~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicPtr;
     |
help: if you import `AtomicPtr`, refer to it directly
     |
1538 -         <imp::AtomicPtr<T>>::is_always_lock_free()
1538 +         <AtomicPtr<T>>::is_always_lock_free()
     |

error[E0412]: cannot find type `AtomicIsize` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3953:17
     |
3953 |     atomic_int!(AtomicIsize, isize, 4);
     |                 ^^^^^^^^^^^ not found in `imp`
     |
note: found an item that was configured out
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/mod.rs:269:47
     |
269  | pub(crate) use self::core_atomic::{AtomicI64, AtomicIsize, AtomicPtr, AtomicU64, AtomicUsize};
     |                                               ^^^^^^^^^^^
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicIsize;
     |

error[E0433]: failed to resolve: could not find `AtomicIsize` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3953:17
     |
3953 |     atomic_int!(AtomicIsize, isize, 4);
     |                 ^^^^^^^^^^^ could not find `AtomicIsize` in `imp`
     |
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicIsize;
     |
472  + use crate::AtomicIsize;
     |

error[E0412]: cannot find type `AtomicUsize` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3955:17
     |
3955 |     atomic_int!(AtomicUsize, usize, 4);
     |                 ^^^^^^^^^^^ not found in `imp`
     |
note: found an item that was configured out
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/mod.rs:269:82
     |
269  | pub(crate) use self::core_atomic::{AtomicI64, AtomicIsize, AtomicPtr, AtomicU64, AtomicUsize};
     |                                                                                  ^^^^^^^^^^^
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicUsize;
     |

error[E0433]: failed to resolve: could not find `AtomicUsize` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3955:17
     |
3955 |     atomic_int!(AtomicUsize, usize, 4);
     |                 ^^^^^^^^^^^ could not find `AtomicUsize` in `imp`
     |
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicUsize;
     |
472  + use crate::AtomicUsize;
     |

error[E0412]: cannot find type `AtomicI8` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3967:17
     |
3967 |     atomic_int!(AtomicI8, i8, 1);
     |                 ^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicI128` defined here
     |
help: a struct with a similar name exists
     |
3967 |     atomic_int!(AtomicI128, i8, 1);
     |                 ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicI8;
     |

error[E0433]: failed to resolve: could not find `AtomicI8` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3967:17
     |
3967 |     atomic_int!(AtomicI8, i8, 1);
     |                 ^^^^^^^^ could not find `AtomicI8` in `imp`
     |
help: a struct with a similar name exists
     |
3967 |     atomic_int!(AtomicI128, i8, 1);
     |                 ~~~~~~~~~~
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicI8;
     |
472  + use crate::AtomicI8;
     |

error[E0412]: cannot find type `AtomicU8` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3968:17
     |
3968 |     atomic_int!(AtomicU8, u8, 1);
     |                 ^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicU128` defined here
     |
help: a struct with a similar name exists
     |
3968 |     atomic_int!(AtomicU128, u8, 1);
     |                 ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicU8;
     |

error[E0433]: failed to resolve: could not find `AtomicU8` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3968:17
     |
3968 |     atomic_int!(AtomicU8, u8, 1);
     |                 ^^^^^^^^ could not find `AtomicU8` in `imp`
     |
help: a struct with a similar name exists
     |
3968 |     atomic_int!(AtomicU128, u8, 1);
     |                 ~~~~~~~~~~
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicU8;
     |
472  + use crate::AtomicU8;
     |

error[E0412]: cannot find type `AtomicI16` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3971:17
     |
3971 |     atomic_int!(AtomicI16, i16, 2);
     |                 ^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicI128` defined here
     |
help: a struct with a similar name exists
     |
3971 |     atomic_int!(AtomicI128, i16, 2);
     |                 ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicI16;
     |

error[E0433]: failed to resolve: could not find `AtomicI16` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3971:17
     |
3971 |     atomic_int!(AtomicI16, i16, 2);
     |                 ^^^^^^^^^ could not find `AtomicI16` in `imp`
     |
help: a struct with a similar name exists
     |
3971 |     atomic_int!(AtomicI128, i16, 2);
     |                 ~~~~~~~~~~
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicI16;
     |
472  + use crate::AtomicI16;
     |

error[E0412]: cannot find type `AtomicU16` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3972:17
     |
3972 |     atomic_int!(AtomicU16, u16, 2);
     |                 ^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicU128` defined here
     |
help: a struct with a similar name exists
     |
3972 |     atomic_int!(AtomicU128, u16, 2);
     |                 ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicU16;
     |

error[E0433]: failed to resolve: could not find `AtomicU16` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3972:17
     |
3972 |     atomic_int!(AtomicU16, u16, 2);
     |                 ^^^^^^^^^ could not find `AtomicU16` in `imp`
     |
help: a struct with a similar name exists
     |
3972 |     atomic_int!(AtomicU128, u16, 2);
     |                 ~~~~~~~~~~
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicU16;
     |
472  + use crate::AtomicU16;
     |

error[E0412]: cannot find type `AtomicI32` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3975:17
     |
3975 |     atomic_int!(AtomicI32, i32, 4);
     |                 ^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicI128` defined here
     |
help: a struct with a similar name exists
     |
3975 |     atomic_int!(AtomicI128, i32, 4);
     |                 ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicI32;
     |

error[E0433]: failed to resolve: could not find `AtomicI32` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3975:17
     |
3975 |     atomic_int!(AtomicI32, i32, 4);
     |                 ^^^^^^^^^ could not find `AtomicI32` in `imp`
     |
help: a struct with a similar name exists
     |
3975 |     atomic_int!(AtomicI128, i32, 4);
     |                 ~~~~~~~~~~
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicI32;
     |
472  + use crate::AtomicI32;
     |

error[E0412]: cannot find type `AtomicU32` in module `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2373:26
     |
2373 |         atomic_int!(int, AtomicU32, $int_type, $align);
     |                          ^^^^^^^^^
...
3976 |     atomic_int!(AtomicU32, u32, 4);
     |     ------------------------------ in this macro invocation
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/imp/fallback/mod.rs:111:9
     |
111  |         pub(crate) struct $atomic_type {
     |         ------------------------------ similarly named struct `AtomicU128` defined here
     |
     = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)
help: a struct with a similar name exists
     |
2373 |         atomic_int!(int, AtomicU128, $int_type, $align);
     |                          ~~~~~~~~~~
help: consider importing this struct
     |
472  + use core::sync::atomic::AtomicU32;
     |

error[E0433]: failed to resolve: could not find `AtomicU32` in `imp`
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2373:26
     |
2373 |         atomic_int!(int, AtomicU32, $int_type, $align);
     |                          ^^^^^^^^^ could not find `AtomicU32` in `imp`
...
3976 |     atomic_int!(AtomicU32, u32, 4);
     |     ------------------------------ in this macro invocation
     |
     = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)
help: a struct with a similar name exists
     |
2373 |         atomic_int!(int, AtomicU128, $int_type, $align);
     |                          ~~~~~~~~~~
help: consider importing one of these items
     |
472  + use core::sync::atomic::AtomicU32;
     |
472  + use crate::AtomicU32;
     |

   Compiling rand_core v0.6.4
   Compiling linked_list_allocator v0.10.5
error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1431:26
     |
1431 |         fmt::Debug::fmt(&self.load(Ordering::Relaxed), f)
     |                          ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1439:28
     |
1439 |         fmt::Pointer::fmt(&self.load(Ordering::Relaxed), f)
     |                            ^^^^ cannot infer type for type parameter `T`

error: constant expression depends on a generic parameter
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:23
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1463:9
     |
1463 |         static_assert_layout!(AtomicPtr<()>, *mut ());
     |         --------------------------------------------- in this macro invocation
     |
     = note: this may fail depending on what value the parameter takes
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `static_assert_layout` (in Nightly builds, run with -Z macro-backtrace for more info)

error: constant expression depends on a generic parameter
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:18
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1463:9
     |
1463 |         static_assert_layout!(AtomicPtr<()>, *mut ());
     |         --------------------------------------------- in this macro invocation
     |
     = note: this may fail depending on what value the parameter takes
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `static_assert_layout` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1463:9
     |
1463 |         static_assert_layout!(AtomicPtr<()>, *mut ());
     |         --------------------------------------------- in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `static_assert_layout` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:1974:13
     |
1974 |             self.as_atomic_usize().fetch_add(val, order) as *mut T
     |             ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2018:13
     |
2018 |             self.as_atomic_usize().fetch_sub(val, order) as *mut T
     |             ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2077:13
     |
2077 |             self.as_atomic_usize().fetch_or(val, order) as *mut T
     |             ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2134:13
     |
2134 |             self.as_atomic_usize().fetch_and(val, order) as *mut T
     |             ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2190:13
     |
2190 |             self.as_atomic_usize().fetch_xor(val, order) as *mut T
     |             ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2238:13
     |
2238 |             self.as_atomic_usize().bit_set(bit, order)
     |             ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2283:13
     |
2283 |             self.as_atomic_usize().bit_clear(bit, order)
     |             ^^^^ cannot infer type for type parameter `T`

error[E0282]: type annotations needed
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2328:13
     |
2328 |             self.as_atomic_usize().bit_toggle(bit, order)
     |             ^^^^ cannot infer type for type parameter `T`

error: constant expression depends on a generic parameter
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:23
     |
13   |           let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2335:9
     |
2335 | /         static_assert!(
2336 | |             core::mem::size_of::<AtomicPtr<()>>() == core::mem::size_of::<AtomicUsize>()
2337 | |         );
     | |_________- in this macro invocation
     |
     = note: this may fail depending on what value the parameter takes
     = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error: constant expression depends on a generic parameter
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:18
     |
13   |           let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2335:9
     |
2335 | /         static_assert!(
2336 | |             core::mem::size_of::<AtomicPtr<()>>() == core::mem::size_of::<AtomicUsize>()
2337 | |         );
     | |_________- in this macro invocation
     |
     = note: this may fail depending on what value the parameter takes
     = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |           let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |               ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2335:9
     |
2335 | /         static_assert!(
2336 | |             core::mem::size_of::<AtomicPtr<()>>() == core::mem::size_of::<AtomicUsize>()
2337 | |         );
     | |_________- in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error: constant expression depends on a generic parameter
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:23
     |
13   |           let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2338:9
     |
2338 | /         static_assert!(
2339 | |             core::mem::align_of::<AtomicPtr<()>>() == core::mem::align_of::<AtomicUsize>()
2340 | |         );
     | |_________- in this macro invocation
     |
     = note: this may fail depending on what value the parameter takes
     = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error: constant expression depends on a generic parameter
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:18
     |
13   |           let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2338:9
     |
2338 | /         static_assert!(
2339 | |             core::mem::align_of::<AtomicPtr<()>>() == core::mem::align_of::<AtomicUsize>()
2340 | |         );
     | |_________- in this macro invocation
     |
     = note: this may fail depending on what value the parameter takes
     = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |           let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |               ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:2338:9
     |
2338 | /         static_assert!(
2339 | |             core::mem::align_of::<AtomicPtr<()>>() == core::mem::align_of::<AtomicUsize>()
2340 | |         );
     | |_________- in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3953:5
     |
3953 |     atomic_int!(AtomicIsize, isize, 4);
     |     ---------------------------------- in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3955:5
     |
3955 |     atomic_int!(AtomicUsize, usize, 4);
     |     ---------------------------------- in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3967:5
     |
3967 |     atomic_int!(AtomicI8, i8, 1);
     |     ---------------------------- in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3968:5
     |
3968 |     atomic_int!(AtomicU8, u8, 1);
     |     ---------------------------- in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3971:5
     |
3971 |     atomic_int!(AtomicI16, i16, 2);
     |     ------------------------------ in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3972:5
     |
3972 |     atomic_int!(AtomicU16, u16, 2);
     |     ------------------------------ in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3975:5
     |
3975 |     atomic_int!(AtomicI32, i32, 4);
     |     ------------------------------ in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
    --> /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/utils.rs:13:13
     |
13   |         let [] = [(); true as usize - $crate::utils::_assert_is_bool($cond) as usize];
     |             ^^ expected `0`, found `true as usize - $crate::utils::_assert_is_bool($cond) as usize`
     |
    ::: /Users/root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/portable-atomic-1.5.1/src/lib.rs:3976:5
     |
3976 |     atomic_int!(AtomicU32, u32, 4);
     |     ------------------------------ in this macro invocation
     |
     = note: expected array `[(); 0]`
                found array `[(); true as usize - $crate::utils::_assert_is_bool($cond) as usize]`
     = note: this error originates in the macro `static_assert` which comes from the expansion of the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0282, E0308, E0412, E0433.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `portable-atomic` (lib) due to 62 previous errors
warning: build failed, waiting for other jobs to finish...

My "rustflags" configuration is as follows:

rustflags = [
  "-C", "link-arg=-Tlinkall.x",

  # Required to obtain backtraces (e.g. when using the "esp-backtrace" crate.)
  # NOTE: May negatively impact performance of produced code
  "-C", "force-frame-pointers",

  # comment the cfgs below if you do _not_ wish to emulate atomics.
  # enable the atomic codegen option for RISCV
  "-C", "target-feature=+a",
  # tell the core library have atomics even though it's not specified in the target definition
  "--cfg", "target_has_atomic_load_store",
  "--cfg", 'target_has_atomic_load_store="8"',
  "--cfg", 'target_has_atomic_load_store="16"',
  "--cfg", 'target_has_atomic_load_store="32"',
  "--cfg", 'target_has_atomic_load_store="ptr"',
  # enable cas
  "--cfg", "target_has_atomic",
  "--cfg", 'target_has_atomic="8"',
  "--cfg", 'target_has_atomic="16"',
  "--cfg", 'target_has_atomic="32"',
  "--cfg", 'target_has_atomic="ptr"',
]

The compilation tool chain of the "nightly" channel is used.

@taiki-e
Copy link

taiki-e commented Dec 6, 2023

As said in taiki-e/portable-atomic#134 (comment), this is not a problem of portable-atomic or static-cell.

EDIT: Actually, I found that portable-atomic 1.5.1 had another problem also on the portable-atomic side, but it has been fixed in the latest version. taiki-e/portable-atomic#134 (comment)

riscv32imc-unknown-none-elf itself builds with no problems, but the manually set --cfg target_has_atomic="..." seems to be causing problems.

The real problem is shown in the first error, which indicates that the standard library does not provide compare_exchange.

$ cargo build --target riscv32imc-unknown-none-elf 
   Compiling portable-atomic v1.5.1 (/Users/taiki/projects/sources/taiki-e/portable-atomic)
error[E0599]: no method named `compare_exchange` found for struct `core::sync::atomic::AtomicPtr` in the current scope
  --> src/imp/core_atomic.rs:97:20
   |
97 |         self.inner.compare_exchange(current, new, success, failure)
   |                    ^^^^^^^^^^^^^^^^ method not found in `AtomicPtr<T>`

This is because it is linked to prebuilt core built without --cfg target_has_atomic="..." applied. So it can be resolved by re-building the core.

$ cargo build --target riscv32imc-unknown-none-elf -Z build-std=core

I don't think anything can be done on our part about this, since the problem here is not with the portable-atomic, but with the situation (and the user who created that situation) where --cfg target_has_atomic="..." is set but core is not actually providing it.

It is not clear if it is also possible to improve the error messages generated like taiki-e/portable-atomic#100, since the problem in this case is that the cfg that should be set correctly is lying.

@haijd
Copy link
Author

haijd commented Dec 6, 2023

"portable-atomic" has just fixed this problem in version 1.6.0, please update the dependencies.

@taiki-e
Copy link

taiki-e commented Dec 14, 2023

please update the dependencies.

FYI, users can get a new version simply by running cargo update and new projects will automatically get the latest version, so there is no need to necessarily update the Cargo.toml in the static-cell itself.

@Dirbaio Dirbaio closed this as completed Dec 19, 2023
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

No branches or pull requests

3 participants