Skip to content

Commit 0b7c4f5

Browse files
committed
Add netbsd amd64 support
1 parent d2cf9f9 commit 0b7c4f5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+271
-41
lines changed

configure

+4
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,10 @@ case $CFG_OSTYPE in
405405
CFG_OSTYPE=unknown-openbsd
406406
;;
407407

408+
NetBSD)
409+
CFG_OSTYPE=unknown-netbsd
410+
;;
411+
408412
Darwin)
409413
CFG_OSTYPE=apple-darwin
410414
;;

mk/cfg/x86_64-unknown-netbsd.mk

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# x86_64-unknown-netbsd configuration
2+
CC_x86_64-unknown-netbsd=$(CC)
3+
CXX_x86_64-unknown-netbsd=$(CXX)
4+
CPP_x86_64-unknown-netbsd=$(CPP)
5+
AR_x86_64-unknown-netbsd=$(AR)
6+
CFG_LIB_NAME_x86_64-unknown-netbsd=lib$(1).so
7+
CFG_STATIC_LIB_NAME_x86_64-unknown-netbsd=lib$(1).a
8+
CFG_LIB_GLOB_x86_64-unknown-netbsd=lib$(1)-*.so
9+
CFG_LIB_DSYM_GLOB_x86_64-unknown-netbsd=$(1)-*.dylib.dSYM
10+
CFG_JEMALLOC_CFLAGS_x86_64-unknown-netbsd := -I/usr/local/include $(CFLAGS)
11+
CFG_GCCISH_CFLAGS_x86_64-unknown-netbsd := -Wall -Werror -g -fPIC -I/usr/local/include $(CFLAGS)
12+
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-netbsd := -shared -fPIC -g -pthread -lrt
13+
CFG_GCCISH_DEF_FLAG_x86_64-unknown-netbsd := -Wl,--export-dynamic,--dynamic-list=
14+
CFG_LLC_FLAGS_x86_64-unknown-netbsd :=
15+
CFG_INSTALL_NAME_x86_64-unknown-netbsd =
16+
CFG_EXE_SUFFIX_x86_64-unknown-netbsd :=
17+
CFG_WINDOWSY_x86_64-unknown-netbsd :=
18+
CFG_UNIXY_x86_64-unknown-netbsd := 1
19+
CFG_LDPATH_x86_64-unknown-netbsd :=
20+
CFG_RUN_x86_64-unknown-netbsd=$(2)
21+
CFG_RUN_TARG_x86_64-unknown-netbsd=$(call CFG_RUN_x86_64-unknown-netbsd,,$(2))
22+
CFG_GNU_TRIPLE_x86_64-unknown-netbsd := x86_64-unknown-netbsd

src/compiletest/util.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const OS_TABLE: &'static [(&'static str, &'static str)] = &[
2121
("ios", "ios"),
2222
("linux", "linux"),
2323
("mingw32", "windows"),
24+
("netbsd", "netbsd"),
2425
("openbsd", "openbsd"),
2526
("win32", "windows"),
2627
("windows", "windows"),

src/doc/reference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,7 @@ The following configurations must be defined by the implementation:
20232023
as a configuration itself, like `unix` or `windows`.
20242024
* `target_os = "..."`. Operating system of the target, examples include
20252025
`"windows"`, `"macos"`, `"ios"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"`,
2026-
`"bitrig"` or `"openbsd"`.
2026+
`"bitrig"` , `"openbsd"` or `"netbsd"`.
20272027
* `target_pointer_width = "..."`. Target pointer width in bits. This is set
20282028
to `"32"` for targets with 32-bit pointers, and likewise set to `"64"` for
20292029
64-bit pointers.

src/etc/snapshot.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ def scrub(b):
4141
download_unpack_base = os.path.join(download_dir_base, "unpack")
4242

