-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
0007-clang-subsystem.patch
83 lines (81 loc) · 4.29 KB
/
0007-clang-subsystem.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
diff -urN rustc-1.52.1-src.orig/compiler/rustc_target/src/spec/windows_gnu_base.rs rustc-1.52.1-src/compiler/rustc_target/src/spec/windows_gnu_base.rs
--- rustc-1.52.1-src.orig/compiler/rustc_target/src/spec/windows_gnu_base.rs 2021-05-09 04:52:39.000000000 +0200
+++ rustc-1.52.1-src/compiler/rustc_target/src/spec/windows_gnu_base.rs 2021-06-06 22:12:33.367953300 +0200
@@ -18,34 +18,13 @@
],
);
- let mut late_link_args = LinkArgs::new();
let mut late_link_args_dynamic = LinkArgs::new();
let mut late_link_args_static = LinkArgs::new();
- // Order of `late_link_args*` was found through trial and error to work with various
- // mingw-w64 versions (not tested on the CI). It's expected to change from time to time.
- let mingw_libs = vec![
- "-lmsvcrt".to_string(),
- "-lmingwex".to_string(),
- "-lmingw32".to_string(),
- "-lgcc".to_string(), // alas, mingw* libraries above depend on libgcc
- // mingw's msvcrt is a weird hybrid import library and static library.
- // And it seems that the linker fails to use import symbols from msvcrt
- // that are required from functions in msvcrt in certain cases. For example
- // `_fmode` that is used by an implementation of `__p__fmode` in x86_64.
- // The library is purposely listed twice to fix that.
- //
- // See https://github.com/rust-lang/rust/pull/47483 for some more details.
- "-lmsvcrt".to_string(),
- "-luser32".to_string(),
- "-lkernel32".to_string(),
- ];
- late_link_args.insert(LinkerFlavor::Gcc, mingw_libs.clone());
- late_link_args.insert(LinkerFlavor::Lld(LldFlavor::Ld), mingw_libs);
let dynamic_unwind_libs = vec![
// If any of our crates are dynamically linked then we need to use
// the shared libgcc_s-dw2-1.dll. This is required to support
// unwinding across DLL boundaries.
- "-lgcc_s".to_string(),
+ "-l:libunwind.dll.a".to_string(),
];
late_link_args_dynamic.insert(LinkerFlavor::Gcc, dynamic_unwind_libs.clone());
late_link_args_dynamic.insert(LinkerFlavor::Lld(LldFlavor::Ld), dynamic_unwind_libs);
@@ -55,8 +34,7 @@
// binaries to be redistributed without the libgcc_s-dw2-1.dll
// dependency, but unfortunately break unwinding across DLL
// boundaries when unwinding across FFI boundaries.
- "-lgcc_eh".to_string(),
- "-l:libpthread.a".to_string(),
+ "-l:libunwind.a".to_string(),
];
late_link_args_static.insert(LinkerFlavor::Gcc, static_unwind_libs.clone());
late_link_args_static.insert(LinkerFlavor::Lld(LldFlavor::Ld), static_unwind_libs);
@@ -66,7 +44,8 @@
env: "gnu".to_string(),
vendor: "pc".to_string(),
// FIXME(#13846) this should be enabled for windows
- function_sections: false,
+ function_sections: true,
+ no_default_libraries: false,
linker: Some("gcc".to_string()),
dynamic_linking: true,
executables: true,
@@ -84,7 +63,6 @@
pre_link_objects_fallback: crt_objects::pre_mingw_fallback(),
post_link_objects_fallback: crt_objects::post_mingw_fallback(),
crt_objects_fallback: Some(CrtObjectsFallback::Mingw),
- late_link_args,
late_link_args_dynamic,
late_link_args_static,
abi_return_struct_as_int: true,
diff -urN rustc-1.53.0-src/src/bootstrap/bootstrap.py.orig rustc-1.53.0-src/src/bootstrap/bootstrap.py
--- rustc-1.53.0-src/src/bootstrap/bootstrap.py.orig 2021-07-03 13:57:23.756296000 +0200
+++ rustc-1.53.0-src/src/bootstrap/bootstrap.py 2021-07-03 13:58:41.037817900 +0200
@@ -425,6 +425,12 @@
with output(self.rustc_stamp(stage0)) as rust_stamp:
rust_stamp.write(key)
+ gcc_libs_hack = os.environ.get('GCC_LIBS_HACK')
+ gcc_libs_hack_dest = '{}/rustlib/{}/lib'.format(lib_dir, self.build)
+ shutil.copy(gcc_libs_hack + '/libgcc.a', gcc_libs_hack_dest)
+ shutil.copy(gcc_libs_hack + '/libgcc_eh.a', gcc_libs_hack_dest)
+ shutil.copy(gcc_libs_hack + '/libgcc_s.a', gcc_libs_hack_dest)
+
if self.rustfmt() and self.rustfmt().startswith(bin_root) and (
not os.path.exists(self.rustfmt())
or self.program_out_of_date(self.rustfmt_stamp(), self.rustfmt_channel)