File clang.spec of Package clang
Name: clang21
Version: 21.1.7
Release: %mkrel 1
Summary: C, C++ and Objective-C compiler (LLVM Clang 21)
Group: Development/C
License: NCSA
URL: https://clang.llvm.org/
Source0: llvm-project-%{version}.src.tar.xz
# Core build tools
BuildRequires: cmake
BuildRequires: ninja
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: python3
# Explicitly depend on your standalone LLVM 21 build
BuildRequires: llvm21 = %{version}
BuildRequires: llvm21-devel = %{version}
# Optional but recommended
BuildRequires: pkgconfig(libedit)
BuildRequires: zlib-devel
%description
Clang is a C, C++ and Objective-C compiler front end for the LLVM compiler
infrastructure. This package provides Clang 21 built against the standalone
LLVM 21 toolchain.
%prep
%setup -q -n llvm-project-%{version}.src
%build
mkdir -p build
cd build
cmake \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DCMAKE_INSTALL_LIBDIR=%{_libdir} \
\
-DLLVM_DIR=%{_libdir}/cmake/llvm \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_EH=ON \
\
-DCLANG_BUILD_CLANG_DYLIB=ON \
-DCLANG_LINK_CLANG_DYLIB=ON \
-DCLANG_ENABLE_ARCMT=ON \
-DCLANG_ENABLE_STATIC_ANALYZER=ON \
-DCLANG_BUILD_TOOLS=ON \
\
-DCLANG_RESOURCE_DIR=%{_libdir}/clang/21 \
-DCLANG_INSTALL_PACKAGE_DIR=%{_libdir}/cmake/clang \
\
-DLLVM_INCLUDE_TESTS=OFF \
-DCLANG_INCLUDE_TESTS=OFF \
../llvm
ninja
%install
cd build
DESTDIR=%{buildroot} ninja install
%files
%license llvm/LICENSE.TXT
%doc clang/README.md
# Main compiler binaries
%{_bindir}/clang
%{_bindir}/clang++
%{_bindir}/clang-*
%{_bindir}/clang-cpp*
# Libraries
%{_libdir}/libclang*.so*
# Clang resource directory
%{_libdir}/clang/*
# CMake files
%{_libdir}/cmake/clang/*
%changelog
* Sun Dec 14 2025 Henrik <henrik@example.com> - 21.1.7-1
- Build Clang 21.1.7 against standalone LLVM 21.1.7
- Added explicit llvm21 BuildRequires to enforce correct build order
- Enabled libclang shared library and clang-tools-extra
- Installed resource directory and CMake package files
- Added LLVM_DIR to correctly detect LLVM shared library