Accepting request 979583 from home:aaronpuchert:branches:devel:tools:compiler

- Update to version 14.0.4.
  * This release contains bug-fixes for the LLVM 14.0.0 release.
    This release is API and ABI compatible with 14.0.0.
- Don't use gold for linking anymore: on s390x we use ld.bfd with
  LLVMgold.so, on ppc64 we disable ThinLTO for now.
- Using ld.bfd on s390x exposed an issue with the existing
  llvm_build_tablegen_component_as_shared_library.patch: linking
  llvm-tblgen with libLLVM.so means we also have to link libraries
  used for that (like LLVMTableGenGlobalISel) with libLLVM.so.
- Rewrite summary and description for llvm-gold to point out that
  it can also be used with ld.bfd, recommend with binutils.
- Prefer RPM macros over shell scripting, so that we can better
  inspect the build script with substitutions in place.
- More memory for stage 1 build jobs due to recent OOMs.
- Add %_libclang_sonum RPM macro to llvm-devel, since that might
  now diverge from %_llvm_sonum.
- Rebase llvm-do-not-install-static-libraries.patch.

OBS-URL: https://build.opensuse.org/request/show/979583
OBS-URL: https://build.opensuse.org/package/show/devel:tools:compiler/llvm14?expand=0&rev=16
This commit is contained in:
Aaron Puchert
2022-05-28 12:45:59 +00:00
committed by Git OBS Bridge
parent 627f10bec9
commit 3b54262c5d
28 changed files with 140 additions and 129 deletions

View File

