llvm/build.spec.inc
Nikita Popov 542735e3c4 Decrease debuginfo verbosity on RHEL 8
To see whether this fixes the OOMs. This also drops the change on
i686 for other OSs, to see whether that works or not.

On s390x this was already not effective due to a mismatch with
the condition in the cmake invocation.
2024-09-02 15:45:30 +02:00

240 lines
6.5 KiB
PHP

# TODO(kkleine): In clang we had this %ifarch s390 s390x aarch64 %ix86 ppc64le
%if 0%{?rhel} == 8
# Decrease debuginfo verbosity to reduce memory consumption during final library linking
%global optflags %(echo %{optflags} | sed 's/-g /-g1 /')
%endif
# 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
# TODO(kkleine): Make sure the paths actually work. I have the feeling this needs adjustment
pwd
%if 0%{?__isa_bits} == 64
sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@/64/g' llvm/test/lit.cfg.py
%else
sed -i 's/\@FEDORA_LLVM_LIB_SUFFIX\@//g' llvm/test/lit.cfg.py
%endif
# 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
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/llvm/%{_vpath_builddir}/%{_lib}"
cd llvm
%if 0%{?rhel} == 8
%undefine __cmake_in_source_build
%endif
# 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.
# TODO: LIBOMP_HAVE_VERSION_SCRIPT_FLAG should be set automatically.
# TODO: Override LIBOMP_INSTALL_LIBDIR, because otherwise the libraries
# are installed to /usr/lib64/$TRIPLE and clang can't find them.
%cmake -G Ninja \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" \
\
\
-DCLANG_DEFAULT_PIE_ON_LINUX=OFF \
%if 0%{?fedora} || 0%{?rhel} > 9
-DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON \
%endif
-DPython3_EXECUTABLE=%{__python3} \
%if %{with compat_build}
-DLLVM_INCLUDE_TESTS:BOOL=OFF \
-DCLANG_INCLUDE_TESTS:BOOL=OFF \
-DCLANG_BUILD_TOOLS:BOOL=OFF \
%else
-DLLVM_INCLUDE_TESTS:BOOL=ON \
-DCLANG_INCLUDE_TESTS:BOOL=ON \
-DLLVM_BUILD_UTILS:BOOL=ON \
%endif
-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}" \
-DCLANG_RESOURCE_DIR=../lib/clang/%{maj_ver} \
-DLLVM_EXTERNAL_CLANG_TOOLS_EXTRA_SOURCE_DIR=../clang-tools-extra \
-DCLANG_CONFIG_FILE_SYSTEM_DIR=%{_sysconfdir}/%{pkg_name_clang}/ \
-DCLANG_DEFAULT_UNWINDLIB=libgcc \
\
\
\
\
%if %{without compat_build}
-DLLVM_ENABLE_RUNTIMES="compiler-rt;openmp;offload" \
%endif
\
\
\
\
\
%if %{without compat_build}
-DCOMPILER_RT_INSTALL_PATH=%{_prefix}/lib/clang/%{maj_ver} \
-DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON \
-DCOMPILER_RT_INCLUDE_TESTS:BOOL=OFF \
%endif
\
\
\
\
\
%if %{without compat_build}
-DLIBOMP_HAVE_VERSION_SCRIPT_FLAG:BOOL=ON \
-DLIBOMP_INSTALL_ALIASES=OFF \
%if 0%{?__isa_bits} == 64
-DOPENMP_LIBDIR_SUFFIX=64 \
%else
-DOPENMP_LIBDIR_SUFFIX= \
%endif
%endif
-DOPENMP_INSTALL_LIBDIR=%{_lib} \
-DOFFLOAD_INSTALL_LIBDIR=%{_lib} \
\
\
\
\
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_SKIP_RPATH:BOOL=ON \
%if 0%{?rhel} == 8
-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 \
%if %{with compat_build}
-DLLVM_INSTALL_GTEST:BOOL=OFF \
%else
-DLLVM_INSTALL_GTEST:BOOL=ON \
%endif
-DLLVM_LIT_ARGS="-vv" \
\
-DLLVM_INCLUDE_EXAMPLES:BOOL=ON \
-DLLVM_BUILD_EXAMPLES:BOOL=OFF \
\
-DLLVM_INCLUDE_UTILS:BOOL=ON \
%if %{with compat_build}
-DLLVM_INSTALL_UTILS:BOOL=OFF \
%else
-DLLVM_INSTALL_UTILS:BOOL=ON \
-DLLVM_UTILS_INSTALL_DIR:PATH=%{_bindir} \
-DLLVM_TOOLS_INSTALL_DIR:PATH=bin \
%endif
\
-DLLVM_INCLUDE_DOCS:BOOL=ON \
-DLLVM_BUILD_DOCS:BOOL=ON \
-DLLVM_ENABLE_SPHINX:BOOL=ON \
-DLLVM_ENABLE_DOXYGEN:BOOL=OFF \
-DLLVM_APPEND_VC_REV:BOOL=OFF \
\
%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 \
\
\
-DLLVM_DYLIB_COMPONENTS="all" \
-DLLVM_COMMON_CMAKE_UTILS=%{install_datadir}/llvm/cmake \
\
\
\
-DLLDB_DISABLE_CURSES:BOOL=OFF \
-DLLDB_DISABLE_LIBEDIT:BOOL=OFF \
-DLLDB_DISABLE_PYTHON:BOOL=OFF \
%ifarch ppc64le
-DLLDB_TEST_USER_ARGS=--skip-category=watchpoint \
%endif
-DLLDB_ENFORCE_STRICT_TEST_REQUIREMENTS:BOOL=ON \
\
\
\
%ifarch x86_64
-DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS -Wl,-z,cet-report=error" \
%endif
%if 0%{?rhel} == 8
-DLLVM_RAM_PER_COMPILE_JOB=2048 \
%endif
%if %{with lto_build}
%if 0%{?fedora} >= 41
-DLLVM_UNITTEST_LINK_FLAGS="-fno-lto"
%else
-DLLVM_UNITTEST_LINK_FLAGS="-Wl,-plugin-opt=O0"
%endif
%endif
# 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
# 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
%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 ..