Skip to content

Commit

Permalink
rust: Update to 1.61.0
Browse files Browse the repository at this point in the history
Fixes a number of issues in compiler/rustc_llvm regarding lib handling.
This is a moving part in current rust releases...

- Disabled llvm-static-stdcpp
Fixes CLANG64 build error:
    thread 'main' panicked at 'assertion failed: !cxxflags.contains(\"stdlib=libc++\")', compiler\rustc_llvm\build.rs:351:13
    note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

- Removed `pthread` from forced libs in compiler/rustc_llvm/build.rs
`pthread` is also provided by llvm-config and having both now triggers an error about mixed link modifiers.
See rust-lang/rust#97299

    $ llvm-config --system-libs --link-static
    -lpsapi -lshell32 -lole32 -luuid -ladvapi32 -lpthread -lz -lxml2

Note that `ffi` is still forced by the patch as llvm-config does not provide it.
See 0001-rustc-llvm-fix-libs.patch (replaces 0001-add-missing-libs.patch).

- Rebased 0007-clang-subsystem.patch
  • Loading branch information
filnet committed May 26, 2022
1 parent cb23dc0 commit b673783
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 55 deletions.
12 changes: 0 additions & 12 deletions mingw-w64-rust/0001-add-missing-libs.patch

This file was deleted.

10 changes: 10 additions & 0 deletions mingw-w64-rust/0001-rustc-llvm-fix-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- rustc-1.61.0-src/compiler/rustc_llvm/build.rs.orig 2022-05-18 03:29:36.000000000 +0200
+++ rustc-1.61.0-src/compiler/rustc_llvm/build.rs 2022-05-26 16:30:44.493262300 +0200
@@ -366,6 +366,6 @@
// Libstdc++ depends on pthread which Rust doesn't link on MinGW
// since nothing else requires it.
if target.contains("windows-gnu") {
- println!("cargo:rustc-link-lib=static:-bundle=pthread");
+ println!("cargo:rustc-link-lib=static:-bundle=ffi");
}
}
65 changes: 32 additions & 33 deletions mingw-w64-rust/0007-clang-subsystem.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
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 @@
--- rustc-1.61.0-src/compiler/rustc_target/src/spec/windows_gnu_base.rs.orig 2022-05-18 03:29:36.000000000 +0200
+++ rustc-1.61.0-src/compiler/rustc_target/src/spec/windows_gnu_base.rs 2022-05-22 15:53:32.596861100 +0200
@@ -16,34 +16,13 @@
],
);