4343
snapshot_files = {
44+
"bitrig": ["bin/rustc"],
45+
"dragonfly": ["bin/rustc"],
46+
"freebsd": ["bin/rustc"],
4447
"linux": ["bin/rustc"],
4548
"macos": ["bin/rustc"],
46-
"winnt": ["bin/rustc.exe"],
47-
"freebsd": ["bin/rustc"],
48-
"dragonfly": ["bin/rustc"],
49-
"bitrig": ["bin/rustc"],
49+
"netbsd": ["bin/rustc"],
5050
"openbsd": ["bin/rustc"],
51+
"winnt": ["bin/rustc.exe"],
5152
}
5253

5354
winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll", "libstdc++-6.dll"]
@@ -103,6 +104,8 @@ def get_kernel(triple):
103104
return "dragonfly"
104105
if os_name == "bitrig":
105106
return "bitrig"
107+
if os_name == "netbsd":
108+
return "netbsd"
106109
if os_name == "openbsd":
107110
return "openbsd"
108111
return "linux"

src/liblibc/lib.rs

+18-10
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ pub mod types {
13221322
}
13231323
}
13241324

1325-
#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
1325+
#[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))]
13261326
pub mod os {
13271327
pub mod common {
13281328
pub mod posix01 {
@@ -1351,7 +1351,7 @@ pub mod types {
13511351
pub __unused7: *mut c_void,
13521352
}
13531353

1354-
#[cfg(target_os = "openbsd")]
1354+
#[cfg(any(target_os = "netbsd", target_os="openbsd"))]
13551355
#[repr(C)]
13561356
#[derive(Copy, Clone)] pub struct glob_t {
13571357
pub gl_pathc: c_int,
@@ -4323,7 +4323,7 @@ pub mod consts {
43234323
}
43244324
}
43254325

4326-
#[cfg(any(target_os = "bitrig", target_os = "openbsd"))]
4326+
#[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"))]
43274327
pub mod os {
43284328
pub mod c95 {
43294329
use types::os::arch::c95::{c_int, c_uint};
@@ -5568,6 +5568,7 @@ pub mod funcs {
55685568
target_os = "freebsd",
55695569
target_os = "dragonfly",
55705570
target_os = "bitrig",
5571+
target_os = "netbsd",
55715572
target_os = "openbsd",
55725573
target_os = "nacl"))]
55735574
pub mod posix88 {
@@ -5584,6 +5585,7 @@ pub mod funcs {
55845585
target_os = "freebsd",
55855586
target_os = "dragonfly",
55865587
target_os = "bitrig",
5588+
target_os = "netbsd",
55875589
target_os = "openbsd",
55885590
target_os = "android",
55895591
target_os = "ios",
@@ -5602,6 +5604,7 @@ pub mod funcs {
56025604
target_os = "freebsd",
56035605
target_os = "dragonfly",
56045606
target_os = "bitrig",
5607+
target_os = "netbsd",
56055608
target_os = "openbsd",
56065609
target_os = "android",
56075610
target_os = "ios",
@@ -5889,6 +5892,7 @@ pub mod funcs {
58895892
target_os = "freebsd",
58905893
target_os = "dragonfly",
58915894
target_os = "bitrig",
5895+
target_os = "netbsd",
58925896
target_os = "openbsd",
58935897
target_os = "nacl"))]
58945898
pub mod posix01 {
@@ -5901,6 +5905,7 @@ pub mod funcs {
59015905
target_os = "freebsd",
59025906
target_os = "dragonfly",
59035907
target_os = "bitrig",
5908+
target_os = "netbsd",
59045909
target_os = "openbsd",
59055910
target_os = "android",
59065911
target_os = "ios",
@@ -6019,16 +6024,17 @@ pub mod funcs {
60196024
}
60206025

60216026

6022-
#[cfg(any(target_os = "windows",
6023-
target_os = "linux",
6024-
target_os = "android",
6025-
target_os = "macos",
6027+
#[cfg(any(target_os = "android",
6028+
target_os = "bitrig",
6029+
target_os = "dragonfly",
60266030
target_os = "ios",
60276031
target_os = "freebsd",
6028-
target_os = "dragonfly",
6029-
target_os = "bitrig",
6032+
target_os = "linux",
6033+
target_os = "macos",
6034+
target_os = "nacl",
6035+
target_os = "netbsd",
60306036
target_os = "openbsd",
6031-
target_os = "nacl"))]
6037+
target_os = "windows"))]
60326038
pub mod posix08 {
60336039
pub mod unistd {
60346040
}
@@ -6115,6 +6121,7 @@ pub mod funcs {
61156121
target_os = "freebsd",
61166122
target_os = "dragonfly",
61176123
target_os = "bitrig",
6124+
target_os = "netbsd",
61186125
target_os = "openbsd"))]
61196126
pub mod bsd44 {
61206127
use types::common::c95::{c_void};
@@ -6192,6 +6199,7 @@ pub mod funcs {
61926199
#[cfg(any(target_os = "freebsd",
61936200
target_os = "dragonfly",
61946201
target_os = "bitrig",
6202+
target_os = "netbsd",
61956203
target_os = "openbsd"))]
61966204
pub mod extra {
61976205
}

