WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Cosmos a "Fat Linux Distro"  (Read 4377 times)

Offline mocore

  • Hero Member
  • *****
  • Posts: 641
  • ~.~
Cosmos a "Fat Linux Distro"
« on: December 05, 2023, 12:42:20 AM »

after hearing of Cosmopolitan Libc
which implements the αcτµαlly pδrταblε εxεcµταblε format"

the potential for a  "Fat (tc derived obviously) Distro" crossed my mind (  unicore or perhaps titanicore  :P  )

then i happened to find this mention of actual a fat distro zip
in the version 3.0 release of the Cosmopolitan library
...

Quote from: https://justine.lol/cosmo3/# Cosmopolitan Third Edition
a "Fat Linux Distro" which I've named the "Cosmos". In the Cosmos, every program is statically linked and contains a PKZIP central directory where its /usr/share dependencies are embedded. You can think of it as a coalition of individualistic executables, where each program can be separated from the whole and run on other OSes. So far it includes programs like Emacs, Vim, CoreUtils, Curl, etc.

cosmos-3.1.3.zip
163mb - PE+ELF+MachO+ZIP+SH executables
For AMD64+ARM64 on Linux+Mac+Windows+FreeBSD+NetBSD+OpenBSD
e280987f99f8c9802fa5564adbdc08ec7a8f8738c16a75cf74fb820cc1c14981

More specifically, the above zip file contains fat binaries for ape, python, lua, qjs, vim, emacs, emacsclient, nano, llama, bash, dash, less, grep, curl, wget, tidy, zip, unzip, zstd, bzip2, sqlite3, life, nesemu1, make (GNU + SECCOMP + Landlock), gmake (GNU), redbean, greenbean, datasette, assimilate, rusage, ctags, wall, pledge, verynice, find, tree, basename, chgrp, cp, date, du, expr, groups, ls, mknod, nl, pathchk, pwd, rm, seq, shred, stat, tee, uname, users, who, basenc, chmod, csplit, dd, echo, factor, head, mktemp, nohup, pinky, rmdir, shuf, stty, test, true, unexpand, vdir, whoami, awk, chown, df, false, id, link, mv, nproc, pr, rsync, sleep, sum, truncate, uniq, yes, b2sum, chroot, dir, fmt, install, md5sum, numfmt, printenv, readlink, runcon, sort, sync, timeout, tsort, unlink, base32, cat, cksum, cut, dircolors, env, fold, join, ln, mkdir, od, printf, realpath, script, split, tac, touch, tty, wc, base64, chcon, comm, dirname, expand, kill, logname, mkfifo, nice, paste, ptx, sed, sha1sum, sha224sum, sha256sum, sha384sum, sha512sum, tail, tr, ttyinfo, and uptime.

created with https://justine.lol/ape.html
Code: [Select]
╠──────────────────────────────────────────────────────────────────────────────╣
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░█▀█░█▀█░▀█▀░█░█░█▀█░█░░░█░░░█░█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░█▀█░█░▄░░█░░█░█░█▀█░█░░░█░░░▀█▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░▀░▀░▀▀▀░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░░▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░█▀█░█▀█░█▀█░▀█▀░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░█▀▀░█ █░██▀░░█░░█▀█░█▀█░█░░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░▀░░░▀▀▀░▀░▀░░▀░░▀░▀░▀▀▀░▀▀▀░▀▀▀░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░│
│░░░░░░░█▀▀░█░█░█▀▀░█▀█░█░█░▀█▀░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░░░░░░░░░░░░░▄▄░░░▐█░░│
│░░░░░░░█▀▀░▄▀▄░█▀▀░█░▄░█░█░░█░░█▀█░█▀█░█░░█▀▀░░░░░░░░░░░░▄▄▄░░░▄██▄░░█▀░░░█░▄░│
│░░░░░░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░░▀░░▀░▀░▀▀▀░▀▀░▀▀▀░░░░░░░░░░▄██▀█▌░██▄▄░░▐█▀▄░▐█▀░░│
│░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▐█▀▀▌░░░▄▀▌░▌░█░▌░░▌░▌░░│
╠──────────────────────────────────────────────────────▌▀▄─▐──▀▄─▐▄─▐▄▐▄─▐▄─▐▄─│
│ αcτµαlly pδrταblε εxεcµταblε § program header                                │
╚─────────────────────────────────────────────────────────────────────────────*/

