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

Cannot compile instant for custom target #44

Open
Takashiidobe opened this issue Nov 8, 2021 · 0 comments
Open

Cannot compile instant for custom target #44

Takashiidobe opened this issue Nov 8, 2021 · 0 comments

Comments

@Takashiidobe
Copy link

Repo to reproduce here: https://github.com/Takashiidobe/rvim/tree/test-building-x86_64-unknown-none

I was trying to compile one of my projects on a generic x86_64 target, which is defined by this target file:

// x86_64-unknown-none.json

{
  "llvm-target": "x86_64-unknown-none",
  "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
  "linker-flavor": "gcc",
  "target-endian": "little",
  "target-pointer-width": "64",
  "target-c-int-width": "32",
  "arch": "x86_64",
  "os": "none",
  "disable-redzone": true,
  "features": "-mmx,-sse,+soft-float",
  "executables": true
}

To do that I ran this command inside of my project to build it:
$ cargo build --target ./x86_64-unknown-none.json

Predictably this outputs an error:

   Compiling cfg-if v1.0.0
   Compiling smallvec v1.7.0
   Compiling scopeguard v1.1.0
   Compiling bitflags v1.3.2
error[E0463]: can't find crate for `core`
  |
  = note: the `x86_64-unknown-none-17810034709879873439` target may not be installed
  = help: consider downloading the target with `rustup target add x86_64-unknown-none-17810034709879873439`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `scopeguard` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

So I need to build the stdlib. I did this by swapping to nightly:
$ rustup default nightly
and then running this:
$ cargo build -Z build-std --target ./x86_64-unknown-none.json

which outputs this:

Compiling compiler_builtins v0.1.49
   Compiling core v0.0.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core)
   Compiling libc v0.2.106
   Compiling cc v1.0.69
   Compiling memchr v2.4.1
   Compiling std v0.0.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/std)
   Compiling parking_lot_core v0.8.5
   Compiling unwind v0.0.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/unwind)
   Compiling rustc-std-workspace-core v1.99.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-core)
   Compiling alloc v0.0.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/alloc)
   Compiling cfg-if v0.1.10
   Compiling adler v0.2.3
   Compiling rustc-demangle v0.1.21
   Compiling rustc-std-workspace-alloc v1.99.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/rustc-std-workspace-alloc)
   Compiling panic_unwind v0.0.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/panic_unwind)
   Compiling panic_abort v0.0.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/panic_abort)
   Compiling gimli v0.25.0
   Compiling object v0.26.2
   Compiling hashbrown v0.11.0
   Compiling std_detect v0.1.5 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/stdarch/crates/std_detect)
   Compiling miniz_oxide v0.4.0
   Compiling addr2line v0.16.0
   Compiling proc_macro v0.0.0 (/Users/takashi/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/proc_macro)
   Compiling cfg-if v1.0.0
   Compiling scopeguard v1.1.0
   Compiling smallvec v1.7.0
   Compiling bitflags v1.3.2
   Compiling unicode-segmentation v1.8.0
   Compiling instant v0.1.12
   Compiling lock_api v0.4.5
error[E0658]: use of unstable library feature 'restricted_std'
  |
  = help: add `#![feature(restricted_std)]` to the crate attributes to enable

For more information about this error, try `rustc --explain E0658`.
error: could not compile `instant` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed

I'm guessing this can be fixed by adding #![feature(restricted_std)] at the crate root for either this project or a dependent, but I'm not sure how this works in practice.

If nightly support and custom targets aren't a priority, feel free to close.
If this is coming from somewhere else, I can move the issue over there.

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

No branches or pull requests

1 participant