@@ -16,14 +16,14 @@
#
%define _relver 14.0.3
%define _relver 14.0.4
%define _version %_relver%{?_rc:rc%_rc}
%define _tagver %_relver%{?_rc:-rc%_rc}
%define _minor 14.0
%define _sonum 14
%define _itsme14 1
# Integer version used by update-alternatives
%define _uaver 1403
%define _uaver 1404
%define _soclang 13
%define _socxx 1
@@ -39,11 +39,10 @@
%bcond_with openmp
%endif
# We use gold where we want to use ThinLTO, but where lld isn't supported (well).
%ifarch ppc64 s390x
%bcond_without gold
%ifarch s390x
%bcond_with use_lld
%else
%bcond_with gold
%bcond_without use_lld
%endif
%ifarch x86_64
@@ -55,7 +54,7 @@
%endif
# Disabled on ARM because it's awfully slow and often times out. (boo#1178070)
%ifarch %{ix86} ppc64 ppc64le s390x x86_64
%ifarch %{ix86} ppc64le s390x x86_64
%bcond_without thin_lto
%else
%bcond_with thin_lto
@@ -87,16 +86,14 @@
# Expands to -n if we're providing the distribution default for the given package.
%define multisource() %{expand:%%{?_itsme%{expand:%%{!?product_libs_llvm_ver_%{1}:%%{_plv}}%%{?product_libs_llvm_ver_%{1}}}:-n}}
# set_jobs type memory
# Set max_<type>_jobs so that every job of the given type has at least the
# given amount of memory.
%define set_jobs() \
max_%{1}_jobs="%{?jobs:%{jobs}}" \
if test -n "$max_%{1}_jobs" -a "$max_%{1}_jobs" -gt 1 ; then \
max_jobs="$(($avail_mem / %2))" \
test "$max_%{1}_jobs" -gt "$max_jobs" && max_%{1}_jobs="$max_jobs" && echo "Warning: Reducing number of %{1} jobs to $max_jobs because of memory limits" \
test "$max_%{1}_jobs" -le 0 && max_%{1}_jobs=1 && echo "Warning: Not %{1}ing in parallel at all because of memory limits" \
fi
%global avail_mem %(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
%global _max_jobs %{?jobs}%{?!jobs:%getncpus}
%define _min() %[%1 <= %2 ? %1 : %2]
%define _clamp() %{_min %[%1 >= %2 ? %1 : %2] %3}
# Return a number of jobs so that every job has at least the given amount of
# memory, if possible.
%define num_jobs() %{_clamp %[%{avail_mem} / %1] 1 %{_max_jobs}}
%define _dwz_low_mem_die_limit 40000000
%define _dwz_max_die_limit 200000000
@@ -169,9 +166,6 @@ Requires(post): update-alternatives
Requires(postun):update-alternatives
# llvm does not work on s390
ExcludeArch: s390
%if %{with gold}
BuildRequires: binutils-gold
%endif
%if %{with ffi}
BuildRequires: pkgconfig(libffi)
%endif
@@ -365,14 +359,18 @@ Group: System/Libraries
This package contains the link-time optimizer for LLVM.
%package gold
Summary: Gold linker plugin for LLVM
Summary: LLVM LTO plugin for ld.bfd and ld.gold
Group: Development/Tools/Building
Conflicts: llvm-gold-provider < %{version}
Provides: llvm-gold-provider = %{version}
Supplements: packageand(clang%{_sonum}:binutils)
Supplements: packageand(clang%{_sonum}:binutils-gold)
%description gold
This package contains the Gold linker plugin for LLVM.
This package contains a plugin for link-time optimization in binutils linkers.
Despite the name, it can also be used with ld.bfd. It is required for using
Clang with -flto=full or -flto=thin when linking with one of those linkers.
%package -n libomp%{_sonum}-devel
Summary: MPI plugin for LLVM
@@ -650,6 +648,8 @@ mv libcxxabi-%{_version}.src projects/libcxxabi
%endif
%build
%global sourcedir %{_builddir}/%{buildsubdir}
%define _lto_cflags %{nil}
# Use optflags, but:
@@ -657,17 +657,18 @@ mv libcxxabi-%{_version}.src projects/libcxxabi
# hardening. The problem is in sanitizers from compiler-rt.
# 2) Remove the -g. We don't want it in stage1 and it will be added by cmake in
# the following stage.
flags=$(echo %{optflags} | sed 's/-D_FORTIFY_SOURCE=./-D_FORTIFY_SOURCE=0/;s/\B-g\b//g')
%global cleaned_flags %(echo %{optflags} | sed 's/-D_FORTIFY_SOURCE=./-D_FORTIFY_SOURCE=0/;s/\B-g\b//g')
%global flags %{cleaned_flags}
%ifarch armv6hl
flags+=" -mfloat-abi=hard -mcpu=arm1176jzf-s -mfpu=vfpv2"
%global flags %{cleaned_flags} -mfloat-abi=hard -mcpu=arm1176jzf-s -mfpu=vfpv2
%endif
%ifarch armv7hl
flags+=" -mfloat-abi=hard -march=armv7-a -mtune=cortex-a17 -mfpu=vfpv3-d16"
%global flags %{cleaned_flags} -mfloat-abi=hard -march=armv7-a -mtune=cortex-a17 -mfpu=vfpv3-d16
%endif
CFLAGS=$flags
CXXFLAGS=$flags
CFLAGS="%flags"
CXXFLAGS="%flags"
# By default build everything
TARGETS_TO_BUILD="all"
@@ -693,25 +694,19 @@ TARGETS_TO_BUILD="host;BPF"
EXPERIMENTAL_TARGETS_TO_BUILD=
%endif
mem_per_compile_job=1000000
%define mem_per_compile_job 1200000
%ifarch i586 ppc armv6hl armv7hl
# 32-bit arches need less memory than 64-bit arches.
mem_per_compile_job=600000
%define mem_per_compile_job 600000
%endif
mem_per_link_job=3000000
%define mem_per_link_job 3000000
%ifarch riscv64
# Give RISCV link jobs more memory.
mem_per_link_job=4000000
%define mem_per_link_job 4000000
%endif
echo "Available memory:"
cat /proc/meminfo
echo "System limits:"
ulimit -a
avail_mem=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
%set_jobs link $mem_per_link_job
%set_jobs compile $mem_per_compile_job
%{echo:Available memory: %avail_mem}
%define __builder ninja
%define __builddir stage1
@@ -722,8 +717,8 @@ avail_mem=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
-DLLVM_HOST_TRIPLE=%{host_triple} \
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
-DLLVM_LINK_LLVM_DYLIB:BOOL=OFF \
-DLLVM_PARALLEL_COMPILE_JOBS="$max_compile_jobs" \
-DLLVM_PARALLEL_LINK_JOBS="$max_link_jobs" \
-DLLVM_PARALLEL_COMPILE_JOBS=%{num_jobs %mem_per_compile_job} \
-DLLVM_PARALLEL_LINK_JOBS=%{num_jobs %mem_per_link_job} \
-DENABLE_LINKER_BUILD_ID=ON \
-DLLVM_BINUTILS_INCDIR=%{_includedir} \
-DLLVM_BUILD_TOOLS:BOOL=OFF \
@@ -744,10 +739,10 @@ avail_mem=$(awk '/MemAvailable/ { print $2 }' /proc/meminfo)
ninja -v %{?_smp_mflags} clang llvm-tblgen clang-tblgen \
%if %{with thin_lto}
llvm-ar llvm-ranlib \
%if %{with gold}
LLVMgold
%else
%if %{with use_lld}
lld
%else
LLVMgold
%endif
%endif
@@ -760,72 +755,51 @@ find ./stage1 \( -name '*.o' -or -name '*.a' \) -delete
# 3) Remove -fstack-clash-protection on architectures where it isn't supported.
# Using it just prints a warning, but that warning prevents the configuration
# step, which uses -Werror, from recognizing the availability of other flags.
if ! ${PWD}/stage1/bin/clang -c -xc -Werror -fstack-clash-protection -o /dev/null /dev/null;
if ! ./stage1/bin/clang -c -xc -Werror -fstack-clash-protection -o /dev/null /dev/null;
then
flags=$(echo $flags | sed 's/-fstack-clash-protection//');
flags=$(echo %flags | sed 's/-fstack-clash-protection//');
fi
CFLAGS=$flags
CXXFLAGS=$flags
# Clang uses a bit less memory.
mem_per_compile_job=700000
%define mem_per_compile_job 700000
%ifarch i586 ppc armv6hl armv7hl
# 32-bit arches need less memory than 64-bit arches.
mem_per_compile_job=500000
%endif
%set_jobs compile $mem_per_compile_job
%if %{with thin_lto}
# A single ThinLTO job is fully parallel already.
max_link_jobs=1
%define mem_per_compile_job 500000
%endif
%define __builddir build
%define build_ldflags -Wl,--build-id=sha1
export PATH=${PWD}/stage1/bin:$PATH
export CC=${PWD}/stage1/bin/clang
export CXX=${PWD}/stage1/bin/clang++
%if %{with thin_lto}
export LLVM_AR=${PWD}/stage1/bin/llvm-ar
export LLVM_RANLIB=${PWD}/stage1/bin/llvm-ranlib
export LLD=${PWD}/stage1/bin/ld.lld
%endif
export LLVM_TABLEGEN=${PWD}/stage1/bin/llvm-tblgen
export CLANG_TABLEGEN=${PWD}/stage1/bin/clang-tblgen
# Build is using absolute paths assuming the monorepo layout, so we need this.
export CLANG_TOOLS_EXTRA_DIR=${PWD}/tools/clang/tools/extra
# The build occasionally uses tools linking against previously built
# libraries (mostly libLLVM.so), but we don't want to set RUNPATHs.
export LD_LIBRARY_PATH=${PWD}/build/%{_lib}
export LD_LIBRARY_PATH=%{sourcedir}/build/%{_lib}
%cmake \
-DCMAKE_C_COMPILER="%{sourcedir}/stage1/bin/clang" \
-DCMAKE_CXX_COMPILER="%{sourcedir}/stage1/bin/clang++" \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DLLVM_HOST_TRIPLE=%{host_triple} \
-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
-DCLANG_LINK_CLANG_DYLIB:BOOL=ON \
-DLLVM_PARALLEL_COMPILE_JOBS="$max_compile_jobs" \
-DLLVM_PARALLEL_LINK_JOBS="$max_link_jobs" \
-DLLVM_PARALLEL_COMPILE_JOBS=%{num_jobs %mem_per_compile_job} \
-DLLVM_PARALLEL_LINK_JOBS=%{?with_thin_lto:1}%{!?with_thin_lto:%{num_jobs %mem_per_link_job}} \
%if %{with thin_lto}
-DLLVM_ENABLE_LTO=Thin \
-DCMAKE_AR="${LLVM_AR}" \
-DCMAKE_RANLIB="${LLVM_RANLIB}" \
%if %{with gold}
-DCMAKE_LINKER=%{_bindir}/ld.gold \
-DLLVM_USE_LINKER=gold \
%else
-DCMAKE_LINKER=${LLD} \
-DLLVM_USE_LINKER=${LLD} \
-DCMAKE_AR="%{sourcedir}/stage1/bin/llvm-ar" \
-DCMAKE_RANLIB="%{sourcedir}/stage1/bin/llvm-ranlib" \
%if %{with use_lld}
-DCMAKE_LINKER="%{sourcedir}/stage1/bin/ld.lld" \
-DLLVM_USE_LINKER="%{sourcedir}/stage1/bin/ld.lld" \
%endif
%else
-DCMAKE_LINKER=%{_bindir}/ld \
%endif
%ifarch %arm ppc s390 %{ix86}
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g1" \
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g1" \
%endif
-DENABLE_LINKER_BUILD_ID=ON \
-DLLVM_TABLEGEN="${LLVM_TABLEGEN}" \
-DCLANG_TABLEGEN="${CLANG_TABLEGEN}" \
-DLLVM_TABLEGEN="%{sourcedir}/stage1/bin/llvm-tblgen" \
-DCLANG_TABLEGEN="%{sourcedir}/stage1/bin/clang-tblgen" \
-DLLVM_ENABLE_RTTI:BOOL=ON \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_PIC=ON \
@@ -879,7 +853,7 @@ cd ..
%install
# Installation seems to build some files not contained in "all".
export LD_LIBRARY_PATH=${PWD}/build/%{_lib}
export LD_LIBRARY_PATH=%{sourcedir}/build/%{_lib}
%cmake_install
# Install FileCheck needed for testing Rust boo#1192629
@@ -1103,6 +1077,7 @@ cat > %{buildroot}%{_rpmconfigdir}/macros.d/macros.llvm <<EOF
%_llvm_relver %{_relver}
%_llvm_minorver %{_minor}
%_llvm_sonum %{_sonum}
%_libclang_sonum %{_soclang}
%_libcxx_sonum %{_socxx}
# Build information
@@ -1172,6 +1147,8 @@ python3 bin/llvm-lit -sv test/
# On s390x, this test complains that a required pass couldn't be found and then crashes. (FIXME)
sed -i '/XFAIL/i// XFAIL: s390x' ../tools/clang/test/CodeGen/sanitize-coverage-old-pm.c
# We're not getting the exact crash dump that was expected. Not sure why, input is cut off.
sed -i '1i// XFAIL: s390x' ../tools/clang/test/Driver/{crash-{diagnostics-dir.c,report-header.h,report-spaces.c},rewrite-map-in-diagnostics.c}
# On ppc, this test fails with "fatal error: error in backend: Relocation type not implemented yet!"
sed -i '/UNSUPPORTED/i// XFAIL: powerpc-' ../tools/clang/test/Interpreter/execute.cpp
# Tests hang on armv6l.