A personal experiment to evaluate the extent of rust's cross compilation capabilities in the context of the nix package manager reproducible environment.
See hello-dynamic-rustup/README.md.
See hello-static-rustup/README.md
See:
-
hello-static-rustup-target-windows/README.md
Trivial no dependency hello world.
-
simple-static-rustup-target-windows/README.md
Non trivial tough simple project with dependencies.
Ready for use as scafolding project.
-
-
rustc -C target-feature=+crt-static foo.rs
To use this feature locally, you typically will use the RUSTFLAGS environment variable to specify flags to the compiler through Cargo For example to compile a statically linked binary on MSVC you would execute:
RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-pc-windows-msvc
-
-
-
Each toolchain has several "components", some of which are required (like rustc) and some that are optional
rust-mingw
— This contains a linker and platform libraries for building on the x86_64-pc-windows-gnu platform. -
rustup automatically determines which toolchain to use when one of the installed commands like rustc is executed
There are several ways to control and override which toolchain is used:
The
RUSTUP_TOOLCHAIN
environment variable.The
rust-toolchain.toml
file.-
toolchain can be named in the project's directory in a file called
rust-toolchain.toml
orrust-toolchain
. If both files are present in a directory, the latter is used for backwards compatibilityFor backwards compatibility,
rust-toolchain
files also support a legacy format that only contains a toolchain name without any TOML encoding
-
-
RUSTUP_HOME
(default: ~/.rustup or %USERPROFILE%/.rustup) Sets the root rustup folder, used for storing installed toolchains and configuration options.RUSTUP_TOOLCHAIN
(default: none) If set, will override the toolchain used for all rust tool invocations. A toolchain with this name should be installed, or invocations will fail.
-
Index and list all available toolchains · Issue #215 · rust-lang/rustup