Skip to content

Commit

Permalink
Rollup merge of #131010 - RalfJung:target-cpu-native, r=jieyouxu
Browse files Browse the repository at this point in the history
extend comment in global_llvm_features regarding target-cpu=native

Based on the description in #83084 by `@nagisa` -- seems better to have this in the code, where it is easier to find.
  • Loading branch information
GuillaumeGomez authored Sep 29, 2024
2 parents ee8ca3a + a78fd69 commit e9c9307
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,11 @@ pub(crate) fn global_llvm_features(
// -Ctarget-cpu=native
match sess.opts.cg.target_cpu {
Some(ref s) if s == "native" => {
// We have already figured out the actual CPU name with `LLVMRustGetHostCPUName` and set
// that for LLVM, so the features implied by that CPU name will be available everywhere.
// However, that is not sufficient: e.g. `skylake` alone is not sufficient to tell if
// some of the instructions are available or not. So we have to also explicitly ask for
// the exact set of features available on the host, and enable all of them.
let features_string = unsafe {
let ptr = llvm::LLVMGetHostCPUFeatures();
let features_string = if !ptr.is_null() {
Expand Down

0 comments on commit e9c9307

Please sign in to comment.