Skip to content

Commit ead198c

Browse files
committed
auto merge of #20024 : mneumann/rust/dragonfly-fixes3, r=alexcrichton
2 parents 65248c5 + 4c3a8f1 commit ead198c

File tree

7 files changed

+46
-26
lines changed

7 files changed

+46
-26
lines changed

mk/cfg/x86_64-unknown-dragonfly.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ CFG_LIB_NAME_x86_64-unknown-dragonfly=lib$(1).so
77
CFG_STATIC_LIB_NAME_x86_64-unknown-dragonfly=lib$(1).a
88
CFG_LIB_GLOB_x86_64-unknown-dragonfly=lib$(1)-*.so
99
CFG_LIB_DSYM_GLOB_x86_64-unknown-dragonfly=$(1)-*.dylib.dSYM
10-
CFG_JEMALLOC_CFLAGS_x86_64-unknown-dragonfly := -I/usr/include -I/usr/local/include $(CFLAGS)
11-
CFG_GCCISH_CFLAGS_x86_64-unknown-dragonfly := -Wall -Werror -g -fPIC -I/usr/include -I/usr/local/include $(CFLAGS)
12-
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-dragonfly := -shared -fPIC -g -pthread -lrt
10+
CFG_JEMALLOC_CFLAGS_x86_64-unknown-dragonfly := -m64 -I/usr/include -I/usr/local/include $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_x86_64-unknown-dragonfly := -Wall -Werror -g -fPIC -m64 -I/usr/include -I/usr/local/include $(CFLAGS)
12+
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-dragonfly := -shared -fPIC -g -pthread -lrt -m64
1313
CFG_GCCISH_DEF_FLAG_x86_64-unknown-dragonfly := -Wl,--export-dynamic,--dynamic-list=
1414
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-whole-archive
1515
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-dragonfly := -Wl,-no-whole-archive

src/etc/snapshot.py

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def scrub(b):
3737
"macos": ["bin/rustc"],
3838
"winnt": ["bin/rustc.exe"],
3939
"freebsd": ["bin/rustc"],
40+
"dragonfly": ["bin/rustc"],
4041
}
4142

4243
winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll",
@@ -86,6 +87,8 @@ def get_kernel(triple):
8687
return "macos"
8788
if os_name == "freebsd":
8889
return "freebsd"
90+
if os_name == "dragonfly":
91+
return "dragonfly"
8992
return "linux"
9093

9194
def get_cpu(triple):

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

+8-3
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ pub fn opts() -> TargetOptions {
1717
dynamic_linking: true,
1818
executables: true,
1919
morestack: true,
20+
linker_is_gnu: true,
2021
has_rpath: true,
2122
pre_link_args: vec!(
2223
"-L/usr/local/lib".to_string(),
23-
"-L/usr/local/lib/gcc47".to_string(),
24-
"-L/usr/local/lib/gcc44".to_string(),
24+
"-L/usr/lib/gcc47".to_string(),
25+
// GNU-style linkers will use this to omit linking to libraries
26+
// which don't actually fulfill any relocations, but only for
27+
// libraries which follow this flag. Thus, use it before
28+
// specifying libraries to link to.
29+
"-Wl,--as-needed".to_string(),
2530
),
26-
31+
position_independent_executables: true,
2732
.. Default::default()
2833
}
2934
}

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/sys/unix/os.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ pub fn join_paths<T: BytesContainer>(paths: &[T]) -> Result<Vec<u8>, &'static st
172172
Ok(joined)
173173
}
174174

175-
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
175+
#[cfg(target_os = "freebsd")]
176176
pub fn load_self() -> Option<Vec<u8>> {
177177
unsafe {
178178
use libc::funcs::bsd44::*;
@@ -198,6 +198,16 @@ pub fn load_self() -> Option<Vec<u8>> {
198198
}
199199
}
200200

201+
#[cfg(target_os = "dragonfly")]
202+
pub fn load_self() -> Option<Vec<u8>> {
203+
use std::io;
204+
205+
match io::fs::readlink(&Path::new("/proc/curproc/file")) {
206+
Ok(path) => Some(path.into_vec()),
207+
Err(..) => None
208+
}
209+
}
210+
201211
#[cfg(any(target_os = "linux", target_os = "android"))]
202212
pub fn load_self() -> Option<Vec<u8>> {
203213
use std::io;

0 commit comments

Comments
 (0)