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