Skip to content

Fix/portable builds#3

Merged
benbierens merged 3 commits intomainfrom
fix/portable-builds
Nov 19, 2025
Merged

Fix/portable builds#3
benbierens merged 3 commits intomainfrom
fix/portable-builds

Conversation

@benbierens
Copy link

Adds nimleopard_portable_build nim flag.

Source project file vendor/leopard/CMakeLists.txt defined "-march=native" explicitly. It provides no means to override this. Because of this, when we build binaries intended to be delivered, they may contain instructions available on the build system that are not necessarily available on the user system.

To be able to build portable binaries, we have no choice but to modify the CMakeLists.txt before building.

@markspanbroek
Copy link

Maybe you could try running CMake with -DCOMPILER_SUPPORTS_MARCH_NATIVE=False? Not entirely sure how CMake works, but it seems to check this flag. If that doesn't work, I'd suggest creating our own fork of leopard, and changing the CMakelist to put the native argument behind an option.

@benbierens
Copy link
Author

Maybe you could try running CMake with -DCOMPILER_SUPPORTS_MARCH_NATIVE=False? Not entirely sure how CMake works, but it seems to check this flag. If that doesn't work, I'd suggest creating our own fork of leopard, and changing the CMakelist to put the native argument behind an option.

It's not just that we need to disable -march=native. Leopard needs instructions-sets that support what it's trying to do. We need to override to x86-64-v3, but only in cases where we want to build portable binaries.

If we took a fork of leopard itself we wouldn't have to mess with the cmake file during the build process. That would be cleaner.

@benbierens
Copy link
Author

We have a fork: https://github.com/durability-labs/leopard
We have a PR for the original people: catid/leopard#26

Copy link

@markspanbroek markspanbroek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @benbierens!

I wonder whether there's an ARM equivalent for x86-64-v3 that we could use?

@benbierens
Copy link
Author

I haven't found one and I haven't seen this issue in ARM builds (yet). If we do run into it, we now have the option to fix it.
Also, this was a useful link during this whole adventure: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html

@benbierens benbierens merged commit 7213817 into main Nov 19, 2025
8 of 9 checks passed
@veaceslavdoina
Copy link

veaceslavdoina commented Nov 19, 2025

I haven't found one and I haven't seen this issue in ARM builds (yet).

Yeah, they exists and manifested on Hetzner ARM Cloud instances.

Hetzner

HETZNER INTRODUCES ARM64-BASED CLOUD SERVERS

They come with up to 16 vCPUs based on Ampere® Altra® processors.

https://amperecomputing.com/briefs/ampere-altra-family-product-brief

Instruction Set Compatibility: Armv8.2+, SBSA 4

GitHub Actions

Linux arm64 hosted runners now available for free in public repositories (Public Preview)

Powered by the Cobalt 100-based processors, these 4 vCPU runners can deliver up to a 40% performance boost compared to Microsoft Azure’s previous generation of Arm-based VMs, providing a power-efficient compute layer for your workloads.

Azure Cobalt processor-based Virtual Machines

The Cobalt 100 processor, based on the Arm's Neoverse N2 design

https://developer.arm.com/Processors/Neoverse%20N2

Armv9-A (plus Armv8.2-A extensions)

Flags

https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

-march=name[+extension…]
This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. This option can be used in conjunction with or instead of the -mcpu= option.

Permissible names are: ‘armv4t’, ‘armv5t’, ‘armv5te’, ‘armv6’, ‘armv6j’, ‘armv6k’, ‘armv6kz’, ‘armv6t2’, ‘armv6z’, ‘armv6zk’, ‘armv7’, ‘armv7-a’, ‘armv7ve’, ‘armv8-a’, ‘armv8.1-a’, ‘armv8.2-a’, ‘armv8.3-a’, ‘armv8.4-a’, ‘armv8.5-a’, ‘armv8.6-a’, ‘armv9-a’, ‘armv7-r’, ‘armv8-r’, ‘armv6-m’, ‘armv6s-m’, ‘armv7-m’, ‘armv7e-m’, ‘armv8-m.base’, ‘armv8-m.main’, ‘armv8.1-m.main’, ‘iwmmxt’ and ‘iwmmxt2’.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants