Skip to content

"rustup target [add, install]" should guide towards successful compilation.  #1483

Open
@ralfbiedert

Description

@ralfbiedert

The README says:

Note that rustup target add only installs the Rust standard library for a given target. There are typically other tools necessary to cross-compile, particularly a linker. For example, to cross compile to Android the Android NDK must be installed. In the future, rustup will provide assistance installing the NDK components as well.

Witnessing myself and my colleagues, most users will:

  • not read this part of the README
  • just try rustup target [add, install] arm-linux-xxx and see what happens.
  • then spend 30 - 60 minutes puzzling together what exactly they need to download and how to configure ~/.cargo/config.

Having everything work out of the box would obviously be the best case.

In lack of that, since the steps for a given host x target combination are similar, there should be clear and simple instructions printed right at the end of an rustup installation, at least for the most common combinations.

What I would have liked (simplified):

> rustup target install aarch64-linux-android

info: component 'rust-std' for target 'aarch64-linux-android' installed.

warning: To successfully compile for `aarch64-linux-android` on `macos` you also 
need the linker from a cross compilation toolchain. In the majority of cases these steps 
are needed:

INSTALL TOOLCHAIN
- Run `brew install [package]`
- (Alternatively) install [URL] 

CONFIGURE TOOLCHAIN
- Locate the file `make-standalone-toolchain.sh`, part of the toolchain.
- Run `make-standalone-toolchain.sh --arch=aarch64-linux-android`

CONFIGURE CARGO
- In your `.cargo/config` set:

[target.aarch64-linux-android]
linker = "[PATH_TO_STANDALONE_TOOLCHAIN]/aarch64-linux-android/bin/aarch64-linux-android-clang"

Other host x target combinations should have these steps modified accordingly.

If the steps for a given host x target are unclear / ambiguous, rustup should print exactly that as part of the INSTALL TOOLCHAIN and CONFIGURE TOOLCHAIN instructions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions