From fff5077f10b8c09427f963b5a2b2c481670ac7b4 Mon Sep 17 00:00:00 2001 From: Tulio Magno Quites Machado Filho Date: Mon, 24 Jul 2023 07:41:02 -0300 Subject: [PATCH] Fix compat build without tests and deduplicate BuildRequires 1. Set LLVM_INCLUDE_TESTS:BOOL=OFF in order to build clang without requiring googletest as we do not run the tests anyway. 2. Backport a patch from upstream that fixes the generation of *.exports. 3. Deduplicate a few BuildRequires entries. --- ...python3-as-required-build-dependency.patch | 39 +++++++++++++++++++ clang.spec | 23 ++++++----- 2 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 0001-clang-set-python3-as-required-build-dependency.patch diff --git a/0001-clang-set-python3-as-required-build-dependency.patch b/0001-clang-set-python3-as-required-build-dependency.patch new file mode 100644 index 0000000..2576518 --- /dev/null +++ b/0001-clang-set-python3-as-required-build-dependency.patch @@ -0,0 +1,39 @@ +From 96962d5512fbc6af0ada0f13e6be332c026529cb Mon Sep 17 00:00:00 2001 +From: Petr Hosek +Date: Fri, 9 Jun 2023 07:51:40 +0000 +Subject: [PATCH] [clang] set python3 as required build dependency + +The required HTMLLogger include file needs python3 to run +resource_bundle.py to bundle all the html/css/js resources. However, if +user sets -DLLVM_INCLUDE_TESTS=OFF, CMake will not find python3 and the +resource bundler will never be executed. This patch set the python3 as a +required build dependency to fix this problem. + +Patch By: Avimitin + +Differential Revision: https://reviews.llvm.org/D152418 +--- + clang/CMakeLists.txt | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt +index 8220a9dbfd4d..f7936d72e088 100644 +--- a/clang/CMakeLists.txt ++++ b/clang/CMakeLists.txt +@@ -82,10 +82,10 @@ if(CLANG_BUILT_STANDALONE) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) + set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} ) + +- if(LLVM_INCLUDE_TESTS) +- find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED +- COMPONENTS Interpreter) ++ find_package(Python3 ${LLVM_MINIMUM_PYTHON_VERSION} REQUIRED ++ COMPONENTS Interpreter) + ++ if(LLVM_INCLUDE_TESTS) + # Check prebuilt llvm/utils. + if(EXISTS ${LLVM_TOOLS_BINARY_DIR}/FileCheck${CMAKE_EXECUTABLE_SUFFIX} + AND EXISTS ${LLVM_TOOLS_BINARY_DIR}/count${CMAKE_EXECUTABLE_SUFFIX} +-- +2.41.0 + diff --git a/clang.spec b/clang.spec index 2f3141b..226541a 100644 --- a/clang.spec +++ b/clang.spec @@ -73,6 +73,9 @@ Patch7: D141581.diff # See https://reviews.llvm.org/D138472 Patch8: D138472.diff +# Backport from LLVM 18. +Patch9: 0001-clang-set-python3-as-required-build-dependency.patch + Patch10: fix-ieee128-cross.diff # https://reviews.llvm.org/D155192 @@ -91,19 +94,20 @@ Patch201: 0001-clang-tools-extra-Make-test-dependency-on-LLVMHello-.patch BuildRequires: clang BuildRequires: cmake BuildRequires: ninja-build + %if %{with compat_build} -BuildRequires: llvm%{maj_ver}-devel = %{version} -BuildRequires: llvm%{maj_ver}-static = %{version} -BuildRequires: llvm%{maj_ver}-cmake-utils = %{version} +%global llvm_pkg_name llvm%{maj_ver} %else -BuildRequires: llvm-devel = %{version} -BuildRequires: llvm-cmake-utils = %{version} -BuildRequires: llvm-test = %{version} +%global llvm_pkg_name llvm +BuildRequires: llvm-test = %{version} +BuildRequires: llvm-googletest = %{version} +%endif + +BuildRequires: %{llvm_pkg_name}-devel = %{version} # llvm-static is required, because clang-tablegen needs libLLVMTableGen, which # is not included in libLLVM.so. -BuildRequires: llvm-static = %{version} -BuildRequires: llvm-googletest = %{version} -%endif +BuildRequires: %{llvm_pkg_name}-static = %{version} +BuildRequires: %{llvm_pkg_name}-cmake-utils = %{version} BuildRequires: libxml2-devel BuildRequires: perl-generators @@ -348,6 +352,7 @@ sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' test/lit.cfg.py -DCLANG_BUILD_TOOLS:BOOL=OFF \ -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ -DCLANG_INCLUDE_TESTS:BOOL=OFF \ + -DLLVM_INCLUDE_TESTS:BOOL=OFF \ -DLLVM_CMAKE_DIR=%{install_libdir}/cmake/llvm \ %else -DCLANG_INCLUDE_TESTS:BOOL=ON \