Skip to content

Commit f189d7a

Browse files
committed
Add Illumos support
1 parent 9041b93 commit f189d7a

35 files changed

+412
-37
lines changed

configure

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/sh
22

3+
# /bin/sh on Solaris is not a POSIX compatible shell, but /usr/bin/ksh is.
4+
if [ `uname -s` = 'SunOS' -a "${POSIX_SHELL}" != "true" ]; then
5+
POSIX_SHELL="true"
6+
export POSIX_SHELL
7+
exec /usr/bin/bash $0 "$@"
8+
fi
9+
unset POSIX_SHELL # clear it so if we invoke other scripts, they run as ksh as well
10+
311
msg() {
412
echo "configure: $*"
513
}
@@ -416,6 +424,11 @@ case $CFG_OSTYPE in
416424
CFG_OSTYPE=apple-darwin
417425
;;
418426

427+
SunOS)
428+
CFG_OSTYPE=sun-solaris
429+
CFG_CPUTYPE=$(isainfo -n)
430+
;;
431+
419432
MINGW*)
420433
# msys' `uname` does not print gcc configuration, but prints msys
421434
# configuration. so we cannot believe `uname -m`:

mk/cfg/x86_64-sun-solaris.mk

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# x86_64-sun-solaris configuration
2+
CROSS_PREFIX_x86_64-sun-solaris=x86_64-sun-solaris2.11-
3+
CC_x86_64-sun-solaris=$(CC)
4+
CXX_x86_64-sun-solaris=$(CXX)
5+
CPP_x86_64-sun-solaris=$(CPP)
6+
AR_x86_64-sun-solaris=$(AR)
7+
CFG_LIB_NAME_x86_64-sun-solaris=lib$(1).so
8+
CFG_STATIC_LIB_NAME_x86_64-sun-solaris=lib$(1).a
9+
CFG_LIB_GLOB_x86_64-sun-solaris=lib$(1)-*.so
10+
CFG_LIB_DSYM_GLOB_x86_64-sun-solaris=$(1)-*.dylib.dSYM
11+
CFG_JEMALLOC_CFLAGS_x86_64-sun-solaris := -I/usr/local/include $(CFLAGS)
12+
CFG_GCCISH_CFLAGS_x86_64-sun-solaris := -Wall -Werror -g -D_POSIX_PTHREAD_SEMANTICS -fPIC -I/usr/local/include $(CFLAGS)
13+
CFG_GCCISH_LINK_FLAGS_x86_64-sun-solaris := -shared -fPIC -g -pthread -lrt
14+
CFG_GCCISH_DEF_FLAG_x86_64-sun-solaris := -Wl,--export-dynamic,--dynamic-list=
15+
CFG_LLC_FLAGS_x86_64-sun-solaris :=
16+
CFG_INSTALL_NAME_x86_64-sun-solaris =
17+
CFG_EXE_SUFFIX_x86_64-sun-solaris :=
18+
CFG_WINDOWSY_x86_64-sun-solaris :=
19+
CFG_UNIXY_x86_64-sun-solaris := 1
20+
CFG_LDPATH_x86_64-sun-solaris :=
21+
CFG_RUN_x86_64-sun-solaris=$(2)
22+
CFG_RUN_TARG_x86_64-sun-solaris=$(call CFG_RUN_x86_64-sun-solaris,,$(2))
23+
CFG_GNU_TRIPLE_x86_64-sun-solaris := x86_64-sun-solaris

src/compiletest/util.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const OS_TABLE: &'static [(&'static str, &'static str)] = &[
2525
("openbsd", "openbsd"),
2626
("win32", "windows"),
2727
("windows", "windows"),
28+
("solaris", "sunos"),
2829
];
2930

3031
const ARCH_TABLE: &'static [(&'static str, &'static str)] = &[

src/etc/local_stage0.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ LIB_PREFIX=lib
1818

1919
OS=`uname -s`
2020
case $OS in
21-
("Linux"|"FreeBSD"|"DragonFly"|"Bitrig"|"OpenBSD")
21+
("Linux"|"FreeBSD"|"DragonFly"|"Bitrig"|"OpenBSD"|"SunOS")
2222
BIN_SUF=
2323
LIB_SUF=.so
2424
;;

src/etc/snapshot.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def scrub(b):
4848
"macos": ["bin/rustc"],
4949
"netbsd": ["bin/rustc"],
5050
"openbsd": ["bin/rustc"],
51+
"sunos": ["bin/rustc"],
5152
"winnt": ["bin/rustc.exe"],
5253
}
5354