Offline mocore

  • Hero Member
  • *****
  • Posts: 641
  • ~.~
Re: Cosmos ~ Patching GCC to build Actually Portable Executables
« Reply #1 on: December 05, 2023, 02:35:27 AM »

https://ahgamut.github.io/2023/07/13/patching-gcc-cosmo/

 https://github.com/ahgamut/gcc/tree/portcosmo-11.2

 https://github.com/jart/cosmopolitan

 
Quote
Now you can build popular software such as bash,
curl, git, ninja, and even gcc itself, with Cosmopolitan Libc via the ./configure or cmake build system,
without having to change source code, and
the built executables should run on Linux, FreeBSD, MacOS, OpenBSD, NetBSD, and Windows too1.
You can download the binaries built using Github Actions
here: https://github.com/ahgamut/superconfigure/releases

build actually portable executables Pre-release

    compress.zip contains tar, zip, unzip, bzip2, zstd, xz, brotli, gzip, and pigz
    cli.zip contains bash, zsh, grep, less, lua, find, berry, GNU coreutils, and ninja
    editor.zip contains vim, nano, and emacs (emacs now has gnutls support)
    x86_64-gcc.zip contains the gcc-11 and binutils-2.35.2 tools targeting x86-64-linux-cosmo
    aarch64-gcc.zip contains the gcc-11 and binutils-2.35.2 tools targeting aarch64-linux-cosmo
    datasette.zip contains datasette a build of CPython 3.11 with the datasette library
    pypack1.zip contains python, a build of CPython 3.11 with a bunch of cli libraries like black, cookiecutter
    web.zip contains links, wget, curl, git, and rsync
    gui.zip contains SDL2 test binaries built with libX11 (experimental, requires X Server to be running on the host system)

 the possibility of actual portability make me think of various "tc install" scripts/programs 
perhaps this could make various methods of scripted/automated installation actual portable!  ???

Offline CardealRusso

  • Full Member
  • ***
  • Posts: 178
Re: Cosmos a "Fat Linux Distro"
« Reply #2 on: December 05, 2023, 05:45:56 AM »
this looks very interesting (although it's clearly against tinycorelinux's philosophies)

One question, will a binary compiled on an x86_64 machine work on any other platform, 32bits, arm etc?

Offline nick65go

  • Hero Member
  • *****
  • Posts: 838
Re: Cosmos a "Fat Linux Distro"
« Reply #3 on: December 05, 2023, 06:31:40 AM »
IMHO: Technically will NOT work on different machine architecture. Just on same architecture but different OS (magic header numbers in executable PE / ELF etc). Because each arch (x86, arm etc) has specific CPU instructions.

ex: So you compiled on x86-64-v3 (intel) the main body (the binary). Then you "glue" this body (less its Linux header) with an "universal" header (Linux / MacOS / Win). Then you try to run it on an ARM machine... The header will "possibly" run (after all is just a fuc*king small binary/ machine code ) and it jumps to body of program (x86/Intel assembly CPU instructions) and crash because those CPU instructions/registries not present on arm CPU.

EDIT: maybe will run, IF the ASM (first 4-10 bytes machine code) is same in each Firmware, and you include BOTH compiled versions of the body (one compiled for x86-64-v3 64 bits, and one cross-compiled for arm-32 bits) as a ZIP-packed collection bodies, etc. So  extra-fat .. not worthy in my opinion.
« Last Edit: December 05, 2023, 06:51:03 AM by nick65go »

Offline CardealRusso

  • Full Member
  • ***
  • Posts: 178
Re: Cosmos a "Fat Linux Distro"
« Reply #4 on: December 05, 2023, 07:33:43 AM »
Just on same architecture but different OS
Got it. Still, having a binary that works on multiple systems is a big deal.

