diff --git a/rust.spec b/rust.spec index dae778133aceb0608cd7eeb5a83d86b81999aa32..8da732a8800d7b15e32e3d89156470f7f455fa26 100644 --- a/rust.spec +++ b/rust.spec @@ -11,7 +11,7 @@ Name: rust Version: 1.76.0 -Release: 1 +Release: 2 Summary: The Rust Programming Language License: Apache-2.0 OR MIT URL: https://www.rust-lang.org @@ -113,6 +113,8 @@ BuildRequires: %{llvm}-static libffi-devel %endif BuildRequires: procps-ng BuildRequires: ninja-build +BuildRequires: compiler-rt +BuildRequires: clang Provides: rustc = %{version}-%{release} Provides: rustc%{?_isa} = %{version}-%{release} Requires: %{name}-std-static%{?_isa} = %{version}-%{release} @@ -312,10 +314,29 @@ 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 + +# Find the compiler-rt library for the Rust profiler_builtins crate. +# But there are two versions in openEuler. Why? +# We don't have macros.clang so we need clang version here +IFS='.' read -ra VERSION_PARTS <<< "$(clang --version | sed -n 's/clang version //p' | sed 's/ (.*//g' | cut -d. -f1-3))" +# This is for avoiding rpm syntax error +%global clang_maj_ver %%(clang --version | sed -n 's/clang version //p' | cut -d. -f1) +%global clang_min_ver %%(${VERSION_PARTS[1]}) +%global clang_patch_ver %%(${VERSION_PARTS[2]}) +%if %{?clang_maj_ver} >= 17 +# This is the new one, used on openEuler 24.03 LTS or later +%define profiler %(echo %{_prefix}/%{_lib}/clang/%{clang_maj_ver}/lib/%{_arch}-openEuler-linux-gnu/libclang_rt.profile.a) +%else +# This is used before openEuler 23.09 +%define profiler %(echo %{_prefix}/%{_lib}/clang/%{clang_maj_ver}.%{clang_min_ver}.%{clang_patch_ver}/lib/libclang_rt.profile-%{_arch}.a) +%endif +test -r "%{profiler}" + %configure --disable-option-checking \ --libdir=%{common_libdir} \ %{rust_musl_root}=%{musl_root} \ --build=%{rust_triple} --host=%{rust_triple} --target=%{rust_triple},%{rust_musl_triple} \ + --set target.%{rust_triple}.profiler="%{profiler}" \ --python=%{python} \ --local-rust-root=%{local_rust_root} \ %{!?with_bundled_llvm: --llvm-root=%{llvm_root} \ @@ -490,6 +511,9 @@ export %{rust_env} %{_mandir}/man1/cargo*.1* %changelog +* Tue Mar 26 2024 misaka00251 - 1.76.0-2 +- Enable profiler builtin + * Tue Feb 20 2024 wangkai <13474090681@163.com> - 1.76.0-1 - Update to 1.76.0