jart / cosmopolitan

build-once run-anywhere c library
ISC License
18.45k stars 637 forks source link

Dependency in documentation #334

Open alexios-angel opened 2 years ago

alexios-angel commented 2 years ago

Following the directions for the hello.com program in the README.md produces an error "run-detectors: unable to find an interpreter for ./hello.com"

(base) alex@alex-Z490-AORUS-PRO-AX ~/down/cosmo $ gcc -g -Os -static -nostdlib -nostdinc -fno-pie -no-pie -mno-red-zone \
  -fno-omit-frame-pointer -pg -mnop-mcount \
  -o hello.com.dbg hello.c -fuse-ld=bfd -Wl,-T,ape.lds \
  -include cosmopolitan.h crt.o ape.o cosmopolitan.a
/usr/local/bin/ld.bfd: warning: .note.gnu.build-id section discarded, --build-id ignored
(base) alex@alex-Z490-AORUS-PRO-AX ~/down/cosmo $ objcopy -S -O binary hello.com.dbg hello.com
(base) alex@alex-Z490-AORUS-PRO-AX ~/down/cosmo $ bash -c "./hello.com"                         
run-detectors: unable to find an interpreter for ./hello.com

I did some research and found https://issueexplorer.com/issue/jart/cosmopolitan/171 I executed

sudo sh -c "echo ':APE:M::MZqFpD::/bin/sh:' >/proc/sys/fs/binfmt_misc/register"

And it worked.

(base) alex@alex-Z490-AORUS-PRO-AX ~/down/cosmo $ bash -c "./hello.com"
hello world

Does this need to happen on all client Linux machines? I feel as this should be documented.

meiskam commented 2 years ago

idk if it's always required, but if you remove support for Windows and XNU (CPPFLAGS=-DSUPPORT_VECTOR=0b1110011), it should output in a more normal ELF format, which would make that command not necessary

notwa commented 2 years ago

it looks like the README was updated at some point to document this, as well as other workarounds over on jart's article on the APE loader, so I think this issue can be closed.

a few notes of my own, mostly pertaining to Linux and cosmopolitan 2.0:

if you do have root permissions, forget all that and run apeinstall.sh or the command from the README.

Does this need to happen on all client Linux machines? I feel as this should be documented.

nope, only distros that use binfmt by default. Alpine doesn't, for example, but many opt to.

Et7f3 commented 1 year ago

I solved permanently by removing binfmt-support this page helped me to find the package https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1856641.html