« Last Edit: December 05, 2023, 07:40:56 AM by Rich »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11618
Re: Cosmos a "Fat Linux Distro"
« Reply #5 on: December 05, 2023, 07:42:13 AM »
Hi CardealRusso
I'm sorry but your attachment has been removed.

The  Forum Rules and Guidelines  state:
Quote
2. No attachments/links of binary extensions
Found here:
http://forum.tinycorelinux.net/index.php/topic,7738.0.html

You are not allowed to post binary attachments, or direct links to external binaries.
You may post a link that leads to an external site, where someone can then choose to download something.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 838
Re: Cosmos a "Fat Linux Distro"
« Reply #6 on: December 05, 2023, 07:52:31 AM »
OR, use win11 OS, which has WSL2 (windows system for Linux) already integrated! So you have in-house build Hyper-HV (optimized virtual machine) with MINIM (no duplication) of resources.

Ex: Extremely-optimized virtual Kernel 5.15.3 (build by Microsoft) with all modules encapsulated in the kernel, so it has all filesystem (fat, exfat, xfs, btrfs, ext3/4 etc etc). And you can run/share all windows / linux commands from a VM (virtual machine). You can mount ANY additional disks (physical or virtual vhd(x), partitioned or not, etc.

My firefox ver-120 starts in 1 second in this Archlinux-Virtual Machine, even without Wayland server. The VHDX 1TB (=1000 GB) is spared (just 1.2 GB on SSD), swap 4 GB auto created in RAM, the VM ram is 16 GB auto (half of my real physical RAM, 32 GB) etc. The best thing: RAM is auto-resized so that VM does NOT take (for itself) reversible RAM from the win11 RAM. All those with 2 minutes of loading an Arch distro from MS store, nothing customized from my part (for now), except install Firefox from this VM linux.

Anyway, I deviated from the subject, just to explain that today we do NOT need to re-invent the wheel. Time is extremely precious for some of us. Money is not so preciously in an perpetual inflationary fiat money system (loved by all governments to pay for their huge debits).

Offline CardealRusso

  • Full Member
  • ***
  • Posts: 178
Re: Cosmos a "Fat Linux Distro"
« Reply #7 on: December 05, 2023, 10:45:21 AM »
use win11
It seems like completely different scenarios to me.

I don't understand how using Windows, paying $200+tax and being forced to swallow all of Microsoft's spyware and backdoors just to be able to emulate Linux compares to a 50kb library.

Offline mocore

  • Hero Member
  • *****
  • Posts: 641
  • ~.~
Re: Cosmos a "Fat Linux Distro"
« Reply #8 on: December 05, 2023, 10:59:26 AM »
will a binary compiled on an x86_64 machine work on any other platform, 32bits, arm etc?

https://justine.lol/cosmopolitan/
says
Quote
Cosmopolitan Libc makes C a build-anywhere run-anywhere language, like Java, except it doesn't need an interpreter or virtual machine.
Instead, it reconfigures stock GCC and Clang
to output a POSIX-approved polyglot format that
runs natively on Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS on AMD64 and ARM64
with the best possible performance.

however https://justine.lol/ape.html mentions emulation ... which i presume is how arm is supported.
Quote
You only use the emulator if you need it.
For example, it's helpful to be able to have cool visualizations of how program execution impacts memory.

It'll be nice to know that any normal PC program we write will "just work" on Raspberry Pi and Apple ARM.

ftr
i find this argument for use of such a system  the most compelling
Quote
Long Lifetime Without Maintenance

One of the reasons why I love working with a lot of these old technologies, is that I want any software work I'm involved in to stand the test of time with minimal toil. Similar to how the Super Mario Bros ROM has managed to survive all these years without needing a GitHub issue tracker.

I believe the best chance we have of doing that, is by gluing together the binary interfaces that've already achieved a decades-long consensus, and ignoring the APIs. For example, here are the magic numbers used by Mac, Linux, BSD, and Windows distros. They're worth seeing at least once in your life, since these numbers underpin the internals of nearly all the computers, servers, and phones you've used.
« Last Edit: December 05, 2023, 11:05:48 AM by mocore »

Offline mocore

  • Hero Member
  • *****
  • Posts: 641
  • ~.~
Re: Cosmos a "Fat Linux Distro"
« Reply #9 on: December 05, 2023, 11:04:50 AM »
use win11
It seems like completely different scenarios to me.

i guess at least its one of the *currently supported options (despite apparent prevalence of megacorp malevolence (Halloween documents anyone?))

* https://github.com/jart/cosmopolitan/issues/426#issuecomment-1165932843
Quote
please be advised there is some risk you may need to rebuild your binaries if Apple breaks the system call interface again.




Offline linic

  • Newbie
  • *
  • Posts: 18
Re: Cosmos a "Fat Linux Distro"
« Reply #10 on: December 05, 2023, 11:31:21 AM »
Quote
Time is extremely precious for some of us. Money is not so preciously
There's a direct relationship between time and money for me. The more money I use, the more time I'll have to put in to repay it. So I need to use money wisely.
Quote
use win11 OS
Windows is only worth it if it saves me more time and/or improves the quality of my time enough.
Also, even if Windows would be worth it for now, I have no guarantee that it will be in the future. Microsoft puts the shareholders first because that's what companies owned by shareholders do. "Entrench the users, make it impossible for them to live without your product and market your product in a way to get a stable evergrowing source of money" is the dream of many shareholders.
For all that, I would say, using Windows is ok if it makes life easier and more profitable for the user, but the user should always keep a contingency plan just in case because we never know what the board of a company owned by shareholders can do in 5 or 10 years. I think many shareholders would be happy with Windows 11 being the last Microsoft OS which can be "owned" and making Windows 12 a service for which users pay a monthly subscription.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 838
Re: Cosmos a "Fat Linux Distro"
« Reply #11 on: December 05, 2023, 11:46:36 AM »
It seems like completely different scenarios to me.
I don't understand how using Windows, paying $200+tax and being forced to swallow all of Microsoft's spyware and backdoors just to be able to emulate Linux compares to a 50kb library.
Yes, it is a different scenario. Time vs. money! I prefer time at (almost) every (reasonable) cost. My time is limited on this planet.Without false modesty, for me  $200/8_years (=25$/year, aka $0.07/day) is nothing. Y.M.M.V. I thing a beggar "earns" more $/day from donations.

I had to make a choice about a full functioning hardware. Every new PC that I tried had a firmware bug in my (bad) choice of hardware (Dell & HP) when using linux, [but was OK in windows10]: bad power management, few Fn-key not working, nothing critical /life changing, but annoying however.

In the country where I live, I had no choose for something better for the same money [~780 euro/PC, Intel Core 13 generation (12 threads), 32 GB RAM, 512 GB SSD, 17 inch Display, win11 + Office2021, etc]. Of course I could install Linux (dual boot) and use only Linux. Maybe I will do it. It is no rush, I know he drill.

But in my spare time I have not yet the need for more tools/programs. Plus I have no private documents on the laptop [they can spy my ass as leisure]. In the mean time I play with Archlinux, Alpine linux, openSUSE, Wayland, x86-64_v3, etc.
« Last Edit: December 05, 2023, 11:55:03 AM by nick65go »

Offline nick65go

  • Hero Member
  • *****
  • Posts: 838
Re: Cosmos a "Fat Linux Distro"
« Reply #12 on: December 05, 2023, 02:42:56 PM »
Quote
author=linic link=topic=26597.msg171463#msg171463 date=1701793881
There's a direct relationship between time and money for me. The more money I use, the more time I'll have to put in to repay it. So I need to use money wisely.

Without intention be pedantic, please allow me to clarify: value of money is NOT LINEAR with the time. it is named compound/ exponential grow. The time is more precious, I would say is invaluable. BTW, how much is you life value? Is not morbid question, is how capitalist social insurance companies evaluate their risk, even the human life...

1. $100 with 5% interest (and 5.01% inflation) is $105 after 1 year in NOMINAL terms, but still "less" than $100 in REAL term money (aka will by the same number of apples with cost inflated by 5.01%).
2. with 10%/year interest, you will "double" your money in 7 years, not in 10 years. Human brain likes to think linearly.
3. with 2% "normal" inflation, the governments will "hidden"/silent steal your wealth in 35 years, not in 50 years.
etc, I think you understand the drill.
4. the happiness is an asymptotic shape curve. After a threshold, the more money will buy you less happiness.
5. Money is infinite (digits on screen) from virtual bank asses. Human time is finite, often less than we think it is.

So if/when I have "enough" money, I prefer to (wisely) spend it to buy back my time. A rich men in the tomb is not an option for me.
« Last Edit: December 05, 2023, 02:56:29 PM by nick65go »

Offline linic

  • Newbie
  • *
  • Posts: 18
Re: Cosmos a "Fat Linux Distro"
« Reply #13 on: December 06, 2023, 10:31:15 AM »
Quote
So if/when I have "enough" money, I prefer to (wisely) spend it to buy back my time. A rich men in the tomb is not an option for me.
I fully agree  :)
Quote
how much is you life value?
I don't think a life can be valued with money. I understand why insurance company do it. They use statistics to offer coverage and make a margin without risking bankruptcy. That price only makes sense within that context.
Quote
1. $100 with 5% interest (and 5.01% inflation) is $105 after 1 year in NOMINAL terms, but still "less" than $100 in REAL term money (aka will by the same number of apples with cost inflated by 5.01%).
2. with 10%/year interest, you will "double" your money in 7 years, not in 10 years.
Aww, I wish I had more money than debt and a way to get 10% interest.  :) There's no real stable 10% interest in my pocket. There's always someone in the middle taking some of that interest away.
Quote
4. the happiness is an asymptotic shape curve. After a threshold, the more money will buy you less happiness.
For me, money buys safety. People close to me and the time I spend with them brings me happiness.
Quote
5. Money is infinite (digits on screen) from virtual bank asses.
My money is finite. It grows as I get paid. I see the bank has infinite money though. I would sure love to be a bank.  :)
Quote
Human time is finite, often less than we think it is.
I fully agree with you here!

