# Setting --mcpu

**URL:** <https://forum.crystal-lang.org/t/setting-mcpu/7153>\
**Category:** Help & Support\
**Created:** [August 29, 2024, 8:04am UTC](https://forum.crystal-lang.org/t/setting-mcpu/7153 "2024-08-29T08:04:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karl-Goethebier](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/karl-goethebier/32/2579_2.png) [@Karl-Goethebier](https://forum.crystal-lang.org/u/Karl-Goethebier)\
**Post date:** [August 29, 2024, 8:04am UTC](https://forum.crystal-lang.org/t/setting-mcpu/7153/1 "2024-08-29T08:04:36Z")

</div>

Hi all,

I’m a bit surprised:

```auto
karl@rantanplan:~/src/crystal$ cpuid -1 | grep uarch
    (uarch synth) = AMD Zen 3, 7nm

karl@rantanplan:~/src/crystal$ grep -m1 "cpu family" /proc/cpuinfo
cpu family : 25

karl@rantanplan:~/src/crystal$ gcc -### -E - -march=native 2>&1 | grep -o "\-march=znver[1-4]\+" 
-march=znver2

```

25 is Zen 3. But from `gcc` i get Zen 2. If i didn’t miss something. I wonder what to do. Forget about it and set `--mcpu native` is perhaps the right option?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [August 29, 2024, 12:49pm UTC](https://forum.crystal-lang.org/t/setting-mcpu/7153/2 "2024-08-29T12:49:42Z")

</div>

What’s the output of `crystal eval 'require "llvm"; pp LLVM.host_cpu_name'` for you? When you use `--mcpu=native`, the value of that method is what is provided. So that should make it more clear what LLVM would be using in that context.

---

<div class="post-metadata">

**Author:** ![Karl-Goethebier](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/karl-goethebier/32/2579_2.png) [@Karl-Goethebier](https://forum.crystal-lang.org/u/Karl-Goethebier)\
**Post date:** [August 29, 2024, 2:26pm UTC](https://forum.crystal-lang.org/t/setting-mcpu/7153/3 "2024-08-29T14:26:23Z")

</div>

> [@Blacksmoke16](#):
>
> `crystal eval 'require "llvm"; pp LLVM.host_cpu_name'`

Big surprise: `"znver3" `. Thanks. I guess then this should be the value i chose. Or rely on. But where do the different values come from?

---

<div class="post-metadata">

**Author:** ![Blacksmoke16](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/blacksmoke16/32/1241_2.png) [@Blacksmoke16](https://forum.crystal-lang.org/u/Blacksmoke16)\
**Post date:** [August 29, 2024, 2:30pm UTC](https://forum.crystal-lang.org/t/setting-mcpu/7153/4 "2024-08-29T14:30:03Z")

</div>

> [@Karl-Goethebier](#):
>
> I guess then this should this be the value i chose. Or rely on.

Again to be clear, in your specific case there is no difference between `--mcpu=znver3` and `--mcpu=native`. The latter at least makes it so you don’t really have to worry about it.

> [@Karl-Goethebier](#):
>
> But where do the different values come from?

Not sure, when running that gcc command on my machine, it matches up with what `LLVM.host_cpu_name` returns so 🤷.

---

<div class="post-metadata">

**Author:** ![Karl-Goethebier](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/karl-goethebier/32/2579_2.png) [@Karl-Goethebier](https://forum.crystal-lang.org/u/Karl-Goethebier)\
**Post date:** [August 29, 2024, 2:43pm UTC](https://forum.crystal-lang.org/t/setting-mcpu/7153/5 "2024-08-29T14:43:06Z")

</div>

OK, thanks.
