Skip to content

-Zbuild-std is appended in the wrong position #1141

Closed
@guihkx

Description

@guihkx

Checklist

Describe your issue

Trying to pass extra arguments to clippy on a target with no std (x86_64-unknown-dragonfly, in my case), fails:

$ cross -v +nightly clippy --target x86_64-unknown-dragonfly -- -D warnings
+ cargo +nightly metadata --format-version 1 --filter-platform x86_64-unknown-dragonfly
+ rustc --print sysroot
+ /usr/bin/podman
+ /usr/bin/podman version -f '{{ .Server.Os }},,,{{ .Server.Arch }}'
+ /usr/bin/podman info -f '{{ .Version.OsArch }}'
+ rustup toolchain list
+ rustup target list --toolchain nightly-x86_64-unknown-linux-gnu
[cross] warning: using newer rustc `1.67.0-nightly (b833ad56f 2022-11-18)` for the target. Current active rustc on the host is `rustc 1.65.0 (897e37553 2022-11-02)`.
 > Update with `rustup update`
+ rustup component list --toolchain nightly-x86_64-unknown-linux-gnu
+ rustup component list --toolchain nightly-x86_64-unknown-linux-gnu
+ /usr/bin/podman run --userns host -e 'PKG_CONFIG_ALLOW_CROSS=1' -e 'XARGO_HOME=/home/gui/.xargo' -e 'CARGO_HOME=/home/gui/.local/share/cargo' -e 'CROSS_RUST_SYSROOT=/home/gui/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu' -e 'CARGO_TARGET_DIR=/target' -e 'CROSS_RUNNER=' -e TERM -e 'USER=gui' -e 'CROSS_RUSTC_MAJOR_VERSION=1' -e 'CROSS_RUSTC_MINOR_VERSION=67' -e 'CROSS_RUSTC_PATCH_VERSION=0' --name cross-nightly-x86_64-unknown-linux-gnu-94e8e-b833ad56f-x86_64-unknown-dragonfly-ca725-1668874801982 --rm -v /home/gui/.xargo:/home/gui/.xargo:z -v /home/gui/.local/share/cargo:/home/gui/.local/share/cargo:z -v /home/gui/.local/share/cargo/bin -v /home/gui/dev/topgrade:/home/gui/dev/topgrade:z -v /home/gui/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu:/home/gui/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu:z,ro -v /home/gui/dev/topgrade/target:/target:z -w /home/gui/dev/topgrade -t ghcr.io/cross-rs/x86_64-unknown-dragonfly:main sh -c 'PATH="$PATH":"/home/gui/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin" cargo -v clippy --target x86_64-unknown-dragonfly -- -D warnings -Zbuild-std'
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/gui/.local/share/rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/clippy-driver rustc - --crate-name ___ --print=file-names --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit status: 1)
  --- stderr
  error: unknown unstable option: `build-std`

+ rustup component list --toolchain nightly-x86_64-unknown-linux-gnu
[cross] warning: rust-std is not available for x86_64-unknown-dragonfly
[cross] note: you may need to build components for the target via `-Z build-std=<components>` or in your cross configuration specify `target.x86_64-unknown-dragonfly.build-std`
              the available components are core, std, alloc, and proc_macro

I believe the issue is caused due to cross passing -Zbuild-std to clippy instead of cargo.

My Cross.toml:

[target.x86_64-unknown-dragonfly]
build-std = true

I've also tried without using Cross.toml, i.e. by setting RUSTFLAGS=-Zbuild-std manually, but I think I confused cross even further?

$ export RUSTFLAGS='-Zbuild-std'
$ cross -v +nightly clippy --target x86_64-unknown-dragonfly -- -D warnings
+ cargo +nightly metadata --format-version 1 --filter-platform x86_64-unknown-dragonfly
[cross] warning: unable to get metadata for package
        error: failed to run `rustc` to learn about target-specific information                Caused by:          process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Zbuild-std --target x86_64-unknown-dragonfly --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=cfg` (exit status: 1)          --- stderr          error: unknown unstable option: `build-std`        
[cross] note: Falling back to `cargo` on the host.
+ cargo -v +nightly clippy --target x86_64-unknown-dragonfly -- -D warnings
error: no such subcommand: `+nightly`

	Cargo does not handle `+toolchain` directives.
	Did you mean to invoke `cargo` through `rustup` instead?

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

other (specify in description)

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

cross 0.2.4 (6635e20 2022-11-16)

Example

git clone https://github.com/guihkx/topgrade.git -b ci-dragonfly
cd topgrade
cross -v +nightly clippy --target x86_64-unknown-dragonfly -- -D warnings

Additional information / notes

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions