rustc_target/spec/base/
windows_gnullvm.rs

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