Skip to content

Commit 14a746f

Browse files
jasonbkingpfmooney
andcommitted
Add illumos triple
Co-Authored-By: Patrick Mooney <[email protected]>
1 parent 357e16e commit 14a746f

File tree

25 files changed

+339
-17
lines changed

25 files changed

+339
-17
lines changed

src/librustc_codegen_ssa/Cargo.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use crate::spec::TargetOptions;
2+
use std::default::Default;
3+
4+
pub fn opts() -> TargetOptions {
5+
TargetOptions {
6+
dynamic_linking: true,
7+
executables: true,
8+
has_rpath: true,
9+
target_family: Some("unix".to_string()),
10+
is_like_solaris: true,
11+
limit_rdylib_exports: false, // Linker doesn't support this
12+
eliminate_frame_pointer: false,
13+
14+
// While we support ELF TLS, rust requires a way to register
15+
// cleanup handlers (in C, this would be something along the lines of:
16+
// void register_callback(void (*fn)(void *), void *arg);
17+
// (see src/libstd/sys/unix/fast_thread_local.rs) that is currently
18+
// missing in illumos. For now at least, we must fallback to using
19+
// pthread_{get,set}specific.
20+
//has_elf_tls: true,
21+
22+
// XXX: Currently, rust is invoking cc to link, which ends up
23+
// causing these to get included twice. We should eventually transition
24+
// to having rustc invoke ld directly, in which case these will need to
25+
// be uncommented.
26+
//
27+
// We want XPG6 behavior from libc and libm. See standards(5)
28+
//pre_link_objects_exe: vec![
29+
// "/usr/lib/amd64/values-Xc.o".to_string(),
30+
// "/usr/lib/amd64/values-xpg6.o".to_string(),
31+
//],
32+
33+
.. Default::default()
34+
}
35+
}

src/librustc_target/spec/mod.rs

Lines changed: 3 additions & 0 deletions
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),
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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,
6+
vec!["-m64".to_string(), "-std=c99".to_string()]);
7+
base.cpu = "x86-64".to_string();
8+
base.max_atomic_width = Some(64);
9+
// illumos has its own stack protection which interferes
10+
// with the rust stack probes. See rust-lang/rust#52577
11+
base.stack_probes = false;
12+
13+
Ok(Target {
14+
// LLVM does not currently have a separate illumos target,
15+
// so we still pass Solaris to it
16+
llvm_target: "x86_64-pc-solaris".to_string(),
17+
target_endian: "little".to_string(),
18+
target_pointer_width: "64".to_string(),
19+
target_c_int_width: "32".to_string(),
20+
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
21+
arch: "x86_64".to_string(),
22+
target_os: "illumos".to_string(),
23+
target_env: String::new(),
24+
target_vendor: "unknown".to_string(),
25+
linker_flavor: LinkerFlavor::Gcc,
26+
options: base,
27+
})
28+
}

src/librustdoc/clean/cfg.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ 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+
// SSP symbols are provided in a separate library, rather that by libc (for now)
35+
println!("cargo:rustc-link-lib=ssp");
36+
// Use libumem for the (malloc-compatible) allocator
37+
println!("cargo:rustc-link-lib=umem");
2838
} else if target.contains("apple-darwin") {
2939
println!("cargo:rustc-link-lib=System");
3040

src/libstd/f64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ impl f64 {
949949
// because of their non-standard behavior (e.g., log(-n) returns -Inf instead
950950
// of expected NaN).
951951
fn log_wrapper<F: Fn(f64) -> f64>(self, log_fn: F) -> f64 {
952-
if !cfg!(target_os = "solaris") {
952+
if !cfg!(any(target_os = "solaris", target_os = "illumos")) {
953953
log_fn(self)
954954
} else {
955955
if self.is_finite() {

src/libstd/os/illumos/fs.rs

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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(since = "1.8.0",
24+
reason = "deprecated in favor of the accessor \
25+
methods of this trait")]
26+
#[allow(deprecated)]
27+
fn as_raw_stat(&self) -> &raw::stat;
28+
29+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
30+
fn st_dev(&self) -> u64;
31+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
32+
fn st_ino(&self) -> u64;
33+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
34+
fn st_mode(&self) -> u32;
35+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
36+
fn st_nlink(&self) -> u64;
37+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
38+
fn st_uid(&self) -> u32;
39+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
40+
fn st_gid(&self) -> u32;
41+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
42+
fn st_rdev(&self) -> u64;
43+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
44+
fn st_size(&self) -> u64;
45+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
46+
fn st_atime(&self) -> i64;
47+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
48+
fn st_atime_nsec(&self) -> i64;
49+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
50+
fn st_mtime(&self) -> i64;
51+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
52+
fn st_mtime_nsec(&self) -> i64;
53+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
54+
fn st_ctime(&self) -> i64;
55+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
56+
fn st_ctime_nsec(&self) -> i64;
57+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
58+
fn st_blksize(&self) -> u64;
59+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
60+
fn st_blocks(&self) -> u64;
61+
}
62+
63+
#[stable(feature = "metadata_ext", since = "1.1.0")]
64+
impl MetadataExt for Metadata {
65+
#[allow(deprecated)]
66+
fn as_raw_stat(&self) -> &raw::stat {
67+
unsafe {
68+
&*(self.as_inner().as_inner() as *const libc::stat
69+
as *const raw::stat)
70+
}
71+
}
72+
fn st_dev(&self) -> u64 {
73+
self.as_inner().as_inner().st_dev as u64
74+
}
75+
fn st_ino(&self) -> u64 {
76+
self.as_inner().as_inner().st_ino as u64
77+
}
78+
fn st_mode(&self) -> u32 {
79+
self.as_inner().as_inner().st_mode as u32
80+
}
81+
fn st_nlink(&self) -> u64 {
82+
self.as_inner().as_inner().st_nlink as u64
83+
}
84+
fn st_uid(&self) -> u32 {
85+
self.as_inner().as_inner().st_uid as u32
86+
}
87+
fn st_gid(&self) -> u32 {
88+
self.as_inner().as_inner().st_gid as u32
89+
}
90+
fn st_rdev(&self) -> u64 {
91+
self.as_inner().as_inner().st_rdev as u64
92+
}
93+
fn st_size(&self) -> u64 {
94+
self.as_inner().as_inner().st_size as u64
95+
}
96+
fn st_atime(&self) -> i64 {
97+
self.as_inner().as_inner().st_atime as i64
98+
}
99+
fn st_atime_nsec(&self) -> i64 {
100+
self.as_inner().as_inner().st_atime_nsec as i64
101+
}
102+
fn st_mtime(&self) -> i64 {
103+
self.as_inner().as_inner().st_mtime as i64
104+
}
105+
fn st_mtime_nsec(&self) -> i64 {
106+
self.as_inner().as_inner().st_mtime_nsec as i64
107+
}
108+
fn st_ctime(&self) -> i64 {
109+
self.as_inner().as_inner().st_ctime as i64
110+
}
111+
fn st_ctime_nsec(&self) -> i64 {
112+
self.as_inner().as_inner().st_ctime_nsec as i64
113+
}
114+
fn st_blksize(&self) -> u64 {
115+
self.as_inner().as_inner().st_blksize as u64
116+
}
117+
fn st_blocks(&self) -> u64 {
118+
self.as_inner().as_inner().st_blocks as u64
119+
}
120+
}

src/libstd/os/illumos/mod.rs

Lines changed: 6 additions & 0 deletions
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

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

0 commit comments

Comments
 (0)