Skip to content

Commit 44e948c

Browse files
celinvaldanielsn
authored andcommitted
Make rmc-rustc errors more user friendly (rust-lang#606)
and also build rmc library as part of the regression script. Co-authored-by: Daniel Schwartz-Narbonne <[email protected]>
1 parent a51c702 commit 44e948c

File tree

2 files changed

+43
-33
lines changed

2 files changed

+43
-33
lines changed

scripts/rmc-regression.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ check-cbmc-viewer-version.py --major 2 --minor 5
2020
# Formatting check
2121
./x.py fmt --check
2222

23-
# Standalone rmc tests, expected tests, and cargo tests
23+
# Build RMC and RMC library
2424
./x.py build -i --stage 1 library/std ${EXTRA_X_PY_BUILD_ARGS}
25+
./scripts/setup/build_rmc_lib.sh
26+
27+
# Standalone rmc tests, expected tests, and cargo tests
2528
./x.py test -i --stage 1 rmc firecracker prusti smack expected cargo-rmc
2629
./x.py test -i --stage 0 compiler/cbmc
2730

scripts/rmc-rustc

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,59 @@ set -eu
1212
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1313
REPO_DIR="$(dirname $SCRIPT_DIR)"
1414

15-
get_rmc_path() {
16-
shopt -s nullglob
17-
RMC_CANDIDATES=("$REPO_DIR"/build/*/stage1/bin/rustc)
15+
RMC_PATH=${RMC_PATH:-""}
16+
RMC_LIB_PATH=${RMC_LIB_PATH:-""}
1817

19-
if [[ ${#RMC_CANDIDATES[@]} -ne 1 ]]; then
20-
echo "ERROR: Could not find RMC binary."
21-
echo "Looked for: $REPO_DIR/build/*/stage1/bin/rustc"
22-
echo "Was RMC successfully built first?"
23-
exit 1
18+
shopt -s nullglob
19+
set_rmc_path() {
20+
local RMC_CANDIDATES=("$REPO_DIR"/build/*/stage1/bin/rustc)
21+
22+
if [ -z "${RMC_PATH}" ]
23+
then
24+
if [[ -z ${RMC_CANDIDATES:-""} ]] || [[ ${#RMC_CANDIDATES[@]} -ne 1 ]]
25+
then
26+
echo "ERROR: Could not find RMC binary."
27+
echo "Looked for: $REPO_DIR/build/*/stage1/bin/rustc"
28+
echo "Was RMC successfully built first?"
29+
exit 1
30+
fi
31+
RMC_PATH=${RMC_CANDIDATES[0]}
2432
fi
25-
echo ${RMC_CANDIDATES[0]}
2633
}
2734

28-
get_rmc_lib_path() {
29-
if [ -z "${RMC_LIB_PATH:-""}" ]
35+
set_rmc_lib_path() {
36+
if [ -z "${RMC_LIB_PATH}" ]
3037
then
31-
RMC_LIB_CANDIDATES=("$REPO_DIR"/target/*/librmc.rlib)
32-
if [[ ${#RMC_LIB_CANDIDATES[@]} -ne 1 ]]; then
38+
local RMC_LIB_CANDIDATES=("$REPO_DIR"/target/*/librmc.rlib)
39+
if [[ -z ${RMC_LIB_CANDIDATES:-""} ]] || [[ ${#RMC_LIB_CANDIDATES[@]} -ne 1 ]]
40+
then
3341
echo "ERROR: Could not find RMC library."
3442
echo "Looked for: \"$REPO_DIR/target/*/librmc.rlib\""
3543
echo "Was RMC library successfully built first?"
3644
exit 1
3745
fi
38-
echo $(dirname ${RMC_LIB_CANDIDATES[0]})
39-
else
40-
echo ${RMC_LIB_PATH}
46+
RMC_LIB_PATH=$(dirname ${RMC_LIB_CANDIDATES[0]})
4147
fi
4248
}
4349

44-
RMC_PATH=$(get_rmc_path)
45-
46-
RMC_FLAGS="--crate-type=lib \
47-
-Z codegen-backend=gotoc \
48-
-Z trim-diagnostic-paths=no \
49-
-Z human_readable_cgu_names \
50-
--cfg=rmc \
51-
-L $(get_rmc_lib_path) \
52-
--extern rmc"
53-
54-
if [ "${1:-''}" == "--rmc-flags" ]
55-
then
56-
echo ${RMC_FLAGS}
57-
elif [ "${1:-''}" == "--rmc-path" ]
50+
set_rmc_path
51+
if [ "${1:-''}" == "--rmc-path" ]
5852
then
5953
echo ${RMC_PATH}
6054
else
61-
# Execute rmc
62-
"${RMC_PATH}" ${RMC_FLAGS} "$@"
55+
set_rmc_lib_path
56+
RMC_FLAGS="--crate-type=lib \
57+
-Z codegen-backend=gotoc \
58+
-Z trim-diagnostic-paths=no \
59+
-Z human_readable_cgu_names \
60+
--cfg=rmc \
61+
-L ${RMC_LIB_PATH} \
62+
--extern rmc"
63+
if [ "${1:-''}" == "--rmc-flags" ]
64+
then
65+
echo ${RMC_FLAGS}
66+
else
67+
# Execute rmc
68+
"${RMC_PATH}" ${RMC_FLAGS} "$@"
69+
fi
6370
fi

0 commit comments

Comments
 (0)