diff --git a/SPECS/rust.spec b/SPECS/rust.spec index 6196a3ca..4322e89f 100644 --- a/SPECS/rust.spec +++ b/SPECS/rust.spec @@ -1,5 +1,9 @@ +%global _optflags '-m64 -O3 -fsigned-char -fno-strength-reduce -mcpu=power8 -mtune=power8 -mpower8-fusion -mpower8-vector -mcrypto -maltivec -mvsx -mdirect-move -mpowerpc-gpopt -mpowerpc-gfxopt -fPIE -fPIC' +%global _smp_mflags -j16 +%define python /usr/bin/python3 + # Only x86_64 and i686 are Tier 1 platforms at this time. -# https://doc.rust-lang.org/nightly/rustc/platform-support.html +# https://forge.rust-lang.org/platform-support.html %global rust_arches x86_64 i686 armv7hl aarch64 ppc64 ppc64le s390x # The channel can be stable, beta, or nightly @@ -9,50 +13,53 @@ # 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.49.0 -%global bootstrap_cargo 1.49.0 -%global bootstrap_channel 1.49.0 -%global bootstrap_date 2020-12-31 +%global bootstrap_rust 1.43.1 +%global bootstrap_cargo 1.43.1 +%global bootstrap_channel 1.43.1 +%global bootstrap_date 2020-05-07 # Only the specified arches will use bootstrap binaries. -%global bootstrap_arches %%{rust_arches} +#global bootstrap_arches %%{rust_arches} # Using llvm-static may be helpful as an opt-in, e.g. to aid LLVM rebases. -%bcond_without llvm_static +%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 9.0+. +# is insufficient. Rust currently requires LLVM 7.0+. +%if 0%{?rhel} && !0%{?epel} %bcond_without bundled_llvm - -# Requires stable libgit2 1.1 -%if 0%{?fedora} >= 34 -%bcond_with bundled_libgit2 %else -%bcond_without bundled_libgit2 +%bcond_with bundled_llvm %endif +# libgit2-sys expects to use its bundled library, which is sometimes just a +# snapshot of libgit2's master branch. This can mean the FFI declarations +# won't match our released libgit2.so, e.g. having changed struct fields. +# So, tread carefully if you toggle this... +%bcond_without bundled_libgit2 + %if 0%{?rhel} -# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) -%bcond_without disabled_libssh2 +%bcond_without bundled_libssh2 %else -%bcond_with disabled_libssh2 +%bcond_with bundled_libssh2 %endif -%if 0%{?rhel} && 0%{?rhel} < 8 +%if 0%{?rhel} && 0%{?rhel} <= 7 %bcond_with curl_http2 %else %bcond_without curl_http2 %endif + # LLDB isn't available everywhere... -%if 0%{?rhel} && 0%{?rhel} < 8 -%bcond_with lldb -%else +%if !0%{?rhel} %bcond_without lldb +%else +%bcond_with lldb %endif Name: rust -Version: 1.50.0 +Version: 1.44.1 Release: 1%{?dist} Summary: The Rust Programming Language License: (ASL 2.0 or MIT) and (BSD and MIT) @@ -67,24 +74,12 @@ ExclusiveArch: %{rust_arches} %endif Source0: https://static.rust-lang.org/dist/%{rustc_package}.tar.xz -# This internal rust-abi change broke s390x -- revert for now. -# https://github.com/rust-lang/rust/issues/80810#issuecomment-781784032 -Patch1: 0001-Revert-Auto-merge-of-79547.patch - -### RHEL-specific patches below ### - -# Disable cargo->libgit2->libssh2 on RHEL, as it's not approved for FIPS (rhbz1732949) -Patch100: rustc-1.48.0-disable-libssh2.patch +# https://github.com/rust-lang/rust/pull/71782 +Patch1: rust-pr71782-Use-a-non-existent-test-path.patch -# libcurl on RHEL7 doesn't have http2, but since cargo requests it, curl-sys +# libcurl on EL7 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.49.0-disable-http2.patch - -# kernel rh1410097 causes too-small stacks for PIE. -# (affects RHEL6 kernels when building for RHEL7) -Patch102: rustc-1.48.0-no-default-pie.patch - -Patch500: rust-llvm-cmake-config-ppc64le.patch +Patch10: rustc-1.44.0-disable-http2.patch # Get the Rust triple for any arch. %{lua: function rust_triple(arch) @@ -96,13 +91,12 @@ Patch500: rust-llvm-cmake-config-ppc64le.patch arch = "powerpc64" elseif arch == "ppc64le" then arch = "powerpc64le" - elseif arch == "riscv64" then - arch = "riscv64gc" end return arch.."-unknown-linux-"..abi end} %global rust_triple %{lua: print(rust_triple(rpm.expand("%{_target_cpu}")))} +%define rust_triple powerpc64le-unknown-linux-gnu %if %defined bootstrap_arches # For each bootstrap arch, add an additional binary Source. @@ -131,11 +125,11 @@ end} Provides: bundled(%{name}-bootstrap) = %{bootstrap_rust} %else BuildRequires: cargo >= %{bootstrap_cargo} -%if 0%{?rhel} && 0%{?rhel} < 8 +%if 0%{?fedora} >= 27 +BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{version}) +%else BuildRequires: %{name} >= %{bootstrap_rust} BuildConflicts: %{name} > %{version} -%else -BuildRequires: (%{name} >= %{bootstrap_rust} with %{name} <= %{version}) %endif %global local_rust_root %{_prefix} %endif @@ -145,31 +139,33 @@ BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: ncurses-devel BuildRequires: curl -# explicit curl-devel to avoid httpd24-curl (rhbz1540167) -BuildRequires: curl-devel BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(liblzma) BuildRequires: pkgconfig(openssl) BuildRequires: pkgconfig(zlib) %if %without bundled_libgit2 -BuildRequires: pkgconfig(libgit2) >= 1.1.0 +BuildRequires: pkgconfig(libgit2) >= 1.0.0 %endif -%if %{without disabled_libssh2} +%if %without bundled_libssh2 # needs libssh2_userauth_publickey_frommemory BuildRequires: pkgconfig(libssh2) >= 1.6.0 %endif +%if 0%{?rhel} && 0%{?rhel} <= 7 +%global python python2 +%else %global python python3 +%endif BuildRequires: %{python} %if %with bundled_llvm BuildRequires: cmake3 >= 3.4.3 -Provides: bundled(llvm) = 11.0.0 +Provides: bundled(llvm) = 9.0.1 %else BuildRequires: cmake >= 2.8.11 -%if 0%{?epel} == 7 +%if 0%{?epel} %global llvm llvm9.0 %endif %if %defined llvm @@ -178,7 +174,7 @@ BuildRequires: cmake >= 2.8.11 %global llvm llvm %global llvm_root %{_prefix} %endif -BuildRequires: %{llvm}-devel >= 9.0 +BuildRequires: %{llvm}-devel >= 8.0 %if %with llvm_static BuildRequires: %{llvm}-static BuildRequires: libffi-devel @@ -191,6 +187,9 @@ BuildRequires: procps-ng # debuginfo-gdb tests need gdb BuildRequires: gdb +# TODO: work on unbundling these! +Provides: bundled(libbacktrace) = 1.0.20200219 + # Virtual provides for folks who attempt "dnf install rustc" Provides: rustc = %{version}-%{release} Provides: rustc%{?_isa} = %{version}-%{release} @@ -212,14 +211,14 @@ Requires: /usr/bin/cc # While we don't want to encourage dynamic linking to Rust shared libraries, as # there's no stable ABI, we still need the unallocated metadata (.rustc) to -# support custom-derive plugins like #[proc_macro_derive(Foo)]. -%if 0%{?rhel} && 0%{?rhel} < 8 -# eu-strip is very eager by default, so we have to limit it to -g, only debugging symbols. -%global _find_debuginfo_opts -g -%undefine _include_minidebuginfo -%else +# support custom-derive plugins like #[proc_macro_derive(Foo)]. But eu-strip is +# very eager by default, so we have to limit it to -g, only debugging symbols. +%if 0%{?fedora} >= 27 # Newer find-debuginfo.sh supports --keep-section, which is preferable. rhbz1465997 %global _find_debuginfo_opts --keep-section .rustc +%else +%global _find_debuginfo_opts -g +%undefine _include_minidebuginfo %endif # Use hardening ldflags. @@ -271,7 +270,11 @@ programs. Summary: LLDB pretty printers for Rust BuildArch: noarch Requires: lldb -Requires: %{python}-lldb +%if 0%{?fedora} >= 31 +Requires: python3-lldb +%else +Requires: python2-lldb +%endif Requires: %{name}-debugger-common = %{version}-%{release} %description lldb @@ -296,7 +299,10 @@ its standard library. %package -n cargo Summary: Rust's package manager and build tool %if %with bundled_libgit2 -Provides: bundled(libgit2) = 1.1.0 +Provides: bundled(libgit2) = 1.0.0 +%endif +%if %with bundled_libssh2 +Provides: bundled(libssh2) = 1.9.0~dev %endif # For tests: BuildRequires: git @@ -339,7 +345,10 @@ 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.1.0 +Provides: bundled(libgit2) = 1.0.0 +%endif +%if %with bundled_libssh2 +Provides: bundled(libssh2) = 1.9.0~dev %endif Requires: rust-analysis # /usr/bin/rls is dynamically linked against internal rustc libs @@ -403,35 +412,23 @@ test -f '%{local_rust_root}/bin/rustc' %patch1 -p1 -%if %with disabled_libssh2 -%patch100 -p1 -%endif - %if %without curl_http2 -%patch101 -p1 +%patch10 -p1 rm -rf vendor/libnghttp2-sys/ %endif -%if 0%{?rhel} && 0%{?rhel} < 8 -%patch102 -p1 -%endif - -%if "%{python}" != "python3" -# Use our preferred python first -sed -i.try-python -e '/^try python3 /i try "%{python}" "$@"' ./configure +%if "%{python}" == "python3" +sed -i.try-py3 -e '/try python2.7/i try python3 "$@"' ./configure %endif %if %without bundled_llvm rm -rf src/llvm-project/ -mkdir -p src/llvm-project/libunwind/ %endif # Remove other unused vendored libraries rm -rf vendor/curl-sys/curl/ rm -rf vendor/jemalloc-sys/jemalloc/ -rm -rf vendor/libssh2-sys/libssh2/ rm -rf vendor/libz-sys/src/zlib/ -rm -rf vendor/libz-sys/src/zlib-ng/ rm -rf vendor/lzma-sys/xz-*/ rm -rf vendor/openssl-src/openssl/ @@ -439,14 +436,17 @@ rm -rf vendor/openssl-src/openssl/ rm -rf vendor/libgit2-sys/libgit2/ %endif -%if %with disabled_libssh2 -rm -rf vendor/libssh2-sys/ +%if %without bundled_libssh2 +rm -rf vendor/libssh2-sys/libssh2/ %endif # This only affects the transient rust-installer, but let it use our dynamic xz-libs sed -i.lzma -e '/LZMA_API_STATIC/d' src/bootstrap/tool.rs -%if %{with bundled_llvm} && 0%{?epel} == 7 +# rename bundled license for packaging +cp -a vendor/backtrace-sys/src/libbacktrace/LICENSE{,-libbacktrace} + +%if %{with bundled_llvm} && 0%{?epel} mkdir -p cmake-bin ln -s /usr/bin/cmake3 cmake-bin/cmake %global cmake_path $PWD/cmake-bin @@ -469,28 +469,21 @@ find vendor -name .cargo-checksum.json \ # it's a shebang and make them executable. Then brp-mangle-shebangs gets upset... 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}" -%if 0%{?cmake_path:1} -%global rust_env %{rust_env} PATH="%{cmake_path}:$PATH" -%endif + +%build + %if %without bundled_libgit2 # convince libgit2-sys to use the distro libgit2 -%global rust_env %{rust_env} LIBGIT2_SYS_USE_PKG_CONFIG=1 +export LIBGIT2_SYS_USE_PKG_CONFIG=1 %endif -%if %without disabled_libssh2 + +%if %without bundled_libssh2 # convince libssh2-sys to use the distro libssh2 -%global rust_env %{rust_env} LIBSSH2_SYS_USE_PKG_CONFIG=1 +export LIBSSH2_SYS_USE_PKG_CONFIG=1 %endif -sed 's/3\.13\.4/3.12.2/' -i src/llvm-project/llvm/CMakeLists.txt -sed 's/5\.1/4.8/' -i src/llvm-project/llvm/cmake/modules/CheckCompilerVersion.cmake - -%patch500 -p0 - - -%build -export %{rust_env} +%{?cmake_path:export PATH=%{cmake_path}:$PATH} +%{?rustflags:export RUSTFLAGS="%{rustflags}"} # We're going to override --libdir when configuring to get rustlib into a # common path, but we'll fix the shared libraries during install. @@ -500,7 +493,7 @@ export %{rust_env} %ifarch %{arm} %{ix86} s390x # full debuginfo is exhausting memory; just do libstd for now # https://github.com/rust-lang/rust/issues/45854 -%if 0%{?rhel} && 0%{?rhel} < 8 +%if (0%{?fedora} && 0%{?fedora} < 27) || (0%{?rhel} && 0%{?rhel} <= 7) # Older rpmbuild didn't work with partial debuginfo coverage. %global debug_package %{nil} %define enable_debuginfo --debuginfo-level=0 @@ -518,15 +511,9 @@ export %{rust_env} %define codegen_units_std --set rust.codegen-units-std=1 %endif -# Some builders have relatively little memory for their CPU count. -# At least 2GB per CPU is a good rule of thumb for building rustc. -ncpus=$(/usr/bin/getconf _NPROCESSORS_ONLN) -max_cpus=$(( ($(free -g | awk '/^Mem:/{print $2}') + 1) / 2 )) -if [ "$max_cpus" -ge 1 -a "$max_cpus" -lt "$ncpus" ]; then - ncpus="$max_cpus" -fi +source /opt/rh/devtoolset-7/enable -%configure --disable-option-checking \ +./configure --disable-option-checking \ --libdir=%{common_libdir} \ --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple} \ --python=%{python} \ @@ -537,19 +524,18 @@ fi --disable-rpath \ %{enable_debuginfo} \ --enable-extended \ - --tools=analysis,cargo,clippy,rls,rustfmt,src \ --enable-vendor \ --enable-verbose-tests \ %{?codegen_units_std} \ - --release-channel=%{channel} \ - --release-description="PowerEL %{version}-%{release}" + --release-channel=%{channel} -%{python} ./x.py build -j "$ncpus" --stage 2 -%{python} ./x.py doc --stage 2 +%{python} ./x.py build +%{python} ./x.py doc %install -export %{rust_env} +%{?cmake_path:export PATH=%{cmake_path}:$PATH} +%{?rustflags:export RUSTFLAGS="%{rustflags}"} DESTDIR=%{buildroot} %{python} ./x.py install @@ -613,22 +599,20 @@ ln -sT ../rust/html/cargo/ %{buildroot}%{_docdir}/cargo/html %if %without lldb rm -f %{buildroot}%{_bindir}/rust-lldb -rm -f %{buildroot}%{rustlibdir}/etc/lldb_* +rm -f %{buildroot}%{rustlibdir}/etc/lldb_*.py* %endif -# We don't want Rust copies of LLVM tools (rust-lld, rust-llvm-dwp) -rm -f %{buildroot}%{rustlibdir}/%{rust_triple}/bin/rust-ll* - %check -export %{rust_env} +%{?cmake_path:export PATH=%{cmake_path}:$PATH} +%{?rustflags:export RUSTFLAGS="%{rustflags}"} # The results are not stable on koji, so mask errors and just log it. -%{python} ./x.py test --no-fail-fast --stage 2 || : -%{python} ./x.py test --no-fail-fast --stage 2 cargo || : -%{python} ./x.py test --no-fail-fast --stage 2 clippy || : -%{python} ./x.py test --no-fail-fast --stage 2 rls || : -%{python} ./x.py test --no-fail-fast --stage 2 rustfmt || : +%{python} ./x.py test --no-fail-fast || : +%{python} ./x.py test --no-fail-fast cargo || : +%{python} ./x.py test --no-fail-fast clippy || : +%{python} ./x.py test --no-fail-fast rls || : +%{python} ./x.py test --no-fail-fast rustfmt || : %ldconfig_scriptlets @@ -636,6 +620,7 @@ export %{rust_env} %files %license COPYRIGHT LICENSE-APACHE LICENSE-MIT +%license vendor/backtrace-sys/src/libbacktrace/LICENSE-libbacktrace %doc README.md %{_bindir}/rustc %{_bindir}/rustdoc @@ -646,6 +631,7 @@ export %{rust_env} %dir %{rustlibdir}/%{rust_triple} %dir %{rustlibdir}/%{rust_triple}/lib %{rustlibdir}/%{rust_triple}/lib/*.so +%exclude %{_bindir}/*miri %files std-static @@ -658,19 +644,19 @@ export %{rust_env} %files debugger-common %dir %{rustlibdir} %dir %{rustlibdir}/etc -%{rustlibdir}/etc/rust_*.py* +%{rustlibdir}/etc/debugger_*.py* %files gdb %{_bindir}/rust-gdb -%{rustlibdir}/etc/gdb_* +%{rustlibdir}/etc/gdb_*.py* %exclude %{_bindir}/rust-gdbgui %if %with lldb %files lldb %{_bindir}/rust-lldb -%{rustlibdir}/etc/lldb_* +%{rustlibdir}/etc/lldb_*.py* %endif @@ -681,6 +667,7 @@ export %{rust_env} %{_docdir}/%{name}/html/*/ %{_docdir}/%{name}/html/*.html %{_docdir}/%{name}/html/*.css +%{_docdir}/%{name}/html/*.ico %{_docdir}/%{name}/html/*.js %{_docdir}/%{name}/html/*.png %{_docdir}/%{name}/html/*.svg @@ -693,7 +680,6 @@ export %{rust_env} %license src/tools/cargo/LICENSE-APACHE src/tools/cargo/LICENSE-MIT src/tools/cargo/LICENSE-THIRD-PARTY %doc src/tools/cargo/README.md %{_bindir}/cargo -%{_libexecdir}/cargo* %{_mandir}/man1/cargo*.1* %{_sysconfdir}/bash_completion.d/cargo %{_datadir}/zsh/site-functions/_cargo @@ -737,51 +723,6 @@ export %{rust_env} %changelog -* Thu Feb 11 2021 Josh Stone - 1.50.0-1 -- Update to 1.50.0. - -* Wed Jan 27 2021 Fedora Release Engineering - 1.49.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Tue Jan 05 2021 Josh Stone - 1.49.0-1 -- Update to 1.49.0. - -* Tue Dec 29 2020 Igor Raits - 1.48.0-3 -- De-bootstrap - -* Mon Dec 28 2020 Igor Raits - 1.48.0-2 -- Rebuild for libgit2 1.1.x - -* Thu Nov 19 2020 Josh Stone - 1.48.0-1 -- Update to 1.48.0. - -* Sat Oct 10 2020 Jeff Law - 1.47.0-2 -- Re-enable LTO - -* Thu Oct 08 2020 Josh Stone - 1.47.0-1 -- Update to 1.47.0. - -* Fri Aug 28 2020 Fabio Valentini - 1.46.0-2 -- Fix LTO with doctests (backported cargo PR#8657). - -* Thu Aug 27 2020 Josh Stone - 1.46.0-1 -- Update to 1.46.0. - -* Mon Aug 03 2020 Josh Stone - 1.45.2-1 -- Update to 1.45.2. - -* Thu Jul 30 2020 Josh Stone - 1.45.1-1 -- Update to 1.45.1. - -* Wed Jul 29 2020 Fedora Release Engineering - 1.45.0-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Thu Jul 16 2020 Josh Stone - 1.45.0-1 -- Update to 1.45.0. - -* Wed Jul 01 2020 Jeff Law - 1.44.1-2 -- Disable LTO - * Thu Jun 18 2020 Josh Stone - 1.44.1-1 - Update to 1.44.1.