Skip to content

Commit e9c9307

Browse files
Rollup merge of rust-lang#131010 - RalfJung:target-cpu-native, r=jieyouxu
extend comment in global_llvm_features regarding target-cpu=native Based on the description in rust-lang#83084 by `@nagisa` -- seems better to have this in the code, where it is easier to find.
2 parents ee8ca3a + a78fd69 commit e9c9307

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

compiler/rustc_codegen_llvm/src/llvm_util.rs

+5
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,11 @@ pub(crate) fn global_llvm_features(
536536
// -Ctarget-cpu=native
537537
match sess.opts.cg.target_cpu {
538538
Some(ref s) if s == "native" => {
539+
// We have already figured out the actual CPU name with `LLVMRustGetHostCPUName` and set
540+
// that for LLVM, so the features implied by that CPU name will be available everywhere.
541+
// However, that is not sufficient: e.g. `skylake` alone is not sufficient to tell if
542+
// some of the instructions are available or not. So we have to also explicitly ask for
543+
// the exact set of features available on the host, and enable all of them.
539544
let features_string = unsafe {
540545
let ptr = llvm::LLVMGetHostCPUFeatures();
541546
let features_string = if !ptr.is_null() {

0 commit comments

Comments
 (0)