rust-osdev / cargo-xbuild

Automatically cross-compiles the sysroot crates core, compiler_builtins, and alloc.
Apache License 2.0
260 stars 25 forks source link

extern crate alloc required? #24

Closed mark-i-m closed 5 years ago

mark-i-m commented 5 years ago

I am currently getting the following error:

error[E0432]: unresolved import `alloc`
 --> src/rust2c.rs:5:5
  |
5 | use alloc::format;
  |     ^^^^^ did you mean `cstr_core::alloc`?

error: cannot determine resolution for the macro `format`
  --> src/rust2c.rs:11:28
   |
11 |     let msg = CString::new(format!("HELLO! {}", x)).unwrap();
   |                            ^^^^^^
   |
   = note: import resolution is stuck, try simplifying macro imports

error: aborting due to 2 previous errors

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

If I add extern crate alloc, then everything compiles just fine. Is this intentional?

phil-opp commented 5 years ago

This is a current limitation of Rust, so cargo-xbuild can't do anything to fix this: See https://rust-lang-nursery.github.io/edition-guide/rust-2018/module-system/path-clarity.html#an-exception and https://github.com/rust-lang/rust/issues/54392

mark-i-m commented 5 years ago

Thanks!