I agree though that 200$+TX is a small price to pay if it saves more time than what it took to gain this amount and/or if it improves the quality of your time. In your case, I see it does.

To use W11, one needs to change the whole PC because backward compatibility has been dropped. None of my computers can run W11. It doesn't make sense for me to throw away something that works perfectly with another OS. I understand backward compatibility may cost money and Microsoft doesn't want to spend that money though. It's not like Microsoft is on the brinks of bankruptcy so it could have chosen to keep the backward, but it prefers to optimize profits for shareholders.

But hey, Microsoft has me covered with this new subscription https://www.theverge.com/2023/12/5/23988896/microsoft-windows-10-extended-security-updates-consumers-paid I could use W10 for longer...  :P

Fortunately, Windows doesn't bring me happiness nor does it save me time anymore.

Offline nick65go

  • Hero Member
  • *****
  • Posts: 838
Re: Cosmos a "Fat Linux Distro"
« Reply #14 on: December 06, 2023, 11:17:44 AM »
@linic: Thank you that you take your time to replay in details. Really nice from you.

I do not buy cheap, I invest in things that have lowest TOC (total ownership cost) for 5-8 years. I never gave up on a "good" working device.
My former laptop could "normally" run just up to win10 , but I manage to run win 11 on it. I (temporary) "retire" it because fan became very noisy after 7 years, even with changing fan, CPU cooling pasta, etc. Sometime DYI (do it yourself) just because you can, it is NOT worthy. It pays to "externalize" the service.

I never paid "explicitly" for any software in my life. In the past ... I just crack it, or run in VM.
Oh, I hate Windows and all that Biil Gate & his crowd did against other software. But.. Sun Tzu's Military the art of war: keep friend close and enemy even closer.
(if you want peace, prepare for the war, etc). But I exploit windows, like employers exploit the brain and time of their workers.