cross-rs/cross

rust-std is not available for mips anymore (for ~2 days)

johannesvollmer opened this issue · 5 comments

Checklist

Describe your issue

summary: mips suddenly stopped working due to std missing. works again when using powerpc target instead, which solves the issue for us. this is just to let you know something went wrong. locally, i couldn't reproduce the behaviour, but in the github workflows, it consistently failed.

details:

  • we have a ci that tests on a big endian system at the exrs library, using github workflows on an ubuntu runner
  • we use simple cross-rs commands such as cross build --target mips-unknown-linux-gnu --verbose
  • we did not change anything, but suddenly the big endian mips tests using qemu did not compile anymore (even for commits that previously worked), see this log
  • rust compiler errors error[E0463]: can't find crate for 'core' note: the 'mips-unknown-linux-gnu' target may not be installed help: consider downloading the target with 'rustup target add mips-unknown-linux-gnu'
    and later cross-rs prints
    warning: rust-std is not available for mips-unknown-linux-gnu
  • works again when changing target from mips to powerpc-unknown-linux-gnu

What target(s) are you cross-compiling for?

mips-unknown-linux-gnu

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

0.2.5

Example

github-workflow-rust.yaml

  mips:
    runs-on: ubuntu-20.04
    name: emulated big endian mips system

    steps:
      - uses: actions/checkout@v2

      - name: Install or use cached cross-rs/cross
        uses: baptiste0928/cargo-install@v1
        with:
          crate: cross

      - name: Cache Cargo Dependencies
        uses: Swatinem/rust-cache@v1.3.0

      - name: Start Docker
        run: sudo systemctl start docker

      - name: Cross-Compile project to mips-unknown-linux-gnu
        run: cross build --target=mips-unknown-linux-gnu --verbose

      # https://github.com/cross-rs/cross#supported-targets
      - name: Cross-Run Tests in mips-unknown-linux-gnu using Qemu
        run: cross test --target mips-unknown-linux-gnu --verbose

Additional information / notes

No response

This would be a perfect opportunity to have CROSS_DEBUG=1 actually show output of commands we invoke.

This seems like a problem with rustup not reporting correctly.

if you look at a successful run, here you see that cross installed the target, in the log where it first failed, it doesnt.

now, cross checks for what is needed using rustup target list, if the target is not marked as installed, it'll install it. Curiously, in the failed run the target seems to have been reported as installed or not available and rust-src was installed instead.

The logic is here:

cross/src/lib.rs

Lines 469 to 476 in 88f49ff

if !uses_xargo
&& !available_targets.is_installed(&target)
&& available_targets.contains(&target)
{
rustup::install(&target, &toolchain, &mut msg_info)?;
} else if !rustup::component_is_installed("rust-src", &toolchain, &mut msg_info)? {
rustup::install_component("rust-src", &toolchain, &mut msg_info)?;
}

if target is not installed && target is available, install the target, else if rust-src is not installed, install rust-src (this is to then use build-std/xargo)

So, I suspect something is wrong with what rustup is reporting, it's probably saying that mips-unknown-linux-gnu is not available. Why? No clue

if this issue still exists, can you show what rustup target list --toolchain stable-x86_64-unknown-linux-gnu gives

and then run rustup target add mips-unknown-linux-gnu --toolchain stable-x86_64-unknown-linux-gnu

This is due to mips being demoted to t3. See rust-lang/rust#115218

To solve this issue with the mips targets being demoted to t3, you'll have to enable build-std, and also be on nightly.

#Cross.toml
[target.mips-unknown-linux-gnu]
build-std = true

Change the target to whatever mips you're using. We should update cross to do this automatically when rustc >= 1.72.0

to not be on nightly, you might be able to instead use xargo = true

ping @rapiz1, this is the solution for your problem as well

This is due to mips being demoted to t3

Good to know. As I said, we solved the problem at hand by using a different target. I just wanted to let you know in case something was horribly wrong - but everything seems alright. Thanks for the time and for the solution :)