https://github.com/jart/cosmopolitan/blob/master/ape/ape.S
It is very commented, in a good way.
https://github.com/jart/cosmopolitan/blob/master/ape/ape.lds
It has a longform explanation in the comment at the top.
I presume it uses tricks similar to those files that are both ZIPs and PDFs simultaneously or whatever - basically they've chosen formats where the parser starts by reading different bits of the file.
But that's an educated guess because I don't think there's a clear explanation anywhere.
This is the start of the realization that building C/C++ on Windows is only the beginning of the pain. Once you are past that, there is a multitude of semantic differences like paths, CRLF, the fact that file move is not atomic, the fact that an opened file cannot be removed (e.g. because Windows Defender or some other BLODA is scanning it), etc, etc. It's a death by a thousand papercuts. My suggestion is to avoid supporting Windows at any cost.
Regarding the C:/ vs. /c/ thing, we got away with not caring for the longest time, because our programs are generally designed to (a) always use relative paths, and (b) never call chdir(). However porting Python changed that, since Python likes to be clever with paths. So I'd say it's really the end of a realization, not the start.
Having a single global root is in fact bad. Having paths be relative some origin is good. DOS was, in a funny way, ahead of the curve.
Nothing about that in the FAQ or guidelines (please link if I missed it) and it was just one day after the linked submission.
> It's just bad form to reprimand others when it's not clearly rooted in the group consensus.
I am not reprimanding anyone. Indicating a dupe allows mods to merge the posts (and no, I'm not setting up a new e-mail account just for that).
> Doubly so when it's about my own prior submission that didn't get attention.
If you did post it within the past year, that submission is not showing up in search (unless you're operating multiple accounts to facilitate your high post rate..?).
Personally I'm glad OP did a repost that did get traction attention but I don't get the assumed hostility here at all.
That said, I'm happy this time around it got more attention.
I am not sure about the APE executable format, it is a nice and technically impressive feature but I would not mind if the lib dropped the support for it in the future.
This might be a minor issue for some, but I do not like having to distribute a .com file, it look suspicious.
Overall, this is fantastic work, very useful and inspiring, the kind of project that could help to fuel a C based apps renaissance.
make -j16 MODE=tinylinuxbsd
Will produce ELF executables that run on Linux, FreeBSD, NetBSD, and OpenBSD. You'll never have to worry about being red-flagged by Microsoft. You won't have worry about Apple breaking your binaries. You won't have to worry about Glibc's license or wine binfmt_misc issues. Your binaries will be smaller, starting at 8kb in size. It's real nice and still supports 4x more platforms than the existing tools. If you use it, please note that "tiny" modes disable a lot of cool features like --ftrace and --strace. You can turn them back on by putting: ifeq ($(MODE), linuxbsd)
CONFIG_CPPFLAGS += \
$(BACKTRACES) \
$(FTRACE) \
-DSYSDEBUG \
-DSUPPORT_VECTOR=113 \
-O2
TARGET_ARCH ?= \
-msse3
endif
In either ~/.cosmo.mk or build/config.mk. Then you'd say `make MODE=linuxbsd`. We also ship a `tinylinux` prebuilt amalgamation on https://justine.lol/cosmopolitan/download.htmlLastly, you can always change the .com extension to .exe. I would have chosen the latter, but I think UNIX has more in common with DOS than it does with Windows. I know people in the Microsoft camp hold negative associations with .com. But I didn't want people in other camps to think APE is just a Windows program.
Unfortunately Windows might not be that smart.
I really like the tiny ELF executable running on any unix, very neat and not scary.
Having the same style of release for macOS and Win32 would be perfect.
From "Getting started":
build/bootstrap/make.com -j8
Lol, do I take it that make.com is built with Cosmopolitan? If so, that's a nice demo of its purpose! Just download and run.
# git clone https://github.com/cosmopolitan
# make -j8 o//third_party/python/python.com
wget https://justine.lol/ftrace/python.com
mkdir .python
printf 'print("hello world")\n' >.python/hello.py
printf -- '-m\nhello\n' >.args
zip -r python.com .python .args
chmod +x ./python.com
./python.com
This is a great way for white-labeling the APE Python interpreter as your own program. You just put your source code inside the executable using the zip command. Then you add a .args file that specifies the default argv[] array if the user didn't specify any arguments.> This change boosts SSL handshake performance from 2,627 to ~10,000 per second which is the same level of performance as NGINX at establishing secure connections.
I'm continuously impressed by how much functionality is baked in and the quality. Fantastic work.
> You can now use Actually Portable Python by building o//third_party/python/python.com
Okay that is seriously amazing.
You love to see it.