WIP: Generate Rust sysexits bindings without bindgen #129
Labels
No Label
bug
duplicate
enhancement
help wanted
invalid
joke
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: bonsai/harakit#129
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "sysxs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
rust-bindgen isn't packaged for OpenBSD/arm64, my operating system. I can't compile it, as even with 2GB RAM I always run out of memory.
We use bindgen to generate Rust bindings for a bunch of cpp(1)
#define
s. Rather than use a program that can't compile on a system with enough memory to hold one thousand copies of DOOM, this patch set simply uses awk(1p), a standard POSIX utility, to rewrite the#define key val
lines aspub const key: i32 = val;
and then compile those to an rlib. In practice this works quite well and should on any POSIX system, rather than only those systems that have been blessed with binary packages available for them. It also fixes the build for swab(1), which I used to test that this was working.While bindgen is a part of the Rust toolchain, this patch set is an elegant and portable replacement of the functionality that will save users from having to install yet another development package. On OpenBSD the only dependency of harakit that isn't included in base is rustc, which is obviously irreplaceable (except by another rustc).
This is much less robust and requires a user to know the awk programming language well enough to read it. I’m working on a way to cross-compile
bindgen(1)
to your system.Why is it less robust? I disagree - this only uses stable Rust features (the code it generates won't be obsoleted) and very elementary Awk features (the empty pattern, print command, and string catenation are often the first things a beginner learns of Awk) that are all also POSIX. If Awk flat-out is not allowed in Bonsai repositories, its functionality can also (awkwardly) be achieved with other POSIX utilities.
This shouldn't have been closed until discussion reached a conclusion.
@trinity and I have verbally discussed how opposed I am to this change and it has decided to create an alternate solution.
@trinity switched to OpenBSD
-current
which contains a packagedbindgen(1)
.I take issue with this. There are
rustc
flags which can be used to compile things using less jobs and less optimization, sacrificing some build time for less memory usage. Havingbindgen(1)
as a dependency makes sense for this project.I used all the rustc flags I could to pare down system resource usage to no avail. Moving to -current isn't really a big deal to me (
sysupgrade -s
did it automagically) but is a pain in the ass just to contribute to Harakit especially considering a 12 line patch could replace this multi-megabyte binary I now have on my system.Generate Rust sysexits bindings without bindgento WIP: Generate Rust sysexits bindings without bindgenI'm working on (and nearly done) a sysexits(1) utility that can be used to look up sysexits and print out valid sysexits source files for various languages. It's an even more stable replacement to an already stable solution and provides additional functionality to make system usage easier (e.g.
sysexits $?
can tell you with what sysexit the previous process exited).Note: on OpenBSD,
bindgen
andllvm
are required to build Harakit.For the record, I was able to compile bindgen and some other crates from source as dependencies on my i386 OpenBSD machine that has 1 gigabyte of RAM without issue.
Checkout
From your project repository, check out a new branch and test the changes.