src/librustc_back/arm.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
6161
-a:0:64-n32".to_string()
6262
}
6363

64-
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
64+
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
6565
"e-p:32:32:32\
6666
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
6767
-f32:32:32-f64:64:64\

src/librustc_back/mips.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
5656
-a:0:64-n32".to_string()
5757
}
5858

59-
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
59+
abi::OsBitrig | abi::OsDragonfly | abi::OsFreebsd | abi::OsNetbsd | abi::OsOpenbsd => {
6060
"E-p:32:32:32\
6161
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
6262
-f32:32:32-f64:64:64\

src/librustc_back/mipsel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
5656
-a:0:64-n32".to_string()
5757
}
5858

59-
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
59+
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
6060
"e-p:32:32:32\
6161
-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64\
6262
-f32:32:32-f64:64:64\

src/librustc_back/target/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ mod dragonfly_base;
5858
mod freebsd_base;
5959
mod linux_base;
6060
mod openbsd_base;
61+
mod netbsd_base;
6162
mod windows_base;
6263
mod windows_msvc_base;
6364

@@ -368,6 +369,7 @@ impl Target {
368369

369370
x86_64_unknown_bitrig,
370371
x86_64_unknown_openbsd,
372+
x86_64_unknown_netbsd,
371373

372374
x86_64_apple_darwin,
373375
i686_apple_darwin,
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2014-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+
use target::TargetOptions;
12+
use std::default::Default;
13+
14+
pub fn opts() -> TargetOptions {
15+
TargetOptions {
16+
linker: "cc".to_string(),
17+
dynamic_linking: true,
18+
executables: true,
19+
morestack: false,
20+
linker_is_gnu: true,
21+
has_rpath: true,
22+
pre_link_args: vec!(
23+
// GNU-style linkers will use this to omit linking to libraries
24+
// which don't actually fulfill any relocations, but only for
25+
// libraries which follow this flag. Thus, use it before
26+
// specifying libraries to link to.
27+
"-Wl,--as-needed".to_string(),
28+
),
29+
position_independent_executables: true,
30+
.. Default::default()
31+
}
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2014-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+
use target::Target;
12+
13+
pub fn target() -> Target {
14+
let mut base = super::netbsd_base::opts();
15+
base.pre_link_args.push("-m64".to_string());
16+
17+
Target {
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-a:0:64-\
20+
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string(),
21+
llvm_target: "x86_64-unknown-netbsd".to_string(),
22+
target_endian: "little".to_string(),
23+
target_pointer_width: "64".to_string(),
24+
arch: "x86_64".to_string(),
25+
target_os: "netbsd".to_string(),
26+
target_env: "".to_string(),
27+
options: base,
28+
}
29+
}

src/librustc_back/x86.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os)
4545
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
4646
}
4747

48-
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
48+
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd | abi::OsNetbsd => {
4949
"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
5050
}
5151

