-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure full bitcode for iOS framework (#2174)
* Add script to check full bitcode inclusion in iOS binaries * Enable full bitcode generation for Release iOS builds * iOS snapshot builds use Release mode and run bitcode check * iOS tagged release builds run bitcode check
- Loading branch information
1 parent
804a7a9
commit 0235946
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash -eo pipefail | ||
# USAGE | ||
# check_bitcode.sh input_file [archs] | ||
# | ||
if [[ ${2} ]]; then | ||
# Take all args after input_file as archs. | ||
archs=${@:2} | ||
else | ||
# If archs not given in args, use lipo to list all archs in file. | ||
archs=$(lipo -archs ${1}) | ||
fi | ||
|
||
echo "Checking bitcode in file=${1} archs=${archs}" | ||
|
||
missing_bitcode=0 | ||
|
||
for arch in ${archs}; do | ||
# The otool command prints object file data for the given arch in the input file. | ||
# The awk command prints the 'size' value following a 'segname' value equal to '__LLVM' (the bitcode segment). | ||
bitcode_size=$(otool -l -arch ${arch} ${1} | awk '/ segname/ { SEGNAME = $2 }; / size/ { if(SEGNAME == "__LLVM") print $2 }') | ||
echo "arch=${arch} bitcode_size=${bitcode_size}" | ||
# Sometimes bitcode exists but is just a stub, so check for segments that are too small. | ||
# This check also covers bitcode_size being empty. | ||
if [[ ${bitcode_size} -lt 0x10 ]]; then | ||
((missing_bitcode++)) | ||
fi | ||
done | ||
|
||
if [[ $missing_bitcode -gt 0 ]]; then | ||
echo "Some archs are missing bitcode." | ||
exit 1 | ||
fi |