brp-compile-lto-elf: Avoid a tmpdir

The mkdir -p was unused as far as I can see. The tmpdir was unnecessary,
since we can just pass -x to clang.
This commit is contained in:
Timm Bäder 2022-03-02 17:14:11 +01:00 committed by tstellar
parent d9c7e4eef8
commit c5a97aad73

View File

@ -1,13 +1,12 @@
#!/usr/bin/bash -eu #!/usr/bin/bash -eu
CLANG_FLAGS=$@
if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then
exit 0 exit 0
fi fi
CLANG_FLAGS=$@
NCPUS=${RPM_BUILD_NCPUS:-1} NCPUS=${RPM_BUILD_NCPUS:-1}
TMPDIR=`mktemp -d`
check_convert_bitcode () { check_convert_bitcode () {
local file_name=$(realpath ${1}) local file_name=$(realpath ${1})
@ -19,11 +18,8 @@ check_convert_bitcode () {
llvm-bcanalyzer -dump ${file_name} | grep -xP '.*\-flto((?!-fno-lto).)*' 2>&1 > /dev/null llvm-bcanalyzer -dump ${file_name} | grep -xP '.*\-flto((?!-fno-lto).)*' 2>&1 > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo "Compiling LLVM bitcode file ${file_name}." echo "Compiling LLVM bitcode file ${file_name}."
# create path to file in temp dir clang ${CLANG_FLAGS} -fno-lto -Wno-unused-command-line-argument \
# move file to temp dir with llvm .bc extension for clang -x ir ${file_name} -c -o ${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 fi
elif [[ "${file_type}" == *"current ar archive"* ]]; then elif [[ "${file_type}" == *"current ar archive"* ]]; then
echo "Unpacking ar archive ${file_name} to check for LLVM bitcode components." echo "Unpacking ar archive ${file_name} to check for LLVM bitcode components."
@ -42,7 +38,6 @@ check_convert_bitcode () {
} }
echo "Checking for LLVM bitcode artifacts" echo "Checking for LLVM bitcode artifacts"
export -f check_convert_bitcode export -f check_convert_bitcode
find "$RPM_BUILD_ROOT" -type f -name "*.[ao]" -print0 | \ find "$RPM_BUILD_ROOT" -type f -name "*.[ao]" -print0 | \
xargs -0 -n1 -P$NCPUS sh -c "check_convert_bitcode \$@" ARG0 xargs -0 -n1 -P$NCPUS sh -c "check_convert_bitcode \$@" ARG0