diff --git a/.gitignore b/.gitignore index 351d602..4edcd5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/rustc-1.57.0-src.tar.xz +SOURCES/rustc-1.59.0-src.tar.xz SOURCES/wasi-libc-ad5133410f66b93a2381db5b542aad5e0964db96.tar.gz diff --git a/.rust.metadata b/.rust.metadata index 8d0c576..cfe48f5 100644 --- a/.rust.metadata +++ b/.rust.metadata @@ -1,2 +1,2 @@ -f036a5589319edb5a741d396d40cc1a95291f426 SOURCES/rustc-1.57.0-src.tar.xz +6b4d78a09afcba3ece6f4f535360cf889eba00a2 SOURCES/rustc-1.59.0-src.tar.xz b8865d1192852214d6d9b0a0957d4b36c16832aa SOURCES/wasi-libc-ad5133410f66b93a2381db5b542aad5e0964db96.tar.gz diff --git a/SOURCES/rust-pr91070.patch b/SOURCES/rust-pr91070.patch deleted file mode 100644 index 1b4f052..0000000 --- a/SOURCES/rust-pr91070.patch +++ /dev/null @@ -1,94 +0,0 @@ -diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -index e77d29bed712..f3d8eb2602a3 100644 ---- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp -@@ -124,8 +124,18 @@ extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M, - - extern "C" LLVMValueRef - LLVMRustGetOrInsertGlobal(LLVMModuleRef M, const char *Name, size_t NameLen, LLVMTypeRef Ty) { -+ Module *Mod = unwrap(M); - StringRef NameRef(Name, NameLen); -- return wrap(unwrap(M)->getOrInsertGlobal(NameRef, unwrap(Ty))); -+ -+ // We don't use Module::getOrInsertGlobal because that returns a Constant*, -+ // which may either be the real GlobalVariable*, or a constant bitcast of it -+ // if our type doesn't match the original declaration. We always want the -+ // GlobalVariable* so we can access linkage, visibility, etc. -+ GlobalVariable *GV = Mod->getGlobalVariable(NameRef, true); -+ if (!GV) -+ GV = new GlobalVariable(*Mod, unwrap(Ty), false, -+ GlobalValue::ExternalLinkage, nullptr, NameRef); -+ return wrap(GV); - } - - extern "C" LLVMValueRef -diff --git a/src/test/ui/statics/issue-91050-1.rs b/src/test/ui/statics/issue-91050-1.rs -new file mode 100644 -index 000000000000..403a41462ef1 ---- /dev/null -+++ b/src/test/ui/statics/issue-91050-1.rs -@@ -0,0 +1,34 @@ -+// build-pass -+// compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes -+ -+// This test declares globals by the same name with different types, which -+// caused problems because Module::getOrInsertGlobal would return a Constant* -+// bitcast instead of a GlobalVariable* that could access linkage/visibility. -+// In alt builds with LLVM assertions this would fail: -+// -+// rustc: /checkout/src/llvm-project/llvm/include/llvm/Support/Casting.h:269: -+// typename cast_retty::ret_type llvm::cast(Y *) [X = llvm::GlobalValue, Y = llvm::Value]: -+// Assertion `isa(Val) && "cast() argument of incompatible type!"' failed. -+// -+// In regular builds, the bad cast was UB, like "Invalid LLVMRustVisibility value!" -+ -+pub mod before { -+ #[no_mangle] -+ pub static GLOBAL1: [u8; 1] = [1]; -+} -+ -+pub mod inner { -+ extern "C" { -+ pub static GLOBAL1: u8; -+ pub static GLOBAL2: u8; -+ } -+ -+ pub fn call() { -+ drop(unsafe { (GLOBAL1, GLOBAL2) }); -+ } -+} -+ -+pub mod after { -+ #[no_mangle] -+ pub static GLOBAL2: [u8; 1] = [2]; -+} -diff --git a/src/test/ui/statics/issue-91050-2.rs b/src/test/ui/statics/issue-91050-2.rs -new file mode 100644 -index 000000000000..2ff954d15cab ---- /dev/null -+++ b/src/test/ui/statics/issue-91050-2.rs -@@ -0,0 +1,24 @@ -+// build-pass -+// compile-flags: --crate-type=rlib --emit=llvm-ir -Cno-prepopulate-passes -+ -+// This is a variant of issue-91050-1.rs -- see there for an explanation. -+ -+pub mod before { -+ extern "C" { -+ pub static GLOBAL1: [u8; 1]; -+ } -+ -+ pub unsafe fn do_something_with_array() -> u8 { -+ GLOBAL1[0] -+ } -+} -+ -+pub mod inner { -+ extern "C" { -+ pub static GLOBAL1: u8; -+ } -+ -+ pub unsafe fn call() -> u8 { -+ GLOBAL1 + 42 -+ } -+} diff --git a/SOURCES/rust-pr94505-mono-item-sort-local.patch b/SOURCES/rust-pr94505-mono-item-sort-local.patch new file mode 100644 index 0000000..7710704 --- /dev/null +++ b/SOURCES/rust-pr94505-mono-item-sort-local.patch @@ -0,0 +1,34 @@ +diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs +index 892808386dee..13c325a14e40 100644 +--- a/compiler/rustc_middle/src/mir/mono.rs ++++ b/compiler/rustc_middle/src/mir/mono.rs +@@ -7,6 +7,7 @@ + use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; + use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; + use rustc_hir::ItemId; ++use rustc_index::vec::Idx; + use rustc_query_system::ich::{NodeIdHashingMode, StableHashingContext}; + use rustc_session::config::OptLevel; + use rustc_span::source_map::Span; +@@ -380,7 +381,7 @@ fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<' + // instances into account. The others don't matter for + // the codegen tests and can even make item order + // unstable. +- InstanceDef::Item(def) => Some(def.did.index.as_usize()), ++ InstanceDef::Item(def) => def.did.as_local().map(Idx::index), + InstanceDef::VtableShim(..) + | InstanceDef::ReifyShim(..) + | InstanceDef::Intrinsic(..) +@@ -391,10 +392,8 @@ fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<' + | InstanceDef::CloneShim(..) => None, + } + } +- MonoItem::Static(def_id) => Some(def_id.index.as_usize()), +- MonoItem::GlobalAsm(item_id) => { +- Some(item_id.def_id.to_def_id().index.as_usize()) +- } ++ MonoItem::Static(def_id) => def_id.as_local().map(Idx::index), ++ MonoItem::GlobalAsm(item_id) => Some(item_id.def_id.index()), + }, + item.symbol_name(tcx), + ) diff --git a/SOURCES/rustc-1.57.0-no-default-pie.patch b/SOURCES/rustc-1.57.0-no-default-pie.patch deleted file mode 100644 index c9c8693..0000000 --- a/SOURCES/rustc-1.57.0-no-default-pie.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig 2021-11-29 10:41:02.380100917 -0800 -+++ rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs 2021-11-29 10:53:31.014783112 -0800 -@@ -1485,15 +1485,14 @@ - } - - fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind { -- let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) { -+ // Only use PIE if explicity specified. -+ let explicit_pic = -+ matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie)); -+ let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) { - (CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe, -- (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => { -- LinkOutputKind::DynamicPicExe -- } -+ (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe, - (CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe, -- (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => { -- LinkOutputKind::StaticPicExe -- } -+ (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe, - (CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe, - (_, true, _) => LinkOutputKind::StaticDylib, - (_, false, _) => LinkOutputKind::DynamicDylib, diff --git a/SOURCES/rustc-1.58.0-no-default-pie.patch b/SOURCES/rustc-1.58.0-no-default-pie.patch new file mode 100644 index 0000000..67fb0c6 --- /dev/null +++ b/SOURCES/rustc-1.58.0-no-default-pie.patch @@ -0,0 +1,44 @@ +diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs +index 638b2a7b5a9f..79d4ecf4cb91 100644 +--- a/compiler/rustc_codegen_ssa/src/back/link.rs ++++ b/compiler/rustc_codegen_ssa/src/back/link.rs +@@ -763,7 +763,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( + && cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") + { + info!("linker output: {:?}", out); +- warn!("Linker does not support -no-pie command line option. Retrying without."); ++ info!("Linker does not support -no-pie command line option. Retrying without."); + for arg in cmd.take_args() { + if arg.to_string_lossy() != "-no-pie" { + cmd.arg(arg); +@@ -782,7 +782,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( + && cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie") + { + info!("linker output: {:?}", out); +- warn!( ++ info!( + "Linker does not support -static-pie command line option. Retrying with -static instead." + ); + // Mirror `add_(pre,post)_link_objects` to replace CRT objects. +@@ -1507,15 +1507,14 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + } + + fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind { +- let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) { ++ // Only use PIE if explicitly specified. ++ let explicit_pic = ++ matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie)); ++ let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) { + (CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe, +- (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => { +- LinkOutputKind::DynamicPicExe +- } ++ (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe, + (CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe, +- (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => { +- LinkOutputKind::StaticPicExe +- } ++ (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe, + (CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe, + (_, true, _) => LinkOutputKind::StaticDylib, + (_, false, _) => LinkOutputKind::DynamicDylib, diff --git a/SOURCES/rustc-1.57.0-disable-http2.patch b/SOURCES/rustc-1.59.0-disable-http2.patch similarity index 65% rename from SOURCES/rustc-1.57.0-disable-http2.patch rename to SOURCES/rustc-1.59.0-disable-http2.patch index 6723dc6..603bd32 100644 --- a/SOURCES/rustc-1.57.0-disable-http2.patch +++ b/SOURCES/rustc-1.59.0-disable-http2.patch @@ -1,6 +1,6 @@ ---- rustc-beta-src/Cargo.lock.orig 2021-11-29 10:37:40.665228216 -0800 -+++ rustc-beta-src/Cargo.lock 2021-11-29 10:37:40.667228175 -0800 -@@ -889,7 +889,6 @@ +--- rustc-1.59.0-src/Cargo.lock.orig 2022-02-22 10:19:00.330367749 -0800 ++++ rustc-1.59.0-src/Cargo.lock 2022-02-22 10:19:00.332367706 -0800 +@@ -909,7 +909,6 @@ dependencies = [ "cc", "libc", @@ -8,7 +8,7 @@ "libz-sys", "openssl-sys", "pkg-config", -@@ -1907,16 +1906,6 @@ +@@ -1957,16 +1956,6 @@ checksum = "7fc7aa29613bd6a620df431842069224d8bc9011086b1db4c0e0cd47fa03ec9a" [[package]] @@ -25,20 +25,20 @@ name = "libz-sys" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" ---- rustc-beta-src/src/tools/cargo/Cargo.toml.orig 2021-11-29 10:37:40.667228175 -0800 -+++ rustc-beta-src/src/tools/cargo/Cargo.toml 2021-11-29 10:38:41.291987733 -0800 -@@ -25,7 +25,7 @@ - cargo-util = { path = "crates/cargo-util", version = "0.1.1" } - crates-io = { path = "crates/crates-io", version = "0.33.0" } +--- rustc-1.59.0-src/src/tools/cargo/Cargo.toml.orig 2022-02-22 10:19:00.332367706 -0800 ++++ rustc-1.59.0-src/src/tools/cargo/Cargo.toml 2022-02-22 10:19:54.029231795 -0800 +@@ -22,7 +22,7 @@ + cargo-util = { path = "crates/cargo-util", version = "0.1.2" } + crates-io = { path = "crates/crates-io", version = "0.33.1" } crossbeam-utils = "0.8" --curl = { version = "0.4.39", features = ["http2"] } -+curl = { version = "0.4.39", features = [] } - curl-sys = "0.4.49" +-curl = { version = "0.4.41", features = ["http2"] } ++curl = { version = "0.4.41", features = [] } + curl-sys = "0.4.50" env_logger = "0.9.0" pretty_env_logger = { version = "0.4", optional = true } ---- rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs.orig 2021-11-27 09:38:17.000000000 -0800 -+++ rustc-beta-src/src/tools/cargo/src/cargo/core/package.rs 2021-11-29 10:37:40.667228175 -0800 -@@ -417,14 +417,8 @@ +--- rustc-1.59.0-src/src/tools/cargo/src/cargo/core/package.rs.orig 2022-02-21 18:48:53.000000000 -0800 ++++ rustc-1.59.0-src/src/tools/cargo/src/cargo/core/package.rs 2022-02-22 10:19:00.332367706 -0800 +@@ -419,14 +419,8 @@ // Also note that pipelining is disabled as curl authors have indicated // that it's buggy, and we've empirically seen that it's buggy with HTTP // proxies. @@ -55,7 +55,7 @@ Ok(PackageSet { packages: package_ids -@@ -653,7 +647,7 @@ +@@ -655,7 +649,7 @@ macro_rules! try_old_curl { ($e:expr, $msg:expr) => { let result = $e; diff --git a/SOURCES/rustc-1.56.0-disable-libssh2.patch b/SOURCES/rustc-1.59.0-disable-libssh2.patch similarity index 59% rename from SOURCES/rustc-1.56.0-disable-libssh2.patch rename to SOURCES/rustc-1.59.0-disable-libssh2.patch index 4d9331b..4afd67c 100644 --- a/SOURCES/rustc-1.56.0-disable-libssh2.patch +++ b/SOURCES/rustc-1.59.0-disable-libssh2.patch @@ -1,6 +1,6 @@ ---- rustc-1.56.0-src/Cargo.lock.orig 2021-10-18 02:52:36.000000000 -0700 -+++ rustc-1.56.0-src/Cargo.lock 2021-10-19 18:00:47.999793566 -0700 -@@ -1895,7 +1895,6 @@ +--- rustc-1.59.0-src/Cargo.lock.orig 2022-02-21 18:48:37.000000000 -0800 ++++ rustc-1.59.0-src/Cargo.lock 2022-02-22 10:16:10.381962862 -0800 +@@ -1935,7 +1935,6 @@ dependencies = [ "cc", "libc", @@ -8,14 +8,14 @@ "libz-sys", "openssl-sys", "pkg-config", -@@ -1918,20 +1917,6 @@ +@@ -1968,20 +1967,6 @@ ] [[package]] -name = "libssh2-sys" --version = "0.2.19" +-version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" --checksum = "ca46220853ba1c512fc82826d0834d87b06bcd3c2a42241b7de72f3d2fe17056" +-checksum = "b094a36eb4b8b8c8a7b4b8ae43b2944502be3e59cd87687595cf6b0a71b3f4ca" -dependencies = [ - "cc", - "libc", @@ -29,9 +29,9 @@ name = "libz-sys" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" ---- rustc-1.56.0-src/vendor/git2/Cargo.toml.orig 2021-10-18 04:05:54.000000000 -0700 -+++ rustc-1.56.0-src/vendor/git2/Cargo.toml 2021-10-19 17:57:37.960500359 -0700 -@@ -52,7 +52,7 @@ +--- rustc-1.59.0-src/vendor/git2/Cargo.toml.orig 2022-02-21 20:14:37.000000000 -0800 ++++ rustc-1.59.0-src/vendor/git2/Cargo.toml 2022-02-22 10:12:23.021772490 -0800 +@@ -51,7 +51,7 @@ version = "0.1.39" [features] diff --git a/SPECS/rust.spec b/SPECS/rust.spec index 669b652..08230b9 100644 --- a/SPECS/rust.spec +++ b/SPECS/rust.spec @@ -5,14 +5,14 @@ # The channel can be stable, beta, or nightly %{!?channel: %global channel stable} -# To bootstrap from scratch, set the channel and date from src/stage0.txt +# To bootstrap from scratch, set the channel and date from src/stage0.json # e.g. 1.10.0 wants rustc: 1.9.0-2016-05-24 # or nightly wants some beta-YYYY-MM-DD # Note that cargo matches the program version here, not its crate version. -%global bootstrap_rust 1.56.1 -%global bootstrap_cargo 1.56.1 -%global bootstrap_channel 1.56.1 -%global bootstrap_date 2021-11-01 +%global bootstrap_rust 1.58.0 +%global bootstrap_cargo 1.58.0 +%global bootstrap_channel 1.58.0 +%global bootstrap_date 2022-01-13 # Only the specified arches will use bootstrap binaries. #global bootstrap_arches %%{rust_arches} @@ -25,8 +25,11 @@ # on certain arches, namely s390x for its lack of lld. So we need to make it an # arch-specific package only for the supported arches. %ifnarch s390x +%if 0%{?fedora} +%global mingw_targets i686-pc-windows-gnu x86_64-pc-windows-gnu +%endif %if 0%{?fedora} || 0%{?rhel} >= 8 -%global cross_targets wasm32-unknown-unknown wasm32-wasi +%global wasm_targets wasm32-unknown-unknown wasm32-wasi %endif %endif @@ -42,16 +45,24 @@ %bcond_with llvm_static # We can also choose to just use Rust's bundled LLVM, in case the system LLVM -# is insufficient. Rust currently requires LLVM 10.0+. +# is insufficient. Rust currently requires LLVM 12.0+. +%global min_llvm_version 12.0.0 +%global bundled_llvm_version 13.0.0 %bcond_with bundled_llvm -# Requires stable libgit2 1.3 +# Requires stable libgit2 1.3, and not the next minor soname change. +# This needs to be consistent with the bindings in vendor/libgit2-sys. +%global min_libgit2_version 1.3.0 +%global next_libgit2_version 1.4.0~ +%global bundled_libgit2_version 1.3.0 %if 0%{?fedora} >= 36 %bcond_with bundled_libgit2 %else %bcond_without bundled_libgit2 %endif +# needs libssh2_userauth_publickey_frommemory +%global min_libssh2_version 1.6.0 %if 0%{?rhel} # Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) %bcond_without disabled_libssh2 @@ -73,7 +84,7 @@ %endif Name: rust -Version: 1.57.0 +Version: 1.59.0 Release: 1%{?dist} Summary: The Rust Programming Language License: (ASL 2.0 or MIT) and (BSD and MIT) @@ -90,25 +101,26 @@ Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz Source1: %{wasi_libc_source} # Sources for bootstrap_arches are inserted by lua below -# Fix a bad typecast for LLVM globals, rhbz#1990657 -# https://github.com/rust-lang/rust/pull/91070 -Patch1: rust-pr91070.patch - # By default, rust tries to use "rust-lld" as a linker for WebAssembly. -Patch2: 0001-Use-lld-provided-by-system-for-wasm.patch +Patch1: 0001-Use-lld-provided-by-system-for-wasm.patch + +# This regressed in 1.59, hanging builds on s390x, rhbz#2058803 +# https://github.com/rust-lang/rust/pull/94505 +Patch2: rust-pr94505-mono-item-sort-local.patch ### RHEL-specific patches below ### # Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) -Patch100: rustc-1.56.0-disable-libssh2.patch +Patch100: rustc-1.59.0-disable-libssh2.patch # libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys # will try to build it statically -- instead we turn off the feature. -Patch101: rustc-1.57.0-disable-http2.patch +Patch101: rustc-1.59.0-disable-http2.patch # kernel rh1410097 causes too-small stacks for PIE. # (affects RHEL6 kernels when building for RHEL7) -Patch102: rustc-1.57.0-no-default-pie.patch +Patch102: rustc-1.58.0-no-default-pie.patch + # Get the Rust triple for any arch. %{lua: function rust_triple(arch) @@ -169,7 +181,6 @@ BuildRequires: make BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: ncurses-devel -BuildRequires: curl # explicit curl-devel to avoid httpd24-curl (rhbz1540167) BuildRequires: curl-devel BuildRequires: pkgconfig(libcurl) @@ -178,25 +189,28 @@ BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(zlib) %if %{without bundled_libgit2} -BuildRequires: pkgconfig(libgit2) >= 1.3.0 +BuildRequires: (pkgconfig(libgit2) >= %{min_libgit2_version} with pkgconfig(libgit2) < %{next_libgit2_version}) %endif %if %{without disabled_libssh2} -# needs libssh2_userauth_publickey_frommemory -BuildRequires: pkgconfig(libssh2) >= 1.6.0 +BuildRequires: pkgconfig(libssh2) >= %{min_libssh2_version} %endif -%global python python3 -BuildRequires: %{python} +%if 0%{?rhel} == 8 +BuildRequires: platform-python +%else +BuildRequires: python3 +%endif +BuildRequires: python3-rpm-macros %if %with bundled_llvm BuildRequires: cmake3 >= 3.13.4 BuildRequires: ninja-build -Provides: bundled(llvm) = 13.0.0 +Provides: bundled(llvm) = %{bundled_llvm_version} %else BuildRequires: cmake >= 2.8.11 %if 0%{?epel} == 7 -%global llvm llvm11 +%global llvm llvm13 %endif %if %defined llvm %global llvm_root %{_libdir}/%{llvm} @@ -204,14 +218,14 @@ BuildRequires: cmake >= 2.8.11 %global llvm llvm %global llvm_root %{_prefix} %endif -BuildRequires: %{llvm}-devel >= 10.0 +BuildRequires: %{llvm}-devel >= %{min_llvm_version} %if %with llvm_static BuildRequires: %{llvm}-static BuildRequires: libffi-devel %endif %endif -# make check needs "ps" for src/test/run-pass/wait-forked-but-failed-child.rs +# make check needs "ps" for src/test/ui/wait-forked-but-failed-child.rs BuildRequires: procps-ng # debuginfo-gdb tests need gdb @@ -231,10 +245,17 @@ Requires: /usr/bin/cc %if 0%{?epel} == 7 %global devtoolset_name devtoolset-9 +BuildRequires: %{devtoolset_name}-binutils BuildRequires: %{devtoolset_name}-gcc BuildRequires: %{devtoolset_name}-gcc-c++ -%global __cc /opt/rh/%{devtoolset_name}/root/usr/bin/gcc -%global __cxx /opt/rh/%{devtoolset_name}/root/usr/bin/g++ +%global devtoolset_bindir /opt/rh/%{devtoolset_name}/root/usr/bin +%global __cc %{devtoolset_bindir}/gcc +%global __cxx %{devtoolset_bindir}/g++ +%global __ar %{devtoolset_bindir}/ar +%global __ranlib %{devtoolset_bindir}/ranlib +%global __strip %{devtoolset_bindir}/strip +%else +%global __ranlib %{_bindir}/ranlib %endif # ALL Rust libraries are private, because they don't keep an ABI. @@ -256,9 +277,6 @@ BuildRequires: %{devtoolset_name}-gcc-c++ %global _find_debuginfo_opts --keep-section .rustc %endif -# Use hardening ldflags. -%global rustflags -Clink-arg=-Wl,-z,relro,-z,now - %if %{without bundled_llvm} %if "%{llvm_root}" == "%{_prefix}" || 0%{?scl:1} %global llvm_has_filecheck 1 @@ -270,12 +288,24 @@ BuildRequires: %{devtoolset_name}-gcc-c++ %global common_libdir %{_prefix}/lib %global rustlibdir %{common_libdir}/rustlib -%if %defined cross_targets +%if %defined mingw_targets +BuildRequires: mingw32-filesystem >= 95 +BuildRequires: mingw64-filesystem >= 95 +BuildRequires: mingw32-crt +BuildRequires: mingw64-crt +BuildRequires: mingw32-gcc +BuildRequires: mingw64-gcc +BuildRequires: mingw32-winpthreads-static +BuildRequires: mingw64-winpthreads-static +%endif + +%if %defined wasm_targets BuildRequires: clang +BuildRequires: lld # brp-strip-static-archive breaks the archive index for wasm %global __os_install_post \ %__os_install_post \ -find '%{buildroot}%{rustlibdir}' -type f -path '*/wasm*/lib/*.rlib' -print -exec '%{llvm_root}/bin/llvm-ranlib' '{}' ';' \ +find '%{buildroot}%{rustlibdir}'/wasm*/lib -type f -regex '.*\\.\\(a\\|rlib\\)' -print -exec '%{llvm_root}/bin/llvm-ranlib' '{}' ';' \ %{nil} %endif @@ -288,37 +318,68 @@ This package includes the Rust compiler and documentation generator. %package std-static Summary: Standard library for Rust +Requires: %{name} = %{version}-%{release} +Requires: glibc-devel%{?_isa} >= 2.11 %description std-static This package includes the standard libraries for building applications written in Rust. -%if %defined cross_targets +%if %defined mingw_targets %{lua: do - for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do + for triple in string.gmatch(rpm.expand("%{mingw_targets}"), "%S+") do local subs = { triple = triple, + name = rpm.expand("%{name}"), + verrel = rpm.expand("%{version}-%{release}"), + mingw = string.sub(triple, 1, 4) == "i686" and "mingw32" or "mingw64", + } + local s = string.gsub([[ + +%package std-static-{{triple}} +Summary: Standard library for Rust {{triple}} +BuildArch: noarch +Provides: {{mingw}}-rust = {{verrel}} +Provides: {{mingw}}-rustc = {{verrel}} +Requires: {{mingw}}-crt +Requires: {{mingw}}-gcc +Requires: {{mingw}}-winpthreads-static +Requires: {{name}} = {{verrel}} + +%description std-static-{{triple}} +This package includes the standard libraries for building applications +written in Rust for the MinGW target {{triple}}. + +]], "{{(%w+)}}", subs) + print(s) + end +end} +%endif + +%if %defined wasm_targets +%{lua: do + for triple in string.gmatch(rpm.expand("%{wasm_targets}"), "%S+") do + local subs = { + triple = triple, + name = rpm.expand("%{name}"), verrel = rpm.expand("%{version}-%{release}"), - wasm = string.sub(triple, 1, 4) == "wasm" and 1 or 0, wasi = string.find(triple, "-wasi") and 1 or 0, } local s = string.gsub([[ %package std-static-{{triple}} -Summary: Standard library for Rust +Summary: Standard library for Rust {{triple}} # FIX: we can't be noarch while excluding s390x for lack of lld # BuildArch: noarch -Requires: rust = {{verrel}} -%if {{wasm}} +Requires: {{name}} = {{verrel}} Requires: lld >= 8.0 -%endif %if {{wasi}} Provides: bundled(wasi-libc) %endif %description std-static-{{triple}} This package includes the standard libraries for building applications -written in Rust for the {{triple}} target. +written in Rust for the WebAssembly target {{triple}}. ]], "{{(%w+)}}", subs) print(s) @@ -352,7 +413,7 @@ programs. Summary: LLDB pretty printers for Rust BuildArch: noarch Requires: lldb -Requires: %{python}-lldb +Requires: python3-lldb Requires: %{name}-debugger-common = %{version}-%{release} %description lldb @@ -377,12 +438,12 @@ its standard library. %package -n cargo Summary: Rust's package manager and build tool %if %with bundled_libgit2 -Provides: bundled(libgit2) = 1.3.0 +Provides: bundled(libgit2) = %{bundled_libgit2_version} %endif # For tests: -BuildRequires: git +BuildRequires: git-core # Cargo is not much use without Rust -Requires: rust +Requires: %{name} # "cargo vendor" is a builtin command starting with 1.37. The Obsoletes and # Provides are mostly relevant to RHEL, but harmless to have on Fedora/etc. too @@ -399,7 +460,7 @@ Summary: Documentation for Cargo BuildArch: noarch # Cargo no longer builds its own documentation # https://github.com/rust-lang/cargo/pull/4904 -Requires: rust-doc = %{version}-%{release} +Requires: %{name}-doc = %{version}-%{release} %description -n cargo-doc This package includes HTML documentation for Cargo. @@ -420,9 +481,9 @@ A tool for formatting Rust code according to style guidelines. %package -n rls Summary: Rust Language Server for IDE integration %if %with bundled_libgit2 -Provides: bundled(libgit2) = 1.3.0 +Provides: bundled(libgit2) = %{bundled_libgit2_version} %endif -Requires: rust-analysis +Requires: %{name}-analysis # /usr/bin/rls is dynamically linked against internal rustc libs Requires: %{name}%{?_isa} = %{version}-%{release} @@ -462,7 +523,7 @@ useful as a reference for code completion tools in various editors. %package analysis Summary: Compiler analysis data for the Rust standard library -Requires: rust-std-static%{?_isa} = %{version}-%{release} +Requires: %{name}-std-static%{?_isa} = %{version}-%{release} %description analysis This package contains analysis data files produced with rustc's -Zsave-analysis @@ -480,7 +541,7 @@ test -f '%{local_rust_root}/bin/cargo' test -f '%{local_rust_root}/bin/rustc' %endif -%if %defined cross_targets +%if %defined wasm_targets %setup -q -n %{wasi_libc_name} -T -b 1 %endif @@ -502,10 +563,8 @@ rm -rf vendor/libnghttp2-sys/ %patch102 -p1 %endif -%if "%{python}" != "python3" -# Use our preferred python first -sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure -%endif +# Use our explicit python3 first +sed -i.try-python -e '/^try python3 /i try "%{__python3}" "$@"' ./configure %if %without bundled_llvm rm -rf src/llvm-project/ @@ -556,18 +615,19 @@ find vendor -name .cargo-checksum.json \ find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+' # Set up shared environment variables for build/install/check -%global rust_env RUSTFLAGS="%{rustflags}" +%global rust_env %{?rustflags:RUSTFLAGS="%{rustflags}"} %if 0%{?cmake_path:1} -%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH" +%global rust_env %{?rust_env} PATH="%{cmake_path}:$PATH" %endif %if %without disabled_libssh2 # convince libssh2-sys to use the distro libssh2 -%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 +%global rust_env %{?rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 %endif +%global export_rust_env %{?rust_env:export %{rust_env}} %build -export %{rust_env} +%{export_rust_env} %ifarch %{arm} %{ix86} s390x # full debuginfo is exhausting memory; just do libstd for now @@ -591,29 +651,55 @@ if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then ncpus="$max_cpus" fi -%if %defined cross_targets -%make_build -C %{wasi_libc_dir} +%define target_config %{shrink: + --set target.%{rust_triple}.linker=%{__cc} + --set target.%{rust_triple}.cc=%{__cc} + --set target.%{rust_triple}.cxx=%{__cxx} + --set target.%{rust_triple}.ar=%{__ar} + --set target.%{rust_triple}.ranlib=%{__ranlib} +} + +%if %defined mingw_targets +%{lua: do + local cfg = "" + for triple in string.gmatch(rpm.expand("%{mingw_targets}"), "%S+") do + local subs = { + triple = triple, + mingw = string.sub(triple, 1, 4) == "i686" and "mingw32" or "mingw64", + } + local s = string.gsub([[%{shrink: + --set target.{{triple}}.linker=%{{{mingw}}_cc} + --set target.{{triple}}.cc=%{{{mingw}}_cc} + --set target.{{triple}}.ar=%{{{mingw}}_ar} + --set target.{{triple}}.ranlib=%{{{mingw}}_ranlib} + }]], "{{(%w+)}}", subs) + cfg = cfg .. " " .. s + end + rpm.define("mingw_target_config " .. cfg) +end} +%endif + +%if %defined wasm_targets +%make_build --quiet -C %{wasi_libc_dir} %{lua: do local wasi_root = rpm.expand("%{wasi_libc_dir}") .. "/sysroot" - local set_wasi_root = "" - for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do + local cfg = "" + for triple in string.gmatch(rpm.expand("%{wasm_targets}"), "%S+") do if string.find(triple, "-wasi") then - set_wasi_root = set_wasi_root .. " --set target." .. triple .. ".wasi-root=" .. wasi_root + cfg = cfg .. " --set target." .. triple .. ".wasi-root=" .. wasi_root end end - if wasi_root ~= "" then - rpm.define("set_wasi_root "..set_wasi_root) - end + rpm.define("wasm_target_config "..cfg) end} %endif %configure --disable-option-checking \ --libdir=%{common_libdir} \ --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \ - --set target.%{rust_triple}.linker=%{__cc} \ - --set target.%{rust_triple}.cc=%{__cc} \ - --set target.%{rust_triple}.cxx=%{__cxx} \ - --python=%{python} \ + %{target_config} \ + %{?mingw_target_config} \ + %{?wasm_target_config} \ + --python=%{__python3} \ --local-rust-root=%{local_rust_root} \ %{!?with_bundled_llvm: --llvm-root=%{llvm_root} \ %{!?llvm_has_filecheck: --disable-codegen-tests} \ @@ -625,30 +711,25 @@ end} --tools=analysis,cargo,clippy,rls,rustfmt,src \ --enable-vendor \ --enable-verbose-tests \ - %{?set_wasi_root} \ --dist-compression-formats=gz \ --release-channel=%{channel} \ --release-description="%{?fedora:Fedora }%{?rhel:Red Hat }%{version}-%{release}" -%{python} ./x.py build -j "$ncpus" --stage 2 -%{python} ./x.py doc --stage 2 +%{__python3} ./x.py build -j "$ncpus" --stage 2 +%{__python3} ./x.py doc --stage 2 -%if %defined cross_targets -for triple in %{cross_targets}; do - %{python} ./x.py build --stage 2 --target=$triple std +for triple in %{?mingw_targets} %{?wasm_targets}; do + %{__python3} ./x.py build --stage 2 --target=$triple std done -%endif %install -export %{rust_env} +%{export_rust_env} -DESTDIR=%{buildroot} %{python} ./x.py install +DESTDIR=%{buildroot} %{__python3} ./x.py install -%if %defined cross_targets -for triple in %{cross_targets}; do - DESTDIR=%{buildroot} %{python} ./x.py install --target=$triple std +for triple in %{?mingw_targets} %{?wasm_targets}; do + DESTDIR=%{buildroot} %{__python3} ./x.py install --target=$triple std done -%endif # These are transient files used by x.py dist and install rm -rf ./build/dist/ ./build/tmp/ @@ -721,7 +802,7 @@ rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll* %check -export %{rust_env} +%{export_rust_env} # Sanity-check the installed binaries, debuginfo-stripped and all. %{buildroot}%{_bindir}/cargo new build/hello-world @@ -729,20 +810,27 @@ env RUSTC=%{buildroot}%{_bindir}/rustc \ LD_LIBRARY_PATH="%{buildroot}%{_libdir}:$LD_LIBRARY_PATH" \ %{buildroot}%{_bindir}/cargo run --manifest-path build/hello-world/Cargo.toml +# Try a build sanity-check for other targets +for triple in %{?mingw_targets} %{?wasm_targets}; do + env RUSTC=%{buildroot}%{_bindir}/rustc \ + LD_LIBRARY_PATH="%{buildroot}%{_libdir}:$LD_LIBRARY_PATH" \ + %{buildroot}%{_bindir}/cargo build --manifest-path build/hello-world/Cargo.toml --target=$triple +done + # The results are not stable on koji, so mask errors and just log it. # Some of the larger test artifacts are manually cleaned to save space. -%{python} ./x.py test --no-fail-fast --stage 2 || : +%{__python3} ./x.py test --no-fail-fast --stage 2 || : rm -rf "./build/%{rust_triple}/test/" -%{python} ./x.py test --no-fail-fast --stage 2 cargo || : +%{__python3} ./x.py test --no-fail-fast --stage 2 cargo || : rm -rf "./build/%{rust_triple}/stage2-tools/%{rust_triple}/cit/" -%{python} ./x.py test --no-fail-fast --stage 2 clippy || : +%{__python3} ./x.py test --no-fail-fast --stage 2 clippy || : env RLS_TEST_WAIT_FOR_AGES=1 \ -%{python} ./x.py test --no-fail-fast --stage 2 rls || : +%{__python3} ./x.py test --no-fail-fast --stage 2 rls || : -%{python} ./x.py test --no-fail-fast --stage 2 rustfmt || : +%{__python3} ./x.py test --no-fail-fast --stage 2 rustfmt || : %ldconfig_scriptlets @@ -769,9 +857,35 @@ env RLS_TEST_WAIT_FOR_AGES=1 \ %{rustlibdir}/%{rust_triple}/lib/*.rlib -%if %defined cross_targets +%if %defined mingw_targets %{lua: do - for triple in string.gmatch(rpm.expand("%{cross_targets}"), "%S+") do + for triple in string.gmatch(rpm.expand("%{mingw_targets}"), "%S+") do + local subs = { + triple = triple, + rustlibdir = rpm.expand("%{rustlibdir}"), + } + local s = string.gsub([[ + +%files std-static-{{triple}} +%dir {{rustlibdir}} +%dir {{rustlibdir}}/{{triple}} +%dir {{rustlibdir}}/{{triple}}/lib +{{rustlibdir}}/{{triple}}/lib/*.rlib +{{rustlibdir}}/{{triple}}/lib/rs*.o +%exclude {{rustlibdir}}/{{triple}}/lib/*.dll +%exclude {{rustlibdir}}/{{triple}}/lib/*.dll.a +%exclude {{rustlibdir}}/{{triple}}/lib/self-contained + +]], "{{(%w+)}}", subs) + print(s) + end +end} +%endif + + +%if %defined wasm_targets +%{lua: do + for triple in string.gmatch(rpm.expand("%{wasm_targets}"), "%S+") do local subs = { triple = triple, rustlibdir = rpm.expand("%{rustlibdir}"), @@ -787,6 +901,7 @@ env RLS_TEST_WAIT_FOR_AGES=1 \ %if {{wasi}} %dir {{rustlibdir}}/{{triple}}/lib/self-contained {{rustlibdir}}/{{triple}}/lib/self-contained/crt*.o +{{rustlibdir}}/{{triple}}/lib/self-contained/libc.a %endif ]], "{{(%w+)}}", subs) @@ -879,6 +994,15 @@ end} %changelog +* Tue Apr 19 2022 Josh Stone - 1.59.0-1 +- Update to 1.59.0. + +* Thu Jan 20 2022 Josh Stone - 1.58.1-1 +- Update to 1.58.1. + +* Thu Jan 13 2022 Josh Stone - 1.58.0-1 +- Update to 1.58.0. + * Wed Dec 15 2021 Josh Stone - 1.57.0-1 - Update to 1.57.0.