diff --git a/brp-llvm-compile-lto-elf b/brp-llvm-compile-lto-elf index 1770d41..03006c7 100755 --- a/brp-llvm-compile-lto-elf +++ b/brp-llvm-compile-lto-elf @@ -1,31 +1,27 @@ #!/usr/bin/bash -eu -CLANG_FLAGS=$@ if [ -z "$RPM_BUILD_ROOT" ] || [ "$RPM_BUILD_ROOT" = "/" ]; then exit 0 fi +CLANG_FLAGS=$@ NCPUS=${RPM_BUILD_NCPUS:-1} -TMPDIR=`mktemp -d` check_convert_bitcode () { local file_name=$(realpath ${1}) local file_type=$(file ${file_name}) - if [[ "${file_type}" == *"LLVM IR bitcode"* ]]; then + if [[ "${file_type}" == *"LLVM IR bitcode"* ]]; then # check for an indication that the bitcode was # compiled with -flto llvm-bcanalyzer -dump ${file_name} | grep -xP '.*\-flto((?!-fno-lto).)*' 2>&1 > /dev/null if [ $? -eq 0 ]; then 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}) - 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} + clang ${CLANG_FLAGS} -fno-lto -Wno-unused-command-line-argument \ + -x ir ${file_name} -c -o ${file_name} 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." # create archive stage for objects local archive_stage=$(mktemp -d) @@ -42,7 +38,6 @@ check_convert_bitcode () { } echo "Checking for LLVM bitcode artifacts" - 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