Skip to content

Commit 6efb982

Browse files
committed
Add libcxx
1 parent 84a9534 commit 6efb982

File tree

1 file changed

+212
-7
lines changed

1 file changed

+212
-7
lines changed

llvm.spec

Lines changed: 212 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
%bcond_with mlir
5252
%endif
5353

54+
# The libcxx build condition also enables libcxxabi and libunwind.
55+
%if %{without compat_build} && 0%{?fedora}
56+
%bcond_without libcxx
57+
%else
58+
%bcond_with libcxx
59+
%endif
60+
5461
# Disable LTO on x86 and riscv in order to reduce memory consumption.
5562
%ifarch %ix86 riscv64
5663
%bcond_with lto_build
@@ -161,8 +168,7 @@
161168
# export ASMFLAGS=$CFLAGS
162169
#endregion COMPILER-RT globals
163170

164-
#region LLD globals
165-
171+
#region openmp globals
166172
%global pkg_name_libomp libomp%{pkg_suffix}
167173

168174
%global so_suffix %{maj_ver}.%{min_ver}
@@ -176,8 +182,7 @@
176182
%else
177183
%global libomp_arch %{_arch}
178184
%endif
179-
180-
#endregion LLD globals
185+
#endregion openmp globals
181186

182187
#region LLD globals
183188
%global pkg_name_lld lld%{pkg_suffix}
@@ -192,11 +197,17 @@
192197
%global pkg_name_mlir mlir%{pkg_suffix}
193198
#endregion MLIR globals
194199

200+
#region libcxx globals
201+
%global pkg_name_libcxx libcxx
202+
%global pkg_name_libcxxabi libcxxabi
203+
%global pkg_name_llvm_libunwind llvm-libunwind
204+
#endregion libcxx globals
205+
195206
#region packages
196207
#region main package
197208
Name: %{pkg_name_llvm}
198209
Version: %{maj_ver}.%{min_ver}.%{patch_ver}%{?rc_ver:~rc%{rc_ver}}%{?llvm_snapshot_version_suffix:~%{llvm_snapshot_version_suffix}}
199-
Release: 2%{?dist}
210+
Release: 3%{?dist}
200211
Summary: The Low Level Virtual Machine
201212

202213
License: Apache-2.0 WITH LLVM-exception OR NCSA
@@ -651,7 +662,7 @@ Requires: python%{python3_pkgversion}
651662
Obsoletes: python3-clang < 18.9
652663
%endif
653664
%description -n python%{python3_pkgversion}-clang
654-
%{summary}.
665+
Python3 bindings for clang.
655666

656667

657668
%endif
@@ -838,6 +849,80 @@ MLIR python bindings.
838849
%endif
839850
#endregion MLIR packages
840851

852+
#region libcxx packages
853+
%if %{with libcxx}
854+
%package -n %{pkg_name_libcxx}
855+
Summary: C++ standard library targeting C++11
856+
License: Apache-2.0 WITH LLVM-exception OR MIT OR NCSA
857+
URL: http://libcxx.llvm.org/
858+
859+
Requires: %{pkg_name_libcxxabi}%{?_isa} = %{version}-%{release}
860+
861+
%description -n %{pkg_name_libcxx}
862+
libc++ is a new implementation of the C++ standard library, targeting C++11 and above.
863+
864+
865+
%package -n %{pkg_name_libcxx}-devel
866+
Summary: Headers and libraries for %{pkg_name_libcxx} devel
867+
Requires: %{pkg_name_libcxx}%{?_isa} = %{version}-%{release}
868+
Requires: %{pkg_name_libcxxabi}-devel
869+
870+
%description -n %{pkg_name_libcxx}-devel
871+
Headers and libraries for %{pkg_name_libcxx} devel.
872+
873+
%package -n %{pkg_name_libcxx}-static
874+
Summary: Static libraries for %{pkg_name_libcxx}
875+
876+
%description -n %{pkg_name_libcxx}-static
877+
Static libraries for %{pkg_name_libcxx}.
878+
879+
%package -n %{pkg_name_libcxxabi}
880+
Summary: Low level support for a standard C++ library
881+
882+
%description -n %{pkg_name_libcxxabi}
883+
libcxxabi provides low level support for a standard C++ library.
884+
885+
%package -n %{pkg_name_libcxx}abi-devel
886+
Summary: Headers and libraries for %{pkg_name_libcxxabi} devel
887+
Requires: %{pkg_name_libcxxabi}%{?_isa} = %{version}-%{release}
888+
889+
%description -n %{pkg_name_libcxxabi}-devel
890+
Headers and libraries for %{pkg_name_libcxxabi} devel.
891+
892+
%package -n %{pkg_name_libcxxabi}-static
893+
Summary: Static libraries for %{pkg_name_libcxxabi}
894+
895+
%description -n %{pkg_name_libcxxabi}-static
896+
Static libraries for %{pkg_name_libcxxabi}.
897+
898+
%package -n %{pkg_name_llvm_libunwind}
899+
Summary: LLVM libunwind
900+
901+
%description -n %{pkg_name_llvm_libunwind}
902+
903+
LLVM libunwind is an implementation of the interface defined by the HP libunwind
904+
project. It was contributed Apple as a way to enable clang++ to port to
905+
platforms that do not have a system unwinder. It is intended to be a small and
906+
fast implementation of the ABI, leaving off some features of HP's libunwind
907+
that never materialized (e.g. remote unwinding).
908+
909+
%package -n %{pkg_name_llvm_libunwind}-devel
910+
Summary: LLVM libunwind development files
911+
Provides: %{pkg_name_llvm_libunwind}(major) = %{maj_ver}
912+
Requires: %{pkg_name_llvm_libunwind}%{?_isa} = %{version}-%{release}
913+
914+
%description -n %{pkg_name_llvm_libunwind}-devel
915+
Unversioned shared library for LLVM libunwind
916+
917+
%package -n %{pkg_name_llvm_libunwind}-static
918+
Summary: Static library for LLVM libunwind
919+
920+
%description -n %{pkg_name_llvm_libunwind}-static
921+
Static library for LLVM libunwind.
922+
923+
%endif
924+
#endregion libcxx packages
925+
841926
#endregion packages
842927

