Hacker GitHub

← All repos

jart/cosmopolitan

View on GitHub ↗ ★ 21,431 C

build-once run-anywhere c library

293 mentions on Hacker News by 135 people: 24 stories, 269 comments · first 2020-06-20 · latest 2026-10-11

Mentions per year 293 mentions · busiest year 2021 (69)
20082026
  1. …constants so you can absolutely use inlining if you like to live dangerously. For example: https://github.com/jart/cosmopolitan/blob/91f4167a45f811fde6... There really isn't any performance advantage to doing this, because the SYSCALL…
  2. The amount of work that went to this is insane. She made a (full ?) implementation of libc: https://github.com/jart/cosmopolitan/tree/master/libc
  3. The are a few options but all require some effort https://github.com/jart/cosmopolitan/issues/27
  4. …it to use cosmopolitan.a when linking system call functions like read(), write(), etc. See https://github.com/jart/cosmopolitan Another option is if Free Pascal wants to write all the system call support from scratch, then doing that now…
  5. …As far as I'm concerned, this is literal magic. Look at the magic numbers: https://github.com/jart/cosmopolitan/blob/37a4c70c3634862d8d... I could go on, but there's no binary portability comparison with any other language. And she h
  6. …using it, since it lets your binaries run on Windows, Mac, FreeBSD, OpenBSD, and NetBSD too. https://github.com/jart/cosmopolitan See https://justine.lol/ape.html which talks about how the executable format is also a valid zip file, which…
    comment by jart · 2021-02-25 · in Static Executables with SBCL v2
  7. …that were too slow even during the days where multitenancy on a single machine mattered. See https://github.com/jart/cosmopolitan and https://github.com/jart/cosmopolitan/issues/20#issuecomment-... to learn more.
  8. …See also this issue where people have requested hardware accelerated graphics: https://github.com/jart/cosmopolitan/issues/35 Cosmopolitan can be doing more if game studios are willing to back the project. Remember how John Carmack dippe
  9. …is the most popular language and Cosmopolitan has an embedded JavaScript interpreter. See https://github.com/jart/cosmopolitan/blob/master/examples/he... where we built a 300kb Actually Portable Executable + ZIP file polyglot that…
  10. Here's something you can paste into your Linux terminal to get started: git clone https://github.com/jart/cosmopolitan cd cosmopolitan make -j8 o/third_party/chibicc/chibicc.com -include libc/integral/normalize.inc -o hello.com.dbg…
  11. …yet. Lots of GNU extensions and an integrated assembler were added. You can read about them here: https://github.com/jart/cosmopolitan/blob/master/third_party... I have automated tests which do a two-stage build and test on every platform…
  12. …all operating systems rather than just Linux. See https://justine.lol/cosmopolitan/index.html and https://github.com/jart/cosmopolitan Trapping (SYSCALL/INT) is a loose binding. The kernel can evolve all it wants internally. It can…
  13. …How readable is the source code to Blinkenlights? See for yourself. Here's the ALU code: https://github.com/jart/cosmopolitan/blob/master/tool/build/...
    comment by jart · 2021-01-29 · in The Evolution of the QEMU Translator
  14. ▲ 6
    Cosmopolitan Libc v0.1 Released
    story by jart · 2021-01-29 · 1 comment
  15. …which helps Mac/Linux/Windows/FreeBSD developers write software that's compatible with OpenBSD: https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s... As you can see, I've studied these systems a lot and I've got to say that…
    comment by jart · 2021-01-27 · in Heap-based buffer overflow in Sudo
  16. …privileges since spectre has made the performance costs of having an operating system too high: https://github.com/jart/cosmopolitan/issues/20#issuecomment-...
    comment by jart · 2021-01-27 · in Heap-based buffer overflow in Sudo
  17. …shell) to support the Actually Portable Executable format used by the Cosmopolitan C Library. See https://github.com/jart/cosmopolitan/issues/23#issuecomment-... and the recent HN thread here: https://news.ycombinator.com/item?id=25556286
    comment by jart · 2021-01-17 · in FreeBSD 2020 Q4 Status Report
  18. …you can always use SUPPORT_VECTOR to squeeze it down to the order of a 4kb ELF executable. See: https://github.com/jart/cosmopolitan/blob/1df136323be2ae806f...
  19. Author here. tcc is tired and chibicc is wired. Check out https://github.com/jart/cosmopolitan/blob/master/third_party... where I've been working on building a 300kb actually portable executable c11 compiler + assembler + linker that…
  20. …on the subset of numbers that systems share in common. In other words, the really old ones. https://github.com/jart/cosmopolitan/blob/master/libc/sysv/c...
  21. …curious, here's the link to memcpy() as it's actually implemented in the Cosmopolitan headers: https://github.com/jart/cosmopolitan/blob/de09bec215675e9b0b... One thing that the web page doesn't mention (for the sake of simplicity) is that…
  22. …provides a 3kb x86 instruction length decoder that supports all past, present, and future ISAs: https://github.com/jart/cosmopolitan/blob/master/third_party... The Cosmopolitan codebase also provides a debugger / emulator for i8086 +…
  23. …which uses an LP64 data model. That hasn't impacted its ability to use the WIN32 API. See https://github.com/jart/cosmopolitan/tree/master/libc/nt where WIN32 API functions are declared using uint32_t, int64_t, etc. It works great. I…
  24. …happen. Cosmopolitan implements a simplified version of the Address Sanitizer (ASAN) runtime. See https://github.com/jart/cosmopolitan/blob/master/libc/log/as... I've been systematically working towards using it to vet the entire codebase.…
  25. …trying to support like WYSE terminals or actual teletypewriters. Here's the dox on the subject: https://github.com/jart/cosmopolitan/blob/1fc91f3/tool/build... > If a user hits Ctrl-C during clean-up operations that might take a long time,…
    comment by jart · 2020-12-21 · in Command Line Interface Guidelines
  26. Sorry here's what a build file looks like, which should hopefully clarify: https://github.com/jart/cosmopolitan/blob/master/libc/mem/me... As you can see, it's just vanilla make. The package program is just a helper that checks to make…
  27. …that checks some build configuration, augments C and postprocesses executable files? (Looking at https://github.com/jart/cosmopolitan it's an interesting hack. Might be useful in some cases, for example command-line tools like git.) Have…
    comment by s_gourichon · 2020-11-28 · in Please – A cross-language build system
  28. …stays sanely formed. It totally got make working like a dream in a way I simply hadn't seen before. https://github.com/jart/cosmopolitan/blob/master/tool/build/...
  29. …supported. CGA is kind of just a uint16_t[20][80] array for personal computers. See also: https://github.com/jart/cosmopolitan/blob/ea0b5d9/tool/build... You're absolutely right that the inconsistencies with textmode used to be about as…
  30. …ps://justine.storage.googleapis.com/ape.html It even supports fork() on windows as of a few days ago: https://github.com/jart/cosmopolitan/commit/db33973e0aae7ffc...
    comment by jesuscyborg · 2020-11-17 · in Best aspects of C
  31. …this day and age like being able to build once run anywhere TUI apps for Windows/Mac/Linux/BSD. See https://github.com/jart/cosmopolitan/commit/9e3e985ae5fdccc9... and https://justine.storage.googleapis.com/ape.html
    comment by jart · 2020-10-23 · in Rejuvenating Autoconf
  32. …days to retool the standard x86_64 compiler to generate 16-bit boot code for The LISP Challenge. https://github.com/jart/cosmopolitan/blob/b6793d42d5ed6b4f78...
    comment by jart · 2020-10-01 · in Defer Reference Implementation for C
  33. Thanks for the feedback! The README has now been updated: https://github.com/jart/cosmopolitan/commit/fd22e55b42503093... It could use more work though. See also https://justine.storage.googleapis.com/ape.html and the HN thread about it…
    comment by jart · 2020-09-30 · in Defer Reference Implementation for C
  34. …That should just work with GCC and Clang. That code is originally from the Cosmopolitan C Library ( https://github.com/jart/cosmopolitan ) so check it out if you like the Gist and want more! Please note the macro operates at function call…
    comment by jart · 2020-09-30 · in Defer Reference Implementation for C
  35. …I put together recently that builds over 9000 objects, 72 libraries, and a few hundred executables. https://github.com/jart/cosmopolitan/blob/master/Makefile The interesting part I've noticed is tuning the makefile so it correctly orders…
    comment by jart · 2020-09-04 · in The Quest to the Perfect Makefile
  36. You can read more in the libc source. The readme gives an overview. https://github.com/jart/cosmopolitan/tree/master/libc
  37. He talks about it a bit as the "magic numbers". You can see the big table: https://github.com/jart/cosmopolitan/blob/c91b3c50068224929c... I guess there's also syscall emulation stubs for Windows but since he only supports "stdio and…
    comment by Mathnerd314 · 2020-08-24 · in αcτµαlly pδrταblε εxεcµταblε
  38. …and distribute tiny native portable programs (like Kilo!) using hermetically sealed tools. See https://github.com/jart/cosmopolitan
    comment by jart · 2020-07-01 · in The End of the Redis Adventure
  39. ▲ 2
    Cosmopolitan: Fast portable static native textmode executable containers
    story by ingve · 2020-06-27 · 0 comments
  40. Static linking ( https://github.com/jart/cosmopolitan ) jart@debian:~/cosmo$ make -j12 CPPFLAGS+=-DIM_FEELING_NAUGHTY MODE=tiny o/tiny/examples/hello.com jart@debian:~/cosmo$ ls -sh o/tiny/examples/hello.com 20K o/tiny/examples/hello.com…
    comment by jart · 2020-06-26 · in Dynamic linking
  41. …like native machine learning code. For example one build system that enables that use case is: https://github.com/jart/cosmopolitan At best these new POWER or ARM architecture Apple PCs are going to be like a C-class Mercedes. So I'm…
  42. …also taught us last year that 4kb of code is all it takes to decode every x86 isa (i.e. 1977-2020) https://github.com/jart/cosmopolitan/blob/d51409c/third_part... Thanks Mark Charney. https://github.com/intelxed/xed
  43. …I want is stdio and math; how can I do that without all the breaking builds and broken hearts?" https://github.com/jart/cosmopolitan Please consider supporting us. These old technologies are widely supported and have stood the test of…