Skip to content

A personal experiment to evaluate the extent of rust's cross compilation capabilities in the context of nix

License

Notifications You must be signed in to change notification settings

jraygauthier/jrg-rust-cross-experiment

Repository files navigation

Readme

A personal experiment to evaluate the extent of rust's cross compilation capabilities in the context of the nix package manager reproducible environment.

Build targetting host platform via rustup / rustc

Dynamically linked to libc

See hello-dynamic-rustup/README.md.

Statically linked to libc

See hello-static-rustup/README.md

Build targetting windows platform via rustup / rustc

Statically linked to libc

See:

References

  • Rust - NixOS Wiki

  • Linkage - The Rust Reference

    • Static and dynamic C runtimes

      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

  • Using RUSTFLAGS - Rust SIMD Performance Guide

  • The rustup book

    • Toolchains

    • Components

      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.

    • Overrides

      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.

      • The toolchain file

        toolchain can be named in the project's directory in a file called rust-toolchain.toml or rust-toolchain. If both files are present in a directory, the latter is used for backwards compatibility

        For backwards compatibility, rust-toolchain files also support a legacy format that only contains a toolchain name without any TOML encoding

    • Environment variables

      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

About

A personal experiment to evaluate the extent of rust's cross compilation capabilities in the context of nix

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published