Macos: killed 9 when running executables

I am packaging a project for nix, which is intended to be ran on linux and macos. On linux everything works fine, but when running the executables after nix-build, they get killed. For reference, the packing nix script is here. I have tried a couple of things:

  • Switch to the latest nixos version
  • Remove the wrappers

When using a similar script as an environment and running cmake manually, there is no issue and the binaries run just fine.

The system I am running this on is an M1 mac with macos Monterey version 12.2.1.

Any hints of what I could try next/investigate?

After some more messing around, I found that the build was producing 32-bit Mach-O files. I traced this to the stripping. After that was disabled it worked fine.

Note, this was ran on commit e24b4c09e963677b1beea49d411cd315a024ad3a of nixpkgs (in the nixos-24.11 branch)