]> git.lizzy.rs Git - rust.git/blob - src/librustc_back/target/windows_base.rs
Remove morestack support
[rust.git] / src / librustc_back / target / windows_base.rs
1 // Copyright 2014 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 target::TargetOptions;
12 use std::default::Default;
13
14 pub fn opts() -> TargetOptions {
15     TargetOptions {
16         // FIXME(#13846) this should be enabled for windows
17         function_sections: false,
18         linker: "gcc".to_string(),
19         dynamic_linking: true,
20         executables: true,
21         dll_prefix: "".to_string(),
22         dll_suffix: ".dll".to_string(),
23         exe_suffix: ".exe".to_string(),
24         staticlib_prefix: "".to_string(),
25         staticlib_suffix: ".lib".to_string(),
26         is_like_windows: true,
27         archive_format: "gnu".to_string(),
28         pre_link_args: vec!(
29             // And here, we see obscure linker flags #45. On windows, it has been
30             // found to be necessary to have this flag to compile liblibc.
31             //
32             // First a bit of background. On Windows, the file format is not ELF,
33             // but COFF (at least according to LLVM). COFF doesn't officially allow
34             // for section names over 8 characters, apparently. Our metadata
35             // section, ".note.rustc", you'll note is over 8 characters.
36             //
37             // On more recent versions of gcc on mingw, apparently the section name
38             // is *not* truncated, but rather stored elsewhere in a separate lookup
39             // table. On older versions of gcc, they apparently always truncated th
40             // section names (at least in some cases). Truncating the section name
41             // actually creates "invalid" objects [1] [2], but only for some
42             // introspection tools, not in terms of whether it can be loaded.
43             //
44             // Long story short, passing this flag forces the linker to *not*
45             // truncate section names (so we can find the metadata section after
46             // it's compiled). The real kicker is that rust compiled just fine on
47             // windows for quite a long time *without* this flag, so I have no idea
48             // why it suddenly started failing for liblibc. Regardless, we
49             // definitely don't want section name truncation, so we're keeping this
50             // flag for windows.
51             //
52             // [1] - https://sourceware.org/bugzilla/show_bug.cgi?id=13130
53             // [2] - https://code.google.com/p/go/issues/detail?id=2139
54             "-Wl,--enable-long-section-names".to_string(),
55
56             // Tell GCC to avoid linker plugins, because we are not bundling
57             // them with Windows installer, and Rust does its own LTO anyways.
58             "-fno-use-linker-plugin".to_string(),
59
60             // Always enable DEP (NX bit) when it is available
61             "-Wl,--nxcompat".to_string(),
62         ),
63
64         .. Default::default()
65     }
66 }