tpwrules / nixos-apple-silicon

Resources to install NixOS bare metal on Apple Silicon Macs
MIT License
791 stars 82 forks source link

Enable BINFMT_MISC in the kernel #3

Closed Lucus16 closed 2 years ago

Lucus16 commented 2 years ago

Compiling the kernel with BINFMT_MISC allows users to emulate x86 software much like Rosetta on macos with:

boot.binfmt.emulatedSystems = [ "x86_64-linux" ];
tpwrules commented 2 years ago

This looks like a good idea, thanks. Do you know how this interacts with the 4k/16k pages? What is the performance like? Having x86 emulate ARM is pretty miserable, but it is functional.

Lucus16 commented 2 years ago

A build of GNU hello takes 15 seconds native and 5 minutes when using x86 emulation and 4k pages. It's not fast. I'll try 16k pages later.

Lucus16 commented 2 years ago

With 16k pages, x86 emulation works too. The GNU hello build fails near the end on a patchelf invocation, after a little over 5 minutes. I'd say binfmt_misc is compatible with 16k pages but emulated patchelf is not. We could add a NixOS assertion like boot.kernelBuildIs16K -> boot.binfmt.emulatedSystems == [ ].