Skip to content

Commit b77aefb

Browse files
pfmooneyjasonbkingjclulow
committed
Add illumos triple
Co-Authored-By: Jason King <[email protected]> Co-Authored-By: Joshua M. Clulow <[email protected]>
1 parent edc0258 commit b77aefb

File tree

27 files changed

+362
-22
lines changed

27 files changed

+362
-22
lines changed

Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1786,9 +1786,9 @@ checksum = "b294d6fa9ee409a054354afc4352b0b9ef7ca222c69b8812cbea9e7d2bf3783f"
17861786

17871787
[[package]]
17881788
name = "libc"
1789-
version = "0.2.66"
1789+
version = "0.2.69"
17901790
source = "registry+https://github.com/rust-lang/crates.io-index"
1791-
checksum = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
1791+
checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005"
17921792
dependencies = [
17931793
"rustc-std-workspace-core",
17941794
]
@@ -4661,9 +4661,9 @@ checksum = "4ecf3b85f68e8abaa7555aa5abdb1153079387e60b718283d732f03897fcfc86"
46614661

46624662
[[package]]
46634663
name = "socket2"
4664-
version = "0.3.11"
4664+
version = "0.3.12"
46654665
source = "registry+https://github.com/rust-lang/crates.io-index"
4666-
checksum = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85"
4666+
checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918"
46674667
dependencies = [
46684668
"cfg-if",
46694669
"libc",

src/librustc_codegen_ssa/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cc = "1.0.1"
1515
num_cpus = "1.0"
1616
memmap = "0.7"
1717
log = "0.4.5"
18-
libc = "0.2.44"
18+
libc = "0.2.50"
1919
jobserver = "0.1.11"
2020
tempfile = "3.1"
2121

src/librustc_codegen_ssa/back/link.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
759759
}
760760
}
761761
LinkerFlavor::Gcc => {
762-
if cfg!(target_os = "solaris") {
762+
if cfg!(any(target_os = "solaris", target_os = "illumos")) {
763763
// On historical Solaris systems, "cc" may have
764764
// been Sun Studio, which is not flag-compatible
765765
// with "gcc". This history casts a long shadow,
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions};
2+
use std::default::Default;
3+
4+
pub fn opts() -> TargetOptions {
5+
let mut late_link_args = LinkArgs::new();
6+
late_link_args.insert(
7+
LinkerFlavor::Gcc,
8+
vec![
9+
// LLVM will insert calls to the stack protector functions
10+
// "__stack_chk_fail" and "__stack_chk_guard" into code in native
11+
// object files. Some platforms include these symbols directly in
12+
// libc, but at least historically these have been provided in
13+
// libssp.so on illumos and Solaris systems.
14+
"-lssp".to_string(),
15+
],
16+
);
17+
18+
TargetOptions {
19+
dynamic_linking: true,
20+
executables: true,
21+
has_rpath: true,
22+
target_family: Some("unix".to_string()),
23+
is_like_solaris: true,
24+
limit_rdylib_exports: false, // Linker doesn't support this
25+
eliminate_frame_pointer: false,
26+
late_link_args,
27+
28+
// While we support ELF TLS, rust requires a way to register
29+
// cleanup handlers (in C, this would be something along the lines of:
30+
// void register_callback(void (*fn)(void *), void *arg);
31+
// (see src/libstd/sys/unix/fast_thread_local.rs) that is currently
32+
// missing in illumos. For now at least, we must fallback to using
33+
// pthread_{get,set}specific.
34+
//has_elf_tls: true,
35+
36+
// FIXME: Currently, rust is invoking cc to link, which ends up
37+
// causing these to get included twice. We should eventually transition
38+
// to having rustc invoke ld directly, in which case these will need to
39+
// be uncommented.
40+
//
41+
// We want XPG6 behavior from libc and libm. See standards(5)
42+
//pre_link_objects_exe: vec![
43+
// "/usr/lib/amd64/values-Xc.o".to_string(),
44+
// "/usr/lib/amd64/values-xpg6.o".to_string(),
45+
//],
46+
..Default::default()
47+
}
48+
}

src/librustc_target/spec/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ mod fuchsia_base;
5656
mod haiku_base;
5757
mod hermit_base;
5858
mod hermit_kernel_base;
59+
mod illumos_base;
5960
mod l4re_base;
6061
mod linux_base;
6162
mod linux_kernel_base;
@@ -447,6 +448,8 @@ supported_targets! {
447448
("x86_64-sun-solaris", "x86_64-pc-solaris", x86_64_sun_solaris),
448449
("sparcv9-sun-solaris", sparcv9_sun_solaris),
449450

451+
("x86_64-unknown-illumos", x86_64_unknown_illumos),
452+
450453
("x86_64-pc-windows-gnu", x86_64_pc_windows_gnu),
451454
("i686-pc-windows-gnu", i686_pc_windows_gnu),
452455
("i686-uwp-windows-gnu", i686_uwp_windows_gnu),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{LinkerFlavor, Target, TargetResult};
2+
3+
pub fn target() -> TargetResult {
4+
let mut base = super::illumos_base::opts();
5+
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-m64".to_string(), "-std=c99".to_string()]);
6+
base.cpu = "x86-64".to_string();
7+
base.max_atomic_width = Some(64);
8+
9+
Ok(Target {
10+
// LLVM does not currently have a separate illumos target,
11+
// so we still pass Solaris to it
12+
llvm_target: "x86_64-pc-solaris".to_string(),
13+
target_endian: "little".to_string(),
14+
target_pointer_width: "64".to_string(),
15+
target_c_int_width: "32".to_string(),
16+
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
17+
arch: "x86_64".to_string(),
18+
target_os: "illumos".to_string(),
19+
target_env: String::new(),
20+
target_vendor: "unknown".to_string(),
21+
linker_flavor: LinkerFlavor::Gcc,
22+
options: base,
23+
})
24+
}

src/librustdoc/clean/cfg.rs

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ impl<'a> fmt::Display for Html<'a> {
360360
"fuchsia" => "Fuchsia",
361361
"haiku" => "Haiku",
362362
"hermit" => "HermitCore",
363+
"illumos" => "illumos",
363364
"ios" => "iOS",
364365
"l4re" => "L4Re",
365366
"linux" => "Linux",

src/libstd/build.rs

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ fn main() {
2525
println!("cargo:rustc-link-lib=posix4");
2626
println!("cargo:rustc-link-lib=pthread");
2727
println!("cargo:rustc-link-lib=resolv");
28+
} else if target.contains("illumos") {
29+
println!("cargo:rustc-link-lib=socket");
30+
println!("cargo:rustc-link-lib=posix4");
31+
println!("cargo:rustc-link-lib=pthread");
32+
println!("cargo:rustc-link-lib=resolv");
33+
println!("cargo:rustc-link-lib=nsl");
34+
// Use libumem for the (malloc-compatible) allocator
35+
println!("cargo:rustc-link-lib=umem");
2836
} else if target.contains("apple-darwin") {
2937
println!("cargo:rustc-link-lib=System");
3038

src/libstd/f64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ impl f64 {
919919
// because of their non-standard behavior (e.g., log(-n) returns -Inf instead
920920
// of expected NaN).
921921
fn log_wrapper<F: Fn(f64) -> f64>(self, log_fn: F) -> f64 {
922-
if !cfg!(target_os = "solaris") {
922+
if !cfg!(any(target_os = "solaris", target_os = "illumos")) {
923923
log_fn(self)
924924
} else {
925925
if self.is_finite() {

src/libstd/os/illumos/fs.rs

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
#![stable(feature = "metadata_ext", since = "1.1.0")]
2+
3+
use libc;
4+
5+
use crate::fs::Metadata;
6+
use crate::sys_common::AsInner;
7+
8+
#[allow(deprecated)]
9+
use crate::os::illumos::raw;
10+
11+
/// OS-specific extensions to [`fs::Metadata`].
12+
///
13+
/// [`fs::Metadata`]: ../../../../std/fs/struct.Metadata.html
14+
#[stable(feature = "metadata_ext", since = "1.1.0")]
15+
pub trait MetadataExt {
16+
/// Gain a reference to the underlying `stat` structure which contains
17+
/// the raw information returned by the OS.
18+
///
19+
/// The contents of the returned `stat` are **not** consistent across
20+
/// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
21+
/// cross-Unix abstractions contained within the raw stat.
22+
#[stable(feature = "metadata_ext", since = "1.1.0")]
23+
#[rustc_deprecated(
24+
since = "1.8.0",
25+
reason = "deprecated in favor of the accessor methods of this trait"
26+
)]
27+
#[allow(deprecated)]
28+
fn as_raw_stat(&self) -> &raw::stat;
29+
30+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
31+
fn st_dev(&self) -> u64;
32+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
33+
fn st_ino(&self) -> u64;
34+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
35+
fn st_mode(&self) -> u32;
36+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
37+
fn st_nlink(&self) -> u64;
38+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
39+
fn st_uid(&self) -> u32;
40+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
41+
fn st_gid(&self) -> u32;
42+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
43+
fn st_rdev(&self) -> u64;
44+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
45+
fn st_size(&self) -> u64;
46+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
47+
fn st_atime(&self) -> i64;
48+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
49+
fn st_atime_nsec(&self) -> i64;
50+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
51+
fn st_mtime(&self) -> i64;
52+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
53+
fn st_mtime_nsec(&self) -> i64;
54+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
55+
fn st_ctime(&self) -> i64;
56+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
57+
fn st_ctime_nsec(&self) -> i64;
58+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
59+
fn st_blksize(&self) -> u64;
60+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
61+
fn st_blocks(&self) -> u64;
62+
}
63+
64+
#[stable(feature = "metadata_ext", since = "1.1.0")]
65+
impl MetadataExt for Metadata {
66+
#[allow(deprecated)]
67+
fn as_raw_stat(&self) -> &raw::stat {
68+
unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) }
69+
}
70+
fn st_dev(&self) -> u64 {
71+
self.as_inner().as_inner().st_dev as u64
72+
}
73+
fn st_ino(&self) -> u64 {
74+
self.as_inner().as_inner().st_ino as u64
75+
}
76+
fn st_mode(&self) -> u32 {
77+
self.as_inner().as_inner().st_mode as u32
78+
}
79+
fn st_nlink(&self) -> u64 {
80+
self.as_inner().as_inner().st_nlink as u64
81+
}
82+
fn st_uid(&self) -> u32 {
83+
self.as_inner().as_inner().st_uid as u32
84+
}
85+
fn st_gid(&self) -> u32 {
86+
self.as_inner().as_inner().st_gid as u32
87+
}
88+
fn st_rdev(&self) -> u64 {
89+
self.as_inner().as_inner().st_rdev as u64
90+
}
91+
fn st_size(&self) -> u64 {
92+
self.as_inner().as_inner().st_size as u64
93+
}
94+
fn st_atime(&self) -> i64 {
95+
self.as_inner().as_inner().st_atime as i64
96+
}
97+
fn st_atime_nsec(&self) -> i64 {
98+
self.as_inner().as_inner().st_atime_nsec as i64
99+
}
100+
fn st_mtime(&self) -> i64 {
101+
self.as_inner().as_inner().st_mtime as i64
102+
}
103+
fn st_mtime_nsec(&self) -> i64 {
104+
self.as_inner().as_inner().st_mtime_nsec as i64
105+
}
106+
fn st_ctime(&self) -> i64 {
107+
self.as_inner().as_inner().st_ctime as i64
108+
}
109+
fn st_ctime_nsec(&self) -> i64 {
110+
self.as_inner().as_inner().st_ctime_nsec as i64
111+
}
112+
fn st_blksize(&self) -> u64 {
113+
self.as_inner().as_inner().st_blksize as u64
114+
}
115+
fn st_blocks(&self) -> u64 {
116+
self.as_inner().as_inner().st_blocks as u64
117+
}
118+
}

src/libstd/os/illumos/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! illumos-specific definitions
2+
3+
#![stable(feature = "raw_ext", since = "1.1.0")]
4+
5+
pub mod fs;
6+
pub mod raw;

src/libstd/os/illumos/raw.rs

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//! illumos-specific raw type definitions
2+
3+
#![stable(feature = "raw_ext", since = "1.1.0")]
4+
#![rustc_deprecated(
5+
since = "1.8.0",
6+
reason = "these type aliases are no longer supported by the standard library, the `libc` \
7+
crate on crates.io should be used instead for the correct definitions"
8+
)]
9+
#![allow(deprecated)]
10+
11+
use crate::os::raw::c_long;
12+
use crate::os::unix::raw::{gid_t, uid_t};
13+
14+
#[stable(feature = "raw_ext", since = "1.1.0")]
15+
pub type blkcnt_t = u64;
16+
#[stable(feature = "raw_ext", since = "1.1.0")]
17+
pub type blksize_t = u64;
18+
#[stable(feature = "raw_ext", since = "1.1.0")]
19+
pub type dev_t = u64;
20+
#[stable(feature = "raw_ext", since = "1.1.0")]
21+
pub type fflags_t = u32;
22+
#[stable(feature = "raw_ext", since = "1.1.0")]
23+
pub type ino_t = u64;
24+
#[stable(feature = "raw_ext", since = "1.1.0")]
25+
pub type mode_t = u32;
26+
#[stable(feature = "raw_ext", since = "1.1.0")]
27+
pub type nlink_t = u64;
28+
#[stable(feature = "raw_ext", since = "1.1.0")]
29+
pub type off_t = u64;
30+
#[stable(feature = "raw_ext", since = "1.1.0")]
31+
pub type time_t = i64;
32+
33+
#[stable(feature = "pthread_t", since = "1.8.0")]
34+
pub type pthread_t = u32;
35+
36+
#[repr(C)]
37+
#[derive(Clone)]
38+
#[stable(feature = "raw_ext", since = "1.1.0")]
39+
pub struct stat {
40+
#[stable(feature = "raw_ext", since = "1.1.0")]
41+
pub st_dev: dev_t,
42+
#[stable(feature = "raw_ext", since = "1.1.0")]
43+
pub st_ino: ino_t,
44+
#[stable(feature = "raw_ext", since = "1.1.0")]
45+
pub st_mode: mode_t,
46+
#[stable(feature = "raw_ext", since = "1.1.0")]
47+
pub st_nlink: nlink_t,
48+
#[stable(feature = "raw_ext", since = "1.1.0")]
49+
pub st_uid: uid_t,
50+
#[stable(feature = "raw_ext", since = "1.1.0")]
51+
pub st_gid: gid_t,
52+
#[stable(feature = "raw_ext", since = "1.1.0")]
53+
pub st_rdev: dev_t,
54+
#[stable(feature = "raw_ext", since = "1.1.0")]
55+
pub st_size: off_t,
56+
#[stable(feature = "raw_ext", since = "1.1.0")]
57+
pub st_atime: time_t,
58+
#[stable(feature = "raw_ext", since = "1.1.0")]
59+
pub st_atime_nsec: c_long,
60+
#[stable(feature = "raw_ext", since = "1.1.0")]
61+
pub st_mtime: time_t,
62+
#[stable(feature = "raw_ext", since = "1.1.0")]
63+
pub st_mtime_nsec: c_long,
64+
#[stable(feature = "raw_ext", since = "1.1.0")]
65+
pub st_ctime: time_t,
66+
#[stable(feature = "raw_ext", since = "1.1.0")]
67+
pub st_ctime_nsec: c_long,
68+
#[stable(feature = "raw_ext", since = "1.1.0")]
69+
pub st_blksize: blksize_t,
70+
#[stable(feature = "raw_ext", since = "1.1.0")]
71+
pub st_blocks: blkcnt_t,
72+
#[stable(feature = "raw_ext", since = "1.1.0")]
73+
pub __unused: [u8; 16],
74+
}

src/libstd/os/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ pub mod freebsd;
5252
pub mod fuchsia;
5353
#[cfg(target_os = "haiku")]
5454
pub mod haiku;
55+
#[cfg(target_os = "illumos")]
56+
pub mod illumos;
5557
#[cfg(target_os = "ios")]
5658
pub mod ios;
5759
#[cfg(target_os = "macos")]

0 commit comments

Comments
 (0)