[llvm] [MC] Add support for -mcpu=native. (PR #159414)
Cameron McInally via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 17 11:36:14 PDT 2025
================
@@ -467,6 +467,10 @@ int main(int argc, char **argv) {
FeaturesStr = Features.getString();
}
+ // Replace -mcpu=native with Host CPU.
----------------
mcinally wrote:
I considered that, but it is a functional change. An unspecified -mcpu gives the baseline CPU, where that change would return the host CPU. It probably needs a whole RFC before changing and I'm not even sure if it's desirable in general. A compiler like GCC won't give you the host CPU by default (which is why `-mcpu=native` exists).
This patch is more in line with how the Frontends deal with `-mcpu=native`. E.g. clang/lib/Driver/ToolChains/Arch/AArch64.cpp:
```
// Handle CPU name is 'native'.
if (CPU == "native")
return std::string(llvm::sys::getHostCPUName());
```
https://github.com/llvm/llvm-project/pull/159414
More information about the llvm-commits
mailing list