Fix printing native CPU on cross-compiled compiler.
This commit is contained in:
parent
fec9adcdbc
commit
e4e4110dc6
@ -310,12 +310,14 @@ static size_t getLongestEntryLength(ArrayRef<KV> Table) {
|
|||||||
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
|
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
|
||||||
const TargetMachine *Target = unwrap(TM);
|
const TargetMachine *Target = unwrap(TM);
|
||||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||||
const Triple::ArchType HostArch = Triple(sys::getProcessTriple()).getArch();
|
const Triple::ArchType HostArch = Triple(sys::getDefaultTargetTriple()).getArch();
|
||||||
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();
|
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();
|
||||||
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
|
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
|
||||||
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
|
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
|
||||||
|
|
||||||
printf("Available CPUs for this target:\n");
|
printf("Available CPUs for this target:\n");
|
||||||
|
// Don't print the "native" entry when the user specifies --target with a
|
||||||
|
// different arch since that could be wrong or misleading.
|
||||||
if (HostArch == TargetArch) {
|
if (HostArch == TargetArch) {
|
||||||
const StringRef HostCPU = sys::getHostCPUName();
|
const StringRef HostCPU = sys::getHostCPUName();
|
||||||
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",
|
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user