forked from lix-project/lix
Artemis Tosini
19de2b137f
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
100 lines
2.5 KiB
TOML
100 lines
2.5 KiB
TOML
# This file is automatically @generated by Cargo.
|
|
# It is not intended for manual editing.
|
|
version = 3
|
|
|
|
[[package]]
|
|
name = "autocfg"
|
|
version = "1.1.0"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
|
|
|
[[package]]
|
|
name = "countme"
|
|
version = "3.0.1"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
|
|
|
|
[[package]]
|
|
name = "dissimilar"
|
|
version = "1.0.7"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "86e3bdc80eee6e16b2b6b0f87fbc98c04bee3455e35174c0de1a125d0688c632"
|
|
|
|
[[package]]
|
|
name = "expect-test"
|
|
version = "1.4.1"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "30d9eafeadd538e68fb28016364c9732d78e420b9ff8853fa5e4058861e9f8d3"
|
|
dependencies = [
|
|
"dissimilar",
|
|
"once_cell",
|
|
]
|
|
|
|
[[package]]
|
|
name = "hashbrown"
|
|
version = "0.14.5"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
|
|
|
[[package]]
|
|
name = "lix-doc"
|
|
version = "0.0.1"
|
|
dependencies = [
|
|
"expect-test",
|
|
"rnix",
|
|
"rowan",
|
|
]
|
|
|
|
[[package]]
|
|
name = "lixutil-rs"
|
|
version = "0.0.0"
|
|
|
|
[[package]]
|
|
name = "memoffset"
|
|
version = "0.9.1"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
|
dependencies = [
|
|
"autocfg",
|
|
]
|
|
|
|
[[package]]
|
|
name = "once_cell"
|
|
version = "1.19.0"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
|
|
|
[[package]]
|
|
name = "rnix"
|
|
version = "0.11.0"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "bb35cedbeb70e0ccabef2a31bcff0aebd114f19566086300b8f42c725fc2cb5f"
|
|
dependencies = [
|
|
"rowan",
|
|
]
|
|
|
|
[[package]]
|
|
name = "rowan"
|
|
version = "0.15.15"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49"
|
|
dependencies = [
|
|
"countme",
|
|
"hashbrown",
|
|
"memoffset",
|
|
"rustc-hash",
|
|
"text-size",
|
|
]
|
|
|
|
[[package]]
|
|
name = "rustc-hash"
|
|
version = "1.1.0"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
|
|
|
[[package]]
|
|
name = "text-size"
|
|
version = "1.1.1"
|
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
|