2 ms·
Found out about cosmopolitan from another HN thread recently and it's some pretty cool stuff. The one thing that I think could use a bit more polish is cross p
by lhorie 6y ago
Found out about cosmopolitan from another HN thread recently and it's some pretty cool stuff.
The one thing that I think could use a bit more polish is cross platform compiler toolchain. I tried to set it up on a mac and it turned out my gcc was aliased to clang because xcode(?). Ended up spinning up a debian docker image to play around, but then found out that the .com binary rewrites itself on run so if you output to a docker volume mount and run from one OS, it ceases to work in the other. Not the end of the world and I'm sure it would all be a much cleaner experience had I just had a linux box setup, but alas.
Golang and ziglang make setting up a compiler toolchain super easy, with prebuilt binaries for the major OSes. Zig in particular looks extremely promising: it has first class support for cross-compilation and it outputs binaries that are very competitive in size w/ cosmopolitan (in addition to providing a bunch of nice language features over C and good interop w/ it).
Overall, I'm really digging all this work being put into innovating the low level layer.
- jart 6y agoBut your binaries run on Mac and every other system once you build them. It's got universal deployment down pat. Universal development is a different story because Cosmopolitan isn't in the business of distributing GCC and Clang. That's why it's designed to work great using the standard operating system provided compilers on Linux and BSD. There's a Linux toolchain binary available for Windows for convenience. One will be available for Mac soon, because the issue with Mac is that all the existing toolchains are configured to use the Apple linker and assembler rather than binutils or lld, and Apple's linker is designed to build binaries that only run on Apple. Zig has accomplished a lot with toolchains and cross-compilers but you have to build your app multiple times. Cosmopolitan is also much newer. But it proves new things are possible, so as you said it's very exciting to think about where the project will be one year hence.
- lhorie 6y agoYeah, that's a good point. I didn't mean it as a criticism of cosmopolitan per se; more that depending on stock toolchains can add friction because they may be susceptible to breakage by random shenanigans by brew or xcode or who knows what else, whereas defaulting to curl -L [...] | tar -xz [...] into a hermetic space is generally less susceptible to yak shaving. (The Make setup in the cosmo repo is quite nice, btw) Zig compile times are definitely slower than Go's, for example (in release mode, anyways), but I guess that's LLVM for ya. Fast cross-platform binaries w/ fast compile times would be the holy grail for me. Looking forward to see where cosmo goes
- jart 6y agoI agree with you. Cosmo's Makefile is hermetically sealed and it works on every LInux distro. I don't do development on any other platform. I wanted a way to write my code on Linux be able to target other systems without ever having to use those systems tools. However I believe in supporting the development use cases other people have too! That's why there's the binary releases. You can take the .h and .a file and use any compiler / os for dev you want. But you can't use the Apple Linker.