diff options
| author | Ralf Jung <post@ralfj.de> | 2025-05-11 12:50:48 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-06-19 09:45:07 +0900 |
| commit | 8bec5bb5adaa1f5a0bc3683fee5f77a5fdac539b (patch) | |
| tree | ce00fdd36f80e8a24b62d9e611fe8b05d228ef4e /compiler/rustc_codegen_llvm/src | |
| parent | e46c234ca4ccbad085f11de7ca1cd25a40431b22 (diff) | |
| download | rust-8bec5bb5adaa1f5a0bc3683fee5f77a5fdac539b.tar.gz rust-8bec5bb5adaa1f5a0bc3683fee5f77a5fdac539b.zip | |
cg_gcc: properly populate cfg(target_features) with -Ctarget-features
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index ee78c310b0d..bc2165fa829 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -7,6 +7,7 @@ use std::{ptr, slice, str}; use libc::c_int; use rustc_codegen_ssa::base::wants_wasm_eh; +use rustc_codegen_ssa::target_features::cfg_target_feature; use rustc_codegen_ssa::{TargetConfig, target_features}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::small_c_str::SmallCStr; @@ -331,24 +332,23 @@ pub(crate) fn target_config(sess: &Session) -> TargetConfig { // by LLVM. let target_machine = create_informational_target_machine(sess, true); - let (unstable_target_features, target_features) = - target_features::cfg_target_feature(sess, &sess.opts.cg.target_feature, |feature| { - if let Some(feat) = to_llvm_features(sess, feature) { - // All the LLVM features this expands to must be enabled. - for llvm_feature in feat { - let cstr = SmallCStr::new(llvm_feature); - // `LLVMRustHasFeature` is moderately expensive. On targets with many - // features (e.g. x86) these calls take a non-trivial fraction of runtime - // when compiling very small programs. - if !unsafe { llvm::LLVMRustHasFeature(target_machine.raw(), cstr.as_ptr()) } { - return false; - } + let (unstable_target_features, target_features) = cfg_target_feature(sess, |feature| { + if let Some(feat) = to_llvm_features(sess, feature) { + // All the LLVM features this expands to must be enabled. + for llvm_feature in feat { + let cstr = SmallCStr::new(llvm_feature); + // `LLVMRustHasFeature` is moderately expensive. On targets with many + // features (e.g. x86) these calls take a non-trivial fraction of runtime + // when compiling very small programs. + if !unsafe { llvm::LLVMRustHasFeature(target_machine.raw(), cstr.as_ptr()) } { + return false; } - true - } else { - false } - }); + true + } else { + false + } + }); let mut cfg = TargetConfig { target_features, |
