Files
MINGW-packages/mingw-w64-rust/0007-clang-subsystem.patch
2023-12-30 06:08:39 +01:00

163 lines
8.0 KiB
Diff

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.65.0-src.orig/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs rustc-1.65.0-src/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs
--- rustc-1.65.0-src.orig/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs 2022-11-09 21:53:40.408733200 +0100
+++ rustc-1.65.0-src/compiler/rustc_target/src/spec/targets/x86_64_pc_windows_gnu.rs 2022-11-09 22:07:46.192364800 +0100
@@ -7,7 +7,7 @@
base.add_pre_link_args(LinkerFlavor::Ld, &["-m", "i386pep", "--high-entropy-va"]);
base.add_pre_link_args(LinkerFlavor::Gcc, &["-m64", "-Wl,--high-entropy-va"]);
base.max_atomic_width = Some(64);
- 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.65.0-src.orig/src/bootstrap/bootstrap.py rustc-1.65.0-src/src/bootstrap/bootstrap.py
--- rustc-1.65.0-src.orig/src/bootstrap/bootstrap.py 2022-11-09 21:53:40.400733100 +0100
+++ rustc-1.65.0-src/src/bootstrap/bootstrap.py 2022-11-09 22:07:46.184853700 +0100
@@ -448,6 +448,12 @@
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 _download_component_helper(
self, filename, pattern, tarball_suffix,
):
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(