Debian Codegraph @

debian/llvm-compile-lto-elf.sh

raw symbols SCIP
1 #!/usr/bin/bashscip-shell filesystem . . `/usr/bin/bash`. -eu
2
3 # Initial version:
4 # https://src.fedoraproject.org/rpms/redhat-rpm-config/blob/rawhide/f/brp-llvm-compile-lto-elf
5
6 CLANG_FLAGS=$@
7
8 if testscip-shell system . . test. -z $P_TO_LLVM; then
9 echoscip-shell system . . echo. "P_TO_LLVM isn't set"
10 exit 1
11 fi
12
13 if testscip-shell system . . test. -z $NJOBS; then
14 echoscip-shell system . . echo. "NJOBS isn't set"
15 exit 1
16 fi
17
18 if testscip-shell system . . test. -z $VERSION; then
19 echoscip-shell system . . echo. "VERSION isn't set"
20 exit 1
21 fi
22
23 NCPUS=$NJOBS
24
25 check_convert_bitcodescip-shell shell llvm-toolchain-19 1:19.1.7-22 check_convert_bitcode(). () {
26 local file_name=$(realpathscip-shell system . . realpath. ${1})
27 local file_type=$(filescip-shell system . . file. ${file_name})
28 shift
29 CLANG_FLAGS="$@"
30
31 if [[ "${file_type}" == *"LLVM IR bitcode"* ]]; then
32 # check for an indication that the bitcode was
33 # compiled with -flto
34 ${P_TO_LLVM}/debian/tmp/usr/bin/llvm-bcanalyzer-${VERSION} -dump ${file_name} | grepscip-shell system . . grep. -xP '.*\-flto((?!-fno-lto).)*' 2>&1 > /dev/nullscip-shell filesystem . . `/dev/null`.
35 if [scip-shell system . . `[`. $? -eq 0 ]; then
36 echoscip-shell system . . echo. "Compiling LLVM bitcode file ${file_name}."
37 ${P_TO_LLVM}/debian/tmp/usr/bin/clang-${VERSION} -fno-lto -opaque-pointers -Wno-unused-command-line-argument \
38 -x ir ${file_name} -c -o ${file_name}
39 fi
40 elif [[ "${file_type}" == *"current ar archive"* ]]; then
41 echoscip-shell system . . echo. "Unpacking ar archive ${file_name} to check for LLVM bitcode components."
42 # create archive stage for objects
43 local archive_stage=$(mktempscip-shell system . . mktemp. -d)
44 local archive=${file_name}
45 pushd ${archive_stage}
46 arscip-shell system . . ar. x ${archive}
47 for archived_file in $(findscip-shell system . . find. -not -type d); do
48 check_convert_bitcodescip-shell shell llvm-toolchain-19 1:19.1.7-22 check_convert_bitcode(). ${archived_file} ${CLANG_FLAGS}
49 echoscip-shell system . . echo. "Repacking ${archived_file} into ${archive}."
50 ${P_TO_LLVM}/debian/tmp/usr/bin/llvm-ar-${VERSION} r ${archive} ${archived_file}
51 done
52 popd
53 fi
54 }
55
56 echoscip-shell system . . echo. "Checking for LLVM bitcode artifacts"
57 export -f check_convert_bitcode
58 findscip-shell system . . find. "$P_TO_LLVM/debian/" -type f -name "*.[ao]" -print0 | \
59 xargs -0 -r -n1 -P$NCPUS bash -c "check_convert_bitcode \$@ $CLANG_FLAGS" ARG0