843928
#region prep
@@ -911,6 +996,12 @@ MLIR python bindings.
911996

912997
#endregion COMPILER-RT preparation
913998

999+
#region libcxx preparation
1000+
%if %{with libcxx}
1001+
%py3_shebang_fix libcxx/utils/
1002+
%endif
1003+
#endregion libcxx preparation
1004+
9141005
#endregion prep
9151006

9161007
#region build
@@ -931,13 +1022,20 @@ MLIR python bindings.
9311022
%endif
9321023

9331024
%global projects clang;clang-tools-extra;lld
1025+
%global runtimes compiler-rt;openmp;offload
1026+
9341027
%if %{with lldb}
9351028
%global projects %{projects};lldb
9361029
%endif
1030+
9371031
%if %{with mlir}
9381032
%global projects %{projects};mlir
9391033
%endif
9401034

1035+
%if %{with libcxx}
1036+
%global runtimes %{runtimes};libcxx;libcxxabi;libunwind
1037+
%endif
1038+
9411039
%global cfg_file_content --gcc-triple=%{_target_cpu}-redhat-linux
9421040

9431041
# We want to use DWARF-5 on all snapshot builds.
@@ -1058,6 +1156,31 @@ popd
10581156
%endif
10591157
#endregion lldb options
10601158

1159+
#region libcxx options
1160+
%if %{with libcxx}
1161+
%global cmake_config_args %{cmake_config_args} \\\
1162+
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \\\
1163+
-DLIBCXX_INCLUDE_BENCHMARKS=OFF \\\
1164+
-DLIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY=ON \\\
1165+
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=ON \\\
1166+
-DLIBCXXABI_USE_LLVM_UNWINDER=OFF \\\
1167+
-DLIBUNWIND_INSTALL_INCLUDE_DIR=%{_includedir}/llvm-libunwind
1168+
1169+
# If we don't set the .._INSTALL_LIBRARY_DIR variables,
1170+
# the *.so files will be placed in a subdirectory that includes the triple
1171+
%global cmake_config_args %{cmake_config_args} \\\
1172+
-DLIBCXX_INSTALL_LIBRARY_DIR=%{_libdir} \\\
1173+
-DLIBCXXABI_INSTALL_LIBRARY_DIR=%{_libdir} \\\
1174+
-DLIBUNWIND_INSTALL_LIBRARY_DIR=%{_libdir}
1175+
1176+
# If we don't adjust this, we will install into this unwanted location:
1177+
# /usr/include/i686-redhat-linux-gnu/c++/v1/__config_site
1178+
%global cmake_config_args %{cmake_config_args} \\\
1179+
-DLIBCXX_INSTALL_INCLUDE_TARGET_DIR=%{_includedir}/c++/v1
1180+
1181+
%endif
1182+
#endregion libcxx options
1183+
10611184
#region llvm options
10621185
%global cmake_config_args %{cmake_config_args} \\\
10631186
-DLLVM_APPEND_VC_REV:BOOL=OFF \\\
@@ -1073,7 +1196,7 @@ popd
10731196
-DLLVM_ENABLE_LIBCXX:BOOL=OFF \\\
10741197
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \\\
10751198
-DLLVM_ENABLE_PROJECTS="%{projects}" \\\
1076-
-DLLVM_ENABLE_RUNTIMES="compiler-rt;openmp;offload" \\\
1199+
-DLLVM_ENABLE_RUNTIMES="%{runtimes}" \\\
10771200
-DLLVM_ENABLE_ZLIB:BOOL=FORCE_ON \\\
10781201
-DLLVM_ENABLE_ZSTD:BOOL=FORCE_ON \\\
10791202
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=%{experimental_targets_to_build} \\\
@@ -1512,6 +1635,25 @@ rm -rf %{buildroot}%{_prefix}/src/python
15121635
%endif
15131636
#endregion mlir installation
15141637

