Skip to content

Commit 1a6fc8b

Browse files
nielxkallisti5
authored andcommitted
Add support for the Haiku operating system on x86 and x86_64 machines
* Hand rebased from Niels original work on 1.9.0
1 parent 2d1d4d1 commit 1a6fc8b

File tree

23 files changed

+468
-11
lines changed

23 files changed

+468
-11
lines changed

mk/cfg/i686-unknown-haiku.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# i686-unknown-haiku configuration
2+
CROSS_PREFIX_i686-unknown-haiku=i586-pc-haiku-
3+
CC_i686-unknown-haiku=$(CC)
4+
CXX_i686-unknown-haiku=$(CXX)
5+
CPP_i686-unknown-haiku=$(CPP)
6+
AR_i686-unknown-haiku=$(AR)
7+
CFG_LIB_NAME_i686-unknown-haiku=lib$(1).so
8+
CFG_STATIC_LIB_NAME_i686-unknown-haiku=lib$(1).a
9+
CFG_LIB_GLOB_i686-unknown-haiku=lib$(1)-*.so
10+
CFG_LIB_DSYM_GLOB_i686-unknown-haiku=lib$(1)-*.dylib.dSYM
11+
CFG_CFLAGS_i686-unknown-haiku := -m32 $(CFLAGS)
12+
CFG_GCCISH_CFLAGS_i686-unknown-haiku := -Wall -Werror -g -fPIC -m32 $(CFLAGS)
13+
CFG_GCCISH_CXXFLAGS_i686-unknown-haiku := -fno-rtti $(CXXFLAGS)
14+
CFG_GCCISH_LINK_FLAGS_i686-unknown-haiku := -shared -fPIC -ldl -pthread -lrt -g -m32
15+
CFG_GCCISH_PRE_LIB_FLAGS_i686-unknown-haiku := -Wl,-whole-archive
16+
CFG_GCCISH_POST_LIB_FLAGS_i686-unknown-haiku := -Wl,-no-whole-archive
17+
CFG_DEF_SUFFIX_i686-unknown-haiku := .linux.def
18+
CFG_LLC_FLAGS_i686-unknown-haiku :=
19+
CFG_INSTALL_NAME_i686-unknown-haiku =
20+
CFG_EXE_SUFFIX_i686-unknown-haiku =
21+
CFG_WINDOWSY_i686-unknown-haiku :=
22+
CFG_UNIXY_i686-unknown-haiku := 1
23+
CFG_PATH_MUNGE_i686-unknown-haiku := true
24+
CFG_LDPATH_i686-unknown-haiku :=
25+
CFG_RUN_i686-unknown-haiku=$(2)
26+
CFG_RUN_TARG_i686-unknown-haiku=$(call CFG_RUN_i686-unknown-haiku,,$(2))
27+
CFG_GNU_TRIPLE_i686-unknown-haiku := i686-unknown-haiku

mk/cfg/x86_64-unknown-haiku.mk

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# x86_64-unknown-haiku configuration
2+
CROSS_PREFIX_x86_64-unknown-haiku=x86_64-unknown-haiku-
3+
CC_x86_64-unknown-haiku=$(CC)
4+
CXX_x86_64-unknown-haiku=$(CXX)
5+
CPP_x86_64-unknown-haiku=$(CPP)
6+
AR_x86_64-unknown-haiku=$(AR)
7+
CFG_LIB_NAME_x86_64-unknown-haiku=lib$(1).so
8+
CFG_STATIC_LIB_NAME_x86_64-unknown-haiku=lib$(1).a
9+
CFG_LIB_GLOB_x86_64-unknown-haiku=lib$(1)-*.so
10+
CFG_LIB_DSYM_GLOB_x86_64-unknown-haiku=lib$(1)-*.dylib.dSYM
11+
CFG_CFLAGS_x86_64-unknown-haiku := -m64 $(CFLAGS)
12+
CFG_GCCISH_CFLAGS_x86_64-unknown-haiku := -Wall -Werror -g -fPIC -m64 $(CFLAGS)
13+
CFG_GCCISH_CXXFLAGS_x86_64-unknown-haiku := -fno-rtti $(CXXFLAGS)
14+
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-haiku := -shared -fPIC -ldl -pthread -lrt -g -m64
15+
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-haiku := -Wl,-whole-archive
16+
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-haiku := -Wl,-no-whole-archive
17+
CFG_DEF_SUFFIX_x86_64-unknown-haiku := .linux.def
18+
CFG_LLC_FLAGS_x86_64-unknown-haiku :=
19+
CFG_INSTALL_NAME_x86_64-unknown-haiku =
20+
CFG_EXE_SUFFIX_x86_64-unknown-haiku =
21+
CFG_WINDOWSY_x86_64-unknown-haiku :=
22+
CFG_UNIXY_x86_64-unknown-haiku := 1
23+
CFG_PATH_MUNGE_x86_64-unknown-haiku := true
24+
CFG_LDPATH_x86_64-unknown-haiku :=
25+
CFG_RUN_x86_64-unknown-haiku=$(2)
26+
CFG_RUN_TARG_x86_64-unknown-haiku=$(call CFG_RUN_x86_64-unknown-haiku,,$(2))
27+
CFG_GNU_TRIPLE_x86_64-unknown-haiku := x86_64-unknown-haiku
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2014 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+
use target::TargetOptions;
13+
use std::default::Default;
14+
15+
pub fn target() -> Target {
16+
Target {
17+
llvm_target: "i686-unknown-haiku".to_string(),
18+
target_endian: "little".to_string(),
19+
target_pointer_width: "32".to_string(),
20+
data_layout: "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128".to_string(),
21+
arch: "x86".to_string(),
22+
target_os: "haiku".to_string(),
23+
target_env: "".to_string(),
24+
target_vendor: "unknown".to_string(),
25+
options: TargetOptions {
26+
linker: "cc".to_string(),
27+
dynamic_linking: true,
28+
executables: true,
29+
has_rpath: true,
30+
.. Default::default()
31+
},
32+
}
33+
}

