# Trying to build rustc from scratch, missing std lib

**URL:** <https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478>\
**Category:** compiler\
**Created:** [February 28, 2025, 1:31am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478 "2025-02-28T01:31:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![nhtyy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nhtyy/32/13016_2.png) [@nhtyy](https://internals.rust-lang.org/u/nhtyy)\
**Post date:** [February 28, 2025, 1:31am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/1 "2025-02-28T01:31:40Z")

</div>

Previously, I had always built rustc with the follow command: `./x build library --stage 2`

Looking at the build logs everything seems correct, however, when I try to build (tag=v.1.85.0) I get an error saying it doesn't have the stdlib. Also, suspiciously, the rustc bin is half the size of my old builds.

```rust
rror[E0463]: can't find crate for `std`
  |
  = note: the `aarch64-apple-darwin` target may not be installed
  = help: consider adding the standard library to the sysroot with `x build library --target aarch64-apple-darwin`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `core`
  |
  = note: the `aarch64-apple-darwin` target may not be installed
  = help: consider adding the standard library to the sysroot with `x build library --target aarch64-apple-darwin`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: could not compile `version_check` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `serde` (build script) due to 1 previous error
error: could not compile `proc-macro2` (build script) due to 1 previous error
error: could not compile `syn` (build script) due to 1 previous error
error: could not compile `base64` (lib) due to 1 previous error
error: could not compile `unicode-ident` (lib) due to 1 previous error
error: could not compile `typenum` (build script) due to 1 previous error
error: could not compile `autocfg` (lib) due to 1 previous error
error: could not compile `unicode-width` (lib) due to 1 previous error

```

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![nhtyy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nhtyy/32/13016_2.png) [@nhtyy](https://internals.rust-lang.org/u/nhtyy)\
**Post date:** [February 28, 2025, 1:34am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/2 "2025-02-28T01:34:10Z")

</div>

Also, my command actually specifies a different target, `aarch64-apple-darwin` is my host machine.

---

<div class="post-metadata">

**Author:** ![nhtyy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nhtyy/32/13016_2.png) [@nhtyy](https://internals.rust-lang.org/u/nhtyy)\
**Post date:** [February 28, 2025, 1:38am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/3 "2025-02-28T01:38:02Z")

</div>

```rust
> rustc +succinct --print target-list | grep succinct
riscv32im-succinct-zkvm-elf

>rustc +succinct --print sysroot
/Users/nhtyy/succinct/rust/build/aarch64-apple-darwin/stage2

>cargo +succinct build --target riscv32im-succinct-zkvm-elf
<elided as in original post>

```

---

<div class="post-metadata">

**Author:** ![bjorn3](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bjorn3/32/2736_2.png) [@bjorn3](https://internals.rust-lang.org/u/bjorn3)\
**Post date:** [February 28, 2025, 6:39am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/4 "2025-02-28T06:39:09Z")

</div>

What is your config.toml?

---

<div class="post-metadata">

**Author:** ![nhtyy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nhtyy/32/13016_2.png) [@nhtyy](https://internals.rust-lang.org/u/nhtyy)\
**Post date:** [February 28, 2025, 8:03am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/5 "2025-02-28T08:03:35Z")

</div>

It looks like this

```rust
[build]
target = ["riscv32im-succinct-zkvm-elf"]
extended = true
tools = ["cargo", "cargo-clippy", "clippy", "rustfmt"]
configure-args = []
cargo-native-static = true

[rust]
lld = true
llvm-tools = true

[llvm]
download-ci-llvm = false

```

This is for a target I maintain (and plan on upstreaming very soon).

I was actually able to resolve this issue by changing the build command to

`./x build --stage 2 compiler/rustc library `.

---

<div class="post-metadata">

**Author:** ![bjorn3](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bjorn3/32/2736_2.png) [@bjorn3](https://internals.rust-lang.org/u/bjorn3)\
**Post date:** [February 28, 2025, 8:32am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/6 "2025-02-28T08:32:15Z")

</div>

In the `target` key you need to also include the triple of the host platform. Otherwise the resulting compiler can't build proc macros and build scripts for the host.

---

<div class="post-metadata">

**Author:** ![nhtyy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nhtyy/32/13016_2.png) [@nhtyy](https://internals.rust-lang.org/u/nhtyy)\
**Post date:** [February 28, 2025, 5:48pm UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/7 "2025-02-28T17:48:41Z")

</div>

Oh interesting are you saying in both cases? What is the difference between the two commands?

I think for my use case I actually only care about cross compilation so maybe thats why I haven't noticed the issue you're describing.

---

<div class="post-metadata">

**Author:** ![bjorn3](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bjorn3/32/2736_2.png) [@bjorn3](https://internals.rust-lang.org/u/bjorn3)\
**Post date:** [February 28, 2025, 6:07pm UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/8 "2025-02-28T18:07:29Z")

</div>

When doing `./x.py build --stage 2 compiler/rustc library` implicitly causes a standard library to be built for the host as that is necessary for building the stage 2 compiler for the host.

> [@nhtyy](#):
>
> I think for my use case I actually only case about cross compilation so maybe thats why I haven't noticed the issue you're describing.

Even when cross-compiling you often have dependencies with build scripts and proc macros that need to be compiled for the host.

---

<div class="post-metadata">

**Author:** ![nhtyy](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/nhtyy/32/13016_2.png) [@nhtyy](https://internals.rust-lang.org/u/nhtyy)\
**Post date:** [February 28, 2025, 6:14pm UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/9 "2025-02-28T18:14:43Z")

</div>

> When doing ./x.py build --stage 2 compiler/rustc library implicitly causes a standard library to be built for the host as that is necessary for building the stage 2 compiler for the host.

Oh so even without my "host" target listed in the `config.toml` it still creates some things for my host, but not everything I may need? And this is the reason I was seeing the errors, even though I was compiling to the custom target?

---

<div class="post-metadata">

**Author:** ![bjorn3](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bjorn3/32/2736_2.png) [@bjorn3](https://internals.rust-lang.org/u/bjorn3)\
**Post date:** [March 1, 2025, 10:19am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/10 "2025-03-01T10:19:22Z")

</div>

Yes, if one of your dependencies has a build script or proc macro it will get compiled for the host. Most projects have at least one build script or proc macro somewhere in their dependency graph. In your case for example serde, base64, typenum and one or more dependencies that use autocfg.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [August 23, 2026, 10:19am UTC](https://internals.rust-lang.org/t/trying-to-build-rustc-from-scratch-missing-std-lib/22478/11 "2026-08-23T10:19:56Z")

</div>

Closed on August 23, 2026, 10:19am UTC

This topic was automatically closed 540 days after the last reply. New replies are no longer allowed.