src/librustc_back/x86_64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
4747
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
4848
}
4949

50-
abi::OsFreebsd | abi::OsDragonfly | abi::OsBitrig | abi::OsOpenbsd => {
50+
abi::OsBitrig | abi::OsDragonfly | abi::OsFreebsd | abi::OsNetbsd | abi::OsOpenbsd => {
5151
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-\
5252
f32:32:32-f64:64:64-v64:64:64-v128:128:128-a:0:64-\
5353
s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()

src/librustdoc/flock.rs

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ mod imp {
6868

6969
#[cfg(any(target_os = "dragonfly",
7070
target_os = "bitrig",
71+
target_os = "netbsd",
7172
target_os = "openbsd"))]
7273
mod os {
7374
use libc;

src/libstd/dynamic_lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ mod tests {
160160
target_os = "freebsd",
161161
target_os = "dragonfly",
162162
target_os = "bitrig",
163+
target_os = "netbsd",
163164
target_os = "openbsd"))]
164165
fn test_errors_do_not_crash() {
165166
// Open /dev/null as a library to get an error, and make sure
@@ -179,6 +180,7 @@ mod tests {
179180
target_os = "freebsd",
180181
target_os = "dragonfly",
181182
target_os = "bitrig",
183+
target_os = "netbsd",
182184
target_os = "openbsd"))]
183185
mod dl {
184186
use prelude::v1::*;

src/libstd/env.rs

+12
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ pub mod consts {
633633
/// - freebsd
634634
/// - dragonfly
635635
/// - bitrig
636+
/// - netbsd
636637
/// - openbsd
637638
/// - android
638639
/// - windows
@@ -759,6 +760,17 @@ mod os {
759760
pub const EXE_EXTENSION: &'static str = "";
760761
}
761762

763+
#[cfg(target_os = "netbsd")]
764+
mod os {
765+
pub const FAMILY: &'static str = "unix";
766+
pub const OS: &'static str = "netbsd";
767+
pub const DLL_PREFIX: &'static str = "lib";
768+
pub const DLL_SUFFIX: &'static str = ".so";
769+
pub const DLL_EXTENSION: &'static str = "so";
770+
pub const EXE_SUFFIX: &'static str = "";
771+
pub const EXE_EXTENSION: &'static str = "";
772+
}
773+
762774
#[cfg(target_os = "openbsd")]
763775
mod os {
764776
pub const FAMILY: &'static str = "unix";

src/libstd/net/tcp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ mod tests {
904904

905905
// FIXME: re-enabled bitrig/openbsd tests once their socket timeout code
906906
// no longer has rounding errors.
907-
#[cfg_attr(any(target_os = "bitrig", target_os = "openbsd"), ignore)]
907+
#[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)]
908908
#[test]
909909
fn timeouts() {
910910
let addr = next_test_ip4();

src/libstd/net/udp.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,9 @@ mod tests {
360360
assert_eq!(format!("{:?}", udpsock), compare);
361361
}
362362

363-
// FIXME: re-enabled bitrig/openbsd tests once their socket timeout code
363+
// FIXME: re-enabled bitrig/openbsd/netbsd tests once their socket timeout code
364364
// no longer has rounding errors.
365-
#[cfg_attr(any(target_os = "bitrig", target_os = "openbsd"), ignore)]
365+
#[cfg_attr(any(target_os = "bitrig", target_os = "netbsd", target_os = "openbsd"), ignore)]
366366
#[test]
367367
fn timeouts() {
368368
let addr = next_test_ip4();

src/libstd/os/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#[cfg(target_os = "linux")] pub mod linux;
2525
#[cfg(target_os = "macos")] pub mod macos;
2626
#[cfg(target_os = "nacl")] pub mod nacl;
27+
#[cfg(target_os = "netbsd")] pub mod netbsd;
2728
#[cfg(target_os = "openbsd")] pub mod openbsd;
2829

2930
pub mod raw;

0 commit comments

Comments
 (0)