I love the idea of Rust cross-compiling to arbitrary glibc versions as easily as Zig does. Seems like parsing Zig's abilists is one part of that goal. Are you working on the complete picture? Is anyone?
My understanding (which could be way off) is that in general terms, Zig uses these abilists to represent the ABI (exported symbols, some with versioning/weak definition or something) of all versions of glibc. You can select one and the linker essentially assumes the existence of a matching .so
somehow.
So how can this work for Rust out of the box? My thoughts below but perhaps yours are more fleshed out...
Short-term: maybe a linker script that can be dropped in via target.<triple>.linker
(see docs) and actually constructs a dummy .so
file (a .so
with the correct definitions and non-functioning implementations) and somehow sets up linker arguments to assume it's installed in the system search path (i.e., not adding an rpath entry to a tempdir or some such).
Long-term: it'd be nice if you could just add glibc-version
to a [target.<arch>-unknown-linux-gnu]
section of your .cargo/config.toml
and cargo
plumbed along the option to rustc
, which took care of the rest for you. Maybe it does what that linker script does, or maybe the linker does/should provide some more abstract interface than an existing .so
file.