Skip to content

Commit 02e5fb2

Browse files
committed
Merge pull request #19852 from mneumann/dragonfly3
Several fixes for DragonFly Reviewed-by: brson
2 parents b924f1b + 6f4a406 commit 02e5fb2

File tree

5 files changed

+33
-22
lines changed

5 files changed

+33
-22
lines changed

src/liblibc/lib.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ pub mod types {
10951095
pub type sighandler_t = size_t;
10961096
}
10971097
pub mod bsd44 {
1098+
use types::common::c95::{c_void};
10981099
use types::os::arch::c95::{c_char, c_int, c_uint};
10991100

11001101
pub type socklen_t = u32;
@@ -1167,6 +1168,17 @@ pub mod types {
11671168
pub sun_family: sa_family_t,
11681169
pub sun_path: [c_char, ..104]
11691170
}
1171+
#[repr(C)]
1172+
#[deriving(Copy)] pub struct ifaddrs {
1173+
pub ifa_next: *mut ifaddrs,
1174+
pub ifa_name: *mut c_char,
1175+
pub ifa_flags: c_uint,
1176+
pub ifa_addr: *mut sockaddr,
1177+
pub ifa_netmask: *mut sockaddr,
1178+
pub ifa_dstaddr: *mut sockaddr,
1179+
pub ifa_data: *mut c_void
1180+
}
1181+
11701182
}
11711183
}
11721184

src/librustc_back/rpath.rs

+1-16
Original file line numberDiff line numberDiff line change
@@ -215,22 +215,7 @@ mod test {
215215
}
216216

217217
#[test]
218-
#[cfg(target_os = "freebsd")]
219-
fn test_rpath_relative() {
220-
let config = &mut RPathConfig {
221-
used_crates: Vec::new(),
222-
has_rpath: true,
223-
is_like_osx: false,
224-
out_filename: Path::new("bin/rustc"),
225-
get_install_prefix_lib_path: || panic!(),
226-
realpath: |p| Ok(p.clone())
227-
};
228-
let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so"));
229-
assert_eq!(res, "$ORIGIN/../lib");
230-
}
231-
232-
#[test]
233-
#[cfg(target_os = "dragonfly")]
218+
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
234219
fn test_rpath_relative() {
235220
let config = &mut RPathConfig {
236221
used_crates: Vec::new(),

src/librustc_back/target/dragonfly_base.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ pub fn opts() -> TargetOptions {
2020
has_rpath: true,
2121
pre_link_args: vec!(
2222
"-L/usr/local/lib".to_string(),
23-
"-L/usr/local/lib/gcc47".to_string(),
24-
"-L/usr/local/lib/gcc44".to_string(),
23+
"-L/usr/local/lib/gcc48".to_string(),
2524
),
2625

2726
.. Default::default()

src/librustc_back/target/x86_64_unknown_dragonfly.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@
1111
use target::Target;
1212

1313
pub fn target() -> Target {
14+
let mut base = super::dragonfly_base::opts();
15+
base.pre_link_args.push("-m64".to_string());
16+
1417
Target {
15-
data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
18+
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
19+
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-\
20+
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
1621
llvm_target: "x86_64-unknown-dragonfly".to_string(),
1722
target_endian: "little".to_string(),
18-
target_word_size: "32".to_string(),
23+
target_word_size: "64".to_string(),
1924
arch: "x86_64".to_string(),
2025
target_os: "dragonfly".to_string(),
21-
options: super::dragonfly_base::opts()
26+
options: base,
2227
}
2328
}

src/libstd/os.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ pub fn dll_filename(base: &str) -> String {
665665
/// ```
666666
pub fn self_exe_name() -> Option<Path> {
667667

668-
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
668+
#[cfg(target_os = "freebsd")]
669669
fn load_self() -> Option<Vec<u8>> {
670670
unsafe {
671671
use libc::funcs::bsd44::*;
@@ -691,6 +691,16 @@ pub fn self_exe_name() -> Option<Path> {
691691
}
692692
}
693693

694+
#[cfg(target_os = "dragonfly")]
695+
fn load_self() -> Option<Vec<u8>> {
696+
use std::io;
697+
698+
match io::fs::readlink(&Path::new("/proc/curproc/file")) {
699+
Ok(path) => Some(path.into_vec()),
700+
Err(..) => None
701+
}
702+
}
703+
694704
#[cfg(any(target_os = "linux", target_os = "android"))]
695705
fn load_self() -> Option<Vec<u8>> {
696706
use std::io;

0 commit comments

Comments
 (0)