about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm_util.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-09-29 12:37:53 +0200
committerGitHub <noreply@github.com>2024-09-29 12:37:53 +0200
commite9c9307d363cc9c9ee27d32801161988c7439dcc (patch)
tree24e945c7e9606904f68de7d848a82e855575d3d8 /compiler/rustc_codegen_llvm/src/llvm_util.rs
parentee8ca3aa6ca9e8fe5414df7520dd45988e03c10a (diff)
parenta78fd694d47608eb382478b038ad0e91b6f5150d (diff)
downloadrust-e9c9307d363cc9c9ee27d32801161988c7439dcc.tar.gz
rust-e9c9307d363cc9c9ee27d32801161988c7439dcc.zip
Rollup merge of #131010 - RalfJung:target-cpu-native, r=jieyouxu
extend comment in global_llvm_features regarding target-cpu=native

Based on the description in https://github.com/rust-lang/rust/pull/83084 by `@nagisa` -- seems better to have this in the code, where it is easier to find.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm_util.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs
index a2a5499597c..201cfbb1918 100644
--- a/compiler/rustc_codegen_llvm/src/llvm_util.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -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() {