Binaries compilation errors, error[E0432], error[E0599]

Issue Report

Environment

  • Operating System: Ubuntu 22.04.3 LTS, 5.15.0-88-generic, x86_64
  • Advanced CLI: gemini-3g-2023-dec-01
  • rustc 1.76.0-nightly (503e12932 2023-12-07)

Problem

On one of my servers I can’t build binaries from source:

error[E0432]: unresolved import `core::simd::SimdUint`
  --> crates/subspace-proof-of-space/src/chiapos/table.rs:16:24
   |
16 | use core::simd::{Simd, SimdUint};
   |                        ^^^^^^^^ no `SimdUint` in `simd`
   |
   = help: consider importing one of these items instead:
           core::simd::prelude::SimdUint
           std::simd::prelude::SimdUint

   Compiling subspace-archiving v0.1.0 (/home/admfc/subspace/crates/subspace-archiving)
error[E0599]: no method named `cast` found for struct `Simd` in the current scope
   --> crates/subspace-proof-of-space/src/chiapos/table.rs:249:22
    |
249 |     let ys = (pre_ys.cast() & pre_ys_mask) | (pre_exts & pre_exts_mask);
    |                      ^^^^ method not found in `Simd<u64, COMPUTE_F1_SIMD_FACTOR>`
   --> /rustc/503e129328080e924c0ddfca6abf4c2812580102/library/core/src/../../portable-simd/crates/core_simd/src/simd/num/uint.rs:17:8
    |
    = note: the method is available for `Simd<u64, COMPUTE_F1_SIMD_FACTOR>` here
    |
    = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
    |
1   + use std::simd::num::SimdUint;
    |

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `subspace-proof-of-space` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Everything is fine on a couple dozen other servers. Neither subspace-node nor subspace-farmer is being built.

How do you compile it exactly?

Because if you just do cargo build it will not use Rust version that you provided, but rather one defined in rust-toolchain.toml, which code compiles with just fine. It is not guaranteed that code will compile with older/newer versions of the compiler because we use nightly-only features.

git clone https://github.com/subspace/subspace.git && cd subspace && git checkout gemini-3g-2023-dec-01
export RUSTFLAGS="-C target-cpu=native -C opt-level=3" && export CFLAGS="-march=native" && export CXXFLSGS="$CFLAGS"
rustup update
cargo build --profile production --bin subspace-farmer --bin subspace-node

How to compile correctly?

Looks a bit random. I don’t think you need to specify optimization level (it is like that for production already) or C/C++ flags (not sure why you have them there). Also native is not always the most performant, but will not hurt generally. Even if you don’t specify any of those environment variables, you should get efficient and performant build (though I would recommend main branch before the next release due to Fix AES-NI enablement by default, including when building container images by nazar-pc · Pull Request #2291 · subspace/subspace · GitHub)…

The command itself seems correct and should pick up rust-toolchain.toml if you installed Rust itself through https://rustup.rs/ and not OS’s package manager, that can have customized Rust toolchain with various “features”.

I always install Rust using curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh command.

Looks a bit random.

My friends suggested it to me… :man_shrugging:

Is rust-toolchain.toml present after you clone the repo? Something is clearly off, but from what you wrote I don’t see what it is.

image
It is.

Okay, can you run rustc --version in the project directory to see which compiler version it picked up?

image

Hm, that is not what it should be. For some reason it doesn’t select correct version.
What does which rustc say?

image
On each such checking I compare the results with another similar server where everything is OK… The results are:
image

Please see #8 :man_shrugging:

Try installing stable rustup and everything else then. We ship rust-toolchain.toml with the project and it will automatically download correct version of the toolchain if it is not already present, no need to install nightly and there is a chance they had some regression that broke rust-toolchain.toml support.

The way Rust tooling works it will usually automatically pick Rust compilation options and will translate them into C/C++ flags downstream. So if you specify target CPU as native, it will be native for C/C++ and -O3 is already default for release builds in Rust, so specifying it explicitly is unnecessary.

And I’m also wondering if you see any difference from recompiling things in the first place, I’d imagine difference with official Skylake builds to be minimum to none.

   Compiling scale-info v2.9.0
   Compiling subspace-core-primitives v0.1.0 (/home/admfc/subspace/crates/subspace-core-primitives)
   Compiling sp-arithmetic v16.0.0 (https://github.com/subspace/polkadot-sdk?rev=892bf8e938c6bd2b893d3827d1093cd81baa59a1#892bf8e9)
   Compiling jsonrpsee-core v0.16.3
   Compiling hyper-rustls v0.24.1
error[E0554]: `#![feature]` may not be used on the stable release channel
  --> crates/subspace-core-primitives/src/lib.rs:21:1
   |
21 | / #![feature(
22 | |     array_chunks,
23 | |     const_option,
24 | |     const_trait_impl,
...  |
29 | |     step_trait
30 | | )]
   | |__^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> crates/subspace-core-primitives/src/lib.rs:22:5
   |
22 |     array_chunks,
   |     ^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> crates/subspace-core-primitives/src/lib.rs:23:5
   |
23 |     const_option,
   |     ^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> crates/subspace-core-primitives/src/lib.rs:26:5
   |
26 |     new_uninit,
   |     ^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> crates/subspace-core-primitives/src/lib.rs:27:5
   |
27 |     portable_simd,
   |     ^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> crates/subspace-core-primitives/src/lib.rs:28:5
   |
28 |     slice_flatten,
   |     ^^^^^^^^^^^^^

error[E0554]: `#![feature]` may not be used on the stable release channel
  --> crates/subspace-core-primitives/src/lib.rs:29:5
   |
29 |     step_trait
   |     ^^^^^^^^^^

For more information about this error, try `rustc --explain E0554`.
error: could not compile `subspace-core-primitives` (lib) due to 7 previous errors
warning: build failed, waiting for other jobs to finish...

I have performed a complete reload of the subspace repository.
image

Can you attach rustup show output? And please do so as text rather than screenshots.

Also in case you ever ran rustup override set to set a specific version, do rustup override unset to remove it.

Seems that did the trick. :partying_face:

In my cheat sheet there was only rustup default stable command to revert these changes.

Well, that doesn’t revert anything, it forces stable version for the directory that overrides rust-toolchain.toml. There is no need to set or install any specific version because we intentionally ship rust-toolchain.toml for things to “just work” out of the box.

1 Like