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

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 18:01:40 PDT 2025


================
@@ -467,6 +467,10 @@ int main(int argc, char **argv) {
     FeaturesStr = Features.getString();
   }
 
+  // Replace -mcpu=native with Host CPU.
+  if (MCPU == "native")
+    MCPU = std::string(llvm::sys::getHostCPUName());
+
----------------
topperc wrote:

> > Clang does use getHostCPUFeatures with -mcpu=native. I wrote the code originally. It's here.
> 
> That's `-march` now. Maybe changed when `-mcpu` was deprecated on X86.
> 
> ```
> $ clang test.c -mcpu=native
> clang: error: unsupported option '-mcpu=' for target 'x86_64-unknown-linux-gnu'
> ```

Sorry I meant -march=native. For all intents and purpose -march on X86 is -mcpu. I've been on RISC-V for too long now so I my brain thinks -mcpu.

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


More information about the llvm-commits mailing list