Packaging Rust for Fedora
The initial spark for the discussion was this
Fedora 38 change proposal driven by Panu Matilainen. The RPM
package manager has long carried its own internal OpenPGP parser for the
management of keys and signatures for packages. This parser seemingly
pleases nobody; the proposal describes it as "rather infamous
for its limitations and flaws
" and puts forward a plan to replace it with
the Sequoia library, which is
written in Rust (and which was covered here
in 2020). The use of Rust provides the sort of safety net that is
welcome in security-relevant code like this, but it can also be a red flag
for developers who worry about how Rust fits into the distribution as a
whole.
Inevitably, there were complaints about this proposal. Kevin Kofler, for
example, asked
why a library written in C had not been chosen. According
to Matilainen, efforts to find such a library have been underway for
years without success. The most obvious alternative, GPGME, is unsuitable
because it is built around communicating with an external GPG process,
"which is a setup you do NOT want in the rpm context where chroots come
and go etc.
". Neal Gompa agreed
that the GPGME model creates pain in this context, and seemed to agree that
there was no better alternative than Sequoia despite his own disagreements
with the Rust
community. "So here we are, in a subpar situation created by bad tools because
nobody cares enough about security anyway
".
Kofler went on to outline his problems with the Rust language. One of those was simply that it's yet another language to deal with, a complaint that didn't draw a lot of sympathy on the list. His other objection, though, struck closer to home:
The worst issue I see with Rust is the way libraries are "packaged", which just implies installing source code and recompiling that source code for every single application. (And as a result, the output obviously gets statically linked into the application, with all the drawbacks of static linking.) I consider a language with no usable shared library support to be entirely unpackageable and hence entirely useless.
Fabio Valentini, who works on packaging Rust crates for Fedora, pointed out that Sequoia is implemented as a shared library with a C ABI, so there will be no need to statically link any Rust code into RPM. He asked Kofler for any constructive suggestions he might have for improving the situation; that request was not addressed in Kofler's response. Fedora project leader Matthew Miller did have some thoughts, though.
Specifically, he agreed with Kofler that Rust applications may, in the end,
just be "unpackagable
". He mentioned his efforts with the Bevy game engine; he found that invoking the
Cargo build system to obtain Bevy's build dependencies will fetch no less
than 390
separate crates, about half of which are not currently packaged for Fedora.
Trying to package such an application is sure to be painful but, he said,
"this is what open source winning looks like
". Cargo makes it easy
to share and reuse software components, which is a great benefit, but it
makes packaging all of those dependencies independently much harder. The
fact that many of those dependencies are on specific versions of the
crates involved makes the task harder yet.
All of this has led him to question the value of the work that is going
into packaging Rust crates for Fedora. Instead, he said, Rust could be an
opportunity to explore different approaches. "Something lightweight
where we cache crates and use them _directly_ in the build process for
_application_ RPMs
". The implication was clearly that, by not trying
to package all of the dependencies or ship dynamically linked executables,
Fedora could work more directly with the Cargo ecosystem, save a lot of
work that is (to him) of dubious value, and more easily get applications
out to users. Fedora, he concluded, needs to adapt to remain relevant in
the current development environment.
Few readers are likely to be surprised by the news that Valentini disagreed with this point of view. Bevy, he said, is a bit of a special case; most Rust applications are relatively easy to package for Fedora because the most popular crates are already packaged. Cargo and RPM, he added, work in similar ways, making the packaging job easier; in many cases, the RPM spec file can be generated automatically from the Cargo metadata. Meanwhile, the packaging effort brings all of the usual benefits, including cross-architecture testing, code and licensing review, and upstream contributions to make packaging easier in the future.
Trying to change the packaging process for Rust applications will, he said,
make things worse instead. That is what happened with both Node.js and
Java, he said (some of the Java discussions were covered here in June). Overall, he concluded,
the situation with Rust is relatively good, and trying to do something
other than "plain RPM packages
" is likely to create more problems
than it solves.
Kofler, instead, decried the ease
with which Rust allows the addition of dependencies, calling the result
"dependency hell
". Rather than Fedora adapting to Rust, he said,
Rust is going to have to adapt to
become more relevant to Linux distributions. Gompa was
not optimistic about that happening, though, saying that his efforts in
that direction had met significant resistance in the past.
The conversation wound down at that point without any definitive conclusions. There is one relevant point that wasn't addressed that is worth considering, and which is highlighted by the use of Sequoia in RPM. Language-specific environments can work nicely as long as the developer sticks with the language in question; they can fall down when faced with the need to combine code written in multiple languages. At that point, the distribution model, which tries to make all packages work well together, shows its value. Given that the Rewrite The World In Rust Project is destined to take years to reach its conclusion, it seems likely that the number of mixed-language applications will increase for some time, and distributors will need to be able to package and ship those applications.
For the time being, the packaging of Rust crates for Fedora
seems likely to continue without significant changes. But the topic of the
intersection between distribution and language-specific package managers
seems destined to reappear regularly for the indefinite future. Finding a
way to make these independent ecosystems interact more smoothly will not be
easy, but it would be beneficial to all involved; it is a problem worth
working on.
