# Result binary issues: CPU ISA level is lower than required

**URL:** <https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854>\
**Category:** Help & Support\
**Created:** [May 20, 2024, 2:58am UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854 "2024-05-20T02:58:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fijxu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fijxu/32/3422_2.png) [@Fijxu](https://forum.crystal-lang.org/u/Fijxu)\
**Post date:** [May 20, 2024, 2:58am UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/1 "2024-05-20T02:58:01Z")

</div>

I tried to compile my program on my PC using `crystal build src/main.cr -p -s --release` but after uploading the result binary to my low RAM server I got this message when I tried to execute it: `./main: CPU ISA level is lower than required`

At that moment I tried to compile the program using either:

- `crystal build src/main.cr -p -s --release --mcpu=x86-64-v3`
- `crystal build src/main.cr -p -s --release --mcpu=x86-64-v2`
- `crystal build src/main.cr -p -s --release --mcpu=x86-64`
- `crystal build src/main.cr -p -s --release --mcpu=generic`

and none of the generated binaries were able to run on my server which supports **x86-64-v3** binaries.

The PC where do all the development is able to compile **x86-64-v4** binaries.

Using `--static` doesn’t work either because the compiler complains about missing development packages which I actually have on my system (Arch Linux):

```auto
/usr/bin/ld: cannot find -lyaml (this usually means you need to install the development package for libyaml): No such file or directory
/usr/bin/ld: cannot find -lssl (this usually means you need to install the development package for libssl): No such file or directory
/usr/bin/ld: cannot find -lcrypto (this usually means you need to install the development package for libcrypto): No such file or directory

```

There is any ways to fix it? Is this a known bug or I am missing something? I only want to be able to compile on my PC and then upload the binary to my server.

---

<div class="post-metadata">

**Author:** ![beta-ziliani](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/beta-ziliani/32/1821_2.png) [@beta-ziliani](https://forum.crystal-lang.org/u/beta-ziliani)\
**Post date:** [May 20, 2024, 3:47pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/2 "2024-05-20T15:47:04Z")

</div>

In my computer I can generate different versions and it works well. Maybe some required lib was compiled using a v4 target?

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 20, 2024, 6:23pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/3 "2024-05-20T18:23:38Z")

</div>

Are you sure this error message is coming from the Crystal part of the program?

According to a quick google search the error might be coming from an incompatible version of glibc.  
You could check that by executing the dynamically linked libc library on your target system. You can get the path via `ldd main | grep libc` and execute the resolved path. It should show some diagnostic information (or maybe the same error message).

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 20, 2024, 6:39pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/4 "2024-05-20T18:39:11Z")

</div>

