Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I assume the executables won't run on ARM platforms? So modern Macs are out, etc.


It works on AMD64 and ARM64 both.

It makes two architecture fat binary, but removes all code not needed. Resulting binary is typically only 30-50% larger than 1-architecture binary.


More details of supported platforms at https://justine.lol/cosmo3/ and https://github.com/jart/cosmopolitan/blob/master/tool/cosmoc..., both linked in the release notes.


Works for sure:

  $ file ./bin/python
  ./bin/python: DOS/MBR boot sector; partition 1 : ID=0x7f, active, start-CHS 
  (0x0,0,1), end-CHS (0x3ff,255,63), startsector 0, 4294967295 sectors

  $ ./bin/python
  Python 3.11.4 (heads/pypack1:6eea485, Jan 24 2024, 10:14:24) [GCC 11.2.0] on 
  linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import platform
  >>> platform.processor()
  'arm'


I forget how I did this, but:

    $ file hello.com
    hello.com: αcτµαlly pδrταblε εxεcµταblε


Out of curiosity, why are you running python packed with cosmopolitan ?


Presumably to demonstrate that it works on Mac ARM platforms, in response to the question about that.


If was satisfied with my own presumption I wouldn't have asked ;)


That Python app is a popular demo for Cosmopolitan. It's what I would have chosen for that demo, too! It's handy because it outputs a little bit of information about the current architecture on the first line when you start the shell.

There's some interesting background on it in this issue: https://github.com/jart/cosmopolitan/issues/141


It depends. It does not work on CentOS 8 / Rocky 8 for example: https://github.com/jart/cosmopolitan/issues/1151


Is that an embedded device with a small address space? APE used to require a 47bit address space. The release I published today fixes that. Maybe give it another try?


No, it's a server with 256GB of RAM, but indeed the kernel config has CONFIG_ARM64_VA_BITS_48=y (and 52 for userspace). I have since moved away from this kernel, I'll see if I find the time to boot it again to test the latest memory map manager.

Edit: I tried booting it, the issue is still present, I updated the github issue.


Looks like there is both an ARM and x86 version according to the docs. Probably need two different binaries, but you still get cross-OS for each architecture.


It's a single binary, cross-OS, cross-arch.

Go to https://cosmo.zip/pub/cosmos/bin/ and download an executable, like https://cosmo.zip/pub/cosmos/bin/basename .

  % curl -O https://cosmo.zip/pub/cosmos/bin/basename
    % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  100  663k  100  663k    0     0   440k      0  0:00:01  0:00:01 --:--:--  441k
  % chmod +x basename
On macOS with an M1:

  % arch
  arm64
  % sha256sum basename
  2e4cf8378b679dd0c2cdcc043bb1f21eaf464d3c3b636ed101fbc5e3230eb5fb  basename
  % file ./basename
  ./basename: DOS/MBR boot sector; partition 1 : ID=0x7f, active, start-CHS (0x0,0,1), end-CHS (0x3ff,255,63), startsector 0, 4294967295 sectors
  % ./basename /dev/null.txt
  null.txt
On FreeBSD with an amd64:

  % uname -sm
  FreeBSD amd64
  % sha256sum basename
  2e4cf8378b679dd0c2cdcc043bb1f21eaf464d3c3b636ed101fbc5e3230eb5fb  basename
  % file basename
  basename: DOS/MBR boot sector; partition 1 : ID=0x7f, active, start-CHS (0x0,0,1), end-CHS (0x3ff,255,63), startsector 0, 4294967295 sectors
  % ./basename /dev/null.pdf
  null.pdf


Kind of. It can be read as a single binary, some supported systems will do that. In others, the executable is first parsed as a shell script. There's definitely more to it than a single binary.

    MZqFpD='

     ø        @               ' <<'justine0e5c7z'
    È  ²@ë 됐ëHƒì1Ò½  ëéE  ü‡>à¿ p1ÉŽÁúŽ×‰Ìûè  ^îr ¸ PP 1ÿ¹ ó¤‡ÒÿêŽ   ŽÙ¹ ¸P ŽÀ1À1ÿóª€ú@tè  °1É0ö¿Pèo ŒÆƒÆ ŽÆOuóê '  SR´Ís1ÀÍrF¸¹ ¶ » ŽÃ1ÛÍr3´Ír-ˆÏ€ç?€áÀÐÁÐÁ†Í1öŽÆ¾‡÷¥¥¥¥¥¤“«®‘«’«Xª’[ÃZ€ò€1ÀÍr÷ë¡PQ†ÍÐÉÐÉÁ1Û°´ÍYXrþÀ:$v
    °þÆ:6)v0öAÃP1ÀÍXë̉þ¬„Àt »  ´ÍëòÃW¿¹&èèÿ_èäÿ¿Á&èÞÿóëü¹ ¾ ­…Àt
    QV—¾Ð&è ^YâîÉú…ÒtRV1ɱʬ^ €îZ¬îBIyúà              €  ÿÿÿ    ÿÿÿÿ                                                Uª
    justine0e5c7z
    #'"

    o=$(command -v "$0")
    [ x"$1" != x--assimilate ] && type ape >/dev/null 2>&1 && exec ape "$o" "$@"
    t="${TMPDIR:-${HOME:-.}}/.ape-1.10"
    [ x"$1" != x--assimilate ] && [ -x "$t" ] && exec "$t" "$o" "$@"
    m=$(uname -m 2>/dev/null) || m=x86_64
    if [ ! -d /Applications ]; then
    if [ x"$1" = x--assimilate ]; then
    if [ "$m" = x86_64 ] || [ "$m" = amd64 ]; then
    exec 7<> "$o" || exit 121
    printf '\177ELF\2\1\1\11\0\0\0\0\0\0\0\0\2\0>\0\1\0\0\0vE@\0\0\0\0\0\510\013\000\000\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\100\0\70\0\006\000\0\0\0\0\0\0' >&7
    exec 7<&-
    fi
    exit


Reminds me of a cool tool I once used, uudecode.com, which was a DOS binary that only used 7-bit characters and could decode uuencoded (base64 predecessor) files. Was useful for getting attachments through e-mail in the face of all kinds of filters.


https://news.ycombinator.com/item?id=16312317 - "A C89 compiler that produces executables that are also valid ASCII text files"

http://tom7.org/abc/

The paper for SIGBOVIK 2017 is both a text file and an executable.


Really near.

Also discussed 11 months ago:

https://news.ycombinator.com/item?id=36821985 (15 comments)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: