Skip to content

Commit a78fd69

Browse files
committed
extend comment in global_llvm_features regarding target-cpu=native handling
1 parent 9903b25 commit a78fd69

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: 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)