-
-
Notifications
You must be signed in to chan 8000 ge notification settings - Fork 680
binfmt_misc tuning can break ape #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same here, same OS: Ubuntu 20.04 on x86_64. Are we missing some objects? λ make -j8 o//tool/viz/printvideo.com
MKDEPS o//depend
ZIPOBJ o//libc/stubs/mcount.S.zip.o
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
run-detectors: make: *** [build/rules.mk:76: o//libc/stubs/errno.S.zip.o] Error 2
unable to find an interpreter for o/build/bootstrap/zipobj.com
make: *** Waiting for unfinished jobs....
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
make: *** [build/rules.mk:76: o//libc/stubs/subvsi3.S.zip.o] Error 2
make: *** [build/rules.mk:76: o//libc/stubs/gcov.S.zip.o] Error 2
make: *** [build/rules.mk:76: o//libc/stubs/triplf.S.zip.o] Error 2
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
make: *** [build/rules.mk:76: o//libc/stubs/asanjmp.greg.S.zip.o] Error 2
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
make: *** [build/rules.mk:76: o//libc/stubs/errnolocation.S.zip.o] Error 2
make: *** [build/rules.mk:76: o//libc/stubs/addvsi3.S.zip.o] Error 2
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
make: *** [build/rules.mk:76: o//libc/stubs/mcount.S.zip.o] Error 2 I'm running on |
Have you configured binfmt_misc to automatically launch Windows binaries under WINE? You may need to disable WINE while using this project. Cosmopolitan can only supports the stock behavior. I recommend avoiding binfmt_misc in general if possible. |
Wine's not installed |
We'll get to the bottom of it, here's some lightly-edited output from vanilla ubuntu to the example not working - what am I missing? λ docker run -it ubuntu
root@66c04a69b391:/# cd /root
root@66c04a69b391:~# apt update && apt install -y git
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
[...]
done.
root@66c04a69b391:~# git clone https://github.com/jart/cosmopolitan.git
Cloning into 'cosmopolitan'...
[...]
Resolving deltas: 100% (4569/4569), done.
root@66c04a69b391:~# cd cosmopolitan/
root@66c04a69b391:~/cosmopolitan # ls
Makefile README.md build examples net third_party usr
NOTICE ape dsp libc test tool
root@66c04a69b391:~/cosmopolitan # apt install -y make
[...]
Setting up make (4.2.1-1.2) ...
root@66c04a69b391:~/cosmopolitan # make -j8 o//tool/viz/printvideo.com
MKDEPS o//depend
ZIPOBJ o//libc/stubs/subvsi3.S.zip.o
ZIPOBJ o//libc/stubs/errno.S.zip.o
make: *** [build/rules.mk:77: o//libc/stubs/subvsi3.S.zip.o] Error 127
make: *** Waiting for unfinished jobs....
build/zipobj: 54: exec: build/zipobj: 54: exec: o/build/bootstrap/zipobj.com: not found
o/build/bootstrap/zipobj.com: not found
make: *** [build/rules.mk:77: o//libc/stubs/errno.S.zip.o] Error 127
ZIPOBJ o//libc/stubs/addvsi3.S.zip.o
build/zipobj: 54: exec: o/build/bootstrap/zipobj.com: not found
build/zipobj: 54: exec: o/build/bootstrap/zipobj.com: not found
ZIPOBJ o//libc/stubs/errnolocation.S.zip.o
make: *** [build/rules.mk:77: o//libc/stubs/addvsi3.S.zip.o] Error 127
ZIPOBJ o//libc/stubs/gcov.S.zip.o
build/zipobj: 54: exec: o/build/bootstrap/zipobj.com: not found
make: *** [build/rules.mk:77: o//libc/stubs/errnolocation.S.zip.o] Error 127
make: *** [build/rules.mk:77: o//libc/stubs/gcov.S.zip.o] Error 127 |
What shell and what version is Docker Ubuntu using? Maybe they mapped zsh to /bin/sh or possibly have a regression with Thompson Shell backwards compatibility, since
If that doesn't print hello then I'd be very concerned. Another troubleshooting step is:
Which should hopefully make it clearer which commands are being invoked. |
|
|
how odd! |
I just installed the latest Ubuntu in a VM since you've got me curious. However I failed to reproduce the issue. Something peculiar must be happening with the Docker variant of Ubuntu. Would you be kind enough to help troubleshoot this down a bit further? Possibly by using strace? I'm very reluctant to install Docker. I am however super happy to implement whatever fix or workaround you need, once we identify the issue. |
I'm not running Ubuntu in docker! |
On my system, the following works and prints hello: echo echo hello >hello
chmod +x hello
/bin/sh -c './hello' And running $ make SILENT=0 o//tool/viz/printvideo.com
♥cosmo
o/build/bootstrap/mkdeps.com -o o//depend -r o// o//srcs.txt o//hdrs.txt
run-detectors: unable to find an interpreter for o/build/bootstrap/mkdeps.com
o/build/bootstrap/zipobj.com -o o//libc/stubs/errno.S.zip.o \
libc/stubs/errno.S
run-detectors: unable to find an interpreter for o/build/bootstrap/zipobj.com
make: *** [build/rules.mk:76: o//libc/stubs/errno.S.zip.o] Error 2 |
Another thing that might help, in Ubuntu |
Almquist shell works fine (outside FreeBSD which added restrictions to it) and is highly recommended. Try exploring the contents of |
❯ ls /proc/sys/fs/binfmt_misc/
cli jar llvm-10-runtime.binfmt llvm-6.0-runtime.binfmt llvm-8-runtime.binfmt python2.7 python3.8 register sbcl status
|
Could you try running the following command and let me know if it fixes the issue?
|
Running the above command fixed it! So what was the problem? Thanks! |
You're welcome! Thanks for the report. I'll update the Makefile shortly to auto-detect and report this workaround. |
@omimo you can read more about binfmt handlers here. I'm guessing here but I think cosmopolitan's binary format requires the host OS to be able to recognize a particular pattern at the start of the file, which this workaround registers. The reason it has to be there for the compilation phase is (again a guess) the compiler has some level of self-hosting going on where it must compile and then use its own toolchain. @jart if you add an auto-detect I'd humbly suggest some explanation of why the binfmt handler is required and what it does. |
Binfmt is absolutely not a requirement. I recommend against using it entirely. Cosmopolitan's executable format is just a shell script without a shebang line. Please read https://justine.storage.googleapis.com/ape.html to learn more. What happens is binfmt_misc gives people like package maintainers the ability to arbitrarily redefine how the kernel processes executables, and in certain cases that break things. |
@jart ah so the workaround is undoing something that Ubuntu has overridden in binfmt_misc? PS I read and very much enjoyed the post. My apologies for misunderstanding. |
This is a recently introduced Linux Kernel feature that gives people like Debian package mantainers the power to arbitrarily redefine how executables are interpreted by the kernel. If your system gets tuned this way and you're not able to disable it, then you need to restore default behavior for the APE MZqFpD prefix as follows: sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register" This prefix will cover all .com executables built with this tooling. Please don't run the above command unless you're certain you need it. See #2 for additional context.
The workaround one-liner doesn't override anything. It simply restores the default behavior for the APE executable prefix MZqFpD, as specified here: Line 121 in f4f4caa
|
Understood, thanks for the explanation. |
Users who don't want to modify their /proc/sys/fs/binfmt_misc/ long-term (eg. because they don't need APE) can select a mode that doesn't produce them at build time, eg. This still requires the binfmt workaround at build time (as the bootstrap executables cocmd, compile, fixupobj, package, unbundle and zipobj as well as the custom ar are necessary to build it and not generally available otherwise), but it moves the problem to one of bootstrapping / building from one of running. |
EDIT: nevermind, I was wrong. the ape loader is still needed in Ubuntu 22.04 |
May I ask what's the path forward here? Doesn't this mean that APE binaries like |
Hello,
I'm just trying this on Ubuntu 20.04 and get the following error:
If I try to run zipobj.com directly, it returns the following:
Thanks!
The text was updated successfully, but these errors were encountered: