SHA256
1
0
forked from pool/llvm14

- Undo macro-based job computation: requires RPM 4.16 which is not

available in Leap yet. (We're on 4.14 there.)

OBS-URL: https://build.opensuse.org/package/show/devel:tools:compiler/llvm14?expand=0&rev=17
This commit is contained in:
Aaron Puchert 2022-05-28 15:16:18 +00:00 committed by Git OBS Bridge
parent 3b54262c5d
commit 18d98014e4

View File

@ -86,14 +86,16 @@
# 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}}
%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}}
# 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
%define _dwz_low_mem_die_limit 40000000
%define _dwz_max_die_limit 200000000
@ -694,19 +696,25 @@ TARGETS_TO_BUILD="host;BPF"
EXPERIMENTAL_TARGETS_TO_BUILD=
%endif
%define mem_per_compile_job 1200000
mem_per_compile_job=1200000
%ifarch i586 ppc armv6hl armv7hl
# 32-bit arches need less memory than 64-bit arches.
%define mem_per_compile_job 600000
mem_per_compile_job=700000
%endif
%define mem_per_link_job 3000000
mem_per_link_job=3000000
%ifarch riscv64
# Give RISCV link jobs more memory.
%define mem_per_link_job 4000000
mem_per_link_job=4000000
%endif
%{echo:Available memory: %avail_mem}
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
%define __builder ninja
%define __builddir stage1
@ -717,8 +725,8 @@ EXPERIMENTAL_TARGETS_TO_BUILD=
-DLLVM_HOST_TRIPLE=%{host_triple} \
-DLLVM_BUILD_LLVM_DYLIB:BOOL=OFF \
-DLLVM_LINK_LLVM_DYLIB:BOOL=OFF \
-DLLVM_PARALLEL_COMPILE_JOBS=%{num_jobs %mem_per_compile_job} \
-DLLVM_PARALLEL_LINK_JOBS=%{num_jobs %mem_per_link_job} \
-DLLVM_PARALLEL_COMPILE_JOBS="$max_compile_jobs" \
-DLLVM_PARALLEL_LINK_JOBS="$max_link_jobs" \
-DENABLE_LINKER_BUILD_ID=ON \
-DLLVM_BINUTILS_INCDIR=%{_includedir} \
-DLLVM_BUILD_TOOLS:BOOL=OFF \
@ -763,10 +771,16 @@ CFLAGS=$flags
CXXFLAGS=$flags
# Clang uses a bit less memory.
%define mem_per_compile_job 700000
mem_per_compile_job=700000
%ifarch i586 ppc armv6hl armv7hl
# 32-bit arches need less memory than 64-bit arches.
%define mem_per_compile_job 500000
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
%endif
%define __builddir build
@ -782,8 +796,8 @@ export LD_LIBRARY_PATH=%{sourcedir}/build/%{_lib}
-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \
-DLLVM_LINK_LLVM_DYLIB:BOOL=ON \
-DCLANG_LINK_CLANG_DYLIB:BOOL=ON \
-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}} \
-DLLVM_PARALLEL_COMPILE_JOBS="$max_compile_jobs" \
-DLLVM_PARALLEL_LINK_JOBS="$max_link_jobs" \
%if %{with thin_lto}
-DLLVM_ENABLE_LTO=Thin \
-DCMAKE_AR="%{sourcedir}/stage1/bin/llvm-ar" \