Empty kernel directory compiles wrong crate
tlambertz opened this issue · comments
I've tried to compile the rusty_demo/hello_world applications on most recent master (16d674b) and ran into obscure compilation errors, which looked like
error[E0463]: can't find crate for `std`
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:9:1
|
9 | extern crate std;
| ^^^^^^^^^^^^^^^^^ can't find crate
To compile the demo apps, I simply followed the readme and ran
cargo build -Z build-std=std,core,alloc,panic_abort -Z build-std-features=compiler-builtins-mem --target x86_64-unknown-hermit --package rusty_demo
# or, taken from CI:
cargo build --package rusty_demo
The error confused me, since the CI works. I then went looking at my Rust compiler, tried different flags etc.
As it turns out, the demo apps in this repo use hermit-sys with with_submodule
and I was missing
git submodule init
git submodule update
There is no error reporting when the submodule is missing. FulllLog below.
For usability, we should:
a) Document submodule checkout in the readme
b) Add a check for empty submodule folder while compiling. Not sure where it currently goes wrong that it complains about missing std. There is a check for missing libhermit-rs folder (for erroring on missing cargo download), but not for empty folder.
info: syncing channel updates for 'nightly-2021-12-04-x86_64-unknown-linux-gnu'
info: latest update on 2021-12-04, rust version 1.59.0-nightly (532d2b14c 2021-12-03)
info: component 'clippy' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'llvm-tools-preview' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'rust-src' is up to date
info: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is up to date
warning: Force-skipping unavailable component 'rust-std-x86_64-unknown-hermit'
Compiling compiler_builtins v0.1.55
Compiling core v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling libc v0.2.108
Compiling cc v1.0.69
Compiling memchr v2.4.1
Compiling std v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std)
Compiling autocfg v1.0.1
Compiling crossbeam-utils v0.8.5
Compiling libc v0.2.99
Compiling crossbeam-epoch v0.9.5
Compiling futures-core v0.3.16
Compiling rayon-core v1.9.1
Compiling same-file v1.0.6
Compiling memchr v2.4.0
Compiling log v0.4.14
Compiling libm v0.2.1
Compiling x86 v0.41.0
Compiling memoffset v0.6.4
Compiling rayon v1.5.1
Compiling walkdir v2.3.2
Compiling unwind v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/unwind)
Compiling hermit-sys v0.1.25 (/home/tom/projects/rftrace_testing/rusty-hermit/hermit-sys)
Compiling rustc-std-workspace-core v1.99.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling alloc v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
Compiling cfg-if v0.1.10
Compiling adler v0.2.3
Compiling rustc-demangle v0.1.21
Compiling hermit-abi v0.1.19
Compiling rustc-std-workspace-alloc v1.99.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
Compiling panic_abort v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_abort)
Compiling panic_unwind v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/panic_unwind)
Compiling gimli v0.25.0
Compiling std_detect v0.1.5 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
Compiling object v0.26.2
Compiling hashbrown v0.11.0
Compiling miniz_oxide v0.4.0
Compiling addr2line v0.16.0
Compiling proc_macro v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/proc_macro)
Compiling cfg-if v1.0.0
Compiling lazy_static v1.4.0
Compiling scopeguard v1.1.0
Compiling bitflags v1.3.2
Compiling pin-project-lite v0.2.7
Compiling waker-fn v1.1.0
Compiling cache-padded v1.1.1
Compiling parking v2.0.0
Compiling futures-io v0.3.16
Compiling bit_field v0.10.1
Compiling fastrand v1.5.0
Compiling async-task v4.0.3
Compiling either v1.6.1
Compiling raw-cpuid v10.2.0
Compiling concurrent-queue v1.2.2
Compiling futures-lite v1.12.0
Compiling crossbeam-channel v0.5.1
Compiling num_cpus v1.13.0
Compiling crossbeam-deque v0.8.1
error: failed to run custom build command for `hermit-sys v0.1.25 (/home/tom/projects/rftrace_testing/rusty-hermit/hermit-sys)`
Caused by:
process didn't exit successfully: `/home/tom/projects/rftrace_testing/rusty-hermit/target/debug/build/hermit-sys-c7034c1d2007de37/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-env-changed=HERMIT_IP
cargo:rerun-if-env-changed=HERMIT_GATEWAY
cargo:rerun-if-env-changed=HERMIT_MASK
--- stderr
info: syncing channel updates for 'nightly-2021-12-04-x86_64-unknown-linux-gnu'
info: latest update on 2021-12-04, rust version 1.59.0-nightly (532d2b14c 2021-12-03)
info: component 'clippy' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'llvm-tools-preview' for target 'x86_64-unknown-linux-gnu' is up to date
info: component 'rust-src' is up to date
info: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is up to date
warning: Force-skipping unavailable component 'rust-std-x86_64-unknown-hermit'
Compiling compiler_builtins v0.1.55
Compiling core v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core)
Compiling autocfg v1.0.1
Compiling libc v0.2.99
Compiling crossbeam-utils v0.8.5
Compiling crossbeam-epoch v0.9.5
Compiling rayon-core v1.9.1
Compiling log v0.4.14
Compiling same-file v1.0.6
Compiling futures-core v0.3.16
Compiling memchr v2.4.0
Compiling x86 v0.41.0
Compiling libm v0.2.1
Compiling memoffset v0.6.4
Compiling num-traits v0.2.14
Compiling rayon v1.5.1
Compiling num-integer v0.1.44
Compiling walkdir v2.3.2
Compiling hermit-sys v0.1.25 (/home/tom/projects/rftrace_testing/rusty-hermit/hermit-sys)
Compiling rustc-std-workspace-core v1.99.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/rustc-std-workspace-core)
Compiling alloc v0.0.0 (/home/tom/.rustup/toolchains/nightly-2021-12-04-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc)
Compiling cfg-if v1.0.0
Compiling lazy_static v1.4.0
error[E0463]: can't find crate for `std`
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:9:1
|
9 | extern crate std;
| ^^^^^^^^^^^^^^^^^ can't find crate
|
= note: the `x86_64-unknown-none-hermitkernel` target may not support the standard library
= help: consider building the standard library from source with `cargo build -Zbuild-std`
error[E0412]: cannot find type `Cell` in this scope
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:19:26
|
19 | pub struct Lazy<T: Sync>(Cell<Option<T>>, Once);
| ^^^^ not found in this scope
|
help: consider importing this struct
|
11 | use core::cell::Cell;
|
error[E0412]: cannot find type `Once` in this scope
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:19:43
|
19 | pub struct Lazy<T: Sync>(Cell<Option<T>>, Once);
| ^^^^ not found in this scope
|
help: consider importing this struct
|
11 | use core::iter::Once;
|
error[E0433]: failed to resolve: use of undeclared type `Cell`
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:23:33
|
23 | pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT);
| ^^^^ not found in this scope
|
help: consider importing this struct
|
11 | use core::cell::Cell;
|
error[E0425]: cannot find value `ONCE_INIT` in this scope
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:23:50
|
23 | pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT);
| ^^^^^^^^^ not found in this scope
error[E0425]: cannot find function `unreachable_unchecked` in this scope
--> /home/tom/.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:42:21
|
42 | unreachable_unchecked()
| ^^^^^^^^^^^^^^^^^^^^^ not found in this scope
|
help: consider importing this function
|
11 | use core::hint::unreachable_unchecked;
|
Some errors have detailed explanations: E0412, E0425, E0433, E0463.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `lazy_static` due to 6 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed
thread 'main' panicked at 'assertion failed: status.success()', hermit-sys/build.rs:131:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace