llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27k stars 11.06k forks source link

-march=native doesn't work in virtualized environment #19610

Open mikulas-patocka opened 10 years ago

mikulas-patocka commented 10 years ago
Bugzilla Link 19236
Version trunk
OS Linux
Attachments [The content of https://user-images.githubusercontent.com/95090467/143749222-ccc47988-4cb1-4ab8-b1b3-9438cd943022.gz), The output of the cpuid utility in the guest system

Extended Description

I have x86-64 Debian sid installed in kvm-qemu. I have 64-bit clang-3.5 installed from Debian repository.

When compiling a simple program with -march=native, clang fails. $ cat hello.c

include

int main(void) { printf("Hello World!\n"); return 0; } $ clang -march=native hello.c error: unknown target CPU 'athlon'

Apparently, there is some bug in processor detection, even if the system is 64-bit, clang detects a 32-bit "athlon" processor and subsequently fails, because the 64-bit target doesn't know this processor.

Note that kvm reports some features of the underlying CPU (the CPU is istanbul-class Opteron) as not present in order to allow the program to be migrated. This probably confuses clang, so that it clasifies the CPU as 32-bit Athlon.

llvmbot commented 1 week ago

@llvm/issue-subscribers-clang-driver

Author: None (mikulas-patocka)

| | | | --- | --- | | Bugzilla Link | [19236](https://llvm.org/bz19236) | | Version | trunk | | OS | Linux | | Attachments | [The content of https://user-images.githubusercontent.com/95090467/143749222-ccc47988-4cb1-4ab8-b1b3-9438cd943022.gz), [The output of the cpuid utility in the guest system](https://user-images.githubusercontent.com/95090467/143749223-ee791819-6fdc-401e-a079-3847691ebf38.gz) | ## Extended Description I have x86-64 Debian sid installed in kvm-qemu. I have 64-bit clang-3.5 installed from Debian repository. When compiling a simple program with -march=native, clang fails. $ cat hello.c #include <stdio.h> int main(void) { printf("Hello World!\n"); return 0; } $ clang -march=native hello.c error: unknown target CPU 'athlon' Apparently, there is some bug in processor detection, even if the system is 64-bit, clang detects a 32-bit "athlon" processor and subsequently fails, because the 64-bit target doesn't know this processor. Note that kvm reports some features of the underlying CPU (the CPU is istanbul-class Opteron) as not present in order to allow the program to be migrated. This probably confuses clang, so that it clasifies the CPU as 32-bit Athlon.