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. …convert to/from the old constants during runtime is too much. Look at the list of constants here: https://github.com/jart/cosmopolitan/blob/master/libc/sysv/c... Every time I used any of these constants, I'd have to load a whole bunch of…
  2. There seems to be a standard socket API in the Cosmopolitan clib though: https://github.com/jart/cosmopolitan/tree/master/libc/sock ..and that also seems to have WinSock support: https://github.com/jart/cosmopolitan/blob/master/libc/sock/c.…
  3. …to inject a SECCOMP filter. Then you can block execve(). See https://justine.lol/pledge/ and https://github.com/jart/cosmopolitan/blob/master/tool/build/...
  4. …you pass a pipe into the whole (server) process, instead of having it open its own sockets? (In https://github.com/jart/cosmopolitan/blob/48b2afb192ec18eca4... , I gather?) I haven't followed cosmopolitan / Linux pledge() too closely; but…
    comment by JoachimSchipper · 2023-06-19 · in Redbean Systems
  5. See https://github.com/jart/cosmopolitan/commit/48b2afb192ec18ec... and https://twitter.com/JustineTunney/status/1670600564164657154
    comment by jart · 2023-06-19 · in Redbean Systems
  6. …datagrams so it can blackhole your IP address in the RAW PREROUTING iptable if you DDOS the system. https://github.com/jart/cosmopolitan/blob/f10845ab9f847e4cad... You can't ban someone's IP without root. So we have two choices: (1) create…
    comment by jart · 2023-06-18 · in Redbean Systems
  7. I'd love to understand more about what the ".verynice()" call does. Source is here: https://github.com/jart/cosmopolitan/blob/f10845ab9f847e4cad... What are the effects of limiting a process priority?
    comment by maxmcd · 2023-06-18 · in Redbean Systems
  8. …which maintains support for old file formats. You can build and use it as follows: git clone https://github.com/jart/cosmopolitan cd cosmopolitan # cross-compile on x86-64-linux for x86-64 linux+windows+macos+freebsd+openbsd+netbsd make…
    comment by jart · 2023-06-06 · in GGML – AI at the Edge
  9. I bet it wouldn't be too extremely hard to port Vim to https://github.com/jart/cosmopolitan and run it without an OS (BIOS mode in cosmopolitan).
    comment by etaioinshrdlu · 2023-04-22 · in Boot to Vim, Vim as Pid 1 (2014)
  10. Cosmopolitan[0] is indeed worth mentioning here. It's an amazing project. [0] https://github.com/jart/cosmopolitan
    comment by loupol · 2023-02-12 · in How to create portable Linux binaries
  11. …Worth noting that we do have Google's outstanding double-conversion library in the cosmo codebase https://github.com/jart/cosmopolitan/tree/master/third_party... as well as gdtoa (which is what we use for printf's floating point support)…
  12. …appear to be. The comments in the code say it can do floats, but the comments are mistaken.) [1] https://github.com/jart/cosmopolitan/blob/master/libc/fmt/vc... [2] https://github.com/jart/cosmopolitan/issues/456
  13. …(a 'minimal vfprintf()') with the one in cosmopolitan starting at https://github.com/jart/cosmopolitan/blob/master/libc/stdio/... . Right away we can see nolibc places many functions in the same file while Cosmopolitan uses
  14. …I recommend obtaining Python from the Comsopolitan mono repo: git clone https://github.com/jart/cosmopolitan make -j8 o//third_party/python/python.com That'll easily give you a static Python 3.6 binary that can be run under Blink.
  15. …really nice `cosmocc` toolchain that makes building POSIX software with Cosmo easier than ever. See https://github.com/jart/cosmopolitan/blob/master/tool/script... and https://github.com/jart/cosmopolitan/blob/master/tool/script...
  16. …I wrote in C (with a focus on readability) which runs https://ipv4.games/ You can read the code at https://github.com/jart/cosmopolitan/blob/master/net/turfwar... This web server runs on a single VM. It was handling about 300 write…
  17. Cosmopolitan Libc uses a musl-cross-make toolchain. https://github.com/jart/cosmopolitan/tree/master/third_party... Its primary developer also runs Alpine. Cosmopolitan is closely related to Musl as far as C libraries go. You could think…
    comment by jart · 2022-12-15 · in Actually Portable Perl
  18. Another example: https://github.com/jart/cosmopolitan/issues/426
    comment by comex · 2022-11-10 · in Why is Rosetta 2 fast?
  19. But python is also universal? You can just bundle jc inside https://github.com/jart/cosmopolitan/tree/master/third_party... and it's as universal as it gets.
    comment by ElectricalUnion · 2022-11-03 · in JC – JSONifies the output of many CLI tools
  20. …rejoice. But it gets better. If you build Python in the Cosmopolitan Libc repository: git clone https://github.com/jart/cosmopolitan cd cosmopolitan build/bootstrap/make.com -j8 o//third_party/python/python.com Then you can use…
  21. Actually Portable Executables / Cosmopolitan https://justine.lol/ape.html https://github.com/jart/cosmopolitan
  22. Oh yes. A good place to start would be our c++ toolchain. https://github.com/jart/cosmopolitan/blob/master/tool/script...
    comment by jart · 2022-10-24 · in Debugging C with Cosmopolitan Libc
  23. …our system call support. Look here, all we need to support a XNU system call is 16-bits of a word. https://github.com/jart/cosmopolitan/blob/2.1/libc/sysv/sysc...
    comment by jart · 2022-09-21 · in Can I use a system call?
  24. Love your naming of the magic numbers headers. https://github.com/jart/cosmopolitan/blob/1.0/libc/sysv/cons...
    comment by davedx · 2022-09-21 · in Can I use a system call?
  25. …to work here) Sadly, it was considered, and XFF is ignored from non-private source addresses: https://github.com/jart/cosmopolitan/blob/155b378a3962e4d291... With private addresses defined as: https://github.com/jart/cosmopolitan/blob/7ab15…
    comment by progval · 2022-09-11 · in IPv4 Turf War
  26. …anything other than educational purposes, at least not until they've been more battle tested. [0]: https://github.com/jart/cosmopolitan/issues/72
    comment by coder543 · 2022-09-08 · in Caddyhttp: Enable HTTP/3 by Default
  27. https://github.com/jart/cosmopolitan/issues/140 https://github.com/golang/go/issues/51900 & from what I gather, APE is tightly-bound to x86_64, & depends on an embedded emulator for other architectures: > All we have to do embed an ARM…
    comment by georgia_peach · 2022-08-30 · in How fat does a fat binary need to be? (2021)
  28. https://github.com/jart/cosmopolitan/blob/master/ape/ape.S https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s... https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s... We do everything static. Even on Apple x86 and M1.
  29. …to define kernel syscalls like how Cosmopolitan [0] uses for building things like RedBean [1]. 0. https://github.com/jart/cosmopolitan 1. https://redbean.dev/
  30. Don't forget the linker script: https://github.com/jart/cosmopolitan/blob/master/ape/ape.lds It has a longform explanation in the comment at the top.
    comment by jart · 2022-08-20 · in Cosmopolitan Libc v2.0
  31. …you're looking for a write-up/blog, however, if you haven't peeked at ape.S you absolutely must: https://github.com/jart/cosmopolitan/blob/master/ape/ape.S It is very commented, in a good way.
    comment by grimgrin · 2022-08-20 · in Cosmopolitan Libc v2.0
  32. …at the moment. However we'd be happy to see them be included. Most of our modules e.g. unix https://github.com/jart/cosmopolitan/blob/master/third_party... only really depend on Lua and POSIX which is available everywhere. You can build…
  33. …runs on M1 Macs with ARM. Daniil Kulchenko pulled off an impressive hack to make that possible. https://github.com/jart/cosmopolitan/issues/429 Redbean also works great on Windows ARM https://youtu.be/CQ7Npip88Yw As for Linux ARM, we're…
  34. …because the difficulty in making graphics cross-platform [0]. Maybe Cosmopolitan circa 2032? [0]: https://github.com/jart/cosmopolitan/issues/35#issuecomment-... .
    comment by actuallyalys · 2022-08-16 · in Win32 Is the Only Stable ABI on Linux?
  35. …seeing something I helped with on the front page of HN[1]. Thanks for the shoutout Justine! [1] https://github.com/jart/cosmopolitan/pull/490
    comment by Toaster-King · 2022-08-07 · in Using Landlock to Sandbox GNU Make
  36. …how to approach implementing this feature. - https://news.ycombinator.com/item?id=32376870 From https://github.com/jart/cosmopolitan#support-vector , supported platforms are Windows, Linux, Mac OS X, FreeBSD, OpenBSD, and NetBSD, on AMD…
    comment by yjftsjthsd-h · 2022-08-07 · in Using Landlock to Sandbox GNU Make
  37. Cosmopolitan Libc Makefile fixes this. And it does it with plain ordinary GNU Make. https://github.com/jart/cosmopolitan/blob/master/Makefile It even has Landlock LSM based sandboxing for strict dependency checking.…
    comment by jart · 2022-08-05 · in Keeping a project bisectable
  38. …Windows' approach always seemed more sensible in the first place. But it's a step worth noting. [1] https://github.com/jart/cosmopolitan/issues/426 [2] https://man7.org/linux/man-pages/man7/vdso.7.html [3]…
  39. …systems unmodified. Cosmopolitan is an incredibly cool project that does more than you think. https://github.com/jart/cosmopolitan
    comment by DenseComet · 2022-07-28 · in Rust is actually portable
  40. …to me. The library this is built on does have a bit of a weakness with respect to GUI software https://github.com/jart/cosmopolitan/issues/35 if this can be fixed this will be an amazing tool for building simple cross platform utilities…
    comment by techdragon · 2022-07-28 · in Rust is actually portable
  41. …format headers (a genius hack nonetheless from Justine) Its a lot more then that. Look at the code. https://github.com/jart/cosmopolitan You compile an executable with flags --nostdlib and --nostdinc because it includes cross platform…
    comment by ActorNightly · 2022-07-27 · in Python is Actually Portable
  42. …uses a polyglot to tell if the processor is running in real mode or long mode within its DOS stub. https://github.com/jart/cosmopolitan/blob/066ed2b2b229dce4d1... APE is also a legal EXE file because it has the MZ header. However... I…
    comment by jart · 2022-07-27 · in Python is Actually Portable
  43. Here's the latest update on TLS https://github.com/jart/cosmopolitan/blob/master/libc/runtim... We need to rewrite the x86 binary code at runtime in order to support it on Mac/Windows. I managed to speed it up from 30ms down to 1ms of…
    comment by jart · 2022-07-27 · in Python is Actually Portable
  44. …the tool to make the default virtual memory limit equal to the total amount of physical ram. https://github.com/jart/cosmopolitan/commit/7f966de48987f79a... I hope this addresses your concern. No default limit is going to be perfect. Some…
  45. As you wish. I've just pushed a change removing the restriction on MAP_POPULATE. https://github.com/jart/cosmopolitan/commit/ccd057a85daf0d2d... Now that we have -n (maximum niceness flag) I doubt anyone will object. If your app is public…
  46. …FreeBSD behavior which we polyfill on Linux using MAP_GROWSDOWN. See our docs for further details. https://github.com/jart/cosmopolitan/blob/0a589add4167c1b587...
  47. …person on earth who's written a libc for that many platforms. Here's what I learned. If you look at https://github.com/jart/cosmopolitan/blob/master/libc/sysv/s... you can see that there's a point in history where consensus between systems…
  48. …NOPs into function calls at runtime for all locking operations as soon as clone() is called. https://github.com/jart/cosmopolitan/blob/5df3e4e7a898d223ce... The big ugly macro that makes it work is here…
    comment by jart · 2022-07-06 · in Python 3.11 vs 3.10 performance
  49. The code is interesting: https://github.com/jart/cosmopolitan/blob/master/tool/viz/me... Feels really old school. Looks like something from people used to write DOS programs.
  50. I use chibicc to generate the documentation for cosmopolitan. https://github.com/jart/cosmopolitan/blob/master/third_party... I added many of the GNU extensions too, including an assembler. https://github.com/jart/cosmopolitan/blob/master/t…