From ba8a6aa05b919575be78682e7ea0bf384901c742 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Sep 2020 10:21:55 +0200 Subject: [PATCH] Update Rust to 1.46 --- mingw-w64-rust/0001-add-missing-libs.patch | 6 +- mingw-w64-rust/0002-fix-install-msys2.patch | 17 +- mingw-w64-rust/70163.patch | 211 ------------------ mingw-w64-rust/72049.patch | 226 ++++++++++++++++++++ mingw-w64-rust/75603.patch | 22 ++ mingw-w64-rust/PKGBUILD | 41 ++-- 6 files changed, 286 insertions(+), 237 deletions(-) delete mode 100644 mingw-w64-rust/70163.patch create mode 100644 mingw-w64-rust/72049.patch create mode 100644 mingw-w64-rust/75603.patch diff --git a/mingw-w64-rust/0001-add-missing-libs.patch b/mingw-w64-rust/0001-add-missing-libs.patch index e13e817aa52e9..ff0a15d5375b5 100644 --- a/mingw-w64-rust/0001-add-missing-libs.patch +++ b/mingw-w64-rust/0001-add-missing-libs.patch @@ -2,15 +2,13 @@ diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index caa2740408..52738a47f7 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs -@@ -269,6 +269,9 @@ +@@ -269,6 +269,7 @@ // LLVM requires symbols from this library, but apparently they're not printed // during llvm-config? if target.contains("windows-gnu") { + println!("cargo:rustc-link-lib=static-nobundle=ffi"); -+ println!("cargo:rustc-link-lib=static-nobundle=z3"); -+ println!("cargo:rustc-link-lib=stdc++"); - println!("cargo:rustc-link-lib=static-nobundle=gcc_s"); println!("cargo:rustc-link-lib=static-nobundle=pthread"); } + } -- 2.12.0 diff --git a/mingw-w64-rust/0002-fix-install-msys2.patch b/mingw-w64-rust/0002-fix-install-msys2.patch index b8217d0e323ee..ee0793419034a 100644 --- a/mingw-w64-rust/0002-fix-install-msys2.patch +++ b/mingw-w64-rust/0002-fix-install-msys2.patch @@ -1,13 +1,12 @@ --- rustc-1.29.2-src/src/bootstrap/install.rs.orig 2018-10-26 14:13:58.455571300 +0300 +++ rustc-1.29.2-src/src/bootstrap/install.rs 2018-10-26 14:14:35.225835900 +0300 -@@ -74,9 +74,7 @@ - let bindir_default = PathBuf::from("bin"); - let libdir_default = PathBuf::from("lib"); - let mandir_default = datadir_default.join("man"); -- let prefix = builder.config.prefix.as_ref().map_or(prefix_default, |p| { -- fs::canonicalize(p).unwrap_or_else(|_| panic!("could not canonicalize {}", p.display())) -- }); -+ let prefix = builder.config.prefix.as_ref().unwrap_or(&prefix_default); +@@ -74,8 +74,7 @@ + let prefix = builder.config.prefix.as_ref().map_or(prefix_default, |p| { + fs::create_dir_all(p) + .unwrap_or_else(|err| panic!("could not create {}: {}", p.display(), err)); +- fs::canonicalize(p) +- .unwrap_or_else(|err| panic!("could not canonicalize {}: {}", p.display(), err)) ++ p.to_path_buf() + }); let sysconfdir = builder.config.sysconfdir.as_ref().unwrap_or(&sysconfdir_default); let datadir = builder.config.datadir.as_ref().unwrap_or(&datadir_default); - let docdir = builder.config.docdir.as_ref().unwrap_or(&docdir_default); diff --git a/mingw-w64-rust/70163.patch b/mingw-w64-rust/70163.patch deleted file mode 100644 index 7699728d4969a..0000000000000 --- a/mingw-w64-rust/70163.patch +++ /dev/null @@ -1,211 +0,0 @@ -From 841558d3bdc9c9510b841c438838196378741021 Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Tue, 4 Feb 2020 19:23:45 +0100 -Subject: [PATCH 1/5] Remove trailing newline from llvm-config output - ---- - src/bootstrap/test.rs | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs -index aa1d1b7c42413..b52fbe4666eb3 100644 ---- a/src/bootstrap/test.rs -+++ b/src/bootstrap/test.rs -@@ -1141,6 +1141,8 @@ impl Step for Compiletest { - let llvm_config = builder.ensure(native::Llvm { target: builder.config.build }); - if !builder.config.dry_run { - let llvm_version = output(Command::new(&llvm_config).arg("--version")); -+ // Remove trailing newline from llvm-config output. -+ let llvm_version = llvm_version.trim_end(); - cmd.arg("--llvm-version").arg(llvm_version); - } - if !builder.is_rust_llvm(target) { - -From 7a14f9ed4fa60f4d8fc042fc678c80c14a850dc0 Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Sat, 18 Jan 2020 23:00:30 +0100 -Subject: [PATCH 2/5] Fix LLVM version handling in compiletest - -Convert version string to integer before comparing. Otherwise -we get into trouble with double digit versions ;) ---- - src/tools/compiletest/src/header.rs | 27 ++++++++++++++++++----- - src/tools/compiletest/src/header/tests.rs | 5 ++--- - 2 files changed, 23 insertions(+), 9 deletions(-) - -diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs -index 2a24a8c3c9485..cb648db8830ef 100644 ---- a/src/tools/compiletest/src/header.rs -+++ b/src/tools/compiletest/src/header.rs -@@ -191,6 +191,7 @@ impl EarlyProps { - return true; - } - if let Some(ref actual_version) = config.llvm_version { -+ let actual_version = version_to_int(actual_version); - if line.starts_with("min-llvm-version") { - let min_version = line - .trim_end() -@@ -199,7 +200,7 @@ impl EarlyProps { - .expect("Malformed llvm version directive"); - // Ignore if actual version is smaller the minimum required - // version -- &actual_version[..] < min_version -+ actual_version < version_to_int(min_version) - } else if line.starts_with("min-system-llvm-version") { - let min_version = line - .trim_end() -@@ -208,7 +209,7 @@ impl EarlyProps { - .expect("Malformed llvm version directive"); - // Ignore if using system LLVM and actual version - // is smaller the minimum required version -- config.system_llvm && &actual_version[..] < min_version -+ config.system_llvm && actual_version < version_to_int(min_version) - } else if line.starts_with("ignore-llvm-version") { - // Syntax is: "ignore-llvm-version [- ]" - let range_components = line -@@ -219,15 +220,15 @@ impl EarlyProps { - .take(3) // 3 or more = invalid, so take at most 3. - .collect::>(); - match range_components.len() { -- 1 => &actual_version[..] == range_components[0], -+ 1 => actual_version == version_to_int(range_components[0]), - 2 => { -- let v_min = range_components[0]; -- let v_max = range_components[1]; -+ let v_min = version_to_int(range_components[0]); -+ let v_max = version_to_int(range_components[1]); - if v_max < v_min { - panic!("Malformed LLVM version range: max < min") - } - // Ignore if version lies inside of range. -- &actual_version[..] >= v_min && &actual_version[..] <= v_max -+ actual_version >= v_min && actual_version <= v_max - } - _ => panic!("Malformed LLVM version directive"), - } -@@ -238,6 +239,20 @@ impl EarlyProps { - false - } - } -+ -+ fn version_to_int(version: &str) -> u32 { -+ let version_without_suffix = version.split('-').next().unwrap(); -+ let components: Vec = version_without_suffix -+ .split('.') -+ .map(|s| s.parse().expect("Malformed version component")) -+ .collect(); -+ match components.len() { -+ 1 => components[0] * 10000, -+ 2 => components[0] * 10000 + components[1] * 100, -+ 3 => components[0] * 10000 + components[1] * 100 + components[2], -+ _ => panic!("Malformed version"), -+ } -+ } - } - } - -diff --git a/src/tools/compiletest/src/header/tests.rs b/src/tools/compiletest/src/header/tests.rs -index 6c478f7e29da4..31d991e0c2f87 100644 ---- a/src/tools/compiletest/src/header/tests.rs -+++ b/src/tools/compiletest/src/header/tests.rs -@@ -122,9 +122,8 @@ fn llvm_version() { - config.llvm_version = Some("9.3.1-rust-1.43.0-dev".to_owned()); - assert!(!parse_rs(&config, "// min-llvm-version 9.2").ignore); - -- // FIXME. -- // config.llvm_version = Some("10.0.0-rust".to_owned()); -- // assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore); -+ config.llvm_version = Some("10.0.0-rust".to_owned()); -+ assert!(!parse_rs(&config, "// min-llvm-version 9.0").ignore); - } - - #[test] - -From 66008eb9e4e46bb5c12a215e2abe2338617c2582 Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Sun, 19 Jan 2020 22:47:45 +0100 -Subject: [PATCH 3/5] Adjust data layout in test - ---- - .../run-make-fulldeps/target-specs/my-awesome-platform.json | 2 +- - .../target-specs/my-x86_64-unknown-linux-gnu-platform.json | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json -index 8d028280a8da7..00de3de05f07a 100644 ---- a/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json -+++ b/src/test/run-make-fulldeps/target-specs/my-awesome-platform.json -@@ -1,5 +1,5 @@ - { -- "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", -+ "data-layout": "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128", - "linker-flavor": "gcc", - "llvm-target": "i686-unknown-linux-gnu", - "target-endian": "little", -diff --git a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json -index 48040ae3da0ef..6d5e964ed4fee 100644 ---- a/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json -+++ b/src/test/run-make-fulldeps/target-specs/my-x86_64-unknown-linux-gnu-platform.json -@@ -1,6 +1,6 @@ - { - "pre-link-args": {"gcc": ["-m64"]}, -- "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", -+ "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", - "linker-flavor": "gcc", - "llvm-target": "x86_64-unknown-linux-gnu", - "target-endian": "little", - -From a94fa896cc92d5e0678376cf5aa8b64af0899732 Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Tue, 4 Feb 2020 20:35:50 +0100 -Subject: [PATCH 4/5] Fix timeTraceProfilerInitialize for LLVM 10 - ---- - src/rustllvm/PassWrapper.cpp | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp -index 90d24d20737db..9e8614e3b6d34 100644 ---- a/src/rustllvm/PassWrapper.cpp -+++ b/src/rustllvm/PassWrapper.cpp -@@ -67,7 +67,11 @@ extern "C" void LLVMInitializePasses() { - } - - extern "C" void LLVMTimeTraceProfilerInitialize() { --#if LLVM_VERSION_GE(9, 0) -+#if LLVM_VERSION_GE(10, 0) -+ timeTraceProfilerInitialize( -+ /* TimeTraceGranularity */ 0, -+ /* ProcName */ "rustc"); -+#elif LLVM_VERSION_GE(9, 0) - timeTraceProfilerInitialize(); - #endif - } - -From 497f879b1e24c369362bcd821959ffabc50a8a31 Mon Sep 17 00:00:00 2001 -From: Nikita Popov -Date: Mon, 2 Mar 2020 22:37:55 +0100 -Subject: [PATCH 5/5] Update CreateMemSet() usage for LLVM 10 - ---- - src/rustllvm/RustWrapper.cpp | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp -index 25cfee3373dc4..799adb418822d 100644 ---- a/src/rustllvm/RustWrapper.cpp -+++ b/src/rustllvm/RustWrapper.cpp -@@ -1333,8 +1333,13 @@ extern "C" LLVMValueRef LLVMRustBuildMemSet(LLVMBuilderRef B, - LLVMValueRef Dst, unsigned DstAlign, - LLVMValueRef Val, - LLVMValueRef Size, bool IsVolatile) { -+#if LLVM_VERSION_GE(10, 0) -+ return wrap(unwrap(B)->CreateMemSet( -+ unwrap(Dst), unwrap(Val), unwrap(Size), MaybeAlign(DstAlign), IsVolatile)); -+#else - return wrap(unwrap(B)->CreateMemSet( - unwrap(Dst), unwrap(Val), unwrap(Size), DstAlign, IsVolatile)); -+#endif - } - - extern "C" LLVMValueRef diff --git a/mingw-w64-rust/72049.patch b/mingw-w64-rust/72049.patch new file mode 100644 index 0000000000000..f938ede9b2a0b --- /dev/null +++ b/mingw-w64-rust/72049.patch @@ -0,0 +1,226 @@ +From db9a84a1af8bd5cea3738833c0e8cd4e1bee3f7d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= +Date: Thu, 7 May 2020 11:52:21 +0200 +Subject: [PATCH 1/2] MinGW: emit dllexport/dllimport by rustc + +This fixes various cases where LD could not guess dllexport correctly and greatly improves compatibility with LLD which is not going to support linker scripts anytime soon +--- + src/librustc_codegen_llvm/callee.rs | 7 ++++++- + src/librustc_codegen_llvm/consts.rs | 2 +- + src/librustc_codegen_llvm/context.rs | 15 ++++++++++++--- + src/librustc_codegen_ssa/back/linker.rs | 23 +++++++++++++++++++++-- + src/librustc_codegen_ssa/back/write.rs | 4 ++-- + src/librustc_session/session.rs | 10 +++++----- + 6 files changed, 47 insertions(+), 14 deletions(-) + +diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs +index 7b341651adf3d..ee6b28b3d1bb1 100644 +--- a/src/librustc_codegen_llvm/callee.rs ++++ b/src/librustc_codegen_llvm/callee.rs +@@ -168,7 +168,12 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value + } + } + +- if cx.use_dll_storage_attrs && tcx.is_dllimport_foreign_item(instance_def_id) { ++ // MinGW: For backward compatibility we rely on the linker to decide whether it ++ // should use dllimport for functions. ++ if cx.use_dll_storage_attrs ++ && tcx.is_dllimport_foreign_item(instance_def_id) ++ && tcx.sess.target.target.target_env != "gnu" ++ { + unsafe { + llvm::LLVMSetDLLStorageClass(llfn, llvm::DLLStorageClass::DllImport); + } +diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs +index 90887b760fb7d..5b9f131115bda 100644 +--- a/src/librustc_codegen_llvm/consts.rs ++++ b/src/librustc_codegen_llvm/consts.rs +@@ -281,7 +281,7 @@ impl CodegenCx<'ll, 'tcx> { + // argument validation. + debug_assert!( + !(self.tcx.sess.opts.cg.linker_plugin_lto.enabled() +- && self.tcx.sess.target.target.options.is_like_msvc ++ && self.tcx.sess.target.target.options.is_like_windows + && self.tcx.sess.opts.cg.prefer_dynamic) + ); + +diff --git a/src/librustc_codegen_llvm/context.rs b/src/librustc_codegen_llvm/context.rs +index 21ba97d15a485..191a337cd565c 100644 +--- a/src/librustc_codegen_llvm/context.rs ++++ b/src/librustc_codegen_llvm/context.rs +@@ -217,7 +217,16 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { + // attributes in LLVM IR as well as native dependencies (in C these + // correspond to `__declspec(dllimport)`). + // +- // Whenever a dynamic library is built by MSVC it must have its public ++ // LD (BFD) in MinGW mode can often correctly guess `dllexport` but ++ // relying on that can result in issues like #50176. ++ // LLD won't support that and expects symbols with proper attributes. ++ // Because of that we make MinGW target emit dllexport just like MSVC. ++ // When it comes to dllimport we use it for constants but for functions ++ // rely on the linker to do the right thing. Opposed to dllexport this ++ // task is easy for them (both LD and LLD) and allows us to easily use ++ // symbols from static libraries in shared libraries. ++ // ++ // Whenever a dynamic library is built on Windows it must have its public + // interface specified by functions tagged with `dllexport` or otherwise + // they're not available to be linked against. This poses a few problems + // for the compiler, some of which are somewhat fundamental, but we use +@@ -254,8 +263,8 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { + // this effect) by marking very little as `dllimport` and praying the + // linker will take care of everything. Fixing this problem will likely + // require adding a few attributes to Rust itself (feature gated at the +- // start) and then strongly recommending static linkage on MSVC! +- let use_dll_storage_attrs = tcx.sess.target.target.options.is_like_msvc; ++ // start) and then strongly recommending static linkage on Windows! ++ let use_dll_storage_attrs = tcx.sess.target.target.options.is_like_windows; + + let check_overflow = tcx.sess.overflow_checks(); + +diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs +index e64aafa599fd8..aba4991c29537 100644 +--- a/src/librustc_codegen_ssa/back/linker.rs ++++ b/src/librustc_codegen_ssa/back/linker.rs +@@ -523,8 +523,9 @@ impl<'a> Linker for GccLinker<'a> { + return; + } + ++ let is_windows = self.sess.target.target.options.is_like_windows; + let mut arg = OsString::new(); +- let path = tmpdir.join("list"); ++ let path = tmpdir.join(if is_windows { "list.def" } else { "list" }); + + debug!("EXPORTED SYMBOLS:"); + +@@ -540,6 +541,21 @@ impl<'a> Linker for GccLinker<'a> { + if let Err(e) = res { + self.sess.fatal(&format!("failed to write lib.def file: {}", e)); + } ++ } else if is_windows { ++ let res: io::Result<()> = try { ++ let mut f = BufWriter::new(File::create(&path)?); ++ ++ // .def file similar to MSVC one but without LIBRARY section ++ // because LD doesn't like when it's empty ++ writeln!(f, "EXPORTS")?; ++ for symbol in self.info.exports[&crate_type].iter() { ++ debug!(" _{}", symbol); ++ writeln!(f, " {}", symbol)?; ++ } ++ }; ++ if let Err(e) = res { ++ self.sess.fatal(&format!("failed to write list.def file: {}", e)); ++ } + } else { + // Write an LD version script + let res: io::Result<()> = try { +@@ -573,7 +589,10 @@ impl<'a> Linker for GccLinker<'a> { + if !self.is_ld { + arg.push("-Wl,") + } +- arg.push("--version-script="); ++ // Both LD and LLD accept export list in *.def file form, there are no flags required ++ if !is_windows { ++ arg.push("--version-script=") ++ } + } + + arg.push(&path); +diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs +index 23e0b9344ec91..b0fae566a5aef 100644 +--- a/src/librustc_codegen_ssa/back/write.rs ++++ b/src/librustc_codegen_ssa/back/write.rs +@@ -1846,11 +1846,11 @@ fn msvc_imps_needed(tcx: TyCtxt<'_>) -> bool { + // something is wrong with commandline arg validation. + assert!( + !(tcx.sess.opts.cg.linker_plugin_lto.enabled() +- && tcx.sess.target.target.options.is_like_msvc ++ && tcx.sess.target.target.options.is_like_windows + && tcx.sess.opts.cg.prefer_dynamic) + ); + +- tcx.sess.target.target.options.is_like_msvc && ++ tcx.sess.target.target.options.is_like_windows && + tcx.sess.crate_types().iter().any(|ct| *ct == CrateType::Rlib) && + // ThinLTO can't handle this workaround in all cases, so we don't + // emit the `__imp_` symbols. Instead we make them unnecessary by disallowing +diff --git a/src/librustc_session/session.rs b/src/librustc_session/session.rs +index fcd5dab94a6c2..eb6fcb93002fc 100644 +--- a/src/librustc_session/session.rs ++++ b/src/librustc_session/session.rs +@@ -1294,19 +1294,19 @@ pub fn build_session( + // commandline argument, you can do so here. + fn validate_commandline_args_with_session_available(sess: &Session) { + // Since we don't know if code in an rlib will be linked to statically or +- // dynamically downstream, rustc generates `__imp_` symbols that help the +- // MSVC linker deal with this lack of knowledge (#27438). Unfortunately, ++ // dynamically downstream, rustc generates `__imp_` symbols that help linkers ++ // on Windows deal with this lack of knowledge (#27438). Unfortunately, + // these manually generated symbols confuse LLD when it tries to merge +- // bitcode during ThinLTO. Therefore we disallow dynamic linking on MSVC ++ // bitcode during ThinLTO. Therefore we disallow dynamic linking on Windows + // when compiling for LLD ThinLTO. This way we can validly just not generate + // the `dllimport` attributes and `__imp_` symbols in that case. + if sess.opts.cg.linker_plugin_lto.enabled() + && sess.opts.cg.prefer_dynamic +- && sess.target.target.options.is_like_msvc ++ && sess.target.target.options.is_like_windows + { + sess.err( + "Linker plugin based LTO is not supported together with \ +- `-C prefer-dynamic` when targeting MSVC", ++ `-C prefer-dynamic` when targeting Windows-like targets", + ); + } + + +From 87abd656dabdb97758413b7f4be5bda9be71e26e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= +Date: Fri, 3 Jul 2020 21:00:14 +0200 +Subject: [PATCH 2/2] Add test for #50176 + +--- + .../mingw-export-call-convention/Makefile | 9 +++++++++ + .../mingw-export-call-convention/foo.rs | 4 ++++ + src/test/run-make-fulldeps/tools.mk | 1 + + 3 files changed, 14 insertions(+) + create mode 100644 src/test/run-make-fulldeps/mingw-export-call-convention/Makefile + create mode 100644 src/test/run-make-fulldeps/mingw-export-call-convention/foo.rs + +diff --git a/src/test/run-make-fulldeps/mingw-export-call-convention/Makefile b/src/test/run-make-fulldeps/mingw-export-call-convention/Makefile +new file mode 100644 +index 0000000000000..4a60059cc5441 +--- /dev/null ++++ b/src/test/run-make-fulldeps/mingw-export-call-convention/Makefile +@@ -0,0 +1,9 @@ ++include ../tools.mk ++ ++# only-windows-gnu ++ ++all: ++ $(RUSTC) foo.rs ++ # FIXME: we should make sure __stdcall calling convention is used here ++ # but that only works with LLD right now ++ nm -g "$(call IMPLIB,foo)" | $(CGREP) bar +diff --git a/src/test/run-make-fulldeps/mingw-export-call-convention/foo.rs b/src/test/run-make-fulldeps/mingw-export-call-convention/foo.rs +new file mode 100644 +index 0000000000000..1fec00311ef06 +--- /dev/null ++++ b/src/test/run-make-fulldeps/mingw-export-call-convention/foo.rs +@@ -0,0 +1,4 @@ ++#![crate_type = "cdylib"] ++ ++#[no_mangle] ++pub extern "system" fn bar() {} +diff --git a/src/test/run-make-fulldeps/tools.mk b/src/test/run-make-fulldeps/tools.mk +index 04bf78ed2105b..381f14a0d382a 100644 +--- a/src/test/run-make-fulldeps/tools.mk ++++ b/src/test/run-make-fulldeps/tools.mk +@@ -48,6 +48,7 @@ ifdef IS_MSVC + STATICLIB = $(TMPDIR)/$(1).lib + STATICLIB_GLOB = $(1)*.lib + else ++IMPLIB = $(TMPDIR)/lib$(1).dll.a + STATICLIB = $(TMPDIR)/lib$(1).a + STATICLIB_GLOB = lib$(1)*.a + endif diff --git a/mingw-w64-rust/75603.patch b/mingw-w64-rust/75603.patch new file mode 100644 index 0000000000000..3cf68c0e29a03 --- /dev/null +++ b/mingw-w64-rust/75603.patch @@ -0,0 +1,22 @@ +From 1627ba19643c18fe9a80e65c8df8bbd2f3ed8432 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= +Date: Sun, 16 Aug 2020 21:54:37 +0200 +Subject: [PATCH] Use more compatible out-implib style + +--- + src/librustc_codegen_ssa/back/linker.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs +index 5100ef8ad4fd7..0ddf8bd316fcd 100644 +--- a/src/librustc_codegen_ssa/back/linker.rs ++++ b/src/librustc_codegen_ssa/back/linker.rs +@@ -266,7 +266,7 @@ impl<'a> GccLinker<'a> { + if let Some(implib_name) = implib_name { + let implib = out_filename.parent().map(|dir| dir.join(&implib_name)); + if let Some(implib) = implib { +- self.linker_arg(&format!("--out-implib,{}", (*implib).to_str().unwrap())); ++ self.linker_arg(&format!("--out-implib={}", (*implib).to_str().unwrap())); + } + } + } diff --git a/mingw-w64-rust/PKGBUILD b/mingw-w64-rust/PKGBUILD index 5b65bcb232e12..9eca7f07bc983 100644 --- a/mingw-w64-rust/PKGBUILD +++ b/mingw-w64-rust/PKGBUILD @@ -6,7 +6,7 @@ _realname=rust _bootstrapping=yes pkgbase=mingw-w64-${_realname} pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" -pkgver=1.43.0 +pkgver=1.46.0 pkgrel=1 pkgdesc="Systems programming language focused on safety, speed and concurrency (mingw-w64)" arch=('any') @@ -24,7 +24,7 @@ makedepends=("bison" "${MINGW_PACKAGE_PREFIX}-llvm" "${MINGW_PACKAGE_PREFIX}-ninja" "${MINGW_PACKAGE_PREFIX}-openssl" - "${MINGW_PACKAGE_PREFIX}-python2" + "${MINGW_PACKAGE_PREFIX}-python" $([[ "$_bootstrapping" == "no" ]] && echo "${MINGW_PACKAGE_PREFIX}-rust") "${MINGW_PACKAGE_PREFIX}-zlib") options=('staticlibs') @@ -36,16 +36,17 @@ source=("https://static.rust-lang.org/dist/${_realname}c-${pkgver}-src.tar.gz"{, "0003-link-with-system-curl.patch" "0004-unbundle-gcc.patch" "0005-win32-config.patch" - "70163.patch") -sha256sums=('75f6ac6c9da9f897f4634d5a07be4084692f7ccc2d2bb89337be86cfc18453a1' + "72049.patch" + "75603.patch") +sha256sums=('2d6a3b7196db474ba3f37b8f5d50a1ecedff00738d7846840605b42bfc922728' 'SKIP' '500f9bd7452c8d35115ad823d8fcb9bda8b86878c2a0f57f9e6a72fc4ba9a8f5' - 'c1b3a4d234ba10d2baf9cc1a15e830f1b722b10d80f37b316f47501f5274c9c5' - 'e54e1da8428c484f41005bf4f9f7a8643253306e115b23e4dc17b24a6647ecab' + '336b9b5a5d094404846d563a29a0f51018dcadd76665adea52c0a0e44cc1e69b' + '13cb1817ef83b396e16fe271172a77648bffe5e90efbbe98eb5fefc5a8d91860' 'b16f65dfdc79e7a722b3e2589e90a1431a971038dd5dfa1394ec0427e3c0a2b4' '1a3d00f3bcf5c21beaa20ee729c45b7b3d76cd2a2c6b70562020f11c1e9dcc6d' '061f1cf5374c926bc130a4afbde005dcd09fdbaee079469ad045fd23a7a88a2c' - 'fcdd07eaf0790064223811aa710392bab15e489842619328e72f336290e06cdb') + '29c2a10920a7a70e22e81527440b069bfa7fe24e9e662f5f473217fbad0ad50f') validpgpkeys=('108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE') # Rust Language (Tag and Release Signing Key) noextract=(${_realname}c-${pkgver}-src.tar.gz) @@ -60,7 +61,8 @@ prepare() { #patch -p1 -i "${srcdir}/0003-link-with-system-curl.patch" patch -p1 -i "${srcdir}/0004-unbundle-gcc.patch" patch -p1 -i "${srcdir}/0005-win32-config.patch" - patch -p1 -i "${srcdir}/70163.patch" + patch -p1 -i "${srcdir}/72049.patch" + patch -p1 -i "${srcdir}/75603.patch" } build() { @@ -75,6 +77,8 @@ build() { _rust_conf+=("--local-rust-root=$(cygpath -m ${MINGW_PREFIX})") fi + export LIBSSH2_SYS_USE_PKG_CONFIG=1 + MSYS2_ARG_CONV_EXCL="--prefix;--sysconfdir;--localstatedir" \ ../${_realname}c-${pkgver}-src/configure \ --prefix=${MINGW_PREFIX} \ @@ -87,28 +91,39 @@ build() { --enable-ninja \ --enable-extended \ --disable-codegen-tests \ - --python=${MINGW_PREFIX}/bin/python2 \ - --llvm-root=${MINGW_PREFIX} \ + --python=${MINGW_PREFIX}/bin/python \ ${_rust_conf} + # i686 builds fails with (exit code: 0xc0000139, STATUS_ENTRYPOINT_NOT_FOUND) + # Probably we have to apply one of Rust's LLVM patches to our LLVM package. + # --llvm-root=${MINGW_PREFIX} \ DEP_NGHTTP_ROOT=${MINGW_PREFIX} \ DEP_OPENSSL_ROOT=${MINGW_PREFIX} \ DEP_Z_ROOT=${MINGW_PREFIX} \ - ${MINGW_PREFIX}/bin/python2 ../${_realname}c-${pkgver}-src/x.py build -j"$(nproc)" --verbose + ${MINGW_PREFIX}/bin/python ../${_realname}c-${pkgver}-src/x.py build --verbose } check() { cd "${srcdir}/${CARCH}" + + export LIBSSH2_SYS_USE_PKG_CONFIG=1 + # it might fail on Windows - ${MINGW_PREFIX}/bin/python2 ../${_realname}c-${pkgver}-src/x.py test || true + DEP_NGHTTP_ROOT=${MINGW_PREFIX} \ + DEP_OPENSSL_ROOT=${MINGW_PREFIX} \ + DEP_Z_ROOT=${MINGW_PREFIX} \ + ${MINGW_PREFIX}/bin/python ../${_realname}c-${pkgver}-src/x.py test || true } package() { cd "${srcdir}/${CARCH}" + + export LIBSSH2_SYS_USE_PKG_CONFIG=1 + DEP_NGHTTP_ROOT=${MINGW_PREFIX} \ DEP_OPENSSL_ROOT=${MINGW_PREFIX} \ DEP_Z_ROOT=${MINGW_PREFIX} \ - DESTDIR=${pkgdir} ${MINGW_PREFIX}/bin/python2 ../${_realname}c-${pkgver}-src/x.py install --verbose + DESTDIR=${pkgdir} ${MINGW_PREFIX}/bin/python ../${_realname}c-${pkgver}-src/x.py install --verbose rm -f ${pkgdir}${MINGW_PREFIX}/bin/libgcc*.dll rm -f ${pkgdir}${MINGW_PREFIX}/bin/libstd*.dll