src/librustc_back/target/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ supported_targets! {
165165
("x86_64-unknown-netbsd", x86_64_unknown_netbsd),
166166
("x86_64-rumprun-netbsd", x86_64_rumprun_netbsd),
167167

168+
("i686_unknown_haiku", i686_unknown_haiku),
169+
("x86_64_unknown_haiku", x86_64_unknown_haiku),
170+
168171
("x86_64-apple-darwin", x86_64_apple_darwin),
169172
("i686-apple-darwin", i686_apple_darwin),
170173

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright 2014 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+
use target::TargetOptions;
13+
use std::default::Default;
14+
15+
pub fn target() -> Target {
16+
Target {
17+
llvm_target: "x86_64-unknown-haiku".to_string(),
18+
target_endian: "little".to_string(),
19+
target_pointer_width: "64".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: "haiku".to_string(),
23+
target_env: "".to_string(),
24+
target_vendor: "unknown".to_string(),
25+
options: TargetOptions {
26+
linker: "cc".to_string(),
27+
dynamic_linking: true,
28+
executables: true,
29+
has_rpath: true,
30+
.. Default::default()
31+
},
32+
}
33+
}

src/librustc_data_structures/flock.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,27 @@ mod imp {
9494
pub const F_SETLKW: libc::c_int = 9;
9595
}
9696

97+
#[cfg(target_os = "haiku")]
98+
mod os {
99+
use libc;
100+
101+
pub struct flock {
102+
pub l_type: libc::c_short,
103+
pub l_whence: libc::c_short,
104+
pub l_start: libc::off_t,
105+
pub l_len: libc::off_t,
106+
pub l_pid: libc::pid_t,
107+
108+
// not actually here, but brings in line with freebsd
109+
pub l_sysid: libc::c_int,
110+
}
111+
112+
pub const F_UNLCK: libc::c_short = 0x0200;
113+
pub const F_WRLCK: libc::c_short = 0x0400;
114+
pub const F_SETLK: libc::c_int = 0x0080;
115+
pub const F_SETLKW: libc::c_int = 0x0100;
116+
}
117+
97118
#[cfg(any(target_os = "macos", target_os = "ios"))]
98119
mod os {
99120
use libc;

src/libstd/env.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,17 @@ mod os {
903903
pub const EXE_EXTENSION: &'static str = "js";
904904
}
905905

906+
#[cfg(target_os = "haiku")]
907+
mod os {
908+
pub const FAMILY: &'static str = "unix";
909+
pub const OS: &'static str = "haiku";
910+
pub const DLL_PREFIX: &'static str = "lib";
911+
pub const DLL_SUFFIX: &'static str = ".so";
912+
pub const DLL_EXTENSION: &'static str = "so";
913+
pub const EXE_SUFFIX: &'static str = "";
914+
pub const EXE_EXTENSION: &'static str = "";
915+
}
916+
906917
#[cfg(target_arch = "x86")]
907918
mod arch {
908919
pub const ARCH: &'static str = "x86";

src/libstd/os/haiku/fs.rs

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

src/libstd/os/haiku/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
//! Haiku-specific definitions
12+
13+
#![stable(feature = "raw_ext", since = "1.1.0")]
14+
15+
pub mod raw;
16+
pub mod fs;

0 commit comments

Comments
 (0)