Avoid passing --cpu-features when empty

Added in 12ac719b99, this logic always
passed --cpu-features, even when the value was the empty string.
This commit is contained in:
Tamir Duberstein 2023-06-01 13:07:51 -04:00
parent 642c92e630
commit cd4354578a
No known key found for this signature in database

View file

@ -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();