News for hackers. Stuff that matters.
Re:Cosmopolitan v3.5.0 by WantonQuantum on Monday June 24, 2024 @02:58AM (#40773178)
I assume the executables won't run on ARM platforms? So modern Macs are out, etc.
Re:Cosmopolitan v3.5.0 by nabla9 on Monday June 24, 2024 @03:05AM (#40773209)
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.

Re:Cosmopolitan v3.5.0 by mkl on Monday June 24, 2024 @04:07AM (#40773545)
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.
Re:Cosmopolitan v3.5.0 by d4rti on Monday June 24, 2024 @03:10AM (#40773242)
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'
Re:Cosmopolitan v3.5.0 by 4gotunameagain on Monday June 24, 2024 @05:40AM (#40774048)
Out of curiosity, why are you running python packed with cosmopolitan ?
Re:Cosmopolitan v3.5.0 by simonw on Monday June 24, 2024 @07:44AM (#40774854)
Presumably to demonstrate that it works on Mac ARM platforms, in response to the question about that.
Re:Cosmopolitan v3.5.0 by 4gotunameagain on Monday June 24, 2024 @08:34AM (#40775271)
If was satisfied with my own presumption I wouldn't have asked ;)
Re:Cosmopolitan v3.5.0 by simonw on Monday June 24, 2024 @09:24AM (#40775750)
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

Re:Cosmopolitan v3.5.0 by smcameron on Monday June 24, 2024 @08:06AM (#40775039)
I forget how I did this, but:

    $ file hello.com
    hello.com: αcτµαlly pδrταblε εxεcµταblε
Re:Cosmopolitan v3.5.0 by lukemerrick on Monday June 24, 2024 @03:09AM (#40773233)
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.
Re:Cosmopolitan v3.5.0 by eesmith on Monday June 24, 2024 @03:51AM (#40773471)
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
Re:Cosmopolitan v3.5.0 by alganet on Monday June 24, 2024 @04:10AM (#40773566)
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
Re:Cosmopolitan v3.5.0 by bux93 on Monday June 24, 2024 @05:50AM (#40774106)
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.
Re:Cosmopolitan v3.5.0 by eesmith on Monday June 24, 2024 @07:18AM (#40774657)
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.

Re:Cosmopolitan v3.5.0 by metadat on Monday June 24, 2024 @12:26PM (#40777988)
Really near.

Also discussed 11 months ago:

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

Re:Cosmopolitan v3.5.0 by Aissen on Monday June 24, 2024 @05:44AM (#40774069)
It depends. It does not work on CentOS 8 / Rocky 8 for example: https://github.com/jart/cosmopolitan/issues/1151
Re:Cosmopolitan v3.5.0 by jart on Monday June 24, 2024 @01:40PM (#40778748)
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?
Re:Cosmopolitan v3.5.0 by Aissen on Tuesday June 25, 2024 @05:42AM (#40786393)
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.