Cross can be further customized by setting certain environment variables. In-depth documentation with examples can be found here.
CROSS_CONTAINER_ENGINE
: The container engine to run cross in. Defaults todocker
thenpodman
, whichever is found first (example:docker
, see the FAQ).XARGO_HOME
: Home forxargo
(example:~/.xargo
).NIX_STORE
: The directory for the Nix store (example:/nix/store
).CROSS_CONTAINER_UID
: Set the user identifier for the cross command (example:1000
).CROSS_CONTAINER_GID
: Set the group identifier for the cross command (example:1000
).CROSS_CONTAINER_IN_CONTAINER
: Informcross
that it is running inside a container (example:true
, see the FAQ).CROSS_CONTAINER_OPTS
: Additional arguments to provide to the container engine during$engine run
(example:--env MYVAR=1
whereengine=docker
).CROSS_CONFIG
: Specify the path to thecross
config file (see Config File).CROSS_BUILD_OPTS
: Space separated flags to add when building a custom image, i.e.--network=host
CROSS_DEBUG
: Print debugging information forcross
.CROSS_COMPATIBILITY_VERSION
: Use oldercross
behavior (example:0.2.1
).CROSS_CUSTOM_TOOLCHAIN
: Specify thatrustup
is using a custom toolchain, and therefore should not try to add targets/install components. Useful withcargo-bisect-rustc
.CROSS_REMOTE
: Informcross
it is using a remote container engine, and use data volumes rather than local bind mounts. See Remote for more information using remote container engines.QEMU_STRACE
: Get a backtrace of system calls from “foreign” (non x86_64) binaries when usingcross
run.CARGO_BUILD_TARGET
: Sets the default target, similar to specifying--target
.CROSS_ROOTLESS_CONTAINER_ENGINE
: Specify whether to container engine runs as root or is rootless. If set toauto
or not provided, it assumesdocker
runs as root and all other container engines are rootless.CROSS_CONTAINER_USER_NAMESPACE
: Custom the container user namespace. If set tonone
, user namespaces will be disabled. If not provided or set toauto
, it will use the default namespace.CROSS_CUSTOM_TOOLCHAIN_COMPAT
: A descriptive name for a custom toolchain socross
can convert it to a fully-qualified toolchain name.CROSS_CONTAINER_ENGINE_NO_BUILDKIT
: The container engine does not havebuildx
command (or BuildKit support) when building custom images.CROSS_NO_WARNINGS
: Set to1
to panic on warnings fromcross
, before building the executables. Use0
to disable this behaviour. The no warnings behaviour is implicitly enabled in CI pipelines.
All config file options can also be specified using environment variables. For
example, setting CROSS_BUILD_XARGO=1
is identical to setting build.xargo = true
, and CROSS_TARGET_AARCH64_UNKNOWN_LINUX_GNU_XARGO=1
is identical to
target.aarch64-unknown-linux-gnu.xargo = true
.
By default, cross
does not pass most environment variables into the build
environment from the calling shell. This is chosen as a safe default as most
use cases will not want the calling environment leaking into the inner
execution environment. There are, however, some notable exceptions: most
environment variables cross
or cargo
reads are passed through automatically
to the build environment. The major exceptions are variables that are set by
cross
or conflict with our build environment, including:
CARGO_HOME
CARGO_TARGET_DIR
CARGO_BUILD_TARGET_DIR
CARGO_BUILD_RUSTC
CARGO_BUILD_RUSTC_WRAPPER
CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER
CARGO_BUILD_RUSTDOC
CROSS_RUNNER
CROSS_RUSTC_MAJOR_VERSION
CROSS_RUSTC_MINOR_VERSION
CROSS_RUSTC_PATCH_VERSION
Otherwise, any environment variables that start with CARGO_ or CROSS_, and a few others, will be available in the build environment. For example, RUSTFLAGS and CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS will both be automatically available in the build environment.
In the instances that you do want to pass through additional environment
variables, this can be done via build.env.passthrough
in your Cross.toml
:
[build.env]
passthrough = [
"RUST_BACKTRACE",
"RUST_LOG",
"TRAVIS",
]
To pass variables through for one target but not others, you can use this syntax instead:
[target.aarch64-unknown-linux-gnu.env]
passthrough = [
"RUST_DEBUG",
]