Parallelize llvm-compile-lto-elf

This commit is contained in:
Timm Bäder 2022-02-25 16:36:03 +01:00 committed by tstellar
parent 200350d957
commit d9c7e4eef8
2 changed files with 13 additions and 9 deletions

View File

@ -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

View File

@ -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 <tbaeder@redhat.com> - 218-1
- Parallelize bpr-llvm-compile-lto-elf
* Tue Apr 19 2022 Tom Stellard <tstellar@redhat.com> - 217-1
- Add -fno-openmp-implicit-rpath when building with clang