cross-rs / cross

“Zero setup” cross compilation and “cross testing” of Rust crates
Apache License 2.0
6.49k stars 365 forks source link

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

Closed johannesvollmer closed 11 months ago

johannesvollmer commented 11 months ago

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:

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?

What architecture is the host?

What container engine is cross using?

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

Emilgardis commented 11 months ago

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: https://github.com/cross-rs/cross/blob/88f49ff79e777bef6d3564531636ee4d3cc2f8d2/src/lib.rs#L469-L476

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

Emilgardis commented 11 months ago

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

Emilgardis commented 11 months ago

This is due to mips being demoted to t3. See https://github.com/rust-lang/rust/issues/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

Emilgardis commented 11 months ago

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

johannesvollmer commented 11 months ago

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 :)