1638+
#region libcxx installation
1639+
%if %{with libcxx}
1640+
# We can't install the unversionned path on default location because that would conflict with
1641+
# https://src.fedoraproject.org/rpms/libunwind
1642+
#
1643+
# The versionned path has a different soname (libunwind.so.1 compared to
1644+
# libunwind.so.8) so they can live together in %%{_libdir}
1645+
#
1646+
# ABI wise, even though llvm-libunwind's library is named libunwind, it doesn't
1647+
# have the exact same ABI as gcc's libunwind (it actually provides a subset).
1648+
rm %{buildroot}%{_libdir}/libunwind.so
1649+
mkdir -p %{buildroot}/%{_libdir}/llvm-unwind/
1650+
1651+
pushd %{buildroot}/%{_libdir}/llvm-unwind
1652+
ln -s ../libunwind.so.1.0 libunwind.so
1653+
popd
1654+
%endif
1655+
#endregion libcxx installation
1656+
15151657
%if %{with compat_build}
15161658
# Add version suffix to binaries. Do this at the end so it includes any
15171659
# additional binaries that may be been added by other steps.
@@ -1872,6 +2014,10 @@ adjust_lit_filter_out test_list_filter_out
18722014
%endif
18732015
%endif
18742016

2017+
#region test libcxx
2018+
# TODO(kkleine): Fedora rawhide didn't contain check runs. Evaluate if we want them here.
2019+
#endregion test libcxx
2020+
18752021

18762022
#region Test LLD
18772023
reset_test_opts
@@ -2711,10 +2857,69 @@ fi
27112857
%{python3_sitearch}/mlir/
27122858
%endif
27132859
#endregion MLIR files
2860+
2861+
#region libcxx files
2862+
%if %{with libcxx}
2863+
2864+
%files -n %{pkg_name_libcxx}
2865+
%license libcxx/LICENSE.TXT
2866+
%doc libcxx/CREDITS.TXT libcxx/TODO.TXT
2867+
%{_libdir}/libc++.so.*
2868+
2869+
%files -n %{pkg_name_libcxx}-devel
2870+
%{_includedir}/c++/
2871+
%exclude %{_includedir}/c++/v1/cxxabi.h
2872+
%exclude %{_includedir}/c++/v1/__cxxabi_config.h
2873+
%{_libdir}/libc++.so
2874+
%{_libdir}/libc++.modules.json
2875+
%{_datadir}/libc++/v1/*
2876+
2877+
%files -n %{pkg_name_libcxx}-static
2878+
%license libcxx/LICENSE.TXT
2879+
%{_libdir}/libc++.a
2880+
%{_libdir}/libc++experimental.a
2881+
2882+
%files -n %{pkg_name_libcxxabi}
2883+
%license libcxxabi/LICENSE.TXT
2884+
%doc libcxxabi/CREDITS.TXT
2885+
%{_libdir}/libc++abi.so.*
2886+
2887+
%files -n %{pkg_name_libcxxabi}-devel
2888+
%{_includedir}/c++/v1/cxxabi.h
2889+
%{_includedir}/c++/v1/__cxxabi_config.h
2890+
%{_libdir}/libc++abi.so
2891+
2892+
%files -n %{pkg_name_libcxxabi}-static
2893+
%{_libdir}/libc++abi.a
2894+
2895+
%files -n %{pkg_name_llvm_libunwind}
2896+
%license libunwind/LICENSE.TXT
2897+
%{_libdir}/libunwind.so.1
2898+
%{_libdir}/libunwind.so.1.0
2899+
2900+
%files -n %{pkg_name_llvm_libunwind}-devel
2901+
%{_includedir}/llvm-libunwind/__libunwind_config.h
2902+
%{_includedir}/llvm-libunwind/libunwind.h
2903+
%{_includedir}/llvm-libunwind/libunwind.modulemap
2904+
%{_includedir}/llvm-libunwind/mach-o/compact_unwind_encoding.h
2905+
%{_includedir}/llvm-libunwind/unwind.h
2906+
%{_includedir}/llvm-libunwind/unwind_arm_ehabi.h
2907+
%{_includedir}/llvm-libunwind/unwind_itanium.h
2908+
%dir %{_libdir}/llvm-unwind
2909+
%{_libdir}/llvm-unwind/libunwind.so
2910+
2911+
%files -n %{pkg_name_llvm_libunwind}-static
2912+
%{_libdir}/libunwind.a
2913+
%endif
2914+
#endregion libcxx files
2915+
27142916
#endregion files
27152917

27162918
#region changelog
27172919
%changelog
2920+
* Tue Dec 24 2024 Konrad Kleine <[email protected]> - 19.1.6-3
2921+
- Add libcxx
2922+
27182923
* Thu Dec 19 2024 Nikita Popov <[email protected]> - 19.1.6-2
27192924
- Fix mlir exports
27202925

0 commit comments

Comments
 (0)