[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rust support

From: David Michael
Subject: Rust support
Date: Mon, 25 Dec 2017 23:19:29 -0500


I've been poking at cross-compiling Rust projects for Hurd on and off
for a couple of weeks, and I thought I'd upload what I have now for
comments.  A new snapshot of my silly Hurd distro is available at
https://github.com/dm0-/gnuxc updated with the Rust reimplementation
of librsvg, so there is an example user of this.

The distro commit contains a patch[1] against the current Rust release
(1.22.1) which can be used to build std libraries for Hurd with your
Linux-based system's existing rustc.  I've also pushed the patch
against master[2].  See the RPM spec file[3] for the commands to build
the std libraries and a target spec JSON file.

Since Rust doesn't have a default path, the environment variable
RUST_TARGET_PATH must be set to the directory containing the JSON spec
file.  With that and the rlib files installed to
/usr/lib/rustlib/i686-pc-gnu/lib, Rust projects can be built for Hurd
with "cargo --target=i686-pc-gnu build".  The command "rustc
--codegen=ar=i686-pc-gnu-gcc-ar --codegen=linker=i686-pc-gnu-gcc
--target=i686-pc-gnu" will directly compile Rust files without cargo.

Note that projects will likely depend on libc, which will need to be
patched with the same changes used to build std.  The librsvg
package[4] has an example of how to do this with vendored crates, but
other projects may require you to set up a local registry and patch it

The current implementation reuses the Linux code with some additional
conditional blocks, but I think it may be better to start a new OS
port for Hurd.  Otherwise, it may turn into whack-a-mole, tweaking
constants when new packages encounter bugs, or adding more conditions
as the Linux implementation is developed.  I'll continue to work on
this (at an as yet undetermined pace) to hopefully make it
upstreamable, but any help or feedback from the Hurd side would be
appreciated to prevent me from doing something dumb.  In case anyone
else does want to work on this before I get to it, I'd suggest
prioritizing porting the libc crate--the sooner it has a release with
Hurd support, the sooner every other project depending on a specific
libc version will be able to update to build out of the box.



[2] https://github.com/dm0-/rust/commits/hurd
[3] https://github.com/dm0-/gnuxc/blob/master/specs/gnuxc-rust.spec#L39
[4] https://github.com/dm0-/gnuxc/blob/master/make.pkg.d/librsvg.mk#L8

reply via email to

[Prev in Thread] Current Thread [Next in Thread]