Skip to content

Commit cbd01f3

Browse files
authored
Produce summary for unsupported features in top 100 crates experiment (rust-lang#1400)
* Adjust script to filter and print unsupported features data * Add utils for unsupported features data (filter and summary) * Address PR comments
1 parent 5246a6d commit cbd01f3

File tree

3 files changed

+77
-4
lines changed

3 files changed

+77
-4
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Copyright Kani Contributors
3+
# SPDX-License-Identifier: Apache-2.0 OR MIT
4+
5+
# Filter lines with unsupported constructs.
6+
# These appear in `stderr` after a warning as follows:
7+
#
8+
# ```
9+
# warning: Found the following unsupported constructs:
10+
# - 'simd_eq' intrinsic (1)
11+
# - Rvalue::ThreadLocalRef (2)
12+
# ```
13+
14+
if [[ $# -ne 1 ]]; then
15+
echo "$0: Error: Missing input file (i.e., a file that contains Kani's `stderr` output)."
16+
exit 1
17+
fi
18+
19+
sed -n '/^ *- [^(]*([0-9]*)/p' $1
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
# Copyright Kani Contributors
3+
# SPDX-License-Identifier: Apache-2.0 OR MIT
4+
5+
# Print a table from a file with data about unsupported features.
6+
# We capture the data in unsupported constructs expressions of the
7+
# form " - <construct> (<instances>)". For example:
8+
# ```
9+
# - 'simd_eq' intrinsic (1)
10+
# - Rvalue::ThreadLocalRef (2)
11+
# ```
12+
#
13+
# And then compute:
14+
# 1. The number of crates impacted by a given construct
15+
# (i.e., the number of times it appears in the data)
16+
# 2. The number of instances of a given construct
17+
# (i.e., the number of instances according to the captured value)
18+
#
19+
# The data is sorted in descending order by the number of crates impacted.
20+
21+
if [[ $# -ne 1 ]]; then
22+
echo "$0: Error: Missing input file."
23+
exit 1
24+
fi
25+
26+
echo "SUMMARY - UNSUPPORTED FEATURES"
27+
echo "========================================================="
28+
echo "Unsupported feature | Crates impacted | Instances of use"
29+
echo "---------------------------------------------------------"
30+
cat $1 | sed -n 's/^ *- \([^(]*\)(\([0-9]*\))/\2 | \1/p' | \
31+
awk -F '|' '{
32+
if(times[$2]){
33+
times[$2] += $1;
34+
crates[$2] += 1;
35+
} else {
36+
times[$2] = $1;
37+
crates[$2] = 1;
38+
}
39+
}
40+
END {
41+
for (i in times) {
42+
printf "%3d | %3d | %s\n", crates[i], times[i], i;
43+
}
44+
}' | \
45+
sort -r | awk -F '|' '{
46+
printf "%45.45s | %3d | %3d\n", $3, $1, $2
47+
}'
48+
echo "========================================================="

scripts/exps/kani-run-on-repos.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export SELF_SCRIPT=$0
3535
export SELF_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
3636
NPROC=$(nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 4) # Linux or Mac or hard-coded default of 4
3737
export WORK_DIRECTORY_PREFIX="$SELF_DIR/../../target/remote-repos"
38-
38+
export TMP_UNSUPPORTED_FEATURES_DATA="/tmp/unsupported_features_data.txt"
3939

4040
export STDOUT_SUFFIX='stdout.cargo-kani'
4141
export STDERR_SUFFIX='stderr.cargo-kani'
@@ -74,9 +74,9 @@ function print_errors_for_each_repo_result {
7474
IS_FAIL='1'
7575
fi
7676

77-
STDERR_GREP=$(grep -A3 -n $TARGET_ERROR_REGEX $DIRECTORY/$STDERR_SUFFIX 2> /dev/null && echo 'STDERR has warnings')
78-
if [[ "$STDERR_GREP" =~ [a-zA-Z0-9] ]]; then
79-
echo -e "STDERR Warnings (Plus 3 lines after) $DIRECTORY/$STDERR_SUFFIX -----\n$STDERR_GREP"
77+
STDERR_GREP=$(./scripts/exps/kani-repos-utils/filter_unsupported_constructs.sh $DIRECTORY/$STDERR_SUFFIX 2> /dev/null)
78+
if [[ -n "$STDERR_GREP" ]]; then
79+
echo -e "STDERR Warnings $DIRECTORY/$STDERR_SUFFIX -----\n$STDERR_GREP" | tee -a $TMP_UNSUPPORTED_FEATURES_DATA
8080
IS_FAIL='1'
8181
fi
8282

@@ -105,6 +105,10 @@ elif [ "$#" -eq "1" ]; then
105105
exit -1
106106
fi
107107

108+
# Generate a file to save data about unsupported features
109+
rm -f $TMP_UNSUPPORTED_FEATURES_DATA
110+
touch $TMP_UNSUPPORTED_FEATURES_DATA
111+
108112
mkdir -p $WORK_DIRECTORY_PREFIX
109113
echo -e "$LIST_OF_CRATE_GIT_URLS" | \
110114
awk -F '\n' 'BEGIN{ a=0 }{ print a++ "," $1 }' | \
@@ -132,6 +136,8 @@ elif [ "$#" -eq "1" ]; then
132136
echo -e '\n--- OVERALL STATS ---'
133137
echo "$num_failed crates failed to compile"
134138
echo "$num_with_warning crates had warning(s)"
139+
echo ""
140+
./scripts/exps/kani-repos-utils/produce_unsupported_summary.sh $TMP_UNSUPPORTED_FEATURES_DATA
135141
else
136142
echo -e 'Needs exactly 1 argument path/to/url-list.\n'
137143
echo -e "$DOCUMENTATION"

0 commit comments

Comments
 (0)