]> git.lizzy.rs Git - rust.git/blob - src/librustc_target/spec/windows_uwp_msvc_base.rs
linker: Pass `/NODEFAULTLIB` in a more regular way
[rust.git] / src / librustc_target / spec / windows_uwp_msvc_base.rs
1 use crate::spec::{LinkArgs, LinkerFlavor, LldFlavor, TargetOptions};
2 use std::default::Default;
3
4 pub fn opts() -> TargetOptions {
5     let pre_link_args_msvc = vec![
6         "/NOLOGO".to_string(),
7         "/NXCOMPAT".to_string(),
8         "/APPCONTAINER".to_string(),
9         "mincore.lib".to_string(),
10     ];
11     let mut pre_link_args = LinkArgs::new();
12     pre_link_args.insert(LinkerFlavor::Msvc, pre_link_args_msvc.clone());
13     pre_link_args.insert(LinkerFlavor::Lld(LldFlavor::Link), pre_link_args_msvc);
14
15     TargetOptions {
16         function_sections: true,
17         dynamic_linking: true,
18         executables: true,
19         dll_prefix: String::new(),
20         dll_suffix: ".dll".to_string(),
21         exe_suffix: ".exe".to_string(),
22         staticlib_prefix: String::new(),
23         staticlib_suffix: ".lib".to_string(),
24         target_family: Some("windows".to_string()),
25         is_like_windows: true,
26         is_like_msvc: true,
27         pre_link_args,
28         crt_static_allows_dylibs: true,
29         crt_static_respected: true,
30         abi_return_struct_as_int: true,
31         emit_debug_gdb_scripts: false,
32         requires_uwtable: true,
33         lld_flavor: LldFlavor::Link,
34         // Currently we don't pass the /NODEFAULTLIB flag to the linker on MSVC
35         // as there's been trouble in the past of linking the C++ standard
36         // library required by LLVM. This likely needs to happen one day, but
37         // in general Windows is also a more controlled environment than
38         // Unix, so it's not necessarily as critical that this be implemented.
39         //
40         // Note that there are also some licensing worries about statically
41         // linking some libraries which require a specific agreement, so it may
42         // not ever be possible for us to pass this flag.
43         no_default_libraries: false,
44
45         ..Default::default()
46     }
47 }