-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Illumos support #31078
Add Illumos support #31078
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
let mut base = super::sunos_base::opts(); | ||
base.pre_link_args.push("-m64".to_string()); | ||
base.pre_link_args.push("-lsocket".to_string()); | ||
base.pre_link_args.push("-lposix4".to_string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sorts of "default libraries" are typically linked where they're needed rather than by the compiler unconditionally. Do you know what symbols these are pulling in? I suspect they're only needed by the standard library so could the linkage directives go there instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these are mostly for socket functions and e.g. fork
.
Could you please point out to the correct place to move it in libstd
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing, they'll probably reside in rtdeps.rs
.
Out of curiosity, is sunos posix? Or would a "true port" of libstd contain an entirely different implementation of std::sys
basically (e.g. how Windows is entirely separate from Unix)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, completely missed it, thank you!
is sunos posix?
Yes, absolutely. I believe historically it's derived from the Unix SVR4 codebase, and mostly compatible with BSD-like OSes. And, as I understand it, at least Illumos (the open source Solaris fork) strives to be maximally compatible with other *nixes, and it includes e.g. GCC toolkit by default instead of some proprietary compilers. Actually, I'm not even sure that this port would work on the original Sun/Oracle Solaris - there are much more diversions from standards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok cool, sounds good to me!
Quite exciting, thanks @nbaksalyar! |
Thanks for the review, Alex! :) |
@@ -1,5 +1,13 @@ | |||
#!/bin/sh | |||
|
|||
# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ksh -> bash
lgtm r? @alexcrichton |
self // log2(Inf) = Inf | ||
} else { | ||
NAN // log2(-Inf) = NaN | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry I was just indicating that the macro could probably be removed in favor of generic functions and/or otherwise non-meta-programming pieces. Could the duplication between the functions here be reduced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, got it - I think it should be possible to just pass a reference to a corresponding intrinsic function. Will give it a try in a moment.
EDIT: Actually, it turns out I totally missed your comment on this regard - sorry, will fix it. Thanks! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It hasn't worked with a generic signature fn foo<F: Fn(f64) -> f64>(val: f64, f: F) -> f64
, because the intrinsic functions are unsafe & extern - they don't implement the Fn trait. However, it worked this way: fn foo(self, log_fn: unsafe extern "rust-intrinsic" fn(f64) -> f64) -> f64
- i.e., with a completely defined type in a function reference.
Would this work as a solution, or should I find a better way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you may want to all it like:
foo(val, |f| unsafe { intrinsics::doit(f) })
(or something like that). I think there are other bugs for taking intrinsics by-value unfortunately
☔ The latest upstream changes (presumably #31120) made this pull request unmergeable. Please resolve the merge conflicts. |
Ok cool, I think this is getting pretty close to being good-to-go. I've got a few final questions about this:
|
@alexcrichton I might be able to add a little explanation to your questions:
The So, it's essentially specifying that it can run on a "Solaris 11" compatible system. The same binary built for a current illumos system in many cases will run just fine on an Oracle Solaris 11 system without an issue.
I don't know about anywhere that it's an official standard, but based on Google search results alone (which I'm sure can always be trusted as a metric 😉):
The difference in terms of "solaris" and "sunos" might be more useful in the future, but are really no different than "darwin" and "macos" or "mingw32" and "windows". The benefit is that if there is ever a future target triple for something like However, beyond that I don't know if there is any explicit reason to use "sunos" over "solaris" for the |
@potatosalad has already answered them all, but I would add my 2c:
Other than Google results, that's the standard build target for GCC on Illumos (only with addition of version 2.11). E.g. compiler tools are called like
@potatosalad is correct, it's more like "darwin". Solaris and Illumos self-identify with Technically, I think But any would work here, so let me know if you want me to change it to some better name. Hopefully that explains it a bit. |
Thanks for the info! That's certainly quite enlightenting. Would it be possible to not pass down 2.11 to LLVM then? I don't think we do this for other platforms, and then LLVM would pick the "default level" I guess in theory. Or is solaris different where the OS version has major changes in ABI for things like thread locals each revision? Also after some discussion with @brson, we think that the |
Sure! I will make required changes and resolve the merge conflict then. |
☔ The latest upstream changes (presumably #31298) made this pull request unmergeable. Please resolve the merge conflicts. |
I've rebased the commits - should be ready to go! |
@@ -25,6 +24,10 @@ use sys::platform::raw; | |||
use sys::{cvt, cvt_r}; | |||
use sys_common::{AsInner, FromInner}; | |||
use vec::Vec; | |||
#[cfg(target_os = "solaris")] | |||
use core_collections::borrow::ToOwned; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can remove the #[cfg]
and the one below by just adding use prelude::v1::*
to the top of this file (these are both in the prelude), and then you don't need the #[cfg]
as well I believe.
Looks good to me, thanks @nbaksalyar! I had just one tiny nit but it's not very relevant, so I'm gonna send this to bors: |
This pull request adds support for [Illumos](http://illumos.org/)-based operating systems: SmartOS, OpenIndiana, and others. For now it's x86-64 only, as I'm not sure if 32-bit installations are widespread. This PR is based on #28589 by @potatosalad, and also closes #21000, #25845, and #25846. Required changes in libc are already merged: rust-lang/libc#138 Here's a snapshot required to build a stage0 compiler: https://s3-eu-west-1.amazonaws.com/nbaksalyar/rustc-sunos-snapshot.tar.gz It passes all checks from `make check`. There are some changes I'm not quite sure about, e.g. macro usage in `src/libstd/num/f64.rs` and `DirEntry` structure in `src/libstd/sys/unix/fs.rs`, so any comments on how to rewrite it better would be greatly appreciated. Also, LLVM configure script might need to be patched to build it successfully, or a pre-built libLLVM should be used. Some details can be found here: https://llvm.org/bugs/show_bug.cgi?id=25409 Thanks! r? @brson
💔 Test failed - auto-mac-ios-opt |
The issue should be fixed by now. Sorry it took so long - it turned out that I was building the bootstrap compiler from an incorrect base (the issue is described in #31142). So actually to run I've yet to make the new stage0 work correctly (it fails with SIGILL for now, for some reason). I guess the reason is that the codebase with the latest commits, on which I based my work, has diverged substantially. I'll try to find & fix the reason, but actually it might be better to wait for a snapshot update before rebuilding the bootstrapping compiler and adding it to the list of snapshots. Other than that, it should work correctly, as the only major change from my previous snapshot is renaming "sunos" to "solaris" (and that's why it wouldn't work). |
This pull request adds support for [Illumos](http://illumos.org/)-based operating systems: SmartOS, OpenIndiana, and others. For now it's x86-64 only, as I'm not sure if 32-bit installations are widespread. This PR is based on #28589 by @potatosalad, and also closes #21000, #25845, and #25846. Required changes in libc are already merged: rust-lang/libc#138 Here's a snapshot required to build a stage0 compiler: https://s3-eu-west-1.amazonaws.com/nbaksalyar/rustc-sunos-snapshot.tar.gz It passes all checks from `make check`. There are some changes I'm not quite sure about, e.g. macro usage in `src/libstd/num/f64.rs` and `DirEntry` structure in `src/libstd/sys/unix/fs.rs`, so any comments on how to rewrite it better would be greatly appreciated. Also, LLVM configure script might need to be patched to build it successfully, or a pre-built libLLVM should be used. Some details can be found here: https://llvm.org/bugs/show_bug.cgi?id=25409 Thanks! r? @brson
Awesome! @alexcrichton, @potatosalad, and everyone - thanks for your help! :) |
@nbaksalyar have you successfully bootstrapped rustc on illumos yet? |
@dhuseby |
@nbaksalyar any update on the WIP branch? |
@dhuseby |
@nbaksalyar oh I should also mention that we've recently got cross-compiled nightlies from Linux to FreeBSD/NetBSD up and running, so we have nightly builds of rustc and the standard library for FreeBSD and NetBSD. If there's a cross compiler from Linux to Illumos then I'd be game to set one up as well for Illumos! |
@alexcrichton |
FWIW we've been shipping rust/cargo packages in SmartOS for a while now, currently 1.22.1 but 1.23 should be ready soon. Our binaries should work on any illumos platform built after 20141030. |
not since 2.11, but a big chunk of userspace is still 32-bit (GNU CC always builds a 32-bit multilib-enabled compiler, for instance) @nbaksalyar: do you still have the target spec JSON files originally used to bootstrap this port? Looking into an |
This pull request adds support for Illumos-based operating systems: SmartOS, OpenIndiana, and others. For now it's x86-64 only, as I'm not sure if 32-bit installations are widespread. This PR is based on #28589 by @potatosalad, and also closes #21000, #25845, and #25846.
Required changes in libc are already merged: rust-lang/libc#138
Here's a snapshot required to build a stage0 compiler:
https://s3-eu-west-1.amazonaws.com/nbaksalyar/rustc-sunos-snapshot.tar.gz
It passes all checks from
make check
.There are some changes I'm not quite sure about, e.g. macro usage in
src/libstd/num/f64.rs
andDirEntry
structure insrc/libstd/sys/unix/fs.rs
, so any comments on how to rewrite it better would be greatly appreciated.Also, LLVM configure script might need to be patched to build it successfully, or a pre-built libLLVM should be used. Some details can be found here: https://llvm.org/bugs/show_bug.cgi?id=25409
Thanks!
r? @brson