public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Nikita Popov <npopov@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/llvm] rawhide: Build with clang on RHEL 8 as well
Date: Tue, 14 Jul 2026 07:10:20 GMT	[thread overview]
Message-ID: <178401302051.1.6675578244677188978.rpms-llvm-a19b9b89273f@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/llvm
            Branch : rawhide
            Commit : a19b9b89273fed7f2178dd0b1e127ac3acaf0dcb
            Author : Nikita Popov <npopov@redhat.com>
            Date   : 2026-07-13T12:11:43+02:00
            Stats  : +16/-33 in 1 file(s)
            URL    : https://src.fedoraproject.org/rpms/llvm/c/a19b9b89273fed7f2178dd0b1e127ac3acaf0dcb?branch=rawhide

            Log:
            Build with clang on RHEL 8 as well

We currently build with GCC (from GCC toolset) on RHEL 8, because
it does not support "global toolchain clang". Switch RHEL 8 to use
a Clang host compiler as well, by manually setting up the
appropriate macros and evironment variables. We mainly need to
make sure that CC/CXX are set and that -specs is replace by
--config.

The goal here is to make the RHEL 8 configuration more similar to
other operating systems, and to avoid issues we've encountered
when mixing the use of GCC with LLD, as discussed in
https://src.fedoraproject.org/rpms/llvm/pull-request/618.

[skip changelog]

---
diff --git a/llvm.spec b/llvm.spec
index 49badbd..bc0bbb7 100644
--- a/llvm.spec
+++ b/llvm.spec
@@ -447,6 +447,18 @@ end
 %endif
 #endregion libclc globals
 
+# RHEL 8 does not support "global toolchain clang", so manually switch to clang here.
+# We need to replace -specs files by --config files, which will be created later.
+%if 0%{?rhel} == 8
+%define __cc clang
+%define __cxx clang++
+%global optflags %(echo "%{optflags} --config=/tmp/redhat-hardened-clang.cfg" | sed -e 's/-specs=[^ ]*//g')
+%global build_ldflags %(echo "%{build_ldflags} --config=/tmp/redhat-hardened-clang-ld.cfg" | sed -e 's/-specs=[^ ]*//g')
+%global set_build_flags %{set_build_flags} ; \
+    CC="%{__cc}" ; export CC ; \
+    CXX="%{__cxx}" ; export CXX
+%endif
+
 #endregion globals
 
 #region packages
@@ -1600,13 +1612,10 @@ cd llvm/utils/lit
 %global cfg_file_content %{cfg_file_content} --gcc-install-dir=/opt/rh/gcc-toolset-%{gts_version}/root/%{_exec_prefix}/lib/gcc/%{_target_cpu}-redhat-linux/%{gts_version}
 %endif
 
-# Already use the new clang config file for the current build. This ensures
-# consistency between the runtimes and non-runtimes builds and makes sure that
-# the new configuration will work without going through a rebuild cycle.
-# Don't do this on RHEL 8, which does not build using clang.
-%if %{defined gts_version} && 0%{?rhel} != 8
-echo "%{cfg_file_content}" > /tmp/clang.cfg
-%global optflags  %{optflags} --config /tmp/clang.cfg
+# Create config files for "global toolchain clang" emulation on RHEL 8.
+%if 0%{?rhel} == 8
+echo "-fPIE" > /tmp/redhat-hardened-clang.cfg
+echo "-pie" > /tmp/redhat-hardened-clang-ld.cfg
 %endif
 
 # Copy CFLAGS into ASMFLAGS, so -fcf-protection is used when compiling assembly files.
@@ -1660,32 +1669,6 @@ popd
     -DLLVM_ENABLE_FFI:BOOL=ON \\\
     -DLLVM_ENABLE_EH=OFF
 
-%if 0%{?rhel} == 8
-# On RHEL 8 we build with gcc, but the runtimes are built with the just built
-# clang, so we need to pass clang supported compiler flags to the runtimes
-# build.  If we pass the gcc flags, some of the cmake feature checkes will
-# fail, because they use -Werror and emit an error when passed gcc specific
-# compiler flags like -specs.
-# Specifically, this is required in order to fix the libomptest.so build.
-
-function strip_specs {
-  echo $1 | sed -e 's/-specs=[^ ]\+//g'
-}
-
-CLANG_CC_CONFIG=$(pwd)/redhat-hardened-clang.cfg
-CLANG_LD_CONFIG=$(pwd)/redhat-hardened-clang-ld.cfg
-echo "-fPIE" >> $CLANG_CC_CONFIG
-echo "-pie" >> $CLANG_LD_CONFIG
-CLANG_CCFLAGS_EXTRA=--config=$CLANG_CC_CONFIG
-CLANG_LDFLAGS_EXTRA=--config=$CLANG_LD_CONFIG
-
-CLANG_CXXFLAGS=$(strip_specs "$CXXFLAGS $CLANG_CCFLAGS_EXTRA")
-CLANG_CFLAGS=$(strip_specs "$CFLAGS $CLANG_CCFLAGS_EXTRA")
-CLANG_LDFLAGS=$(strip_specs "$LDFLAGS $CLANG_LDFLAGS_EXTRA")
-%global cmake_common_args %{cmake_common_args} \\\
-    -DRUNTIMES_CMAKE_ARGS="-DCMAKE_C_FLAGS=$CLANG_C_FLAGS;-DCMAKE_CXX_FLAGS=$CLANG_CXX_FLAGS;-DCMAKE_SHARED_LINKER_FLAGS=$CLANG_LD_FLAGS"
-%endif
-
 %if %reduce_debuginfo == 1
 	%global cmake_common_args %{cmake_common_args} -DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG"
 	%global cmake_common_args %{cmake_common_args} -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG"

                 reply	other threads:[~2026-07-14  7:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178401302051.1.6675578244677188978.rpms-llvm-a19b9b89273f@fedoraproject.org \
    --to=npopov@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox