-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
0007-clang-subsystem.patch
163 lines (151 loc) · 8.06 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
diff -urN rustc-1.65.0-src.orig/compiler/rustc_target/src/spec/crt_objects.rs rustc-1.65.0-src/compiler/rustc_target/src/spec/crt_objects.rs
--- rustc-1.65.0-src.orig/compiler/rustc_target/src/spec/crt_objects.rs 2022-11-02 15:36:24.000000000 +0100
+++ rustc-1.65.0-src/compiler/rustc_target/src/spec/crt_objects.rs 2022-11-09 22:12:19.171603900 +0100
@@ -52,17 +52,6 @@
obj_table.iter().map(|(z, k)| (*z, k.iter().map(|b| (*b).into()).collect())).collect()
}
-pub(super) fn all(obj: &'static str) -> CrtObjects {
- new(&[
- (LinkOutputKind::DynamicNoPicExe, &[obj]),
- (LinkOutputKind::DynamicPicExe, &[obj]),
- (LinkOutputKind::StaticNoPicExe, &[obj]),
- (LinkOutputKind::StaticPicExe, &[obj]),
- (LinkOutputKind::DynamicDylib, &[obj]),
- (LinkOutputKind::StaticDylib, &[obj]),
- ])
-}
-
pub(super) fn pre_musl_self_contained() -> CrtObjects {
new(&[
(LinkOutputKind::DynamicNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]),
@@ -87,25 +76,25 @@
pub(super) fn pre_mingw_self_contained() -> CrtObjects {
new(&[
- (LinkOutputKind::DynamicNoPicExe, &["crt2.o", "rsbegin.o"]),
- (LinkOutputKind::DynamicPicExe, &["crt2.o", "rsbegin.o"]),
- (LinkOutputKind::StaticNoPicExe, &["crt2.o", "rsbegin.o"]),
- (LinkOutputKind::StaticPicExe, &["crt2.o", "rsbegin.o"]),
- (LinkOutputKind::DynamicDylib, &["dllcrt2.o", "rsbegin.o"]),
- (LinkOutputKind::StaticDylib, &["dllcrt2.o", "rsbegin.o"]),
+ (LinkOutputKind::DynamicNoPicExe, &["crt2.o"]),
+ (LinkOutputKind::DynamicPicExe, &["crt2.o"]),
+ (LinkOutputKind::StaticNoPicExe, &["crt2.o"]),
+ (LinkOutputKind::StaticPicExe, &["crt2.o"]),
+ (LinkOutputKind::DynamicDylib, &["dllcrt2.o"]),
+ (LinkOutputKind::StaticDylib, &["dllcrt2.o"]),
])
}
pub(super) fn post_mingw_self_contained() -> CrtObjects {
- all("rsend.o")
+ CrtObjects::new()
}
pub(super) fn pre_mingw() -> CrtObjects {
- all("rsbegin.o")
+ CrtObjects::new()
}
pub(super) fn post_mingw() -> CrtObjects {
- all("rsend.o")
+ CrtObjects::new()
}
pub(super) fn pre_wasi_self_contained() -> CrtObjects {
diff -urN rustc-1.65.0-src.orig/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs rustc-1.65.0-src/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs
--- rustc-1.65.0-src.orig/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs 2022-11-09 21:53:40.404728900 +0100
+++ rustc-1.65.0-src/compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs 2022-11-09 22:07:46.188364200 +0100
@@ -5,7 +5,7 @@
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
base.frame_pointer = FramePointer::Always; // Required for backtraces
- base.linker = Some("i686-w64-mingw32-gcc".into());
+ base.linker = Some("i686-w64-mingw32-clang".into());
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
$ diff -urN rustc-1.75.0-src/compiler/rustc_target/src/spec/base/windows_gnu.rs.orig rustc-1.75.0-src/compiler/rustc_target/src/spec/base/windows_gnu.rs
--- rustc-1.75.0-src/compiler/rustc_target/src/spec/base/windows_gnu.rs.orig 2023-12-21 17:55:28.000000000 +0100
+++ rustc-1.75.0-src/compiler/rustc_target/src/spec/base/windows_gnu.rs 2023-12-22 17:29:48.415890500 +0100
@@ -27,29 +27,14 @@
// 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 = &[
- "-lmsvcrt",
- "-lmingwex",
- "-lmingw32",
- "-lgcc", // 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",
- "-luser32",
- "-lkernel32",
- ];
+ let mingw_libs = &[];
let mut late_link_args =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), mingw_libs);
add_link_args(&mut late_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), mingw_libs);
// 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.
- let dynamic_unwind_libs = &["-lgcc_s"];
+ let dynamic_unwind_libs = &["-l:libunwind.dll.a"];
let mut late_link_args_dynamic =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), dynamic_unwind_libs);
add_link_args(
@@ -62,7 +47,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.
- let static_unwind_libs = &["-lgcc_eh", "-l:libpthread.a"];
+ let static_unwind_libs = &["-l:libunwind.a"];
let mut late_link_args_static =
TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), static_unwind_libs);
add_link_args(
@@ -76,7 +61,8 @@
env: "gnu".into(),
vendor: "pc".into(),
// FIXME(#13846) this should be enabled for windows
- function_sections: false,
+ function_sections: true,
+ no_default_libraries: false,
linker: Some("gcc".into()),
dynamic_linking: true,
dll_tls_export: false,
diff -urN rustc-1.78.0-src/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs.orig rustc-1.78.0-src/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs
--- rustc-1.78.0-src/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs.orig 2024-05-03 21:03:07.983614400 +0200
+++ rustc-1.78.0-src/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs 2024-05-03 21:37:12.067938000 +0200
@@ -12,7 +12,7 @@
);
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64", "-Wl,--high-entropy-va"]);
base.max_atomic_width = Some(128);
- base.linker = Some("x86_64-w64-mingw32-gcc".into());
+ base.linker = Some("x86_64-w64-mingw32-clang".into());
Target {
llvm_target: "x86_64-pc-windows-gnu".into(),
diff -urN rustc-1.76.0-src/src/bootstrap/bootstrap.py.orig rustc-1.76.0-src/src/bootstrap/bootstrap.py
--- rustc-1.76.0-src/src/bootstrap/bootstrap.py.orig 2024-02-05 22:14:29.622617100 +0100
+++ rustc-1.76.0-src/src/bootstrap/bootstrap.py 2024-02-05 22:21:11.207527500 +0100
@@ -616,6 +616,13 @@
with output(self.rustc_stamp()) as rust_stamp:
rust_stamp.write(key)
+ gcc_libs_hack = os.environ.get('GCC_LIBS_HACK')
+ gcc_libs_hack_dest = '{}/lib/rustlib/{}/lib'.format(bin_root, 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)
+
+
def should_fix_bins_and_dylibs(self):
"""Whether or not `fix_bin_or_dylib` needs to be run; can only be True
on NixOS or if config.toml has `build.patch-binaries-for-nix` set.
diff -urN rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/common.rs.orig rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/common.rs
--- rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/common.rs.orig 2023-06-03 18:04:48.695354700 +0200
+++ rustc-1.69.0-src/compiler/rustc_codegen_llvm/src/common.rs 2023-06-03 18:04:55.208081500 +0200
@@ -379,7 +379,7 @@
}
pub(crate) fn is_mingw_gnu_toolchain(target: &Target) -> bool {
- target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
+ false && target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
}
pub(crate) fn i686_decorated_name(