]> git.lizzy.rs Git - rust.git/blob - src/librustc_target/spec/x86_64_fortanix_unknown_sgx.rs
Auto merge of #56926 - alexcrichton:update-stdsimd, r=TimNN
[rust.git] / src / librustc_target / spec / x86_64_fortanix_unknown_sgx.rs
1 // Copyright 2018 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 std::iter;
12
13 use super::{LinkerFlavor, PanicStrategy, Target, TargetOptions};
14
15 pub fn target() -> Result<Target, String> {
16     const PRE_LINK_ARGS: &[&str] = &[
17         "-Wl,--as-needed",
18         "-Wl,-z,noexecstack",
19         "-m64",
20         "-fuse-ld=gold",
21         "-nostdlib",
22         "-shared",
23         "-Wl,-e,sgx_entry",
24         "-Wl,-Bstatic",
25         "-Wl,--gc-sections",
26         "-Wl,-z,text",
27         "-Wl,-z,norelro",
28         "-Wl,--rosegment",
29         "-Wl,--no-undefined",
30         "-Wl,--error-unresolved-symbols",
31         "-Wl,--no-undefined-version",
32         "-Wl,-Bsymbolic",
33         "-Wl,--export-dynamic",
34     ];
35
36     const EXPORT_SYMBOLS: &[&str] = &[
37         "sgx_entry",
38         "HEAP_BASE",
39         "HEAP_SIZE",
40         "RELA",
41         "RELACOUNT",
42         "ENCLAVE_SIZE",
43         "CFGDATA_BASE",
44         "DEBUG",
45         "EH_FRM_HDR_BASE",
46         "EH_FRM_HDR_SIZE",
47         "TEXT_BASE",
48         "TEXT_SIZE",
49     ];
50     let opts = TargetOptions {
51         dynamic_linking: false,
52         executables: true,
53         linker_is_gnu: true,
54         max_atomic_width: Some(64),
55         panic_strategy: PanicStrategy::Unwind,
56         cpu: "x86-64".into(),
57         features: "+rdrnd,+rdseed".into(),
58         position_independent_executables: true,
59         pre_link_args: iter::once((
60             LinkerFlavor::Gcc,
61             PRE_LINK_ARGS.iter().cloned().map(String::from).collect(),
62         ))
63         .collect(),
64         post_link_objects: vec!["libunwind.a".into()],
65         override_export_symbols: Some(EXPORT_SYMBOLS.iter().cloned().map(String::from).collect()),
66         ..Default::default()
67     };
68     Ok(Target {
69         llvm_target: "x86_64-unknown-linux-gnu".into(),
70         target_endian: "little".into(),
71         target_pointer_width: "64".into(),
72         target_c_int_width: "32".into(),
73         target_os: "unknown".into(),
74         target_env: "sgx".into(),
75         target_vendor: "fortanix".into(),
76         data_layout: "e-m:e-i64:64-f80:128-n8:16:32:64-S128".into(),
77         arch: "x86_64".into(),
78         linker_flavor: LinkerFlavor::Gcc,
79         options: opts,
80     })
81 }