Skip to content

Commit 4cdb362

Browse files
committed
Auto merge of rust-lang#44407 - mattico:print-native-cpu, r=arielb1
Add 'native' to -C target-cpu=help Fixes rust-lang#44393
2 parents 183329c + 824fb38 commit 4cdb362

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/rustllvm/PassWrapper.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -299,10 +299,17 @@ static size_t getLongestEntryLength(ArrayRef<SubtargetFeatureKV> Table) {
299299
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
300300
const TargetMachine *Target = unwrap(TM);
301301
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
302+
const Triple::ArchType HostArch = Triple(sys::getProcessTriple()).getArch();
303+
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();
302304
const ArrayRef<SubtargetFeatureKV> CPUTable = MCInfo->getCPUTable();
303305
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
304306

305307
printf("Available CPUs for this target:\n");
308+
if (HostArch == TargetArch) {
309+
const StringRef HostCPU = sys::getHostCPUName();
310+
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",
311+
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
312+
}
306313
for (auto &CPU : CPUTable)
307314
printf(" %-*s - %s.\n", MaxCPULen, CPU.Key, CPU.Desc);
308315
printf("\n");

0 commit comments

Comments
 (0)