Correction: If I interpret the [C code that prints this error](https://github.com/bminor/glibc/blob/2be3352f0b1ebaa39596393fffe1062275186669/sysdeps/x86/dl-prop.h#L57-L58) correctly, the prefix `./main` should tell us that the error is on the executable, not a library. Not 100% certain, it would still be useful to do the test.

Assuming it’s an issue with the Crystal code, you may need to be more specific with the CPU or CPU feature targeting.  
Which processor do you want the code to run on?

---

<div class="post-metadata">

**Author:** ![Fijxu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fijxu/32/3422_2.png) [@Fijxu](https://forum.crystal-lang.org/u/Fijxu)\
**Post date:** [May 20, 2024, 6:54pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/5 "2024-05-20T18:54:30Z")

</div>

A Ryzen 9 of 3rd generation. It’s a VPS but that is the processor that it has assigned to it. My PC has a i7-11850H and there is where I compile the program

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 20, 2024, 7:17pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/6 "2024-05-20T19:17:42Z")

</div>

You might want to try `--mcpu=zenver3` then.

---

<div class="post-metadata">

**Author:** ![Fijxu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fijxu/32/3422_2.png) [@Fijxu](https://forum.crystal-lang.org/u/Fijxu)\
**Post date:** [May 20, 2024, 7:18pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/7 "2024-05-20T19:18:10Z")

</div>

When executing libc on my PC, I get this:

```auto
GNU C Library (GNU libc) stable release version 2.39.
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 14.1.1 20240507.
libc ABIs: UNIQUE IFUNC ABSOLUTE
Minimum supported kernel: 6.1.0
For bug reporting instructions, please see:
<https://gitlab.archlinux.org/archlinux/packaging/packages/glibc/-/issues>.

```

And on my server I get this:

```auto
GNU C Library (Debian GLIBC 2.36-9+deb12u7) stable release version 2.36.
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 12.2.0.
libc ABIs: UNIQUE IFUNC ABSOLUTE
Minimum supported kernel: 3.2.0
For bug reporting instructions, please see:
<http://www.debian.org/Bugs/>.

```

If the problem is the difference between the installed glibc packages I could make use of the `--static` argument but it just doesn’t work as I pointed in OP.

---

<div class="post-metadata">

**Author:** ![Fijxu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fijxu/32/3422_2.png) [@Fijxu](https://forum.crystal-lang.org/u/Fijxu)\
**Post date:** [May 20, 2024, 7:19pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/8 "2024-05-20T19:19:01Z")

</div>

```auto
$ crystal build src/main.cr --release --mcpu=zenver3 ✘ 
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
[1] 324977 IOT instruction (core dumped) crystal build src/main.cr --release --mcpu=zenver3

```

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 20, 2024, 7:19pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/9 "2024-05-20T19:19:19Z")

</div>

Static linking is completely unrelated and won’t fix any issues with Crystal codegen not working for your target CPU.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 20, 2024, 7:22pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/10 "2024-05-20T19:22:26Z")

</div>

Sorry, I forgot to mention but you need to add `--cross-compile` because you’re explicitly building for a different CPU than the host.  
In this mode the compiler prints a linker command which you need to execute. It might work fine to run it on the host and upload the final executable. But the proper process is to upload he object file to the target system and run the linker command there.

---

<div class="post-metadata">

**Author:** ![Fijxu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fijxu/32/3422_2.png) [@Fijxu](https://forum.crystal-lang.org/u/Fijxu)\
**Post date:** [May 20, 2024, 7:26pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/11 "2024-05-20T19:26:25Z")

</div>

Yeah this doesn’t seem to work too.

```auto
$ crystal build src/main.cr --mcpu=zenver3 --cross-compile

'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
[1] 325951 IOT instruction (core dumped) crystal build src/main.cr --mcpu=zenver3 --cross-compile

```

```auto
$ crystal build src/main.cr --release --mcpu=zenver3 --cross-compile
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
'zenver3' is not a recognized processor for this target (ignoring processor)
LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
[1] 326030 IOT instruction (core dumped) crystal build src/main.cr --release --mcpu=zenver3 --cross-compile

```

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 20, 2024, 7:29pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/12 "2024-05-20T19:29:18Z")

</div>

Sorry, the correct spelling is `--mcpu=znver3` 🙈

---

<div class="post-metadata">

**Author:** ![Fijxu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fijxu/32/3422_2.png) [@Fijxu](https://forum.crystal-lang.org/u/Fijxu)\
**Post date:** [May 20, 2024, 7:44pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/13 "2024-05-20T19:44:09Z")

</div>

Thanks, that did the trick. I used `crystal build src/main.cr --mcpu=znver3 --cross-compile`, uploaded the generated object and **linked the object** inside the VPS using the command that `crystal build src/main.cr --mcpu=znver3 --cross-compile` outputs (`cc main.o -o main -rdynamic ...`)

`crystal build src/main.cr --release --no-debug --mcpu=x86-64-v3 --cross-compile` also works well. Thank you \<3

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 20, 2024, 8:10pm UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/14 "2024-05-20T20:10:18Z")

</div>

Great to hear that it works now! 🚀

I’m a bit stumped why this is even necessary, though. Zen 3 is a pretty modern architecture. Surely the default configuration for an `x86_64` target should produce compatible code.

If you’re willing to help investigate this a bit further, could you try building in a different environment, just to exclude any influence from local configuration? An easy way would be to use the docker image `crystallang/crystal` to build the executable there (without any special configuration). Then check if that runs on the Ryzen system.

---

<div class="post-metadata">

**Author:** ![Fijxu](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/fijxu/32/3422_2.png) [@Fijxu](https://forum.crystal-lang.org/u/Fijxu)\
**Post date:** [May 26, 2024, 4:08am UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/15 "2024-05-26T04:08:12Z")

</div>

Using the `crystallang/crystal:latest` docker image to compile the program works without problems and the VPS is able to execute the binary.

I used `docker run -v "$(pwd)":/app -w /app -i -t crystallang/crystal:latest crystal build src/main.cr` by the way.

---

<div class="post-metadata">

**Author:** ![straight-shoota](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/straight-shoota/32/36_2.png) [@straight-shoota](https://forum.crystal-lang.org/u/straight-shoota)\
**Post date:** [May 26, 2024, 11:49am UTC](https://forum.crystal-lang.org/t/result-binary-issues-cpu-isa-level-is-lower-than-required/6854/16 "2024-05-26T11:49:39Z")

</div>

All right, thanks. That seems to indicate that the default configuration is working out okay.  
There must be something specific to your system that causes the ISA incompatibility.  
Maybe `gcc` on ArchLinux is just targeting a tighter architecture 🤷
