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

alloc is incomplete #468

Open
nazar-pc opened this issue Sep 29, 2024 · 0 comments
Open

alloc is incomplete #468

nazar-pc opened this issue Sep 29, 2024 · 0 comments

Comments

@nazar-pc
Copy link

I tried to compile some no-std code and it failed like this:

error[E0432]: unresolved import `alloc::sync`
  --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/stdlib.rs:53:31
   |
53 |         pub(crate) use alloc::sync::*;
   |                               ^^^^ could not find `sync` in `alloc`

error[E0432]: unresolved imports `crate::stdlib::sync::Arc`, `crate::stdlib::sync::Weak`
   --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/dispatcher.rs:137:9
    |
137 |         Arc, Weak,
    |         ^^^  ^^^^ no `Weak` in `stdlib::no_std::sync`
    |         |
    |         no `Arc` in `stdlib::no_std::sync`
    |
    = help: consider importing one of these structs instead:
            crate::stdlib::rc::Weak
            alloc::rc::Weak

error[E0432]: unresolved import `crate::stdlib::sync::Arc`
 --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/subscriber.rs:7:5
  |
7 |     sync::Arc,
  |     ^^^^^^^^^ no `Arc` in `stdlib::no_std::sync`

   Compiling indexmap v2.3.0
error[E0599]: no method named `compare_exchange_weak` found for struct `AtomicBool` in the current scope
  --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/spin/mutex.rs:43:14
   |
41 |           while self
   |  _______________-
42 | |             .lock
43 | |             .compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed)
   | |             -^^^^^^^^^^^^^^^^^^^^^ method not found in `AtomicBool`
   | |_____________|
   |

error[E0599]: no method named `compare_exchange` found for struct `AtomicBool` in the current scope
  --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/spin/mutex.rs:70:14
   |
68 |           if self
   |  ____________-
69 | |             .lock
70 | |             .compare_exchange(false, true, Ordering::Acquire, Ordering::Relaxed)
   | |             -^^^^^^^^^^^^^^^^ method not found in `AtomicBool`
   | |_____________|
   |

error[E0599]: no method named `compare_exchange` found for struct `AtomicUsize` in the current scope
  --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/spin/once.rs:77:39
   |
77 |             status = match self.state.compare_exchange(
   |                            -----------^^^^^^^^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `compare_exchange` found for struct `AtomicU8` in the current scope
   --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/callsite.rs:312:33
    |
312 |         match self.registration.compare_exchange(
    |               ------------------^^^^^^^^^^^^^^^^ method not found in `AtomicU8`

error[E0599]: no method named `compare_exchange` found for struct `AtomicUsize` in the current scope
    --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes.rs:1206:10
     |
1204 |       if (*shared)
     |  ________-
1205 | |         .ref_cnt
1206 | |         .compare_exchange(1, 0, Ordering::AcqRel, Ordering::Relaxed)
     | |         -^^^^^^^^^^^^^^^^ method not found in `AtomicUsize`
     | |_________|
     |

error[E0599]: no method named `fetch_add` found for struct `AtomicUsize` in the current scope
    --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes.rs:1282:38
     |
1282 |     let old_size = (*shared).ref_cnt.fetch_add(1, Ordering::Relaxed);
     |                                      ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `compare_exchange` found for struct `AtomicPtr` in the current scope
   --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/callsite.rs:453:34
    |
453 |             match self.list_head.compare_exchange(
    |                   ---------------^^^^^^^^^^^^^^^^ method not found in `AtomicPtr<DefaultCallsite>`

error[E0599]: no method named `compare_exchange` found for reference `&AtomicPtr<()>` in the current scope
    --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes.rs:1342:16
     |
1342 |     match atom.compare_exchange(ptr as _, shared as _, Ordering::AcqRel, Ordering::Acquire) {
     |                ^^^^^^^^^^^^^^^^ method not found in `&AtomicPtr<()>`

error[E0599]: no method named `fetch_sub` found for struct `AtomicUsize` in the current scope
    --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes.rs:1370:23
     |
1370 |     if (*ptr).ref_cnt.fetch_sub(1, Ordering::Release) != 1 {
     |                       ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `compare_exchange` found for struct `AtomicUsize` in the current scope
   --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/dispatcher.rs:308:10
    |
307 |       if GLOBAL_INIT
    |  ________-
308 | |         .compare_exchange(
    | |         -^^^^^^^^^^^^^^^^ method not found in `AtomicUsize`
    | |_________|
    |

error[E0599]: no method named `fetch_add` found for struct `AtomicUsize` in the current scope
    --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes_mut.rs:1421:37
     |
1421 |     let old_size = (*ptr).ref_count.fetch_add(1, Ordering::Relaxed);
     |                                     ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `fetch_sub` found for struct `AtomicUsize` in the current scope
    --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bytes-1.7.1/src/bytes_mut.rs:1430:25
     |
1430 |     if (*ptr).ref_count.fetch_sub(1, Ordering::Release) != 1 {
     |                         ^^^^^^^^^ method not found in `AtomicUsize`

error[E0599]: no method named `swap` found for struct `AtomicUsize` in the current scope
   --> /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tracing-core-0.1.32/src/metadata.rs:746:19
    |
746 |         MAX_LEVEL.swap(val, Ordering::AcqRel);
    |                   ^^^^ method not found in `AtomicUsize`

I have not found an issue that details what is already supported and what is not.

I'm also wondering whether enabling guest-std has any drawbacks? Enabling it while keeping no_std works and brings full alloc into the picture, but I suspect it may result in a different version of the code (at least from standard library point of view, not sure about jolt itslef) being compiled. Dependencies will still be compiled with no_std support though.

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

1 participant