]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_target/src/spec/linux_base.rs
Auto merge of #77618 - fusion-engineering-forks:windows-parker, r=Amanieu
[rust.git] / compiler / rustc_target / src / spec / linux_base.rs
1 use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions};
2
3 pub fn opts() -> TargetOptions {
4     let mut args = LinkArgs::new();
5     args.insert(
6         LinkerFlavor::Gcc,
7         vec![
8             // We want to be able to strip as much executable code as possible
9             // from the linker command line, and this flag indicates to the
10             // linker that it can avoid linking in dynamic libraries that don't
11             // actually satisfy any symbols up to that point (as with many other
12             // resolutions the linker does). This option only applies to all
13             // following libraries so we're sure to pass it as one of the first
14             // arguments.
15             "-Wl,--as-needed".to_string(),
16             // Always enable NX protection when it is available
17             "-Wl,-z,noexecstack".to_string(),
18         ],
19     );
20
21     TargetOptions {
22         os: "linux".to_string(),
23         dynamic_linking: true,
24         executables: true,
25         os_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         crt_static_respected: true,
33         ..Default::default()
34     }
35 }