rustc_target/spec/base/
windows_gnullvm.rs

1use std::borrow::Cow;
2
3use crate::spec::{Cc, DebuginfoKind, LinkerFlavor, Lld, SplitDebuginfo, TargetOptions, cvs};
4
5pub(crate) fn opts() -> TargetOptions {
6    // We cannot use `-nodefaultlibs` because compiler-rt has to be passed
7    // as a path since it's not added to linker search path by the default.
8    // There were attempts to make it behave like libgcc (so one can just use -l<name>)
9    // but LLVM maintainers rejected it: https://reviews.llvm.org/D51440
10    let pre_link_args = TargetOptions::link_args(
11        LinkerFlavor::Gnu(Cc::Yes, Lld::No),
12        &["-nolibc", "--unwindlib=none"],
13    );
14    // Order of `late_link_args*` does not matter with LLD.
15    let late_link_args = TargetOptions::link_args(
16        LinkerFlavor::Gnu(Cc::Yes, Lld::No),
17        &["-lmingw32", "-lmingwex", "-lmsvcrt", "-lkernel32", "-luser32"],
18    );
19
20    TargetOptions {
21        os: "windows".into(),
22        env: "gnu".into(),
23        vendor: "pc".into(),
24        abi: "llvm".into(),
25        linker: Some("clang".into()),
26        dynamic_linking: true,
27        dll_tls_export: false,
28        dll_prefix: "".into(),
29        dll_suffix: ".dll".into(),
30        exe_suffix: ".exe".into(),
31        families: cvs!["windows"],
32        is_like_windows: true,
33        allows_weak_linkage: false,
34        pre_link_args,
35        late_link_args,
36        abi_return_struct_as_int: true,
37        emit_debug_gdb_scripts: false,
38        requires_uwtable: true,
39        eh_frame_header: false,
40        no_default_libraries: false,
41        has_thread_local: true,
42        crt_static_allows_dylibs: true,
43        crt_static_respected: true,
44        debuginfo_kind: DebuginfoKind::Dwarf,
45        // FIXME(davidtwco): Support Split DWARF on Windows GNU - may require LLVM changes to
46        // output DWO, despite using DWARF, doesn't use ELF..
47        supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
48        ..Default::default()
49    }
50}