Skip to content

Several fixes for DragonFly #19852

New issue

Have a question about this project? No Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “No Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? No Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,7 @@ pub mod types {
pub type sighandler_t = size_t;
}
pub mod bsd44 {
use types::common::c95::{c_void};
use types::os::arch::c95::{c_char, c_int, c_uint};

pub type socklen_t = u32;
Expand Down Expand Up @@ -1167,6 +1168,17 @@ pub mod types {
pub sun_family: sa_family_t,
pub sun_path: [c_char, ..104]
}
#[repr(C)]
#[deriving(Copy)] pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: c_uint,
pub ifa_addr: *mut sockaddr,
pub ifa_netmask: *mut sockaddr,
pub ifa_dstaddr: *mut sockaddr,
pub ifa_data: *mut c_void
}

}
}

Expand Down
17 changes: 1 addition & 16 deletions src/librustc_back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,22 +215,7 @@ mod test {
}

#[test]
#[cfg(target_os = "freebsd")]
fn test_rpath_relative() {
let config = &mut RPathConfig {
used_crates: Vec::new(),
has_rpath: true,
is_like_osx: false,
out_filename: Path::new("bin/rustc"),
get_install_prefix_lib_path: || panic!(),
realpath: |p| Ok(p.clone())
};
let res = get_rpath_relative_to_output(config, &Path::new("lib/libstd.so"));
assert_eq!(res, "$ORIGIN/../lib");
}

#[test]
#[cfg(target_os = "dragonfly")]
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
fn test_rpath_relative() {
let config = &mut RPathConfig {
used_crates: Vec::new(),
Expand Down
11 changes: 8 additions & 3 deletions src/librustc_back/target/x86_64_unknown_dragonfly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@
use target::Target;

pub fn target() -> Target {
let mut base = super::dragonfly_base::opts();
base.pre_link_args.push("-m64".to_string());

Target {
data_layout: "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string(),
data_layout: "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-\
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
llvm_target: "x86_64-unknown-dragonfly".to_string(),
target_endian: "little".to_string(),
target_word_size: "32".to_string(),
target_word_size: "64".to_string(),
arch: "x86_64".to_string(),
target_os: "dragonfly".to_string(),
options: super::dragonfly_base::opts()
options: base,
}
}
12 changes: 11 additions & 1 deletion src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ pub fn dll_filename(base: &str) -> String {
/// ```
pub fn self_exe_name() -> Option<Path> {

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

#[cfg(target_os = "dragonfly")]
fn load_self() -> Option<Vec<u8>> {
use std::io;

match io::fs::readlink(&Path::new("/proc/curproc/file")) {
Ok(path) => Some(path.into_vec()),
Err(..) => None
}
}

#[cfg(any(target_os = "linux", target_os = "android"))]
fn load_self() -> Option<Vec<u8>> {
use std::io;
Expand Down