Skip to content

Commit 3caf63c

Browse files
authored
Auto merge of #37313 - raphlinus:fuchsia, r=alexcrichton
Add Fuchsia support Adds support for the x86_64-unknown-fuchsia target, which covers the Fuchsia operating system.
2 parents 7bd2427 + cea6140 commit 3caf63c

File tree

21 files changed

+545
-40
lines changed

21 files changed

+545
-40
lines changed

mk/cfg/x86_64-unknown-fuchsia.mk

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# rustbuild-only target

src/liballoc_jemalloc/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ fn main() {
3636
// targets, which means we have to build the alloc_jemalloc crate
3737
// for targets like emscripten, even if we don't use it.
3838
if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") ||
39-
target.contains("msvc") || target.contains("emscripten") {
39+
target.contains("msvc") || target.contains("emscripten") || target.contains("fuchsia") {
4040
println!("cargo:rustc-cfg=dummy_jemalloc");
4141
return;
4242
}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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::TargetOptions;
12+
use std::default::Default;
13+
14+
pub fn opts() -> TargetOptions {
15+
TargetOptions {
16+
dynamic_linking: true,
17+
executables: true,
18+
linker_is_gnu: true,
19+
has_rpath: true,
20+
pre_link_args: vec![
21+
// We want to be able to strip as much executable code as possible
22+
// from the linker command line, and this flag indicates to the
23+
// linker that it can avoid linking in dynamic libraries that don't
24+
// actually satisfy any symbols up to that point (as with many other
25+
// resolutions the linker does). This option only applies to all
26+
// following libraries so we're sure to pass it as one of the first
27+
// arguments.
28+
// FIXME: figure out whether these linker args are desirable
29+
//"-Wl,--as-needed".to_string(),
30+
31+
// Always enable NX protection when it is available
32+
//"-Wl,-z,noexecstack".to_string(),
33+
],
34+
position_independent_executables: true,
35+
exe_allocation_crate: "alloc_system".to_string(),
36+
has_elf_tls: true,
37+
.. Default::default()
38+
}
39+
}

src/librustc_back/target/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ mod solaris_base;
6767
mod windows_base;
6868
mod windows_msvc_base;
6969
mod thumb_base;
70+
mod fuchsia_base;
7071

7172
pub type TargetResult = Result<Target, String>;
7273

@@ -175,6 +176,8 @@ supported_targets! {
175176
("x86_64-apple-darwin", x86_64_apple_darwin),
176177
("i686-apple-darwin", i686_apple_darwin),
177178

179+
("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia),
180+
178181
("i386-apple-ios", i386_apple_ios),
179182
("x86_64-apple-ios", x86_64_apple_ios),
180183
("aarch64-apple-ios", aarch64_apple_ios),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright 2016 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, TargetResult};
12+
13+
pub fn target() -> TargetResult {
14+
let mut base = super::fuchsia_base::opts();
15+
base.cpu = "x86-64".to_string();
16+
base.max_atomic_width = Some(64);
17+
base.pre_link_args.push("-m64".to_string());
18+
19+
Ok(Target {
20+
llvm_target: "x86_64-unknown-fuchsia".to_string(),
21+
target_endian: "little".to_string(),
22+
target_pointer_width: "64".to_string(),
23+
data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".to_string(),
24+
arch: "x86_64".to_string(),
25+
target_os: "fuchsia".to_string(),
26+
target_env: "".to_string(),
27+
target_vendor: "unknown".to_string(),
28+
options: base,
29+
})
30+
}

src/libstd/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn main() {
2626
let target = env::var("TARGET").expect("TARGET was not set");
2727
let host = env::var("HOST").expect("HOST was not set");
2828
if cfg!(feature = "backtrace") && !target.contains("apple") && !target.contains("msvc") &&
29-
!target.contains("emscripten") {
29+
!target.contains("emscripten") && !target.contains("fuchsia") {
3030
build_libbacktrace(&host, &target);
3131
}
3232

src/libstd/os/fuchsia/fs.rs

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
// Copyright 2016 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+
#![stable(feature = "metadata_ext", since = "1.1.0")]
12+
13+
use fs::Metadata;
14+
use sys_common::AsInner;
15+
16+
/// OS-specific extension methods for `fs::Metadata`
17+
#[stable(feature = "metadata_ext", since = "1.1.0")]
18+
pub trait MetadataExt {
19+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
20+
fn st_dev(&self) -> u64;
21+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
22+
fn st_ino(&self) -> u64;
23+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
24+
fn st_mode(&self) -> u32;
25+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
26+
fn st_nlink(&self) -> u64;
27+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
28+
fn st_uid(&self) -> u32;
29+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
30+
fn st_gid(&self) -> u32;
31+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
32+
fn st_rdev(&self) -> u64;
33+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
34+
fn st_size(&self) -> u64;
35+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
36+
fn st_atime(&self) -> i64;
37+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
38+
fn st_atime_nsec(&self) -> i64;
39+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
40+
fn st_mtime(&self) -> i64;
41+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
42+
fn st_mtime_nsec(&self) -> i64;
43+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
44+
fn st_ctime(&self) -> i64;
45+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
46+
fn st_ctime_nsec(&self) -> i64;
47+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
48+
fn st_blksize(&self) -> u64;
49+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
50+
fn st_blocks(&self) -> u64;
51+
}
52+
53+
#[stable(feature = "metadata_ext", since = "1.1.0")]
54+
impl MetadataExt for Metadata {
55+
fn st_dev(&self) -> u64 {
56+
self.as_inner().as_inner().st_dev as u64
57+
}
58+
fn st_ino(&self) -> u64 {
59+
self.as_inner().as_inner().st_ino as u64
60+
}
61+
fn st_mode(&self) -> u32 {
62+
self.as_inner().as_inner().st_mode as u32
63+
}
64+
fn st_nlink(&self) -> u64 {
65+
self.as_inner().as_inner().st_nlink as u64
66+
}
67+
fn st_uid(&self) -> u32 {
68+
self.as_inner().as_inner().st_uid as u32
69+
}
70+
fn st_gid(&self) -> u32 {
71+
self.as_inner().as_inner().st_gid as u32
72+
}
73+
fn st_rdev(&self) -> u64 {
74+
self.as_inner().as_inner().st_rdev as u64
75+
}
76+
fn st_size(&self) -> u64 {
77+
self.as_inner().as_inner().st_size as u64
78+
}
79+
fn st_atime(&self) -> i64 {
80+
self.as_inner().as_inner().st_atime as i64
81+
}
82+
fn st_atime_nsec(&self) -> i64 {
83+
self.as_inner().as_inner().st_atime_nsec as i64
84+
}
85+
fn st_mtime(&self) -> i64 {
86+
self.as_inner().as_inner().st_mtime as i64
87+
}
88+
fn st_mtime_nsec(&self) -> i64 {
89+
self.as_inner().as_inner().st_mtime_nsec as i64
90+
}
91+
fn st_ctime(&self) -> i64 {
92+
self.as_inner().as_inner().st_ctime as i64
93+
}
94+
fn st_ctime_nsec(&self) -> i64 {
95+
self.as_inner().as_inner().st_ctime_nsec as i64
96+
}
97+
fn st_blksize(&self) -> u64 {
98+
self.as_inner().as_inner().st_blksize as u64
99+
}
100+
fn st_blocks(&self) -> u64 {
101+
self.as_inner().as_inner().st_blocks as u64
102+
}
103+
}

src/libstd/os/fuchsia/mod.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 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+
//! Fuchsia-specific definitions
12+
13+
#![stable(feature = "raw_ext", since = "1.1.0")]
14+
15+
pub mod raw;
16+
pub mod fs;

0 commit comments

Comments
 (0)