[llvm] [MC] Add support for -mcpu=native. (PR #159414)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 11:18:50 PDT 2025


================
@@ -467,6 +467,10 @@ int main(int argc, char **argv) {
     FeaturesStr = Features.getString();
   }
 
+  // Replace -mcpu=native with Host CPU.
----------------
jurahul wrote:

Would it make sense instead to change the default value of -mcpu to be the host cpu name? That is, instead of:

```
static cl::opt<std::string>
    MCPU("mcpu",
         cl::desc("Target a specific cpu type (-mcpu=help for details)"),
         cl::value_desc("cpu-name"), cl::init(""), cl::cat(MCCategory));
```

use

```
static cl::opt<std::string>
    MCPU("mcpu",
         cl::desc("Target a specific cpu type (-mcpu=help for details)"),
         cl::value_desc("cpu-name"), cl::init((llvm::sys::getHostCPUName())), cl::cat(MCCategory));
```

if that works.

https://github.com/llvm/llvm-project/pull/159414


More information about the llvm-commits mailing list