Open sternenseemann opened 3 years ago
Well, can't say I'm too surprised. I googled "binfmt_misc" and "child"/"fork" and didn't see anything obvious either.
According to Qemu docs we're using qemu-${arch}
which is user emulation, but you could try with qemu-system-${arch}
which is full emulation but slower.
I'm new to all this so I might be wrong :)
Basically the execve call goes straight to the kernel, which doesn't know it's supposed to be emulating.
Unfortunately there is no upstream support for this, but there are downstream patches which fix this: https://github.com/pld-linux/qemu/blob/9793852df1b6132791fd7995b4eedd04d6c7948e/qemu-user-execve.patch
I don't think we can really solve this in nixpkgs. However, there's a new tool called makeBinaryWrapper in our toolbox which may help with this situation.
Describe the bug
Consider the following expression where
koka
is a shell script created usingwrapProgram
:This will fail with the following error message:
At first I suspected that qemu can't deal with shebang scripts for some reason since swapping out
koka
for.koka-wrapped
works (at least the binary runs, but fails due to missing certain environment variables). But the issue seems to be even worse than that:${crossPkgs.bash} -c ${crossPkgs.koka}/bin/koka
doesn't work${crossPkgs.bash} -c ${crossPkgs.koka}/bin/.koka-wrapped
doesn't workSeems like it's pretty much impossible for a process started by the emulator to call
exec
without running into executable format issues. Not sure if this is fixable without launching a full VM?!Note that this makes most sense to test against #119468.
Notify maintainers
cc @Ericson2314 @matthewbauer @siraben