#30 Fix building against LLVM compat library
Merged 23 days ago by jistone. Opened 2 months ago by nikic.
rpms/ nikic/rust compat-build  into  rawhide

file modified
+10 -4
@@ -66,6 +66,8 @@ 

  # is insufficient.  Rust currently requires LLVM 15.0+.

  %global min_llvm_version 15.0.0

  %global bundled_llvm_version 17.0.6

+ #global llvm_compat_version 17

+ %global llvm llvm%{?llvm_compat_version}

  %bcond_with bundled_llvm

  

  # Requires stable libgit2 1.7, and not the next minor soname change.
@@ -250,10 +252,9 @@ 

  Provides:       bundled(llvm) = %{bundled_llvm_version}

  %else

  BuildRequires:  cmake >= 3.5.1

- %if %defined llvm

+ %if %defined llvm_compat_version

  %global llvm_root %{_libdir}/%{llvm}

  %else

- %global llvm llvm

  %global llvm_root %{_prefix}

  %endif

  BuildRequires:  %{llvm}-devel >= %{min_llvm_version}
@@ -335,7 +336,7 @@ 

  %endif

  

  # For profiler_builtins

- BuildRequires:  compiler-rt

+ BuildRequires:  compiler-rt%{?llvm_compat_version}

  

  # This component was removed as of Rust 1.69.0.

  # https://github.com/rust-lang/rust/pull/101841
@@ -735,12 +736,17 @@ 

  %endif

  

  # Find the compiler-rt library for the Rust profiler_builtins crate.

+ %if %defined llvm_compat_version

+ # clang_resource_dir is not defined for compat builds.

+ %define profiler /usr/lib/clang/%{llvm_compat_version}/lib/%{_arch}-redhat-linux-gnu/libclang_rt.profile.a

+ %else

  %if 0%{?clang_major_version} >= 17

  %define profiler %{clang_resource_dir}/lib/%{_arch}-redhat-linux-gnu/libclang_rt.profile.a

  %else

  # The exact profiler path is version dependent..

  %define profiler %(echo %{_libdir}/clang/??/lib/libclang_rt.profile-*.a)

  %endif

+ %endif

  test -r "%{profiler}"

  

  %configure --disable-option-checking \
@@ -789,7 +795,7 @@ 

  env LLVM_PROFILE_FILE="%{profraw}/default_%%m_%%p.profraw" \

    %{__x} --keep-stage=0 --keep-stage=1 build cargo

  # Finalize the profile data and clean up the raw files

- llvm-profdata merge -o "%{profdata}" "%{profraw}"

+ %{llvm_root}/bin/llvm-profdata merge -o "%{profdata}" "%{profraw}"

  rm -r "%{profraw}" build/%{rust_triple}/stage2*/

  # Redefine the macro to use that profile data from now on

  %global __x %{__x} --rust-profile-use="%{profdata}"

We also need to use the corresponding compiler-rt version and
use the llvm-profdata from the correct path.

The compat build is now enabled by defining llvm_compat_version rather than llvm.

rebased onto e07959e

2 months ago

We probably can't land this until we have LLVM 18 compat with 1.77, right? Or else go ahead and force it to llvm17 now for f40+.

Hm yeah, I guess we can't do builds right now without actually switching to the compat package. I think it's fine to land this after the 1.77 update.

rebased onto f6ac4da

24 days ago

I've rebase this now that the update has landed. I've also created a scratch build with llvm_compat_version commented-in to confirm that actually works here: https://koji.fedoraproject.org/koji/taskinfo?taskID=116072444

Pull-Request has been merged by jistone

23 days ago
Metadata