2024-05-30 08:18:56 +00:00
|
|
|
# TODO(kkleine): In clang we had this %ifarch s390 s390x aarch64 %ix86 ppc64le
|
2024-07-21 13:03:26 +00:00
|
|
|
# Decrease debuginfo verbosity to reduce memory consumption during final library linking.
|
|
|
|
%global reduce_debuginfo 0
|
|
|
|
%ifarch %ix86
|
|
|
|
%global reduce_debuginfo 1
|
|
|
|
%endif
|
2024-07-20 13:40:00 +00:00
|
|
|
%if 0%{?rhel} == 8
|
2024-07-21 13:03:26 +00:00
|
|
|
%global reduce_debuginfo 1
|
|
|
|
%endif
|
|
|
|
|
|
|
|
%if %reduce_debuginfo == 1
|
2023-10-12 09:15:14 +00:00
|
|
|
%global optflags %(echo %{optflags} | sed 's/-g /-g1 /')
|
|
|
|
%endif
|
|
|
|
|
2024-07-30 14:59:07 +00:00
|
|
|
%global projects clang;clang-tools-extra;lld
|
|
|
|
%if %{with lldb}
|
|
|
|
%global projects %{projects};lldb
|
|
|
|
%endif
|
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
# Copy CFLAGS into ASMFLAGS, so -fcf-protection is used when compiling assembly files.
|
|
|
|
export ASMFLAGS="%{build_cflags}"
|
|
|
|
|
|
|
|
# We set CLANG_DEFAULT_PIE_ON_LINUX=OFF and PPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON to match the
|
|
|
|
# defaults used by Fedora's GCC.
|
|
|
|
|
|
|
|
#region BEGIN: COPIED FROM CLANG
|
|
|
|
|
|
|
|
# Disable dwz on aarch64, because it takes a huge amount of time to decide not to optimize things.
|
|
|
|
%ifarch aarch64
|
|
|
|
%define _find_debuginfo_dwz_opts %{nil}
|
|
|
|
%endif
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2024-07-31 13:54:15 +00:00
|
|
|
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/%{build_libdir}"
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
cd llvm
|
|
|
|
|
2024-07-22 12:25:34 +00:00
|
|
|
#region LLVM lit
|
2024-07-30 14:59:07 +00:00
|
|
|
%if %{with python_lit}
|
2024-07-22 12:25:34 +00:00
|
|
|
pushd utils/lit
|
|
|
|
%py3_build
|
|
|
|
popd
|
2024-07-30 14:59:07 +00:00
|
|
|
%endif
|
2024-07-22 12:25:34 +00:00
|
|
|
#endregion
|
|
|
|
|
2024-07-16 10:45:51 +00:00
|
|
|
%if 0%{?rhel} == 8
|
|
|
|
%undefine __cmake_in_source_build
|
|
|
|
%endif
|
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
# TODO(kkleine): Follow more closely the Distribution guidelines found here: https://llvm.org/docs/BuildingADistribution.html
|
|
|
|
# force off shared libs as cmake macros turns it on.
|
|
|
|
# TODO: Disable LLVM_UNREACHABLE_OPTIMIZE.
|
2024-03-16 20:09:57 +00:00
|
|
|
# TODO: Override LIBOMP_INSTALL_LIBDIR, because otherwise the libraries
|
|
|
|
# are installed to /usr/lib64/$TRIPLE and clang can't find them.
|
2023-10-12 09:15:14 +00:00
|
|
|
%cmake -G Ninja \
|
2024-07-30 14:59:07 +00:00
|
|
|
-DLLVM_ENABLE_PROJECTS="%{projects}" \
|
2023-10-12 09:15:14 +00:00
|
|
|
\
|
|
|
|
\
|
|
|
|
-DCLANG_DEFAULT_PIE_ON_LINUX=OFF \
|
|
|
|
%if 0%{?fedora} || 0%{?rhel} > 9
|
|
|
|
-DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON \
|
|
|
|
%endif
|
2024-07-16 12:27:11 +00:00
|
|
|
-DPython3_EXECUTABLE=%{__python3} \
|
2023-10-12 09:15:14 +00:00
|
|
|
-DLLVM_INCLUDE_TESTS:BOOL=ON \
|
|
|
|
-DCLANG_INCLUDE_TESTS:BOOL=ON \
|
|
|
|
-DLLVM_BUILD_UTILS:BOOL=ON \
|
|
|
|
-DCLANG_ENABLE_ARCMT:BOOL=ON \
|
|
|
|
-DCLANG_ENABLE_STATIC_ANALYZER:BOOL=ON \
|
|
|
|
-DCLANG_INCLUDE_DOCS:BOOL=ON \
|
|
|
|
-DCLANG_PLUGIN_SUPPORT:BOOL=ON \
|
|
|
|
-DENABLE_LINKER_BUILD_ID:BOOL=ON \
|
|
|
|
-DLLVM_ENABLE_EH=ON \
|
|
|
|
-DCLANG_LINK_CLANG_DYLIB=ON \
|
|
|
|
-DCLANG_BUILD_EXAMPLES:BOOL=OFF \
|
|
|
|
-DCLANG_REPOSITORY_STRING="%{?dist_vendor} %{version}-%{release}" \
|
2024-07-31 15:57:48 +00:00
|
|
|
%if %{with compat_build}
|
2023-10-12 09:15:14 +00:00
|
|
|
-DCLANG_RESOURCE_DIR=../lib/clang/%{maj_ver} \
|
2024-07-31 15:57:48 +00:00
|
|
|
%else
|
|
|
|
-DCLANG_RESOURCE_DIR=../../../lib/clang/%{maj_ver} \
|
|
|
|
%endif
|
2023-10-12 09:15:14 +00:00
|
|
|
-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../clang-tools-extra \
|
|
|
|
-DCLANG_CONFIG_FILE_SYSTEM_DIR=%{_sysconfdir}/%{pkg_name_clang}/ \
|
|
|
|
-DCLANG_DEFAULT_UNWINDLIB=libgcc \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
2024-04-24 13:46:54 +00:00
|
|
|
-DLLVM_ENABLE_RUNTIMES="compiler-rt;openmp;offload" \
|
2023-10-12 09:15:14 +00:00
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
-DCOMPILER_RT_INSTALL_PATH=%{_prefix}/lib/clang/%{maj_ver} \
|
|
|
|
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
|
|
|
|
-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF \
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
-DLIBOMP_INSTALL_ALIASES=OFF \
|
2024-07-31 12:51:01 +00:00
|
|
|
%if %{without compat_build}
|
2023-10-12 09:15:14 +00:00
|
|
|
%if 0%{?__isa_bits} == 64
|
|
|
|
-DOPENMP_LIBDIR_SUFFIX=64 \
|
|
|
|
%else
|
|
|
|
-DOPENMP_LIBDIR_SUFFIX= \
|
|
|
|
%endif
|
|
|
|
%endif
|
2024-03-16 20:09:57 +00:00
|
|
|
-DOPENMP_INSTALL_LIBDIR=%{_lib} \
|
2024-04-26 20:28:49 +00:00
|
|
|
-DOFFLOAD_INSTALL_LIBDIR=%{_lib} \
|
2023-10-12 09:15:14 +00:00
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
|
|
|
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
|
|
|
-DLLVM_PARALLEL_LINK_JOBS=1 \
|
|
|
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
|
|
|
-DCMAKE_SKIP_RPATH:BOOL=ON \
|
2024-07-21 13:03:26 +00:00
|
|
|
%if %reduce_debuginfo == 1
|
2023-10-12 09:15:14 +00:00
|
|
|
-DCMAKE_C_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \
|
|
|
|
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="%{optflags} -DNDEBUG" \
|
|
|
|
%endif
|
|
|
|
%if %{without compat_build}
|
|
|
|
%if 0%{?__isa_bits} == 64
|
|
|
|
-DLLVM_LIBDIR_SUFFIX=64 \
|
|
|
|
%else
|
|
|
|
-DLLVM_LIBDIR_SUFFIX= \
|
|
|
|
%endif
|
|
|
|
%endif
|
|
|
|
\
|
|
|
|
-DLLVM_TARGETS_TO_BUILD=%{targets_to_build} \
|
|
|
|
-DLLVM_ENABLE_LIBCXX:BOOL=OFF \
|
|
|
|
-DLLVM_ENABLE_ZLIB:BOOL=ON \
|
|
|
|
-DLLVM_ENABLE_FFI:BOOL=ON \
|
|
|
|
-DLLVM_ENABLE_RTTI:BOOL=ON \
|
|
|
|
-DLLVM_USE_PERF:BOOL=ON \
|
|
|
|
%if %{with gold}
|
|
|
|
-DLLVM_BINUTILS_INCDIR=%{_includedir} \
|
|
|
|
%endif
|
|
|
|
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=%{experimental_targets_to_build} \
|
|
|
|
\
|
|
|
|
-DLLVM_BUILD_RUNTIME:BOOL=ON \
|
|
|
|
\
|
|
|
|
-DLLVM_INCLUDE_TOOLS:BOOL=ON \
|
|
|
|
-DLLVM_BUILD_TOOLS:BOOL=ON \
|
|
|
|
\
|
|
|
|
-DLLVM_BUILD_TESTS:BOOL=ON \
|
|
|
|
-DLLVM_INSTALL_GTEST:BOOL=ON \
|
2024-05-08 06:06:52 +00:00
|
|
|
-DLLVM_LIT_ARGS="-vv" \
|
2023-10-12 09:15:14 +00:00
|
|
|
\
|
|
|
|
-DLLVM_INCLUDE_EXAMPLES:BOOL=ON \
|
|
|
|
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
|
|
|
|
\
|
|
|
|
-DLLVM_INCLUDE_UTILS:BOOL=ON \
|
|
|
|
-DLLVM_INSTALL_UTILS:BOOL=ON \
|
2024-07-31 11:27:03 +00:00
|
|
|
-DLLVM_UTILS_INSTALL_DIR:PATH=bin \
|
2023-10-12 09:15:14 +00:00
|
|
|
-DLLVM_TOOLS_INSTALL_DIR:PATH=bin \
|
|
|
|
\
|
|
|
|
-DLLVM_INCLUDE_DOCS:BOOL=ON \
|
|
|
|
-DLLVM_BUILD_DOCS:BOOL=ON \
|
|
|
|
-DLLVM_ENABLE_SPHINX:BOOL=ON \
|
|
|
|
-DLLVM_ENABLE_DOXYGEN:BOOL=OFF \
|
2024-05-08 03:45:11 +00:00
|
|
|
-DLLVM_APPEND_VC_REV:BOOL=OFF \
|
2023-10-12 09:15:14 +00:00
|
|
|
\
|
|
|
|
%if %{with snapshot_build}
|
|
|
|
-DLLVM_VERSION_SUFFIX="%{llvm_snapshot_version_suffix}" \
|
|
|
|
%else
|
|
|
|
%if %{without compat_build}
|
|
|
|
-DLLVM_VERSION_SUFFIX='' \
|
|
|
|
%endif
|
|
|
|
%endif
|
|
|
|
-DLLVM_UNREACHABLE_OPTIMIZE:BOOL=ON \
|
|
|
|
-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
|
|
|
|
-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
|
|
|
|
-DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \
|
|
|
|
-DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \
|
|
|
|
-DLLVM_DEFAULT_TARGET_TRIPLE=%{llvm_triple} \
|
|
|
|
-DSPHINX_WARNINGS_AS_ERRORS=OFF \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=%{install_prefix} \
|
|
|
|
-DLLVM_INSTALL_SPHINX_HTML_DIR=%{_pkgdocdir}/html \
|
|
|
|
-DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 \
|
|
|
|
-DLLVM_INCLUDE_BENCHMARKS=OFF \
|
2024-05-03 11:12:47 +00:00
|
|
|
\
|
|
|
|
\
|
|
|
|
-DLLVM_DYLIB_COMPONENTS="all" \
|
|
|
|
-DLLVM_COMMON_CMAKE_UTILS=%{install_datadir}/llvm/cmake \
|
|
|
|
\
|
|
|
|
\
|
2024-07-01 11:30:45 +00:00
|
|
|
\
|
2024-07-30 14:59:07 +00:00
|
|
|
%if %{with lldb}
|
2024-07-01 11:30:45 +00:00
|
|
|
-DLLDB_DISABLE_CURSES:BOOL=OFF \
|
|
|
|
-DLLDB_DISABLE_LIBEDIT:BOOL=OFF \
|
|
|
|
-DLLDB_DISABLE_PYTHON:BOOL=OFF \
|
2024-07-05 15:21:26 +00:00
|
|
|
%ifarch ppc64le
|
|
|
|
-DLLDB_TEST_USER_ARGS=--skip-category=watchpoint \
|
|
|
|
%endif
|
2024-07-11 11:37:05 +00:00
|
|
|
-DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS:BOOL=ON \
|
2024-07-30 14:59:07 +00:00
|
|
|
%endif
|
2024-07-01 11:30:45 +00:00
|
|
|
\
|
|
|
|
\
|
|
|
|
\
|
2024-01-16 08:36:17 +00:00
|
|
|
%ifarch x86_64
|
2023-10-12 09:15:14 +00:00
|
|
|
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS -Wl,-z,cet-report=error" \
|
2024-01-16 08:36:17 +00:00
|
|
|
%endif
|
2024-07-16 15:21:53 +00:00
|
|
|
%if 0%{?rhel} == 8
|
|
|
|
-DLLVM_RAM_PER_COMPILE_JOB=2048 \
|
|
|
|
%endif
|
2024-05-27 07:16:41 +00:00
|
|
|
%if %{with lto_build}
|
|
|
|
%if 0%{?fedora} >= 41
|
|
|
|
-DLLVM_UNITTEST_LINK_FLAGS="-fno-lto"
|
|
|
|
%else
|
2023-10-12 09:15:14 +00:00
|
|
|
-DLLVM_UNITTEST_LINK_FLAGS="-Wl,-plugin-opt=O0"
|
2024-05-27 07:16:41 +00:00
|
|
|
%endif
|
|
|
|
%endif
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# Build libLLVM.so first. This ensures that when libLLVM.so is linking, there
|
|
|
|
# are no other compile jobs running. This will help reduce OOM errors on the
|
|
|
|
# builders without having to artificially limit the number of concurrent jobs.
|
|
|
|
%cmake_build --target LLVM
|
|
|
|
|
2024-06-08 00:52:12 +00:00
|
|
|
# Also build libclang-cpp.so separately to avoid OOM errors.
|
|
|
|
# This is to fix occasional OOM errors on the ppc64le COPR builders.
|
|
|
|
%cmake_build --target libclang-cpp.so
|
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
%cmake_build
|
|
|
|
|
|
|
|
# If we don't build the runtimes target here, we'll have to wait for the %check
|
|
|
|
# section until these files are available but they need to be installed.
|
|
|
|
#
|
|
|
|
# /usr/lib64/libomptarget.devicertl.a
|
|
|
|
# /usr/lib64/libomptarget-amdgpu-*.bc
|
|
|
|
# /usr/lib64/libomptarget-nvptx-*.bc
|
|
|
|
|
|
|
|
%cmake_build --target runtimes
|
|
|
|
|
|
|
|
cd ..
|