Cosmopolitan v3.5.8
github.com
github.com
One question, is C++ supported?
Is it possible that a single binary will run on both AMD64 and ARM64?
If you speak english, go to page 7.
Si hablas español, ve a la página 25.
Note that the instructions don't have to be completely equivalent - all that's required is for some set of bytes to be arranged such that the same pattern will be interpreted by AMD64 as jump to X and by ARM64 as jump to Y.Afterwards, it's all about segmenting the instructions in blocks, one for each OS/architecture.
"Cosmopolitan Libc makes C a build-anywhere run-anywhere language"
Let the furious downvoting begin.
It does allow appending binary data to the end of a shell script* as long as it is guarded from being parsed as shell code by an exit, exec, etc. but that's it.
* https://pubs.opengroup.org/onlinepubs/9799919799/utilities/s...
> The input file can be of any type, but the initial portion of the file intended to be parsed according to the shell grammar […] shall consist of characters and shall not contain the NUL character.
Then POSIX doesn’t proscribe against appending binary data at all, it just requires that binary data appears after whatever portion of the file is intended to be parsed according to the grammar… there’s nothing stating that intention can’t apply to a zero characters.
> The shell shall not enforce any line length limits.
That seems to unambiguously allow a zero-length initial portion.
> If the input file consists solely of zero or more blank lines and comments, sh shall exit with a zero exit status.
And so does that, while also making an enormous loophole for any input file that is not zero or more blank lines.
In other words it seems to me on a quick reading that a decent rules-lawyer could drive a planet through that part of the spec, as written.
The paragraph you linked to was part of it, but also this paragraph under RATIONALE[3]:
> Earlier versions of this standard required that input files to the shell be text files except that line lengths were unlimited. However, that was overly restrictive in relation to the fact that shells can parse a script without a trailing newline, and in relation to a common practice of concatenating a shell script ending with an exit or exec $command with a binary data payload to form a single-file self-extracting archive.
So Cosmopolitan indeed seems to be POSIX-approved as far as this behavior goes.
[1]: https://justine.lol/cosmo3/
[2]: https://austingroupbugs.net/view.php?id=1250
[3]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/s...
Personally I don't find the APE part of cosmopolitan that interesting, but their own POSIX API <https://justine.lol/cosmopolitan/functions.html> which also covers windows is interesting for sure. Zig's std also offers something similar, but perhaps not as good coverage. Getting fork, mmap, and poll work on windows is not small feat.