liblinux
DISCONTINUED
cosmopolitan
Our great sponsors
liblinux | cosmopolitan | |
---|---|---|
16 | 200 | |
195 | 14,432 | |
- | - | |
0.0 | 9.8 | |
over 4 years ago | 4 days ago | |
Makefile | C | |
MIT License | ISC License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
liblinux
- Liblinux – architecture-independent access to Linux system calls
-
A standalone zero-dependency Lisp for Linux
> libc isn't really getting in the way here.
For the standard set of system calls, the libc is pretty great. For Linux-specific features, it could take years for glibc to gain support. Perhaps it's gotten better since then, perhaps it still takes years. I don't know.
Years ago I read about the tale of the getrandom system call and the quest to get glibc to support it:
https://lwn.net/Articles/711013/
A kernel hacker wrote in an email:
> maybe the kernel developers should support a libinux.a library that would allow us to bypass glibc when they are being non-helpful
That made a lot of sense to me. I took that concept and kind of ran with it. Started a liblinux project, essentially a libc with nothing but the thinnest possible system call wrappers. Researched quite a bit about glibc's attitude towards Linux to justify it:
https://github.com/matheusmoreira/liblinux#why
Eventually I discovered Linux was already doing the same thing with their own nolibc.h file which they were already using in their own tools. It was a single file back then, by now it's become a sprawling directory full of code:
https://github.com/torvalds/linux/tree/master/tools/include/...
Even asked Greg Kroah-Hartman on reddit about it once:
https://old.reddit.com/r/linux/comments/fx5e4v/im_greg_kroah...
Since the kernel was developing their own awesome headers, I decided to drop liblinux and start lone instead. :)
-
Nolibc: A minimal C-library replacement shipped with the kernel
It gives you access to 100% of Linux's system calls. It eliminates a lot of global state. It gets rid of a lot of legacy libc crap.
Years ago I wrote a fairly referenced rationale in my liblinux project:
https://github.com/matheusmoreira/liblinux/blob/master/READM...
-
Win32 Is the Only Stable ABI on Linux
> Now, do I think it would make total sense for syscall wrappers and NSS to be split into their own libs (or dbus interfaces maybe) with stable ABIs to enable other libc's, absolutely!
I worked on this a few years ago: liblinux.
https://github.com/matheusmoreira/liblinux
I'm not developing it anymore though because I found out the Linux kernel itself has a superior nolibc library:
https://github.com/torvalds/linux/tree/master/tools/include/...
It used to be a single header but it looks like they've recently organized it into a proper project!
I wonder if it will become some kind of official kernel library at some point. I asked Greg Kroah-Hartman about this and he mentioned there was once a klibc:
https://old.reddit.com/r/linux/comments/fx5e4v/im_greg_kroah...
> This is something the BSD's got absolutely right.
BSDs, every other operating system really, force us to use the bundled C libraries and the C ABI. I think Linux's approach is better. It has a language-agnostic system call binary interface: it's just a simple calling convention and the system call instruction.
The right place for system call support is the compiler. We should have system_call keywords that cause it to emit code in the aforementioned calling convention. With this single keyword, it's possible to do program literally anything on Linux. Wrappers for every specific system call should be part of every language's standard library with language-specific types and semantics.
-
Oasis: Small statically-linked Linux system
I'm not using this stuff professionally, it's just my own home lab's virtual machines with little services implemented as freestanding C programs. Not doing anything fancy right now, much of it was just to see if I could do it.
I've seen other people commenting here on HN saying they're using the same approach so it's defenitely not my invention.
I published some of my work in the form of a liblinux that I use to make system calls:
https://github.com/matheusmoreira/liblinux
I'm not developing it anymore though because I found out the kernel itself has a nolibc library:
https://github.com/torvalds/linux/tree/master/tools/include/...
It used to be a single header but it looks like they've organized it into a proper project.
-
A Tutorial on Portable Makefiles
That's awesome. I didn't know about rwildcard until now. Is it part of GMSL? I searched for rwildcard on gmsl.sourceforge.io but didn't find it.
I think my function is needlessly complicated compared to rwildcard. Here's my code:
https://github.com/matheusmoreira/liblinux/blob/modular-buil...
https://github.com/matheusmoreira/liblinux/blob/modular-buil...
The file? and directory? functions were inspired by GMSL.
I wrote a general recursion function. It takes a function to apply to lists and a function to compute whether an element is a base case.
The recursive file system traversal function applies a directory globbing function to the list of paths and has file? as base case.
The find function filters out any items not matching a given predicate function. It was my intention to provide predicates like C_file? and header_file? but I stopped developing that project before that happened.
I think rwildcard is probably simpler and more efficient!
- GitHub - matheusmoreira/liblinux: Linux system calls.
- liblinux: Architecture-independent access to Linux system calls
-
Ah yes, my mouse driver is asking for a firewall exemption (2019)
Thanks for this, it's extremely awesome! Really happy to see others have gone so much farther than I ever did.
I started looking into this myself some years ago. Even started developing a liblinux with process startup code and everything. Abandoned it after I found the kernel itself had an awesome nolibc.h file that was much more practical for my C programming needs:
https://elixir.bootlin.com/linux/latest/source/tools/include...
My code is here if you'd like to take a look as well:
https://github.com/matheusmoreira/liblinux
It's amazing how this really lets you do everything... Want a JIT compiler? Map some executable pages and emit some code. You can statically allocate memory at process startup and then implement memory allocation and garbage collection in your own language.
-
Git's list of banned C functions
> A new libc starting fresh would be nice.
Agreed. I want to make something like this on top of Linux. I discarded the entire libc and started from scratch with freestanding C and nothing but the Linux system call interface. Turns out the Linux system call interface is so much nicer.
https://github.com/matheusmoreira/liblinux/blob/master/examp...
I wish I still had the free time to work on this...
cosmopolitan
-
Ask HN: What Underrated Open Source Project Deserves More Recognition?
Cosmopolitan https://github.com/jart/cosmopolitan and https://justine.lol/cosmopolitan/index.html
Some genius realized that you can actually embed valid win32 programs inside valid posix shell scripts, and found a way to make a C cross-platform solution out of it, meaning that you can write C programs that compile to a single executable that will run on (quoting the site) Linux + Mac + Windows + FreeBSD + OpenBSD + NetBSD + BIOS
It all started from this post.
-
Show HN: Usr/bin/env Docker run
For this .args file, put one argument per line. This will run on start. You can use `/zip/mydepencency.anything` to read from files, but if you have an executable dependency you'll need to extract it first.
You can do this with any software you can compile with comsocc, by adding a call to LoadZipArgs[1] in the main function.
It'seasy to get started, your ideas will branch out as soon as you start playing with it.
[1]: https://github.com/jart/cosmopolitan/blob/master/tool/args/a...
-
Libwebsockets
FWIW there is ongoing work with good progress to add websocket support to redbean (https://github.com/jart/cosmopolitan/pull/967)
-
Actually Portable Vim (With a Cute Vimrc)
The binary was compiled with Cosmopolitan Libc [0], and therefore the binary will execute natively on Linux, Mac, Windows, FreeBSD, OpenBSD, NetBSD, and bare metal (BIOS boot).
I would call that portable.
-
Show HN: PyApp – runtime installer for Python applications
will go on my "to try" list where i already have cosmopolitan [2]. my last setup (windows) was shiv + wine + nsis (used that as pyinstaller had some issues)[2]
[1] https://github.com/jart/cosmopolitan/issues/141#issuecomment...
-
Ask HN: What are some unpopular technologies you wish people knew more about?
- cosmopolitan: https://github.com/jart/cosmopolitan
-
A standalone zero-dependency Lisp for Linux
Just compile regular Lisp with cosmopolitan. Then the same binary will run on windows, linux, mac, and BIOS. /s
This has been done with Lua, see: https://github.com/jart/cosmopolitan/issues/61
-
Cosmopolitan Third Edition
Cool. Somebody still needs to teach sscanf how to parse floats though. https://github.com/jart/cosmopolitan/issues/456
The code to do it would probably go in here: https://github.com/jart/cosmopolitan/blob/master/libc/stdio/...
I mean, I know why it's not done (parsing floats correctly is a lot harder than it would at first seem to be) and I'm not complaining, more like hinting to some of the fine people that haunt this website who might find such a task interesting.
There's so much cool stuff in this post.
https://github.com/jart/cosmopolitan/releases/download/3.0.1... is 213MB file which contains "fat binaries" (single binaries that execute on a bewildering array of hardware platforms and operating systems) for dozens of programs, including zip, curl, wget, python, ctags and even my own Datasette Python application!
It's absolutely wild that this works.
I just tried it out (on macOS). I downloaded and extracted that zip and did this:
cd ~/Downloads/cosmos-3.0.1/bin
What are some alternatives?
libc - libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.
src - Read-only git conversion of OpenBSD's official CVS src repository. Pull requests not accepted - send diffs to the tech@ mailing list.
SDL - Simple Directmedia Layer
llvm-project - The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
luastatic - Build a standalone executable from a Lua program.
v - Simple, fast, safe, compiled language for developing maintainable software. Compiles itself in <1s with zero library dependencies. Supports automatic C => V translation. https://vlang.io
open_iot - ocpu
zig-window - window client library
linux - Linux kernel source tree
darkhttpd - When you need a web server in a hurry.
glibc - Unofficial mirror of sourceware glibc repository. Updated daily.
vscode-gitlens - Supercharge Git inside VS Code and unlock untapped knowledge within each repository — Visualize code authorship at a glance via Git blame annotations and CodeLens, seamlessly navigate and explore Git repositories, gain valuable insights via rich visualizations and powerful comparison commands, and so much more