A modern, delicious implementation of the Nix package manager, focused on correctness, usability, and growth — and committed to doing right by its community
Find a file
Artemis Tosini 19de2b137f libutil: Add support for Rust
Add basic support for building and linking Rust into libutil.
This also includes a basic test to show that the linking is successful.
This test should be removed once a more practical use for the Rust has
been found, as testing those would necessarily require linking to work.

--- 👻 jade haunting section 👻 ---

This uses a very cursed approach to ensure that static builds do not
invoke undefined behaviour caused by linking libstd and friends multiple
times. That is, for static targets, we just statically link the whole
thing into the executable, and for dynamic targets we dynamically link
all the Rust stuff.

Reference re this being ostensibly illegal: https://github.com/rust-lang/rust/issues/44322

Even if it does not cause linker errors, it is not a *good idea* to link
a Rust staticlib containing libstd into multiple C++ dylibs to be loaded
into the same executable, since it is highly unclear whether libstd
globals would be correctly shared (and stuff like -Bdynamic ever getting
into link args can absolutely murder you by changing *intra-dylib*
references to not indirect through the PLT (and thus ignore any other
loaded dylib containing the symbol) underneath your nose).

This means that a solution of liblixutil_rs, liblixcmd_rs, etc, that are
statically linked into liblixutil, liblixcmd, etc *is not safe*.

Effectively `libstd` *must* be in its own dylib in an environment
containing dynamic linking of multiple bits of Rust code.

The reason that we shouldn't just jam all the Rust in one staticlib for
shared targets as well (though I::jade can still be convinced we
*should* do it for those), is that we would have to build a
liblixrust.so that depends on *every* other Lix library, **and** every
other Lix library depends on it, exploding our dylib hierarchy
completely to uselessness.

Building a libfirefoxrust.a and then linking it in *is* what Firefox
does, but it does not work for us since our system is not one big
library/etc. It would probably have perf benefits, but so would getting
rid of dynamic linking completely.

Meson bugs encountered (for github xref to find):
Meson does not set the soname for us: https://github.com/mesonbuild/meson/issues/13537
Meson ignores link_args for Rust targets: https://github.com/mesonbuild/meson/issues/13538

Co-authored-by: Qyriad <qyriad@qyriad.me>
Co-authored-by: Jade Lovelace <lix@jade.fyi>

Change-Id: Ide390b1d2635fd0a80f12f1de992003b9dc7dfce
2024-08-20 23:39:27 -07:00
.github .github: clean up stale things and wrong references 2024-06-12 15:34:23 -07:00
bench Add benchmarking scripts 2024-04-08 19:50:24 -07:00
contrib function-trace: always show the trace 2019-09-18 23:23:21 +02:00
doc doc: fix broken meson deps for various manuals outputs 2024-08-18 15:19:15 -07:00
maintainers rl-next: fix incorrect CL list syntax 2024-08-09 19:03:08 -07:00
meson build: build lix-doc with Meson! 🎉 2024-08-20 17:21:13 +00:00
misc build: remove expect as a dependency 2024-08-10 16:10:16 -07:00
nix-support De-vendor nixfmt 2024-07-22 21:09:58 +04:00
perl Merge changes Ib7c80826,I636f8a71,I67669b98 into main 2024-08-09 19:24:29 +00:00
releng releng: fix the git push 2024-08-07 21:46:44 -07:00
scripts remove the autoconf+Make buildsystem 2024-05-07 17:04:30 -06:00
src libutil: Add support for Rust 2024-08-20 23:39:27 -07:00
subprojects build: build lix-doc with Meson! 🎉 2024-08-20 17:21:13 +00:00
tests libutil: Add support for Rust 2024-08-20 23:39:27 -07:00
.clang-format Add pre-commit checks 2024-03-29 22:57:40 -07:00
.clang-tidy clang-tidy: write a lint for charptr_cast 2024-08-08 14:53:17 -07:00
.dir-locals.el .dir-locals.el: Set c-block-comment-prefix 2020-07-10 11:21:06 +02:00
.editorconfig add editorconfig for markdown 2024-05-24 02:22:44 +00:00
.envrc .envrc: remove MAKEFLAGS and use clang environment by default 2024-06-25 12:36:18 -06:00
.gitignore build: move to a Cargo workspace 2024-08-20 23:36:19 -07:00
.this-is-lix devShell: guard against running from another directory 2024-06-24 13:41:38 -07:00
Cargo.lock libutil: Add support for Rust 2024-08-20 23:39:27 -07:00
Cargo.toml libutil: Add support for Rust 2024-08-20 23:39:27 -07:00
CONTRIBUTING.md chore: re-work the contribution guide 2024-05-07 01:28:35 +00:00
COPYING Add pre-commit checks 2024-03-29 22:57:40 -07:00
default.nix Format Nix code with nixfmt 2024-04-08 13:00:00 -07:00
docker.nix releng: support multiarch docker images 2024-06-09 20:33:24 -07:00
flake.lock update flake.lock 2024-07-26 11:22:34 +04:00
flake.nix build: integrate clang-tidy into CI 2024-08-08 14:53:17 -07:00
justfile build: implement clang-tidy using our plugin 2024-08-04 20:41:19 -07:00
meson.build libutil: Add support for Rust 2024-08-20 23:39:27 -07:00
meson.options build: implement clang-tidy using our plugin 2024-08-04 20:41:19 -07:00
package.nix libutil: Add support for Rust 2024-08-20 23:39:27 -07:00
README.md README: clarify license to match documentation 2024-08-10 16:11:58 -07:00
shell.nix shell.nix: conform to documentation 2024-05-27 16:47:40 +02:00
treefmt.toml Format Nix code with nixfmt 2024-04-08 13:00:00 -07:00
version.json Update version to 2.92 2024-08-12 18:06:08 -07:00

Lix

Lix is an implementation of Nix, a powerful package management system for Linux and other Unix systems that makes package management reliable and reproducible.

Read more about us at https://lix.systems.

Installation

On Linux and macOS the easiest way to install Lix is to run the following shell command (as a user other than root):

$ curl -sSf -L https://install.lix.systems/lix | sh -s -- install

For systems that already have a Nix implementation installed, such as NixOS systems, read our install page

Building And Developing

See our Hacking guide in our manual for instruction on how to to set up a development environment and build Lix from source.

Additional Resources

License

Lix is released under LGPL-2.1-or-later.