Building rustc on Solaris

Hi, out of curiosity, I wanted to try to compile rust on Solaris today and quickly ran into a problem. When configured on a Solaris system, current rustc from repo attempts to downlod rustc (for stage0 compilation, I presume) from this location:

https://static.rust-lang.org/dist/2016-05-24/rustc-beta-x86_64-sun-solaris.tar.gz.sha256

which is a 404.

I wonder if there’s a way to bootstrap rustc on Solaris at all…

Building rustc requires a working rustc. Solaris is a tier 3 platform, so rust-lang.org doesn’t distribute binaries (see https://doc.rust-lang.org/book/getting-started.html). Therefore, you either need to cross-compile it or find an unofficial binary. (Not sure where to find unofficial binaries for Solaris in particular; maybe @nbaksalyar knows?)

You can pass “–enable-local-rust” to configure to prevent it from trying to download a binary from rust-lang.org, but obviously that only works if you already have rustc installed.

For now not all flavors of Solaris are tested/supported, but if you’re using SmartOS you can get rustc from pkgsrc: pkgin in rust or here. There’s a good chance that this build will work on other Illumos distributions, but it doesn’t work on Oracle Solaris. In that case you’d have to cross-compile a snapshot (e.g. from Linux).

Or you can just wait a little bit, as I’m currently porting Cargo and Rust 1.9. :slight_smile: This time an official snapshot will be added as well.

I'm indeed running Oracle Solaris, but I'll give it a try...

Oh, cool, which Solaris flavors are you targeting?

Actually I want to try making a distribution-independent snapshot. Newer versions of Illumos has diverged too much from the OpenSolaris version, but I guess it's worth trying to build rustc on OpenSolaris or some older version of Illumos that is compatible with Oracle's Solaris.

The plan B is to provide a separate snapshot for Oracle Solaris, so it will be supported in either case.

Cool. A distro-independent snapshot would be nice. I’m actually a Solaris developer, I guess I could lend a hand if needed, at least for testing.

EDIT: Your SmartOS snapshot does work on my Solaris box, provided I set the linker to gcc . Very nice, thanks! I’ll try to use it as a stage0 rustc.

@nbaksalyar You commented in thread.rs that Illumos has no way to set a thread name. Is that true? Solaris definitely has that.

Uh, nuts. Looks like we’re going to need to differentiate between Solaris and Illumos :-/

Yeah, it seems that they're mostly different OSes now, very much like FreeBSD & DragonflyBSD.

It would be nice to have a separate target/triplet like x86_64-sun-illumos, but I'm guessing that would require patching LLVM.

I'm not sure yet how to handle this & snapshots gracefully.

You can set the llvm-triple associated to a Rust target, just like all the other target options.

Hi guys,

How do I install rust on Solaris 11? Looks like rustup doesn’t support Solaris. Will I have to cross compile from some other platform? Please help.

@gurry

I think it depends on what version of rust you need. I haven’t attempted on Solaris 11 specifically but you could try using pkgsrc packages to install rust 1.14. The only challenge there being that it doesn’t give you cargo. https://pkgsrc.joyent.com/ . I started trying to build a bootstrap package for cargo to use for compiling a more recent rust on illumos but haven’t completed it yet.

Rust should now build natively on Solaris. A couple of us Oracle folks have pushed a number of fixes, so it should just work now, at least on nightly (well, beta now, I guess). I haven’t yet tried an unpatched 1.16, so I’m not sure about that. And there’s a fix to the fs2 crate that I still need to figure out the best solution, but if you get stuck on flock(), let me know and I’ll send you a patch.

Note that I haven’t yet tried Solaris 11, only S12, so there may be more fixes required, but I can’t think of any reason why it shouldn’t just work.

1 Like

@dhduvall thats awesome. I haven’t had much luck getting it to compile on illumos yet but perhaps I ought to try solaris 11.

Definitely no luck on getting it to compile without an existing bootstrap image. Rust 0.16.X beta requires a cargo binary, and compiling cargo also requires the cargo binary. Unless I’m missing something solaris/illumos users will still have to get a stage-0 bootstrap image from somewhere?

Well we have rustc and cargo on Solaris 12 (thanks to @dhduvall as well as others), I guess we should find a way to share that with S11 users. However, there’s still some bits and pieces not working 100% right, for example mio doesn’t compile on S12. I’ve been meaning to have a look at it but haven’t found the time yet.

1 Like

Thanks guys and awesome news @dhduvall :slight_smile: More power to you guys.Thanks for the hard work.

So here’s a dumb question :confused:. I’m still not quite sure how I can get rustc and stdlib to run on Solaris. Will I have to build it using the instructions on Rust Github repo? If yes, will following those instructions build stdlib as well along side rustc?

If someone that’s gotten patched rust compiled on solaris 12 has the bootstrap image they used for both cargo and rust and can share them for local compile that would be suuuuuuper dope.

I’m going to have to check with our legal department first, so this may still take some time, but I’ll see what I can make available.

1 Like

Thanks @eeyun. I completely missed seeing your post. Sorry about that. I’ll try the pkgsrc method as well :slight_smile:

1 Like

I tried to compile using instructions on the rust github repo and it failed with a 404. Same as the OP. Now I finally understand all this talk about bootstrap/stage0 binaries (sorry, I’m a bit new to this stuff). So, looks like no bootstrap binaries are available for Solaris11 :frowning:. Let’s wait for @dhduvall and see if can help us there.

@eeyun Based on the above, looks like the pkgsrc method won’t work either. Isn’t that so?