Issues compiling core

Hi all,

I've been trying to compile the core library by invoking rustc directly. I have some reasons as to why I cannot use cargo and instead have to invoke rustc directly.

I've been running into issues compiling core from the rust git repository running
rustc --crate-type rlib --crate-name core --edition=2021 src\

I'm getting the below errors

error[E0522]: definition of an unknown language item: `ResumeTy`
  --> src\future\
47 | #[cfg_attr(not(bootstrap), lang = "ResumeTy")]
   |                            ^^^^^^^^^^^^^^^^^ definition of unknown language item `ResumeTy`

error[E0522]: definition of an unknown language item: `get_context`
   --> src\future\
105 | #[lang = "get_context"]
    | ^^^^^^^^^^^^^^^^^^^^^^^ definition of unknown language item `get_context`

error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `assert_mem_uninitialized_valid`
   --> src\
968 |     pub fn assert_mem_uninitialized_valid<T>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0093]: unrecognized intrinsic function: `assert_mem_uninitialized_valid`
   --> src\
968 |     pub fn assert_mem_uninitialized_valid<T>();
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unrecognized intrinsic

error: aborting due to 4 previous errors

I'm a bit lost because running the same command on the core library source code that is in my rustup directory compiles fine. I'm using rustc 1.68.0-nightly (d0dc9efff 2022-12-18) on x86_64-pc-windows-msvc. However, I run into the same issue while building on Mac.

I suspect it has something to do with code for the different compiler stages that come with the rust git repository that might not be included with the released artifacts.

Any advice is appreciated :smiley:

The standard library (or core) are designed to only work with the bootstrap compiler (currently still 1.66.0-beta.1 AFAICT) or the exact same compiler that's checked out in the repository at the time. (I don’t know the details of how to configure whether or not you’re in bootstrap mode for these cfg(bootstrap) flags, but that’s probable straightforward to find out online somewhere…) Looking up just one of the lang items you list ResumeTy was added 5 days ago, but the nightly you used is older than that.

You can see in a PR like this, the usage of a lang item in core is happening at the same time as the compiler source code is changed. Changes to intrinsics should be working analogously.

So – I assume – to make it work with nightly, you could e.g. pick a commit that also is a nightly compiler, and then use the correct nightly. For the nightly at hand, following the version information you listed above, do git checkout d0dc9efff in your rust repo checkout, and you’re at the right commit. For the latest nightly, rustup update your nightly, then check out the commit hash reported by rustc +nightly --version afterwards.

Thanks for your help! I had my suspicions and it makes sense now :smiley:

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.