Expand All @@ -11,53 +10,53 @@ diff -urN rustc-1.52.1-src.orig/compiler/rustc_target/src/spec/windows_gnu_base.
- // 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
- "-lmsvcrt".into(),
- "-lmingwex".into(),
- "-lmingw32".into(),
- "-lgcc".into(), // 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(),
- "-lmsvcrt".into(),
- "-luser32".into(),
- "-lkernel32".into(),
- ];
- 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(),
- "-lgcc_s".into(),
+ "-l:libunwind.dll.a".into(),
];
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 @@
@@ -53,8 +32,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(),
- "-lgcc_eh".into(),
- "-l:libpthread.a".into(),
+ "-l:libunwind.a".into(),
];
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(),
@@ -64,7 +42,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".to_string()),
linker: Some("gcc".into()),
dynamic_linking: true,
executables: true,
@@ -84,7 +63,6 @@
@@ -80,7 +59,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),
Expand All @@ -81,25 +80,25 @@ diff -urN rustc-1.53.0-src/src/bootstrap/bootstrap.py.orig rustc-1.53.0-src/src/
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)
--- rustc-1.57.0-src/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs.orig 2022-02-18 14:41:41.509000000 +0100
+++ rustc-1.57.0-src/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs 2022-02-18 14:41:49.361435000 +0100
--- rustc-1.61.0-src/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs.orig 2022-05-22 16:08:33.258876100 +0200
+++ rustc-1.61.0-src/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs 2022-05-22 16:13:31.577741200 +0200
@@ -7,7 +7,7 @@
.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pe".to_string()]);
base.max_atomic_width = Some(64);
base.frame_pointer = FramePointer::Always; // Required for backtraces
- base.linker = Some("i686-w64-mingw32-gcc".to_string());
+ base.linker = Some("i686-w64-mingw32-clang".to_string());
- 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.
--- rustc-1.57.0-src/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs.orig 2022-02-18 14:41:21.116000000 +0100
+++ rustc-1.57.0-src/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs 2022-02-18 14:41:24.641880900 +0100
--- rustc-1.61.0-src/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs.orig 2022-05-22 16:08:33.258876100 +0200
+++ rustc-1.61.0-src/compiler/rustc_target/src/spec/x86_64_pc_windows_gnu.rs 2022-05-22 16:13:31.577741200 +0200
@@ -10,7 +10,7 @@
base.pre_link_args
.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".to_string(), "i386pep".to_string()]);
.insert(LinkerFlavor::Lld(LldFlavor::Ld), vec!["-m".into(), "i386pep".into()]);
base.max_atomic_width = Some(64);
- base.linker = Some("x86_64-w64-mingw32-gcc".to_string());
+ base.linker = Some("x86_64-w64-mingw32-clang".to_string());
- 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".to_string(),
llvm_target: "x86_64-pc-windows-gnu".into(),
34 changes: 24 additions & 10 deletions mingw-w64-rust/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ _bootstrapping=yes
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-rust-docs")
pkgver=1.60.0
pkgver=1.61.0
pkgrel=1
pkgdesc="Systems programming language focused on safety, speed and concurrency (mingw-w64)"
arch=('any')
Expand All @@ -31,34 +31,47 @@ options=('staticlibs' 'strip')
#install=rust.install
noextract=(${_realname}c-${pkgver}-src.tar.gz)
source=("https://static.rust-lang.org/dist/${_realname}c-${pkgver}-src.tar.gz"{,.asc}
"0001-add-missing-libs.patch"
"0001-rustc-llvm-fix-libs.patch"
"0004-unbundle-gcc.patch"
"0005-win32-config.patch"
"0007-clang-subsystem.patch"
"0008-disable-self-contained.patch")
sha256sums=('20ca826d1cf674daf8e22c4f8c4b9743af07973211c839b85839742314c838b7'
sha256sums=('ad0b4351675aa9abdf4c7e066613bd274c4391c5506db152983426376101daed'
'SKIP'
'8c9c37f2ff3bee7d9ac520c66d3f37fd7f002012ddca4ddeeab2b009f520e4ce'
'a069c402609589aa312937550d1ca7cd5985c790eaaeb0a0a735e8eb1f28557c'
'6cc3234644768e24824e455d6304585c717ae25aa53ebf9cf1f1dea87bf869b7'
'c4e5ffeef84296d39c3e3e8f807fc8b33ce786b1e4edb21eef26b053586aca27'
'c79d91a7419e8b0da76295c3d64aa5e984851c7e03b778f6230a660a010c9a66'
'4a5801c7d5169a68541d5af9accb311624764ef29c853a31c48909179ab208de'
'29f84cb8e05ce304e102e28912a3b4464add406a8ec37a6c6d717b9b7d81b67b')
validpgpkeys=('108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE' # Rust Language (Tag and Release Signing Key) <rust-key@rust-lang.org>
'474E22316ABF4785A88C6E8EA2C794A986419D8A' # Tom Stellard <tstellar@redhat.com>
'B6C8F98282B944E3B0D5C2530FC3042E345AD05D') # Hans Wennborg <hans@chromium.org>

# =========================================== #
# Helper macros to help make tasks easier #
apply_patch_with_msg() {
for _patch in "$@"
do
msg2 "Applying ${_patch}"
patch -Nbp1 -i "${srcdir}/${_patch}"
done
}
# =========================================== #

prepare() {
[[ -d ${srcdir}/${_realname}c-${pkgver}-src ]] && rm -rf ${srcdir}/${_realname}c-${pkgver}-src
tar -xzf ${srcdir}/${_realname}c-${pkgver}-src.tar.gz -C ${srcdir} || true

cd ${srcdir}/${_realname}c-${pkgver}-src
patch -p1 -i "${srcdir}/0001-add-missing-libs.patch"
patch -p1 -i "${srcdir}/0004-unbundle-gcc.patch"
patch -p1 -i "${srcdir}/0005-win32-config.patch"
patch -p1 -i "${srcdir}/0008-disable-self-contained.patch"
apply_patch_with_msg \
0001-rustc-llvm-fix-libs.patch \
0004-unbundle-gcc.patch \
0005-win32-config.patch \
0008-disable-self-contained.patch

if [[ $MINGW_PACKAGE_PREFIX == *-clang-* ]]; then
patch -p1 -i "${srcdir}/0007-clang-subsystem.patch"
apply_patch_with_msg \
0007-clang-subsystem.patch
fi
}

Expand Down Expand Up @@ -103,6 +116,7 @@ build() {
--release-channel=stable \
--enable-ninja \
--enable-extended \
--disable-llvm-static-stdcpp \
--disable-codegen-tests \
--llvm-root=${MINGW_PREFIX} \
--python=${MINGW_PREFIX}/bin/python \
Expand Down

0 comments on commit b673783

Please sign in to comment.