Skip to content

Commit bec5fd1

Browse files
authored
Update CBMC build instructions for Amazon Linux 2 (#3431)
The default compiler on Amazon Linux 2 is GCC 7, which is not sufficiently recent for building CBMC v6+. Install and use GCC 10, adjust warnings to cope with the flex version provided by Amazon Linux 2, and handle the non-default std::filesystem support. Furthermore, apply a workaround until diffblue/cbmc#8357 has been fixed on the CBMC side. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.
1 parent 7a6f1a4 commit bec5fd1

File tree

2 files changed

+77
-3
lines changed

2 files changed

+77
-3
lines changed

scripts/setup/al2/install_cbmc.sh

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,83 @@ git clone \
2121

2222
pushd "${WORK_DIR}"
2323

24-
mkdir build
25-
git submodule update --init
24+
# apply workaround for https://github.com/diffblue/cbmc/issues/8357 until it is
25+
# properly fixed in CBMC
26+
cat > varargs.patch << "EOF"
27+
--- a/src/ansi-c/library/stdio.c
28+
+++ b/src/ansi-c/library/stdio.c
29+
@@ -1135,7 +1135,7 @@ int vfscanf(FILE *restrict stream, const char *restrict format, va_list arg)
2630
27-
cmake3 -S . -Bbuild -DWITH_JBMC=OFF -Dsat_impl="minisat2;cadical"
31+
(void)*format;
32+
while((__CPROVER_size_t)__CPROVER_POINTER_OFFSET(*(void **)&arg) <
33+
- __CPROVER_OBJECT_SIZE(arg))
34+
+ __CPROVER_OBJECT_SIZE(*(void **)&arg))
35+
{
36+
void *a = va_arg(arg, void *);
37+
__CPROVER_havoc_object(a);
38+
@@ -1233,7 +1233,7 @@ int __stdio_common_vfscanf(
39+
40+
(void)*format;
41+
while((__CPROVER_size_t)__CPROVER_POINTER_OFFSET(*(void **)&args) <
42+
- __CPROVER_OBJECT_SIZE(args))
43+
+ __CPROVER_OBJECT_SIZE(*(void **)&args))
44+
{
45+
void *a = va_arg(args, void *);
46+
__CPROVER_havoc_object(a);
47+
@@ -1312,7 +1312,7 @@ __CPROVER_HIDE:;
48+
(void)*s;
49+
(void)*format;
50+
while((__CPROVER_size_t)__CPROVER_POINTER_OFFSET(*(void **)&arg) <
51+
- __CPROVER_OBJECT_SIZE(arg))
52+
+ __CPROVER_OBJECT_SIZE(*(void **)&arg))
53+
{
54+
void *a = va_arg(arg, void *);
55+
__CPROVER_havoc_object(a);
56+
@@ -1388,7 +1388,7 @@ int __stdio_common_vsscanf(
57+
(void)*s;
58+
(void)*format;
59+
while((__CPROVER_size_t)__CPROVER_POINTER_OFFSET(*(void **)&args) <
60+
- __CPROVER_OBJECT_SIZE(args))
61+
+ __CPROVER_OBJECT_SIZE(*(void **)&args))
62+
{
63+
void *a = va_arg(args, void *);
64+
__CPROVER_havoc_object(a);
65+
@@ -1774,12 +1774,12 @@ int vsnprintf(char *str, size_t size, const char *fmt, va_list ap)
66+
(void)*fmt;
67+
68+
while((__CPROVER_size_t)__CPROVER_POINTER_OFFSET(*(void **)&ap) <
69+
- __CPROVER_OBJECT_SIZE(ap))
70+
+ __CPROVER_OBJECT_SIZE(*(void **)&ap))
71+
72+
{
73+
(void)va_arg(ap, int);
74+
__CPROVER_precondition(
75+
- __CPROVER_POINTER_OBJECT(str) != __CPROVER_POINTER_OBJECT(ap),
76+
+ __CPROVER_POINTER_OBJECT(str) != __CPROVER_POINTER_OBJECT(*(void **)&ap),
77+
"vsnprintf object overlap");
78+
}
79+
80+
@@ -1822,12 +1822,12 @@ int __builtin___vsnprintf_chk(
81+
(void)*fmt;
82+
83+
while((__CPROVER_size_t)__CPROVER_POINTER_OFFSET(*(void **)&ap) <
84+
- __CPROVER_OBJECT_SIZE(ap))
85+
+ __CPROVER_OBJECT_SIZE(*(void **)&ap))
86+
87+
{
88+
(void)va_arg(ap, int);
89+
__CPROVER_precondition(
90+
- __CPROVER_POINTER_OBJECT(str) != __CPROVER_POINTER_OBJECT(ap),
91+
+ __CPROVER_POINTER_OBJECT(str) != __CPROVER_POINTER_OBJECT(*(void **)&ap),
92+
"vsnprintf object overlap");
93+
}
94+
95+
EOF
96+
97+
cmake3 -S . -Bbuild -DWITH_JBMC=OFF -Dsat_impl="minisat2;cadical" \
98+
-DCMAKE_C_COMPILER=gcc10-cc -DCMAKE_CXX_COMPILER=gcc10-c++ \
99+
-DCMAKE_CXX_STANDARD_LIBRARIES=-lstdc++fs \
100+
-DCMAKE_CXX_FLAGS=-Wno-error=register
28101
cmake3 --build build -- -j$(nproc)
29102
sudo make -C build install
30103

scripts/setup/al2/install_deps.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set -eu
1111
DEPS=(
1212
cmake
1313
cmake3
14+
gcc10-c++
1415
git
1516
openssl-devel
1617
python3-pip

0 commit comments

Comments
 (0)