From 099db205552c73c9b87f760d1ae7def52840b3f3 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Tue, 7 Jun 2022 16:43:17 +0200 Subject: [PATCH] Use target-applies-to-host to avoid unnecessary cache invalidation --- .cargo/config.toml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 39e4bff851e..222cbe1dc8d 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,3 +1,13 @@ +# Pass the rustflags specified to host dependencies (build scripts, proc-macros) +# when a `--target` is passed to Cargo. Historically this was not the case, and +# because of that, cross-compilation would not set the rustflags configured +# below in `target.'cfg(all())'` for them, resulting in cache invalidation. +# +# Since this is an unstable feature (enabled at the bottom of the file), this +# setting is unfortunately ignored on stable toolchains, but it's still better +# to have it apply on nightly than using the old behavior for all toolchains. +target-applies-to-host = false + [alias] xtask = "run --package xtask --" @@ -23,3 +33,8 @@ rustflags = [ "-Wclippy::str_to_string", "-Wclippy::todo", ] + +# activate the target-applies-to-host feature. +# Required for `target-applies-to-host` at the top to take effect. +[unstable] +target-applies-to-host = true