Skip to content

Commit cc3dc63

Browse files
committed
Merge pull request #1 from korli/rust-haiku-1.2.0
Haiku: Add support for x86_64.
2 parents f293c83 + c6e21ba commit cc3dc63

File tree

11 files changed

+212
-58
lines changed

11 files changed

+212
-58
lines changed

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

src/libbacktrace/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10333,7 +10333,7 @@ haiku*)
1033310333
soname_spec='${libname}${release}${shared_ext}$major'
1033410334
shlibpath_var=LIBRARY_PATH
1033510335
shlibpath_overrides_runpath=yes
10336-
sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/beos/system/lib'
10336+
sys_lib_dlsearch_path_spec='/boot/home/config/non-packaged/lib /boot/home/config/lib /boot/system/non-packaged/lib /boot/system/lib'
1033710337
hardcode_into_libs=yes
1033810338
;;
1033910339

src/liblibc/lib.rs

Lines changed: 125 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ extern {}
175175
#[cfg(all(target_os = "nacl", not(feature = "cargo-build"), not(test)))]
176176
#[link(name = "pnaclmm", kind = "static")]
177177
extern {}
178-
178+
179179
#[cfg(target_os = "haiku")]
180180
#[link(name = "root")]
181181
#[link(name = "network")]
@@ -2426,17 +2426,18 @@ pub mod types {
24262426
}
24272427
}
24282428
}
2429-
2429+
24302430
#[cfg(target_os = "haiku")]
24312431
pub mod os {
24322432
pub mod common {
24332433
pub mod posix01 {
24342434
use types::common::c95::{c_void};
24352435
use types::os::arch::c95::{c_char, c_int, size_t,
24362436
time_t, suseconds_t, c_long};
2437+
use types::os::arch::c99::{uintptr_t};
24372438

2438-
pub type pthread_t = u32;
2439-
pub type rlim_t = u32;
2439+
pub type pthread_t = uintptr_t;
2440+
pub type rlim_t = uintptr_t;
24402441

24412442
#[repr(C)]
24422443
#[derive(Copy, Clone)] pub struct glob_t {
@@ -2468,31 +2469,31 @@ pub mod types {
24682469
}
24692470

24702471
pub enum timezone {}
2471-
2472-
// TODO: find whether this definition is correct
2472+
2473+
// FIXME: find whether this definition is correct
24732474
pub type sighandler_t = size_t;
2474-
2475+
24752476
#[repr(C)]
24762477
#[derive(Copy, Clone)]
24772478
pub struct rlimit {
2478-
pub rlim_cur: rlim_t,
2479-
pub rlim_max: rlim_t,
2479+
pub rlim_cur: rlim_t,
2480+
pub rlim_max: rlim_t,
24802481
}
24812482
}
2482-
2483+
24832484
pub mod bsd43 {
24842485
use types::os::common::posix01::timeval;
2485-
2486+
24862487
#[repr(C)]
24872488
#[derive(Copy, Clone)]
24882489
pub struct rusage {
24892490
pub ru_utime: timeval,
24902491
pub ru_stime: timeval,
24912492
}
24922493
}
2493-
2494+
24942495
pub mod bsd44 {
2495-
use core::clone::Clone;
2496+
use core::clone::Clone;
24962497
use types::os::arch::c95::{c_char, c_int, c_uint};
24972498

24982499
pub type socklen_t = u32;
@@ -2514,7 +2515,7 @@ pub mod types {
25142515
pub __ss_pad2: [u8; 112],
25152516
}
25162517
impl Clone for sockaddr_storage {
2517-
fn clone(&self) -> sockaddr_storage { *self }
2518+
fn clone(&self) -> sockaddr_storage { *self }
25182519
}
25192520
#[repr(C)]
25202521
#[derive(Copy, Clone)] pub struct sockaddr_in {
@@ -2569,11 +2570,102 @@ pub mod types {
25692570
pub sun_path: [c_char; 126]
25702571
}
25712572
impl Clone for sockaddr_un {
2572-
fn clone(&self) -> sockaddr_un { *self }
2573+
fn clone(&self) -> sockaddr_un { *self }
2574+
}
2575+
}
2576+
}
2577+
2578+
#[cfg(target_arch = "x86_64")]
2579+
pub mod arch {
2580+
pub mod c95 {
2581+
pub type c_char = i8;
2582+
pub type c_schar = i8;
2583+
pub type c_uchar = u8;
2584+
pub type c_short = i16;
2585+
pub type c_ushort = u16;
2586+
pub type c_int = i32;
2587+
pub type c_uint = u32;
2588+
pub type c_long = i64;
2589+
pub type c_ulong = u64;
2590+
pub type c_float = f32;
2591+
pub type c_double = f64;
2592+
pub type size_t = u64;
2593+
pub type ptrdiff_t = i64;
2594+
pub type clock_t = i32;
2595+
pub type time_t = i32;
2596+
pub type suseconds_t = i32;
2597+
pub type wchar_t = i32;
2598+
}
2599+
pub mod c99 {
2600+
pub type c_longlong = i64;
2601+
pub type c_ulonglong = u64;
2602+
pub type intptr_t = i64;
2603+
pub type uintptr_t = u64;
2604+
pub type intmax_t = i64;
2605+
pub type uintmax_t = u64;
2606+
}
2607+
pub mod posix88 {
2608+
pub type off_t = i64;
2609+
pub type dev_t = i32;
2610+
pub type ino_t = i64;
2611+
pub type pid_t = i32;
2612+
pub type uid_t = u32;
2613+
pub type gid_t = u32;
2614+
pub type useconds_t = u32;
2615+
pub type mode_t = u32;
2616+
pub type ssize_t = i64;
2617+
}
2618+
pub mod posix01 {
2619+
use types::common::c95::{c_void};
2620+
use types::os::arch::c95::{time_t, c_long};
2621+
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
2622+
use types::os::arch::posix88::{mode_t, off_t};
2623+
use types::os::arch::posix88::{uid_t};
2624+
2625+
pub type nlink_t = i32;
2626+
pub type blksize_t = i32;
2627+
pub type blkcnt_t = i64;
2628+
2629+
#[repr(C)]
2630+
#[derive(Copy, Clone)] pub struct stat {
2631+
pub st_dev: dev_t,
2632+
pub st_ino: ino_t,
2633+
pub st_mode: mode_t,
2634+
pub st_nlink: nlink_t,
2635+
pub st_uid: uid_t,
2636+
pub st_gid: gid_t,
2637+
pub st_size: off_t,
2638+
pub st_rdev: dev_t,
2639+
pub st_blksize: blksize_t,
2640+
pub st_atime: time_t,
2641+
pub st_atime_nsec: c_long,
2642+
pub st_mtime: time_t,
2643+
pub st_mtime_nsec: c_long,
2644+
pub st_ctime: time_t,
2645+
pub st_ctime_nsec: c_long,
2646+
pub st_crtime: time_t,
2647+
pub st_crtime_nsec: c_long,
2648+
pub st_type: u32,
2649+
pub st_blocks: blkcnt_t,
25732650
}
2651+
2652+
#[repr(C)]
2653+
#[derive(Copy, Clone)] pub struct utimbuf {
2654+
pub actime: time_t,
2655+
pub modtime: time_t,
2656+
}
2657+
2658+
pub type pthread_attr_t = *mut c_void;
2659+
}
2660+
pub mod posix08 {
2661+
}
2662+
pub mod bsd44 {
2663+
}
2664+
pub mod extra {
25742665
}
25752666
}
2576-
2667+
2668+
#[cfg(target_arch = "x86")]
25772669
pub mod arch {
25782670
pub mod c95 {
25792671
pub type c_char = i8;
@@ -2614,7 +2706,8 @@ pub mod types {
26142706
pub type ssize_t = i32;
26152707
}
26162708
pub mod posix01 {
2617-
use types::os::arch::c95::{time_t};
2709+
use types::common::c95::{c_void};
2710+
use types::os::arch::c95::{time_t, c_long};
26182711
use types::os::arch::posix88::{dev_t, gid_t, ino_t};
26192712
use types::os::arch::posix88::{mode_t, off_t};
26202713
use types::os::arch::posix88::{uid_t};
@@ -2635,27 +2728,24 @@ pub mod types {
26352728
pub st_rdev: dev_t,
26362729
pub st_blksize: blksize_t,
26372730
pub st_atime: time_t,
2638-
pub st_atime_nsec: i32,
2731+
pub st_atime_nsec: c_long,
26392732
pub st_mtime: time_t,
2640-
pub st_mtime_nsec: i32,
2733+
pub st_mtime_nsec: c_long,
26412734
pub st_ctime: time_t,
2642-
pub st_ctime_nsec: i32,
2735+
pub st_ctime_nsec: c_long,
26432736
pub st_crtime: time_t,
2644-
pub st_crtime_nsec: i32,
2737+
pub st_crtime_nsec: c_long,
26452738
pub st_type: u32,
26462739
pub st_blocks: blkcnt_t,
26472740
}
2648-
2741+
26492742
#[repr(C)]
26502743
#[derive(Copy, Clone)] pub struct utimbuf {
26512744
pub actime: time_t,
26522745
pub modtime: time_t,
26532746
}
26542747

2655-
#[repr(C)]
2656-
#[derive(Copy, Clone)] pub struct pthread_attr_t {
2657-
pub __size: [u32; 4]
2658-
}
2748+
pub type pthread_attr_t = *mut c_void;
26592749
}
26602750
pub mod posix08 {
26612751
}
@@ -5468,7 +5558,7 @@ pub mod consts {
54685558
pub const _SC_PASS_MAX : c_int = 131;
54695559
}
54705560
}
5471-
5561+
54725562
#[cfg(target_os = "haiku")]
54735563
pub mod os {
54745564
pub mod c95 {
@@ -5546,7 +5636,8 @@ pub mod consts {
55465636
pub const PROT_WRITE : c_int = 2;
55475637
pub const PROT_EXEC : c_int = 4;
55485638

5549-
pub const MAP_FILE : c_int = 0x00; // Warning: Haiku does not have a MAP_FILE, but libstd/os.rs requires it
5639+
// Warning: Haiku does not have a MAP_FILE, but libstd/os.rs requires it
5640+
pub const MAP_FILE : c_int = 0x00;
55505641
pub const MAP_SHARED : c_int = 0x01;
55515642
pub const MAP_PRIVATE : c_int = 0x02;
55525643
pub const MAP_FIXED : c_int = 0x04;
@@ -5672,7 +5763,7 @@ pub mod consts {
56725763
pub const F_SETFD : c_int = 0x0004;
56735764
pub const F_GETFL : c_int = 0x0008;
56745765
pub const F_SETFL : c_int = 0x0010;
5675-
5766+
56765767
pub const FD_CLOEXEC : c_int = 1;
56775768

56785769
pub const SIGTRAP : c_int = 22;
@@ -5723,7 +5814,7 @@ pub mod consts {
57235814

57245815
pub const CLOCK_REALTIME: c_int = -1;
57255816
pub const CLOCK_MONOTONIC: c_int = 0;
5726-
5817+
57275818
pub const RLIMIT_CORE: c_int = 0;
57285819
pub const RLIMIT_CPU: c_int = 1;
57295820
pub const RLIMIT_DATA: c_int = 2;
@@ -5733,20 +5824,20 @@ pub mod consts {
57335824
pub const RLIMIT_AS: c_int = 6;
57345825
// Haiku specific
57355826
pub const RLIMIT_NOVMON: c_int = 7;
5736-
5827+
57375828
pub const RLIMIT_NLIMITS: c_int = 8;
57385829
pub const RLIM_INFINITY: rlim_t = 0xffffffff;
57395830
pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
57405831
pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
5741-
5832+
57425833
pub const RUSAGE_SELF: c_int = 0;
57435834
pub const RUSAGE_CHILDREN: c_int = -1;
57445835
}
57455836
pub mod posix08 {
57465837
}
57475838
pub mod bsd44 {
57485839
use types::os::arch::c95::c_int;
5749-
5840+
57505841
// In Haiku these are prefixed with POSIX_
57515842
pub const MADV_NORMAL : c_int = 1;
57525843
pub const MADV_RANDOM : c_int = 3;
@@ -6762,7 +6853,7 @@ pub mod funcs {
67626853
#[cfg(target_os = "windows")]
67636854
pub mod bsd44 {
67646855
}
6765-
6856+
67666857
#[cfg(target_os = "haiku")]
67676858
pub mod bsd44 {
67686859
use types::os::arch::c95::{c_int, c_ulong};

src/librustc_back/target/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ impl Target {
367367
x86_64_unknown_dragonfly,
368368

369369
i686_unknown_haiku,
370+
x86_64_unknown_haiku,
370371

371372
x86_64_unknown_bitrig,
372373
x86_64_unknown_openbsd,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
18+
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
19+
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
20+
llvm_target: "x86_64-unknown-haiku".to_string(),
21+
target_endian: "little".to_string(),
22+
target_pointer_width: "64".to_string(),
23+
arch: "x86_64".to_string(),
24+
target_os: "haiku".to_string(),
25+
target_env: "".to_string(),
26+
options: TargetOptions {
27+
linker: "cc".to_string(),
28+
dynamic_linking: true,
29+
executables: true,
30+
has_rpath: true,
31+
.. Default::default()
32+
},
33+
}
34+
}

src/librustdoc/flock.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ mod imp {
115115
use libc;
116116

117117
pub struct flock {
118+
pub l_type: libc::c_short,
119+
pub l_whence: libc::c_short,
118120
pub l_start: libc::off_t,
119121
pub l_len: libc::off_t,
120122
pub l_pid: libc::pid_t,
121-
pub l_type: libc::c_short,
122-
pub l_whence: libc::c_short,
123123

124124
// not actually here, but brings in line with freebsd
125125
pub l_sysid: libc::c_int,

0 commit comments

Comments
 (0)