[packages/iwyu] - rel 2, build and test fixes from fedora
baggins
baggins at pld-linux.org
Sun Apr 19 19:17:19 CEST 2026
commit 3e4f53f629ba24d7a7c85b7863938820962fbd48
Author: Jan Rękorajski <baggins at pld-linux.org>
Date: Sun Apr 19 21:17:00 2026 +0200
- rel 2, build and test fixes from fedora
fix-libraries.patch | 60 +++++++++++++++++++++++++
iwyu.spec | 10 ++++-
packaged-gtest.patch | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 193 insertions(+), 2 deletions(-)
---
diff --git a/iwyu.spec b/iwyu.spec
index b56f1bd..322d403 100644
--- a/iwyu.spec
+++ b/iwyu.spec
@@ -5,15 +5,18 @@ Summary(pl.UTF-8): Include What You Use - narzędzie dla clanga do analizy plik
Name: iwyu
# 0.21.x for llvm 17, 0.22.x for llvm 18 etc.
Version: 0.26
-Release: 1
+Release: 2
License: LLVM (BSD-like)
Group: Development/Tools
#Source0Download: https://github.com/include-what-you-use/include-what-you-use/releases
Source0: https://github.com/include-what-you-use/include-what-you-use/archive/%{version}/include-what-you-use-%{version}.tar.gz
# Source0-md5: 75cba17d42417d91c53edbad2de1f37d
+Patch0: fix-libraries.patch
+Patch1: packaged-gtest.patch
URL: https://github.com/include-what-you-use/include-what-you-use
BuildRequires: clang-devel >= %{llvm_ver}
BuildRequires: cmake >= 3.20.0
+BuildRequires: gtest-devel
BuildRequires: llvm-devel >= %{llvm_ver}
BuildRequires: rpmbuild(macros) >= 1.605
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -37,11 +40,14 @@ wymagania.
%prep
%setup -q -n include-what-you-use-%{version}
+%patch -P0 -p1
+%patch -P1 -p1
%{__sed} -i -e '1s,/usr/bin/env python3,%{__python3},' fix_includes.py iwyu_tool.py
%build
-%cmake -B build
+%cmake -B build \
+ -DIWYU_USE_SYSTEM_GTEST:BOOL=ON
%{__make} -C build
diff --git a/fix-libraries.patch b/fix-libraries.patch
new file mode 100644
index 0000000..005c296
--- /dev/null
+++ b/fix-libraries.patch
@@ -0,0 +1,60 @@
+From 816b81ce2129f5fe60b06261a166a05a3d22af27 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Kim=20Gr=C3=A4sman?= <kim.grasman at gmail.com>
+Date: Sat, 28 Mar 2026 14:15:04 +0100
+Subject: [PATCH] [cmake] Use vanilla add_library for static libraries
+
+The add_llvm_library macro has a lot of customization and
+parameterization to fit libraries into the LLVM conventions.
+
+Unfortunately the macro forces libraries to be built as SHARED if the
+BUILD_SHARED_LIBS option is on, no matter if we explicitly specify
+STATIC. This in turn led to packaging failures, because the shared
+libraries were not installed.
+
+Switch to using vanilla add_library, and make the libraries OBJECT
+libraries, which is the cheapest kind (we have no use for proper static
+libraries either). Use the llvm_update_compile_flags functions to make
+exception and RTTI flags consistent with LLVM.
+
+This reverts b828e17 and also e9a08a9, which is no longer necessary.
+
+Fixes #1961.
+---
+ CMakeLists.txt | 8 ++++++--
+ 1 file changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 6f59e476b..422c21ff2 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -135,7 +135,8 @@ set(LLVM_LINK_COMPONENTS
+ AllTargetsInfos
+ )
+
+-add_llvm_library(iwyu BUILDTREE_ONLY
++add_library(iwyu
++ OBJECT
+ iwyu.cc
+ iwyu_ast_util.cc
+ iwyu_cache.cc
+@@ -152,6 +153,7 @@ add_llvm_library(iwyu BUILDTREE_ONLY
+ iwyu_regex.cc
+ iwyu_verrs.cc
+ )
++llvm_update_compile_flags(iwyu)
+
+ add_llvm_executable(include-what-you-use
+ iwyu_main.cc
+@@ -233,9 +235,11 @@ if (WIN32)
+ endif()
+
+ # Build vendored gtest library
+-add_llvm_library(iwyu-gtest BUILDTREE_ONLY
++add_library(iwyu-gtest
++ OBJECT
+ vendor/googletest/src/gtest-all.cc
+ )
++llvm_update_compile_flags(iwyu-gtest)
+
+ target_include_directories(iwyu-gtest
+ PUBLIC
diff --git a/packaged-gtest.patch b/packaged-gtest.patch
new file mode 100644
index 0000000..dcce9e3
--- /dev/null
+++ b/packaged-gtest.patch
@@ -0,0 +1,125 @@
+From 53fda738ddca6353d38d845a92b435c4e8495da0 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Kim=20Gr=C3=A4sman?= <kim.grasman at gmail.com>
+Date: Sat, 28 Mar 2026 15:34:01 +0100
+Subject: [PATCH] [cmake] Add IWYU_USE_SYSTEM_GTEST option
+
+The IWYU project prefers to bundle GTest because we know its exact
+version and we can control when to upgrade it, how to build it, etc.
+
+But some environments prefer to use a vetted system GTest over our
+bundled version, to allow for lifecycle control, patching, etc.
+
+Add a Boolean IWYU_USE_SYSTEM_GTEST option to let packagers use a system
+GTest (as found by CMake's find_package). Expose it to the IWYU build
+using a target alias.
+
+Fixes #1962.
+---
+ CMakeLists.txt | 77 ++++++++++++++++++++++++++++++--------------------
+ 1 file changed, 46 insertions(+), 31 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 7ced3e81b..722872380 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -60,6 +60,11 @@ option(IWYU_LINK_CLANG_DYLIB
+ ${CLANG_LINK_CLANG_DYLIB}
+ )
+
++option(IWYU_USE_SYSTEM_GTEST
++ "Use system gtest instead of bundled version"
++ off
++)
++
+ # IWYU needs to know where to find Clang builtin headers (stddef.h, stdint.h,
+ # etc). The builtin headers are shipped in the Clang resource directory.
+ # You can configure IWYU's resource directory lookup using two options:
+@@ -234,47 +239,57 @@ if (WIN32)
+ )
+ endif()
+
+-# Build vendored gtest library
+-add_library(iwyu-gtest
+- OBJECT
+- vendor/googletest/src/gtest-all.cc
+-)
+-llvm_update_compile_flags(iwyu-gtest)
++if (IWYU_USE_SYSTEM_GTEST)
++ message(STATUS "IWYU: using system gtest")
++ find_package(GTest CONFIG REQUIRED)
+
+-target_include_directories(iwyu-gtest
+- PUBLIC
+- vendor/googletest/include
+- PRIVATE
+- vendor/googletest
+-)
++ # Make it available under the expected name.
++ add_library(iwyu-gtest ALIAS GTest::gtest)
++else()
++ message(STATUS "IWYU: using bundled gtest")
+
+-# gtest: Disable -Wcovered-switch-default if compiler supports it.
+-include(CheckCompilerFlag)
+-check_compiler_flag(CXX
+- -Wcovered-switch-default
+- iwyu_cxx_supports_covered_switch_default)
++ # Build vendored gtest library.
++ add_library(iwyu-gtest
++ OBJECT
++ vendor/googletest/src/gtest-all.cc
++ )
++ llvm_update_compile_flags(iwyu-gtest)
+
+-if (iwyu_cxx_supports_covered_switch_default)
+- target_compile_options(iwyu-gtest
++ target_include_directories(iwyu-gtest
++ PUBLIC
++ vendor/googletest/include
+ PRIVATE
+- -Wno-covered-switch-default
++ vendor/googletest
+ )
+-endif()
+
+-# gtest: Disable use of cxxabi.h, which can cause conflict between libc++abi and
+-# libsupc++. See https://github.com/llvm/llvm-project/issues/121300.
+-target_compile_options(iwyu-gtest
+- PUBLIC
+- -DGTEST_HAS_CXXABI_H_=0
+-)
++ # gtest: Disable -Wcovered-switch-default if compiler supports it.
++ include(CheckCompilerFlag)
++ check_compiler_flag(CXX
++ -Wcovered-switch-default
++ iwyu_cxx_supports_covered_switch_default)
+
+-# gtest: Use portable exception semantics for MSVC.
+-if (MSVC)
++ if (iwyu_cxx_supports_covered_switch_default)
++ target_compile_options(iwyu-gtest
++ PRIVATE
++ -Wno-covered-switch-default
++ )
++ endif()
++
++ # gtest: Disable use of cxxabi.h, which can cause conflict between libc++abi and
++ # libsupc++. See https://github.com/llvm/llvm-project/issues/121300.
+ target_compile_options(iwyu-gtest
+ PUBLIC
+- /EHsc
++ -DGTEST_HAS_CXXABI_H_=0
+ )
+-endif()
++
++ # gtest: Use portable exception semantics for MSVC.
++ if (MSVC)
++ target_compile_options(iwyu-gtest
++ PUBLIC
++ /EHsc
++ )
++ endif()
++endif(IWYU_USE_SYSTEM_GTEST)
+
+ # Add unittest target.
+ add_llvm_executable(iwyu-unittests
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/iwyu.git/commitdiff/3e4f53f629ba24d7a7c85b7863938820962fbd48
More information about the pld-cvs-commit
mailing list