@@ -150809,7 +150809,7 @@ class CacheConfig {
150809150809 /** The prefix portion of the cache key */
150810150810 this.keyPrefix = "";
150811150811 /** The rust version considered for the cache key */
150812- this.keyRust = "" ;
150812+ this.keyRust = [] ;
150813150813 /** The environment variables considered for the cache key */
150814150814 this.keyEnvs = [];
150815150815 /** The files considered for the cache key */
@@ -150863,12 +150863,15 @@ class CacheConfig {
150863150863 // The env vars are sorted, matched by prefix and hashed into the
150864150864 // resulting environment hash.
150865150865 let hasher = external_crypto_default().createHash("sha1");
150866- const rustVersion = await getRustVersion(cmdFormat);
150867- let keyRust = `${rustVersion.release} ${rustVersion.host}`;
150868- hasher.update(keyRust);
150869- hasher.update(rustVersion["commit-hash"]);
150870- keyRust += ` (${rustVersion["commit-hash"]})`;
150871- self.keyRust = keyRust;
150866+ const rustVersions = Array.from(await getRustVersions(cmdFormat));
150867+ // Doesn't matter how they're sorted, just as long as it's deterministic.
150868+ rustVersions.sort();
150869+ for (const rustVersion of rustVersions) {
150870+ const { release, host, "commit-hash": commitHash } = rustVersion;
150871+ const keyRust = `${release} ${host} ${commitHash}`;
150872+ hasher.update(keyRust);
150873+ self.keyRust.push(keyRust);
150874+ }
150872150875 // these prefixes should cover most of the compiler / rust / cargo keys
150873150876 const envPrefixes = ["CARGO", "CC", "CFLAGS", "CXX", "CMAKE", "RUST"];
150874150877 envPrefixes.push(...lib_core.getInput("env-vars").split(/\s+/).filter(Boolean));
@@ -151052,7 +151055,10 @@ class CacheConfig {
151052151055 lib_core.info(`.. Prefix:`);
151053151056 lib_core.info(` - ${this.keyPrefix}`);
151054151057 lib_core.info(`.. Environment considered:`);
151055- lib_core.info(` - Rust Version: ${this.keyRust}`);
151058+ lib_core.info(` - Rust Versions:`);
151059+ for (const rust of this.keyRust) {
151060+ lib_core.info(` - ${rust}`);
151061+ }
151056151062 for (const env of this.keyEnvs) {
151057151063 lib_core.info(` - ${env}`);
151058151064 }
@@ -151087,9 +151093,31 @@ function isCacheUpToDate() {
151087151093function digest(hasher) {
151088151094 return hasher.digest("hex").substring(0, HASH_LENGTH);
151089151095}
151090- async function getRustVersion(cmdFormat) {
151091- const stdout = await getCmdOutput(cmdFormat, "rustc -vV");
151092- let splits = stdout
151096+ async function getRustVersions(cmdFormat) {
151097+ const versions = new Set();
151098+ versions.add(parseRustVersion(await getCmdOutput(cmdFormat, "rustc -vV")));
151099+ const stdout = await (async () => {
151100+ try {
151101+ return await getCmdOutput(cmdFormat, "rustup toolchain list --quiet");
151102+ }
151103+ catch (e) {
151104+ lib_core.warning(`Error running rustup toolchain list, falling back to default toolchain only: ${e}`);
151105+ return undefined;
151106+ }
151107+ })();
151108+ if (stdout !== undefined) {
151109+ for (const toolchain of stdout.split(/[\n\r]+/)) {
151110+ const trimmed = toolchain.trim();
151111+ if (!trimmed) {
151112+ continue;
151113+ }
151114+ versions.add(parseRustVersion(await getCmdOutput(cmdFormat, `rustup run ${toolchain} rustc -vV`)));
151115+ }
151116+ }
151117+ return versions;
151118+ }
151119+ function parseRustVersion(stdout) {
151120+ const splits = stdout
151093151121 .split(/[\n\r]+/)
151094151122 .filter(Boolean)
151095151123 .map((s) => s.split(":").map((s) => s.trim()))
0 commit comments