[HN Gopher] Cosmopolitan Third Edition
___________________________________________________________________
Cosmopolitan Third Edition
Author : jart
Score : 364 points
Date : 2023-11-01 17:25 UTC (5 hours ago)
(HTM) web link (justine.lol)
(TXT) w3m dump (justine.lol)
| eatonphil wrote:
| > The end result is that if you switch your Linux build process
| to use cosmocc instead of cc then the programs you build, e.g.
| Bash and Emacs, will just work on the command prompts of totally
| different platforms like Windows and MacOS, and when you run your
| programs there, it'll feel like you're on Linux. However
| portability isn't the only selling point. Cosmo Libc will make
| your software faster and use less memory too. For example, when I
| build Emacs using the cosmocc toolchain, Emacs thinks it's
| building for Linux. Then, when I run it on Windows:
|
| > It actually goes 2x faster than the native WIN32 port that the
| Emacs authors wrote on their own. Cosmo Emacs loads my dotfiles
| in 1.2 seconds whereas GNU Emacs on Windows loads them in 2.3
| seconds.
|
| Impressive stuff.
| AYoung010 wrote:
| That was the most interesting part of the article for me. I
| don't understand how it can be faster, given that there's
| syscall translation going on. Is this more of a commentary on
| the quality of the `libc` available on Windows? Or on the
| quality of the GNU Emacs Windows port?
| PrivateButts wrote:
| Could be like the improvements seen when running applications
| using DXVK. My understanding is that sometimes these
| translation layers can use newer and more efficient methods
| than the path that a native implement for the time would use.
| I'm not a subject matter expert though, and could be
| completely off base.
| vitiral wrote:
| IIUC there is no syscall translation, it's more like there
| are separate libc implementations and the correct one gets
| selected at program start based on the OS.
| stephc_int13 wrote:
| This is all super impressive especially for such a small team.
|
| But we should keep in mind that this project is what POSIX
| should have been, this is a big patch to make things right, as
| they should have been more than 20 years ago.
|
| It seems magical because of the failure of numerous other teams
| and people who never managed to tackle the portability issue
| with the right mindset and skills.
| smusamashah wrote:
| Will it allow native like bash script support on Windows? I use
| windows as my main OS and use cmder for CLI things but really
| miss proper bash script support.
|
| Other than bash itself, does it mean it can be used to make whole
| set of GNU tools cross platform?
| jart wrote:
| Absolutely. cosmos-3.0.1.zip contains bash, GNU coreutils,
| Emacs, and a whole lot more. All of which run great on the
| Windows console. On our github release page, there's also a
| cosmocc zip of a GNU/Linux style GCC compiler. Cosmo provides a
| refreshing way to build Windows software, because we use the
| System V ABI (i.e. long is actually 64-bit) when we build
| Windows software. So there's a much more consistent cross
| platform development experience.
| smusamashah wrote:
| Tried running bash by renaming it to bash.exe using both CMD
| and Powershell and both return "Access denied.
|
| Even though Windows 10 already has Terminal and I was getting
| [error 2147942405 (0x80070005) when launching `C:\bin\bash
| -l']
|
| I downloaded Terminal Preview which still throws the same
| error. Is Terminal or Terminal Preview the only way to run
| bash? There might be a way to configure cmder to use bash in
| a similar way you suggested for Terminal. Don't know how yet.
| jart wrote:
| Try whitelisting the folder with Windows Defender.
| Sometimes when I get EACCES style errors on Windows
| mysteriously, it's because I need to recalibrate the
| security on the folder. Here's an example of something I
| ran once which fixed it. PS
| C:\WINDOWS\system32> $ACL = Get-ACL -Path C:\Users\jtunn
| PS C:\WINDOWS\system32> $ACL | Set-ACL -Path C:\bin
|
| I also just uploaded cosmos-3.0.1.zip to Microsoft Security
| Intelligence to make sure they get whitelisted with their
| cloud security.
| AMICABoard wrote:
| Discuss here:
| https://github.com/jart/cosmopolitan/discussions Add issues
| here: https://github.com/jart/cosmopolitan/issues
| paulclinger wrote:
| Yes and yes.
| NeutralForest wrote:
| That's some pretty amazing stuff considering how difficult C/C++
| portability is.
| simonw wrote:
| There's so much cool stuff in this post.
|
| https://github.com/jart/cosmopolitan/releases/download/3.0.1...
| is 213MB file which contains "fat binaries" (single binaries that
| execute on a bewildering array of hardware platforms and
| operating systems) for dozens of programs, including zip, curl,
| git, wget, python, ctags and even my own Datasette Python
| application!
|
| It's absolutely wild that this works.
|
| I just tried it out (on macOS). I downloaded and extracted that
| zip and did this: cd
| ~/Downloads/cosmos-3.0.1/bin ./python -c 'print(4 + 5)'
|
| It refused the first time because of macOS security settings. I
| had to open the security panel and click "allow"... and then it
| worked!
|
| Likewise, this worked: ./datasette -m datasette
| -p 8000
|
| That started a https://datasette.io/ server running on port 8000.
|
| Git works too: ./git clone
| https://github.com/simonw/sqlite-utils
|
| That git binary is 6.3MB, and I believe that same exact file can
| be copied to a Linux or Windows machine and will work the same
| way.
| simonw wrote:
| Here's a bit of a clue to how it works:
| ./python Python 3.11.4 (heads/pypack1:65ac8ac, Oct 16
| 2023, 02:35:05) [GCC 11.2.0] on linux Type "help",
| "copyright", "credits" or "license" for more information.
| >>> import sqlite3 >>> sqlite3 <module
| 'sqlite3' from '/zip/Lib/sqlite3/__init__.pyc'> >>>
| import pathlib >>> list(pathlib.Path("/zip").glob("*"))
| [PosixPath('/zip/.symtab.amd64'),
| PosixPath('/zip/.symtab.arm64'), PosixPath('/zip/usr'),
| PosixPath('/zip/.cosmo'), PosixPath('/zip/Lib'),
| PosixPath('/zip/build')]
|
| From Python's point of view there a "/zip/" folder with stuff
| in it, presumably stuff that's hidden inside the fat binary.
| mhink wrote:
| Yup, this is basically it. If you check out the "Actually
| Portable Executable" blogpost by the same author [1] and go
| to the "PKZIP Executables Make Pretty Good Containers"
| section there's a note on the approach.
|
| 1: https://justine.lol/ape.html
| ForHackernews wrote:
| absolutely impressive
| ahgamut wrote:
| The "/zip/" folder refers to the ZIP store inside the
| actually portable executable -- you can run `unzip -vl
| ./python` to see what's inside.
|
| Also, to add new pure-python packages, you just need to unzip
| them into a local folder "./Lib", and add that folder to the
| APE.
| skybrian wrote:
| I wonder if llm would work?
| simonw wrote:
| Base https://llm.datasette.io/ should work just fine, but
| it's basically a thin Python wrapper around the OpenAI Python
| library which then makes HTTP requests to their API.
|
| The bigger challenge would be LLM with plugins. Those add all
| sorts of extra dependencies to help LLM run models directly -
| PyTorch, Transformers, llama-cpp-python etc.
|
| I'd be surprised to see "llm install llm-gpt4all" work for
| example, since that pulls in compiled Python wheels and I'm
| not sure it would know which architecture to use.
|
| pip install DOES work: $ ./python -m pip
| install httpx Defaulting to user installation because
| normal site-packages is not writeable Collecting
| httpx Downloading httpx-0.25.0-py3-none-any.whl (75
| kB) ----------------------------------------
| 75.7/75.7 kB 2.7 MB/s eta 0:00:00 ...
| Successfully installed anyio-4.0.0 h11-0.14.0 httpcore-0.18.0
| httpx-0.25.0 sniffio-1.3.0 $ ./python
| Python 3.11.4 (heads/pypack1:65ac8ac, Oct 16 2023, 02:35:05)
| [GCC 11.2.0] on linux Type "help", "copyright",
| "credits" or "license" for more information. >>>
| import httpx >>> httpx <module 'httpx' from
| '/Users/simon/.local/lib/python3.11/site-
| packages/httpx/__init__.py'> $ ls
| ~/.local/lib/python3.11/site-packages anyio
| anyio-4.0.0.dist-info h11 h11-0.14.0.dist-
| info httpcore httpcore-0.18.0.dist-info
| httpx httpx-0.25.0.dist-info sniffio
| sniffio-1.3.0.dist-info
|
| That ~/.local/lib/python3.11/ directory didn't exist until I
| ran the ./python -m pip install command.
|
| Unfortunately "./python -m pip install llm" didn't quite
| work, I got this: ./python -m pip install
| llm Defaulting to user
| installation because normal site-packages is not writeable
| Collecting llm Downloading llm-0.11.1-py3-none-
| any.whl (36 kB) Requirement already satisfied: click
| in /zip/Lib/site-packages (from llm) (8.1.6)
| Collecting openai (from llm) Downloading
| openai-0.28.1-py3-none-any.whl (76 kB)
| ---------------------------------------- 77.0/77.0 kB 31.0
| MB/s eta 0:00:00 Collecting click-default-
| group>=1.2.3 (from llm) Downloading
| click_default_group-1.2.4-py2.py3-none-any.whl (4.1 kB)
| Collecting sqlite-utils>=3.35.0 (from llm)
| Downloading sqlite_utils-3.35.1-py3-none-any.whl (67 kB)
| ---------------------------------------- 67.2/67.2 kB 4.9
| MB/s eta 0:00:00 Collecting sqlite-migrate>=0.1a2
| (from llm) Downloading
| sqlite_migrate-0.1b0-py3-none-any.whl (10.0 kB)
| Requirement already satisfied: pydantic>=1.10.2 in
| /zip/Lib/site-packages (from llm) (1.10.12)
| Requirement already satisfied: PyYAML in /zip/Lib/site-
| packages (from llm) (6.0) Collecting pluggy (from
| llm) Downloading pluggy-1.3.0-py3-none-any.whl (18
| kB) Collecting python-ulid (from llm)
| Downloading python_ulid-2.2.0-py3-none-any.whl (9.4 kB)
| Requirement already satisfied: setuptools in /zip/Lib/site-
| packages (from llm) (68.0.0) Requirement already
| satisfied: pip in /zip/Lib/site-packages (from llm) (23.1.2)
| Requirement already satisfied: typing-extensions>=4.2.0 in
| /zip/Lib/site-packages (from pydantic>=1.10.2->llm) (4.7.1)
| Collecting sqlite-fts4 (from sqlite-utils>=3.35.0->llm)
| Downloading sqlite_fts4-1.0.3-py3-none-any.whl (10.0 kB)
| Collecting tabulate (from sqlite-utils>=3.35.0->llm)
| Downloading tabulate-0.9.0-py3-none-any.whl (35 kB)
| Requirement already satisfied: python-dateutil in
| /zip/Lib/site-packages (from sqlite-utils>=3.35.0->llm)
| (2.8.2) Requirement already satisfied: requests>=2.20
| in /zip/Lib/site-packages (from openai->llm) (2.31.0)
| Collecting tqdm (from openai->llm) Downloading
| tqdm-4.66.1-py3-none-any.whl (78 kB)
| ---------------------------------------- 78.3/78.3 kB 41.9
| MB/s eta 0:00:00 Collecting aiohttp (from
| openai->llm) Downloading
| aiohttp-3.8.6-cp311-cp311-macosx_11_0_arm64.whl (343 kB)
| ---------------------------------------- 343.5/343.5 kB 3.5
| MB/s eta 0:00:00 Requirement already satisfied:
| charset-normalizer<4,>=2 in /zip/Lib/site-packages (from
| requests>=2.20->openai->llm) (3.2.0) Requirement
| already satisfied: idna<4,>=2.5 in /zip/Lib/site-packages
| (from requests>=2.20->openai->llm) (3.4) Requirement
| already satisfied: urllib3<3,>=1.21.1 in /zip/Lib/site-
| packages (from requests>=2.20->openai->llm) (2.0.4)
| Requirement already satisfied: certifi>=2017.4.17 in
| /zip/Lib/site-packages (from requests>=2.20->openai->llm)
| (2023.7.22) Collecting attrs>=17.3.0 (from
| aiohttp->openai->llm) Downloading
| attrs-23.1.0-py3-none-any.whl (61 kB)
| ---------------------------------------- 61.2/61.2 kB 41.9
| MB/s eta 0:00:00 Collecting multidict<7.0,>=4.5 (from
| aiohttp->openai->llm) Downloading
| multidict-6.0.4-cp311-cp311-macosx_11_0_arm64.whl (29 kB)
| Collecting async-timeout<5.0,>=4.0.0a3 (from
| aiohttp->openai->llm) Downloading
| async_timeout-4.0.3-py3-none-any.whl (5.7 kB)
| Collecting yarl<2.0,>=1.0 (from aiohttp->openai->llm)
| Downloading yarl-1.9.2-cp311-cp311-macosx_11_0_arm64.whl (61
| kB) ----------------------------------------
| 61.3/61.3 kB 427.1 kB/s eta 0:00:00 Collecting
| frozenlist>=1.1.1 (from aiohttp->openai->llm)
| Downloading
| frozenlist-1.4.0-cp311-cp311-macosx_11_0_arm64.whl (46 kB)
| ---------------------------------------- 46.7/46.7 kB 14.8
| MB/s eta 0:00:00 Collecting aiosignal>=1.1.2 (from
| aiohttp->openai->llm) Downloading
| aiosignal-1.3.1-py3-none-any.whl (7.6 kB) Requirement
| already satisfied: six>=1.5 in /zip/Lib/site-packages (from
| python-dateutil->sqlite-utils>=3.35.0->llm) (1.16.0)
| Installing collected packages: sqlite-fts4, tqdm, tabulate,
| python-ulid, pluggy, multidict, frozenlist, click-default-
| group, attrs, async-timeout, yarl, sqlite-utils, aiosignal,
| sqlite-migrate, aiohttp, openai, llm ERROR: Could not
| install packages due to an OSError: [Errno 2] ENOENT/2/No
| such file or directory: '/Users/simon/.local/bin/sqlite-
| utils'
| ahgamut wrote:
| Yes, so pip works because the Python APE has OpenSSL built-
| in.
|
| pip install requires modifying the APE, so I end up
| installing pure-Python libraries as follows:
| mkdir Lib ./python -m pip download httpx
| unzip ./*.whl -d ./Lib mv python python.com # in
| case the next step doesn't work zip -r ./python.com
| Lib mv python.com python
|
| Installing CPython extensions like this is an unsolved
| problem, but I think there might be some interesting
| workarounds possible.
| AMICABoard wrote:
| Yes they do!
|
| https://github.com/jart/cosmopolitan/tree/master/third_party.
| ..
|
| and
|
| https://github.com/trholding/llama2.c
| BiteCode_dev wrote:
| Now imagine nuitka and gcc bundled as a standalone cross
| plateform binary so you can basically compile a cross plaform
| python exe from any script.
| summarity wrote:
| sudo xattr -rd com.apple.quarantine /path/to/binary/or/app
|
| should also allow anything to run without opening settings
| sgammon wrote:
| Mind blowing, excited to play with Cosmo 3.
| AMICABoard wrote:
| I swear this is the coolest project ever!!! I am using cosmo for
| our stuff too. jart & the team is super dedicated and responsive.
|
| Kinda feels like they are super intelligent alien beings from
| another planet trying to save us from software bloat and
| fragmentation.
|
| > POSIX even changed their rules about binary in shell scripts
| specifically to let us do it.
|
| I don't know what to say.
| 1970-01-01 wrote:
| Its not immediately clear what this is. The quick description is
| completely off on another part of the website on another webpage.
| TLDR: "Cosmopolitan" makes C a build-once run-anywhere language.
| So here's your very easy tip of the day: Describe what your thing
| does on the very same webpage you announce it. Very easy to do,
| but not done nearly enough.
| neogodless wrote:
| I _kind of_ felt that way, as it starts with the assumption you
| know what it is.
|
| The first sub-title headline tells you, but it isn't clear to
| someone new if this is "one of the features of something" or
| "the thing."
|
| > Build Once Anywhere, Run Anywhere C/C++
|
| I clicked to the home page and then to here:
| https://justine.lol/cosmopolitan/
|
| Then I understood!
|
| > Cosmopolitan Libc makes C a build-once run-anywhere language,
| like Java, except it doesn't need an interpreter or virtual
| machine.
|
| While anyone familiar probably finds these comments "stupid",
| just some helpful advice to the author - if it matters to you,
| there are people discovering this for the first time who might
| not realize what "it" is until you tell them!
| 1970-01-01 wrote:
| >it starts with the assumption you know what it is.
|
| That's the gripe! It's all context! Here it is with SUNSHINE
| 3.0.1: After nearly one year of
| development, I'm pleased to announce our version 3.0.1
| release of Sunshine. The project is an entirely new day. For
| starters, Apple sponsored our work as part of their FLOWER
| program. Google also awarded me an open source peer bonus for
| my work on Sunshine, which is a rare honor, and it's nice to
| see our project listed up there among the greats, e.g. OPEN,
| QUIT, etc. In terms of this release, we're living up to the
| great expectations you've all held for this project in a
| number of ways. The first is we invented a new widget that
| lets you grow large dirt which...
| compiler-guy wrote:
| An announcement on someone's project web site is not targeted
| at the random folks on Hacker News, or even random folks in
| general. They know their audience, and folks showing up from
| random places should do at least a little bit of work to figure
| out the context and surrounding pages.
|
| If you've never read their blog or announcements before, I
| don't know why you would expect them to cater to you.
|
| HN's headline policy makes it especially hard here, because the
| submitter can't provide context.
| 1970-01-01 wrote:
| >I don't know why you would expect them to cater to you.
|
| Its odd to think someone should not expect new user interest
| when they've made a new thing. Announcements are for new
| users and old users alike.
| gaucheries wrote:
| The author might be interested to know that this page might be
| displaying in an undesired way on iPhone mini screens:
|
| https://i.ibb.co/v4s0Xpj/IMG-1221.png
| jart wrote:
| Eek. If anyone has a quick CSS fix for mobile I'll happily add
| it. I'm talking to some of my people too. Thanks for bringing
| it to my attention.
| imiric wrote:
| I'm amused by the fact that even authors of the most
| technically brilliant projects in recent memory also struggle
| with CSS, just like us mere mortals. :)
|
| Love your work! <3
| _jackdk_ wrote:
| This is the only concession to mobile that I have on my
| website, and it seems to do okay: <meta
| name="viewport" content="width=device-width, initial-
| scale=1">
| mamcx wrote:
| This could work with Rust? I have a great use case for it and
| could slash half of my CI if is true!
| vitiral wrote:
| The trick could definitely work with rust since fundamentally
| it's "just" a hack on how the various scripts work on different
| systems. Actually getting the rust compiler to produce
| cosmopolitan binaries would likely be a heavy lift though.
|
| Also it says it supports WASM (wasi?) so some applications
| might work out of the box with that.
| ahgamut wrote:
| https://github.com/ahgamut/rust-ape-example
|
| My above repo contains example with the Rust standard library
| that build as fat executables with Cosmopolitan Libc.
|
| I also got ripgrep to build
| https://github.com/ahgamut/ripgrep/tree/cosmopolitan, but it
| wasn't part of the cosmocc binaries because some crates that
| are part of the build require `#!feature(rustc_private)]` to be
| added to their source code. Same goes for bat and fd.
|
| To summarize, Rust CLI tools can be built with Cosmopolitan
| Libc, but to build them like we can build gcc/emacs/git right
| now, we will need some support and Rust expertise.
| Georgelemental wrote:
| Last time I looked into Rust-on-Cosmopolitan, I couldn't make
| it work as Cosmopolitan determined syscall numbers, signal
| numbers, and such at runtime, but Rust standard library
| assumes compile-time constants (basically the same issue that
| C switch-case has). How did you get around that? Have you
| tested these binaries on non-Linux platforms?
| jart wrote:
| [delayed]
| Alifatisk wrote:
| Can I recompile Ruby with this and make the ruby runtime
| portable?
| ahgamut wrote:
| Try it out! We got Lua/LuaJIT, Python, PHP, and Rust building
| (the latter two are not fully automatic yet), so Ruby might be
| possible even now.
| NotSammyHagar wrote:
| It says arm64 linux support, I will have to try this on a
| raspberry pi. It's kind of amazing and magical that this person
| pulled it off. We need a MacArther genius award for software. And
| this should be the first award.
| mprovost wrote:
| Every time I see an update from Justine I get so excited. It's
| like watching the future of computing unfold in real time. It
| makes me wish we could send them back in time - all of the pieces
| to make this work have been in place for a long long time but
| nobody connected all the dots. The funniest part of this post are
| the instructions to integrate it with autoconf. All of that
| autotools nonsense wouldn't have had to exist if this had been
| around!
| haptic wrote:
| This is a neat trick and clever technical work, but is it useful
| in practical terms?
|
| Like, wouldn't you just download the binary that's been compiled
| specifically for the platform and architecture that you're using?
| Rather than relying on a potentially quite fragile method of
| cross-platform execution.
|
| In a way it kind of reminds me of Urbit. Very clever, very cool,
| but also very niche and more of a hobbyist showcase project than
| anything else. Not that there's anything wrong with that of
| course.
| pie_flavor wrote:
| Write once, run anywhere has been a slogan for coming up on
| thirty years. Except all implementations of it have acceded to
| reality in one or more important aspects, such as needing to
| install Java separately. And it's not just platform-specific
| compilation, it's everything that could _support_ platform-
| specific compilation (if you 've never tried to cross-compile
| from Linux to MSVC, you should), and also all sorts of
| platform-specific code (like console functions vs terminal
| sequences, or even stuff as banal as $HOME vs $USERPROFILE).
| Cosmopolitan still isn't perfect, because it doesn't emulate
| _all_ of Linux, so you still need kernel32.dll here and there.
| But it is still the best of any attempts.
| jart wrote:
| I agree. You sound like you're speaking from experience. If
| so, I'd love to hear what sort of stuff you're building with
| Cosmo, if you're able to share! Feel free to reach out
| anytime (privately or discord) and let me know what the
| project can be doing to better serve your needs.
| piaste wrote:
| For the consumer it's a simple switch(arch) statement to
| download the right binary.
|
| But for the _developer_ , it means setting up 9 different build
| pipelines and artifacts (and realistically, most won't bother
| with BSD builds and a lot still don't bother with arm64
| builds).
|
| It's not necessarily a huge hurdle or an unbearable expense
| with modern CI services, but it's still a massive deal that
| this project can make it all unnecessary for every single C/C++
| developer out there. If this were a paid product, literally
| millions of companies would be happy to pay a small fee to save
| on CI costs, time and maintenance.
| gary_0 wrote:
| Christmas came early! Thanks, jart-Claus, it's just what I
| wanted!
| pie_flavor wrote:
| Is specific effort being put in to dodge antiviruses? I've been
| unable to use redbean at work due to Crowdstrike deciding it's
| malware.
| dflock wrote:
| Can we just put @jart in charge of computers now, please?
| DrNosferatu wrote:
| What would be the best/lightest GUI-via-the-browser framework to
| employ with a program compiled as a Cosmopolitan fat binary?
|
| (say, Qt WebAssembly? ...something else?)
|
| Or is there a even better route to run-anywhere Cosmopolitan apps
| with a GUI?
| radiator wrote:
| Perhaps, by the same authors, redbean, which "embeds Lua,
| SQLite, and MbedTLS into a fork() driven application server"
| ... " a great fit for when you want to build an app that's
| vertically integrated into a single tiny file that runs on
| nearly all PCs and servers". It looks like as of now, greenbean
| exists as well.
| spandextwins wrote:
| Docker actually solved this quite a while ago with tags and
| downloads of the correct architecture container. But this is
| interesting even though it won't scale well.
| vanderZwan wrote:
| > Even though it won't scale well.
|
| Why not?
| holoduke wrote:
| You cant compare these. And if you would then Docker would be
| Mcafee alike.
| c-c-c-c-c wrote:
| > POSIX even changed their rules about binary in shell scripts
| specifically to let us do it.
|
| What does this refer to?
|
| The latest POSIX standard was released 2007. [1]
|
| 1: https://standards.ieee.org/ieee/1003.1/7101/
| mananaysiempre wrote:
| POSIX / SUS / the Open Group Base Specifications have issues
| (pun not intended, but I'll take it), and then those issues
| have editions. The last one of those is from 2018[1], being a
| revision of (indeed) the 2008 issue. (I remember Landley being
| more than a little acidic about this versioning scheme.)
|
| I still have no idea what the quote is referring to, though,
| and given Justine's slightly (deliberately?) unhinged manner of
| writing, I'd give even odds the change is in fact from 2001 or
| something like that.
|
| [1]
| https://pubs.opengroup.org/onlinepubs/9699919799.2018edition...
| csande17 wrote:
| [delayed]
| jart wrote:
| Author here. See https://austingroupbugs.net/view.php?id=1250
| and https://austingroupbugs.net/view.php?id=1226
| tedunangst wrote:
| Don't think this is the bug they refer to, but it's one
| affecting sh input rules. There are others.
|
| https://austingroupbugs.net/view.php?id=1250
| davikr wrote:
| Trying to run Cosmos apps from the Windows Terminal opens a pop-
| up saying "Select an app to open '<app>'". How can I execute
| them?
|
| I ended up finding a solution:
|
| > If you want to run them on Windows, then you simply need to
| rename the file so that it has the .com suffix. Better yet,
| consider making that a symlink (a.k.a. reparse point).
| jart wrote:
| What I like to do is configure Windows Terminal Preview so it
| launches `C:\bin\bash -l` as my command prompt. Once you're
| inside bash, it doesn't care about the .com or .exe suffix
| being there. Only CMD.EXE really cares about the suffix. So you
| have to simply rename the files if you want to run it there.
| NKosmatos wrote:
| What kind of sorcery is this???
|
| Just kidding, I've played around with some of the stuff @jart and
| other contributors have created and it's mind blowing. Well done
| and keep up the good work.
| matheusmoreira wrote:
| Congratulations on your release and sponsorships!
|
| > In the Cosmos, every program is statically linked and contains
| a PKZIP central directory where its /usr/share dependencies are
| embedded.
|
| Sounds really neat, even the data and configuration files are
| linked into the executable. Can't wait to see what else you'll
| come up with.
| vanderZwan wrote:
| > _However portability isn 't the only selling point. Cosmo Libc
| will make your software faster and use less memory too._
|
| With that in mind, is there a "slim binary" mode that lets me
| only export the code to run the binaries on _my_ system, so that
| I can reap these benefits for personal use without added "bloat"
| for a feature that I won't need? (where "bloat" is contextual,
| with the current context being "not actually planning to make use
| of portability")
| jart wrote:
| Author here. We've got you covered. Search for `MODE=tinylinux`
| in the https://github.com/jart/cosmopolitan#getting-started
| section of the README. If you use that build mode, then hello
| world for x86 linux is only 8kb in size. It's very similar to
| what you'd expect from Musl Libc. All the Windows / BSD / Mac /
| BIOS stuff gets removed from the compilation.
|
| That predefined mode is actually a friendly wrapper around a
| more generalized platform support system Cosmopolitan offers,
| which is called `-DSUPPORT_VECTOR` where you can define a
| bitset of specifically what platforms you want to be supported.
| Then dead code elimination takes care of the rest. The same
| concept also generally applies to microarchitecture support,
| where you can have as much or as little runtime dispatching as
| you want.
| mananaysiempre wrote:
| I think you can subset supported systems, like you could only
| compile for x86_64 ELF systems (aka Linux and *BSD) and have
| the shim be much smaller; presumably a subset of one is also
| acceptable. I don't know how (or if) you can do this with the
| new build environment, though.
| dataflow wrote:
| As awesome as these are, they're not really portable
| _executables_ if you can 't set their setuid bits and expect them
| to run as root like with normal executables, right?
| jart wrote:
| There's a program that's part of cosmos called `assimilate`
| which can turn any APE binary into a platform-specific binary.
| jart@nightmare:~$ /opt/cosmos/bin/assimilate --help
| assimilate: illegal option -- - actually portable
| executable assimilate v1.6 copyright 2023 justine
| alexandra roberts tunney usage: assimilate
| [-xapembfchv] [-o PATH] FILE... -h show help
| -v show version -f ignore soft errors
| -b don't remove freebsd from elf os/abi -c
| clobber input path w/o making backup -e
| convert to elf regardless of host os -m
| convert to macho regardless of host os -x
| convert to amd64 regardless of host cpu -a
| convert to arm64 regardless of host cpu -p
| convert to ppc64 regardless of host cpu -o PATH
| write modified binary to different file
|
| If you aren't using binfmt_misc then you can also pass the
| `--assimilate` flag to your APE binary, to turn it into a
| native executable, without having to use the tool. It's baked
| into the shell script. Just use the `less` command on any APE
| file and read the shell script.
|
| Once assimilated, you're free to turn it into a setuid binary.
|
| We also have patches in flight for the Linux Kernel as well as
| BSDs, to make APE native. https://justine.lol/ape.patch
| dataflow wrote:
| Oh wow, that's very nice! Thanks for sharing!
| Fraterkes wrote:
| Very cool! What would the "gui-version" of this look like? Would
| you write it once with linux bindings and the executable would
| succesfully create a window in every operating system?
| jart wrote:
| I think it'd be pretty sweet to have a basically an APE
| approach to having a blank GPU framebuffer canvas, and let high
| level libraries do the rest. Other folks on my team have been
| floating the idea of getting X to build as an APE binary. Who
| knows what the future holds? We don't have any resources
| devoted however to the problem at the moment.
___________________________________________________________________
(page generated 2023-11-01 23:00 UTC)