]> git.lizzy.rs Git - rust.git/blob - src/librustc_target/spec/redox_base.rs
Rollup merge of #63332 - marmistrz:truncate, r=alexcrichton
[rust.git] / src / librustc_target / spec / redox_base.rs
1 use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions, RelroLevel};
2 use std::default::Default;
3
4 pub fn opts() -> TargetOptions {
5     let mut args = LinkArgs::new();
6     args.insert(LinkerFlavor::Gcc, vec![
7         // We want to be able to strip as much executable code as possible
8         // from the linker command line, and this flag indicates to the
9         // linker that it can avoid linking in dynamic libraries that don't
10         // actually satisfy any symbols up to that point (as with many other
11         // resolutions the linker does). This option only applies to all
12         // following libraries so we're sure to pass it as one of the first
13         // arguments.
14         "-Wl,--as-needed".to_string(),
15
16         // Always enable NX protection when it is available
17         "-Wl,-z,noexecstack".to_string()
18     ]);
19
20     TargetOptions {
21         dynamic_linking: true,
22         executables: true,
23         target_family: Some("unix".to_string()),
24         linker_is_gnu: true,
25         has_rpath: true,
26         pre_link_args: args,
27         position_independent_executables: true,
28         relro_level: RelroLevel::Full,
29         has_elf_tls: true,
30         crt_static_default: true,
31         crt_static_respected: true,
32         .. Default::default()
33     }
34 }