From d9c7e4eef8d39f1660a0ee3372eabe44239bd121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 25 Feb 2022 16:36:03 +0100 Subject: [PATCH] Parallelize llvm-compile-lto-elf --- brp-llvm-compile-lto-elf | 17 +++++++++-------- redhat-rpm-config.spec | 5 ++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/brp-llvm-compile-lto-elf b/brp-llvm-compile-lto-elf index 19783fa..1770d41 100755 --- a/brp-llvm-compile-lto-elf +++ b/brp-llvm-compile-lto-elf @@ -6,11 +6,12 @@ if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then exit 0 fi +NCPUS=${RPM_BUILD_NCPUS:-1} TMPDIR=`mktemp -d` check_convert_bitcode () { - local file_name=`realpath ${1}` - local file_type=`file ${file_name}` + local file_name=$(realpath ${1}) + local file_type=$(file ${file_name}) if [[ "${file_type}" == *"LLVM IR bitcode"* ]]; then # check for an indication that the bitcode was @@ -20,18 +21,18 @@ check_convert_bitcode () { echo "Compiling LLVM bitcode file ${file_name}." # create path to file in temp dir # move file to temp dir with llvm .bc extension for clang - mkdir -p ${TMPDIR}/`dirname ${file_name}` + mkdir -p ${TMPDIR}/$(dirname ${file_name}) mv $file_name ${TMPDIR}/${file_name}.bc clang -c ${CLANG_FLAGS} -fno-lto -Wno-unused-command-line-argument ${TMPDIR}/${file_name}.bc -o ${file_name} fi elif [[ "${file_type}" == *"current ar archive"* ]]; then echo "Unpacking ar archive ${file_name} to check for LLVM bitcode components." # create archive stage for objects - local archive_stage=`mktemp -d` + local archive_stage=$(mktemp -d) local archive=${file_name} pushd ${archive_stage} ar x ${archive} - for archived_file in `find -not -type d`; do + for archived_file in $(find -not -type d); do check_convert_bitcode ${archived_file} echo "Repacking ${archived_file} into ${archive}." ar r ${archive} ${archived_file} @@ -41,7 +42,7 @@ check_convert_bitcode () { } echo "Checking for LLVM bitcode artifacts" -for i in `find $RPM_BUILD_ROOT -type f -name "*.[ao]"`; do - check_convert_bitcode ${i} -done +export -f check_convert_bitcode +find "$RPM_BUILD_ROOT" -type f -name "*.[ao]" -print0 | \ + xargs -0 -n1 -P$NCPUS sh -c "check_convert_bitcode \$@" ARG0 diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index ba8f0c7..c6676bd 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 217 +Version: 218 Release: 1%{?dist} # No version specified. License: GPL+ @@ -215,6 +215,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %doc buildflags.md %changelog +* Wed Apr 20 2022 Timm Bäder - 218-1 +- Parallelize bpr-llvm-compile-lto-elf + * Tue Apr 19 2022 Tom Stellard - 217-1 - Add -fno-openmp-implicit-rpath when building with clang