From cd4354578a9a8cae62d9340eda66ec6689ac8ba7 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 1 Jun 2023 13:07:51 -0400 Subject: [PATCH] Avoid passing --cpu-features when empty Added in 12ac719b99560072cbe52a957f22d3fe6946cf2a, this logic always passed --cpu-features, even when the value was the empty string. --- compiler/rustc_codegen_ssa/src/back/link.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index f8bb9bf2bb50b..8dbd4456a6b89 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2256,11 +2256,13 @@ fn add_order_independent_options( } else if flavor == LinkerFlavor::Bpf { cmd.arg("--cpu"); cmd.arg(&codegen_results.crate_info.target_cpu); - cmd.arg("--cpu-features"); - cmd.arg(match &sess.opts.cg.target_feature { - feat if !feat.is_empty() => feat.as_ref(), - _ => sess.target.options.features.as_ref(), - }); + if let Some(feat) = [sess.opts.cg.target_feature.as_str(), &sess.target.options.features] + .into_iter() + .find(|feat| !feat.is_empty()) + { + cmd.arg("--cpu-features"); + cmd.arg(feat); + } } cmd.linker_plugin_lto();