Skip to content

Commit 955a4ea

Browse files
committed
Add redox target
1 parent 8f02c42 commit 955a4ea

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

src/librustc_back/target/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ mod windows_base;
6969
mod windows_msvc_base;
7070
mod thumb_base;
7171
mod fuchsia_base;
72+
mod redox_base;
7273

7374
pub type TargetResult = Result<Target, String>;
7475

@@ -184,6 +185,8 @@ supported_targets! {
184185
("aarch64-unknown-fuchsia", aarch64_unknown_fuchsia),
185186
("x86_64-unknown-fuchsia", x86_64_unknown_fuchsia),
186187

188+
("x86_64-unknown-redox", x86_64_unknown_redox),
189+
187190
("i386-apple-ios", i386_apple_ios),
188191
("x86_64-apple-ios", x86_64_apple_ios),
189192
("aarch64-apple-ios", aarch64_apple_ios),
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
pre_link_args: vec![
17+
// We want to be able to strip as much executable code as possible
18+
// from the linker command line, and this flag indicates to the
19+
// linker that it can avoid linking in dynamic libraries that don't
20+
// actually satisfy any symbols up to that point (as with many other
21+
// resolutions the linker does). This option only applies to all
22+
// following libraries so we're sure to pass it as one of the first
23+
// arguments.
24+
"-Wl,--as-needed".to_string(),
25+
26+
// Always enable NX protection when it is available
27+
"-Wl,-z,noexecstack".to_string(),
28+
29+
// Do not link libc
30+
"-nostdlib".to_string(),
31+
32+
// Static link
33+
"-static".to_string()
34+
],
35+
executables: true,
36+
relocation_modal: "static".to_string(),
37+
disable_redzone: true,
38+
eliminate_frame_pointer: false,
39+
linker_is_gnu: true,
40+
no_compiler_rt: true,
41+
no_default_libraries: true,
42+
has_elf_tls: true,
43+
.. Default::default()
44+
}
45+
}
Lines changed: 30 additions & 0 deletions
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::redox_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-redox".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: "redox".to_string(),
26+
target_env: "".to_string(),
27+
target_vendor: "unknown".to_string(),
28+
options: base,
29+
})
30+
}

0 commit comments

Comments
 (0)