src/librustc_back/target/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ mod freebsd_base;
5959
mod linux_base;
6060
mod openbsd_base;
6161
mod netbsd_base;
62+
mod sunos_base;
6263
mod windows_base;
6364
mod windows_msvc_base;
6465

@@ -155,6 +156,10 @@ pub struct TargetOptions {
155156
/// Whether the target toolchain is like OSX's. Only useful for compiling against iOS/OS X, in
156157
/// particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
157158
pub is_like_osx: bool,
159+
/// Whether the target toolchain is like Solaris's.
160+
/// Only useful for compiling against Illumos/Solaris,
161+
/// as they have a different set of linker flags. Defaults to false.
162+
pub is_like_sunos: bool,
158163
/// Whether the target toolchain is like Windows'. Only useful for compiling against Windows,
159164
/// only really used for figuring out how to find libraries, since Windows uses its own
160165
/// library naming convention. Defaults to false.
@@ -227,6 +232,7 @@ impl Default for TargetOptions {
227232
staticlib_suffix: ".a".to_string(),
228233
target_family: None,
229234
is_like_osx: false,
235+
is_like_sunos: false,
230236
is_like_windows: false,
231237
is_like_android: false,
232238
is_like_msvc: false,
@@ -447,6 +453,8 @@ impl Target {
447453
armv7_apple_ios,
448454
armv7s_apple_ios,
449455

456+
x86_64_sun_solaris,
457+
450458
x86_64_pc_windows_gnu,
451459
i686_pc_windows_gnu,
452460

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use target::TargetOptions;
12+
use std::default::Default;
13+
14+
pub fn opts() -> TargetOptions {
15+
TargetOptions {
16+
linker: "cc".to_string(),
17+
dynamic_linking: true,
18+
executables: true,
19+
has_rpath: true,
20+
is_like_sunos: true,
21+
archive_format: "gnu".to_string(),
22+
exe_allocation_crate: super::maybe_jemalloc(),
23+
24+
.. Default::default()
25+
}
26+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use target::Target;
12+
13+
pub fn target() -> Target {
14+
let mut base = super::sunos_base::opts();
15+
base.pre_link_args.push("-m64".to_string());
16+
base.pre_link_args.push("-lsocket".to_string());
17+
base.pre_link_args.push("-lposix4".to_string());
18+
19+
Target {
20+
llvm_target: "x86_64-pc-solaris2.11".to_string(),
21+
target_endian: "little".to_string(),
22+
target_pointer_width: "64".to_string(),
23+
arch: "x86_64".to_string(),
24+
target_os: "sunos".to_string(),
25+
target_env: "".to_string(),
26+
target_vendor: "sun".to_string(),
27+
options: base,
28+
}
29+
}

src/librustc_trans/back/linker.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ impl<'a> Linker for GnuLinker<'a> {
131131
// insert it here.
132132
if self.sess.target.target.options.is_like_osx {
133133
self.cmd.arg("-Wl,-dead_strip");
134+
} else if self.sess.target.target.options.is_like_sunos {
135+
self.cmd.arg("-Wl,-z");
136+
self.cmd.arg("-Wl,ignore");
134137

135138
// If we're building a dylib, we don't use --gc-sections because LLVM
136139
// has already done the best it can do, and we also don't want to

src/librustdoc/flock.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,27 @@ mod imp {
111111
pub const F_SETLKW: libc::c_int = 9;
112112
}
113113

114+
#[cfg(target_os = "sunos")]
115+
mod os {
116+
use libc;
117+
118+
pub struct flock {
119+
pub l_type: libc::c_short,
120+
pub l_whence: libc::c_short,
121+
pub l_start: libc::off_t,
122+
pub l_len: libc::off_t,
123+
pub l_sysid: libc::c_int,
124+
pub l_pid: libc::pid_t,
125+
126+
// __unused1: [libc::c_long; 4]
127+
}
128+
129+
pub const F_WRLCK: libc::c_short = 2;
130+
pub const F_UNLCK: libc::c_short = 3;
131+
pub const F_SETLK: libc::c_int = 6;
132+
pub const F_SETLKW: libc::c_int = 7;
133+
}
134+
114135
pub struct Lock {
115136
fd: libc::c_int,
116137
}

src/libstd/dynamic_lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ mod tests {
172172
target_os = "dragonfly",
173173
target_os = "bitrig",
174174
target_os = "netbsd",
175-
target_os = "openbsd"))]
175+
target_os = "openbsd",
176+
target_os = "sunos"))]
176177
#[allow(deprecated)]
177178
fn test_errors_do_not_crash() {
178179
use path::Path;
@@ -195,7 +196,8 @@ mod tests {
195196
target_os = "dragonfly",
196197
target_os = "bitrig",
197198
target_os = "netbsd",
198-
target_os = "openbsd"))]
199+
target_os = "openbsd",
200+
target_os = "sunos"))]
199201
mod dl {
200202
use prelude::v1::*;
201203

src/libstd/env.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ pub mod consts {
642642
/// - bitrig
643643
/// - netbsd
644644
/// - openbsd
645+
/// - sunos
645646
/// - android
646647
/// - windows
647648
#[stable(feature = "env", since = "1.0.0")]
@@ -802,6 +803,17 @@ mod os {
802803
pub const EXE_EXTENSION: &'static str = "";
803804
}
804805

806+
#[cfg(target_os = "sunos")]
807+
mod os {
808+
pub const FAMILY: &'static str = "unix";
809+
pub const OS: &'static str = "sunos";
810+
pub const DLL_PREFIX: &'static str = "lib";
811+
pub const DLL_SUFFIX: &'static str = ".so";
812+
pub const DLL_EXTENSION: &'static str = "so";
813+
pub const EXE_SUFFIX: &'static str = "";
814+
pub const EXE_EXTENSION: &'static str = "";
815+
}
816+
805817
#[cfg(target_os = "windows")]
806818
mod os {
807819
pub const FAMILY: &'static str = "windows";

src/libstd/num/f64.rs

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,38 @@ mod cmath {
8484
}
8585
}
8686

87+
#[cfg(not(target_os = "sunos"))]
88+
macro_rules! log_wrapper {
89+
($num:ident, $f:ident) => (
90+
unsafe { intrinsics::$f($num) }
91+
)
92+
}
93+
94+
// Illumos requires a wrapper around log, log2, and log10 functions
95+
// because of non-standard behavior (e.g. log(-n) returns -Inf instead
96+
// of expected NaN).
97+
#[cfg(target_os = "sunos")]
98+
macro_rules! log_wrapper {
99+
($num:ident, $f:ident) => (
100+
if $num.is_finite() {
101+
if $num > 0.0 {
102+
return unsafe { intrinsics::$f($num) }
103+
}
104+
return if $num == 0.0 {
105+
NEG_INFINITY // log(0) = -Inf
106+
} else {
107+
NAN // log(-ve) = NaN
108+
}
109+
} else if $num.is_nan() {
110+
$num // log(NaN) = NaN
111+
} else if $num > 0.0 {
112+
$num // log(Inf) = Inf
113+
} else {
114+
return NAN // log(-Inf) = NaN
115+
}
116+
)
117+
}
118+
87119
#[cfg(not(test))]
88120
#[lang = "f64"]
89121
impl f64 {
@@ -511,7 +543,7 @@ impl f64 {
511543
#[stable(feature = "rust1", since = "1.0.0")]
512544
#[inline]
513545
pub fn ln(self) -> f64 {
514-
unsafe { intrinsics::logf64(self) }
546+
log_wrapper!(self, logf64)
515547
}
516548

517549
/// Returns the logarithm of the number with respect to an arbitrary base.
@@ -546,7 +578,7 @@ impl f64 {
546578
#[stable(feature = "rust1", since = "1.0.0")]
547579
#[inline]
548580
pub fn log2(self) -> f64 {
549-
unsafe { intrinsics::log2f64(self) }
581+
log_wrapper!(self, log2f64)
550582
}
551583

552584
/// Returns the base 10 logarithm of the number.
@@ -562,7 +594,7 @@ impl f64 {
562594
#[stable(feature = "rust1", since = "1.0.0")]
563595
#[inline]
564596
pub fn log10(self) -> f64 {
565-
unsafe { intrinsics::log10f64(self) }
597+
log_wrapper!(self, log10f64)
566598
}
567599

568600
/// Converts radians to degrees.

src/libstd/os/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@ pub use sys::ext as windows;
3030
#[cfg(target_os = "nacl")] pub mod nacl;
3131
#[cfg(target_os = "netbsd")] pub mod netbsd;
3232
#[cfg(target_os = "openbsd")] pub mod openbsd;
33+
#[cfg(target_os = "sunos")] pub mod sunos;
3334

3435
pub mod raw;

src/libstd/os/sunos/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
//! Solaris-specific definitions
12+
13+
#![stable(feature = "raw_ext", since = "1.1.0")]
14+
15+
pub mod raw;
16+
17+
#[stable(feature = "raw_ext", since = "1.1.0")]
18+
pub mod fs {
19+
#[stable(feature = "raw_ext", since = "1.1.0")]
20+
pub use sys::fs::MetadataExt;
21+
}

0 commit comments

Comments
 (0)