From db79438ddbc3a4861f7c8da389802b553bcf0cc6 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 19 Aug 2021 11:05:54 -0500 Subject: [PATCH] Fix cross-compilation via the CLI (#3212) The `strategy` was chosen after the `target` which meant that the target choice was blown away because the `strategy` method overwrites the currently configured compiler. --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a23509710d..a6ac4f2bf2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -298,13 +298,15 @@ impl CommonOptions { fn config(&self, target: Option<&str>) -> Result { let mut config = Config::new(); - // Set the target before setting any cranelift options + // Set the compiler and target before setting any cranelift options, + // since the strategy determines which compiler is in use and the target + // will reset any target-specific options. + config.strategy(pick_compilation_strategy(self.cranelift, self.lightbeam)?)?; if let Some(target) = target { config.target(target)?; } config - .strategy(pick_compilation_strategy(self.cranelift, self.lightbeam)?)? .cranelift_debug_verifier(self.enable_cranelift_debug_verifier) .debug_info(self.debug_info) .cranelift_opt_level(self.opt_level())