--print target-cpus
shows default target cpu, updated docs
This commit is contained in:
parent
eb7a743421
commit
ea17aa9141
3 changed files with 18 additions and 4 deletions
|
@ -329,7 +329,13 @@ pub(crate) fn print(req: PrintRequest, sess: &Session) {
|
|||
require_inited();
|
||||
let tm = create_informational_target_machine(sess);
|
||||
match req {
|
||||
PrintRequest::TargetCPUs => unsafe { llvm::LLVMRustPrintTargetCPUs(tm) },
|
||||
PrintRequest::TargetCPUs => {
|
||||
println!(
|
||||
"Default CPU for this target:\n {}",
|
||||
handle_native(sess.target.cpu.as_ref())
|
||||
);
|
||||
unsafe { llvm::LLVMRustPrintTargetCPUs(tm, handle_native(sess.target.cpu.as_ref())) };
|
||||
}
|
||||
PrintRequest::TargetFeatures => print_target_features(sess, tm),
|
||||
_ => bug!("rustc_codegen_llvm can't handle print request: {:?}", req),
|
||||
}
|
||||
|
|
|
@ -307,7 +307,7 @@ static size_t getLongestEntryLength(ArrayRef<KV> Table) {
|
|||
return MaxLen;
|
||||
}
|
||||
|
||||
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
|
||||
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, &Char[]) {
|
||||
const TargetMachine *Target = unwrap(TM);
|
||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||
const Triple::ArchType HostArch = Triple(sys::getDefaultTargetTriple()).getArch();
|
||||
|
@ -324,7 +324,14 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
|
|||
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
|
||||
}
|
||||
for (auto &CPU : CPUTable)
|
||||
printf(" %-*s\n", MaxCPULen, CPU.Key);
|
||||
|
||||
printf(" %-*s", MaxCPULen, CPU.Key);
|
||||
if (CPU.Key == Target->getTargetTriple().getArch()) {
|
||||
printf(" default target\n");
|
||||
}
|
||||
else {
|
||||
printf("\n");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -574,7 +574,8 @@ change in the future.
|
|||
This instructs `rustc` to generate code specifically for a particular processor.
|
||||
|
||||
You can run `rustc --print target-cpus` to see the valid options to pass
|
||||
here. Each target has a default base CPU. Special values include:
|
||||
and the default target CPU for the current buid target.
|
||||
Each target has a default base CPU. Special values include:
|
||||
|
||||
* `native` can be passed to use the processor of the host machine.
|
||||
* `generic` refers to an LLVM target with minimal features but modern tuning.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue