Revert use of clang/lld; patch cc-rs#1354 instead

This commit is contained in:
Josh Stone 2025-01-09 17:24:50 -08:00
commit 81b4dce864
2 changed files with 46 additions and 13 deletions

View file

@ -0,0 +1,39 @@
From e4e678eb9cbd90acf2ba51e9ec0209b05c4403b5 Mon Sep 17 00:00:00 2001
From: Josh Stone <cuviper@gmail.com>
Date: Thu, 9 Jan 2025 16:47:10 -0800
Subject: [PATCH] Only translate profile flags for Clang
---
src/flags.rs | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/src/flags.rs b/src/flags.rs
index 81834cf625f7..1a53c1b2345c 100644
--- a/src/flags.rs
+++ b/src/flags.rs
@@ -201,13 +201,15 @@ impl<'this> RustcCodegenFlags<'this> {
if self.no_vectorize_slp {
push_if_supported("-fno-slp-vectorize".into());
}
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-generate
- if let Some(value) = self.profile_generate {
- push_if_supported(format!("-fprofile-generate={value}").into());
- }
- // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-use
- if let Some(value) = self.profile_use {
- push_if_supported(format!("-fprofile-use={value}").into());
+ if let ToolFamily::Clang { .. } = family {
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-generate
+ if let Some(value) = self.profile_generate {
+ push_if_supported(format!("-fprofile-generate={value}").into());
+ }
+ // https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fprofile-use
+ if let Some(value) = self.profile_use {
+ push_if_supported(format!("-fprofile-use={value}").into());
+ }
}
// https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-mguard
if let Some(value) = self.control_flow_guard {
--
2.47.1

View file

@ -133,6 +133,9 @@ Patch6: rustc-1.84.0-unbundle-sqlite.patch
# https://github.com/rust-lang/rust/pull/134240
Patch7: 0001-Only-dist-llvm-objcopy-if-llvm-tools-are-enabled.patch
# https://github.com/rust-lang/cc-rs/issues/1354
Patch8: 0001-Only-translate-profile-flags-for-Clang.patch
### RHEL-specific patches below ###
# Simple rpm macros for rust-toolset (as opposed to full rust-packaging)
@ -232,11 +235,9 @@ BuildRequires: (%{name} >= %{bootstrap_version} with %{name} <= %{version})
%global local_rust_root %{_prefix}
%endif
%global toolchain clang
BuildRequires: make
BuildRequires: clang
BuildRequires: lld
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: ncurses-devel
# explicit curl-devel to avoid httpd24-curl (rhbz1540167)
BuildRequires: curl-devel
@ -661,6 +662,7 @@ rm -rf %{wasi_libc_dir}/dlmalloc/
%patch -P6 -p1
%endif
%patch -P7 -p1
%patch -P8 -p1 -d vendor/cc-1.2.5
%if %with disabled_libssh2
%patch -P100 -p1
@ -733,9 +735,6 @@ find -name '*.rs' -type f -perm /111 -exec chmod -v -x '{}' '+'
%global build_rustflags %{nil}
%endif
# This is mostly needed for lld < 19 which defaulted to a short --build-id=fast.
%global rustflags -Clink-arg=%{?_build_id_flags}%{!?_build_id_flags:-Wl,--build-id=sha1}
# These are similar to __cflags_arch_* in /usr/lib/rpm/redhat/macros
%global rustc_target_cpus %{lua: do
local fedora = tonumber(rpm.expand("0%{?fedora}"))
@ -816,12 +815,7 @@ end}
# 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}"
@ -845,7 +839,7 @@ test -r "%{profiler}"
%{!?with_llvm_static: --enable-llvm-link-shared } } \
--disable-llvm-static-stdcpp \
--disable-llvm-bitcode-linker \
--disable-lld --set rust.use-lld=true \
--disable-lld \
--disable-rpath \
%{enable_debuginfo} \
%{enable_rust_opts} \