Skip to content

Commit 08f269c

Browse files
authored
Merge pull request #1388 from smowton/merge-develop-20170914
Merge develop 20170914
2 parents f25db0a + e3f3abd commit 08f269c

File tree

353 files changed

+4492
-40367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

353 files changed

+4492
-40367
lines changed

.travis.yml

+36-29
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,6 @@ jobs:
3939
# env: COMPILER=g++-5 SAN_FLAGS="-fsanitize=undefined -fno-sanitize-recover -fno-omit-frame-pointer"
4040
env: COMPILER="ccache g++-5"
4141

42-
# Alpine Linux with musl-libc using g++
43-
- stage: Test different OS/CXX/Flags
44-
os: linux
45-
sudo: required
46-
compiler: gcc
47-
cache: ccache
48-
services:
49-
- docker
50-
before_install:
51-
- docker pull diffblue/cbmc-builder:alpine-0.0.3
52-
env:
53-
- PRE_COMMAND="docker run -v ${TRAVIS_BUILD_DIR}:/cbmc -v ${HOME}/.ccache:/root/.ccache diffblue/cbmc-builder:alpine-0.0.3"
54-
- COMPILER="ccache g++"
55-
5642
# OS X using g++
5743
- stage: Test different OS/CXX/Flags
5844
os: osx
@@ -151,29 +137,50 @@ jobs:
151137
- EXTRA_CXXFLAGS="-DDEBUG"
152138
script: echo "Not running any tests for a debug build."
153139

140+
- stage: Test different OS/CXX/Flags
141+
os: linux
142+
cache: ccache
143+
env:
144+
- BUILD_SYSTEM=cmake
145+
addons:
146+
apt:
147+
sources:
148+
- ubuntu-toolchain-r-test
149+
packages:
150+
- g++-5
151+
install:
152+
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_CXX_COMPILER=g++-5'
153+
- cmake --build build -- -j4
154+
script: (cd build; ctest -V -L CORE)
155+
156+
- stage: Test different OS/CXX/Flags
157+
os: osx
158+
cache: ccache
159+
env:
160+
- BUILD_SYSTEM=cmake
161+
- CCACHE_CPP2=yes
162+
install:
163+
- cmake -H. -Bbuild '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_OSX_ARCHITECTURES=x86_64'
164+
- cmake --build build -- -j4
165+
script: (cd build; ctest -V -L CORE)
166+
167+
154168
allow_failures:
155169
- <<: *linter-stage
156170

157171
install:
158172
- ccache --max-size=1G
159-
- COMMAND="make -C src minisat2-download" &&
160-
eval ${PRE_COMMAND} ${COMMAND}
161-
- COMMAND="make -C src boost-download" &&
162-
eval ${PRE_COMMAND} ${COMMAND}
163-
- COMMAND="make -C src/ansi-c library_check" &&
164-
eval ${PRE_COMMAND} ${COMMAND}
165-
- COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -Werror -pedantic -O2 -g -DUSE_BOOST $EXTRA_CXXFLAGS\" -j2" &&
166-
eval ${PRE_COMMAND} ${COMMAND}
167-
- COMMAND="make -C src CXX=\"$COMPILER\" CXXFLAGS=\"$FLAGS $EXTRA_CXXFLAGS\" -j2 clobber.dir memory-models.dir musketeer.dir" &&
168-
eval ${PRE_COMMAND} ${COMMAND}
173+
- make -C src minisat2-download
174+
- make -C src boost-download
175+
- make -C src/ansi-c library_check
176+
- make -C src "CXX=${COMPILER}" "CXXFLAGS=-Wall -Werror -pedantic -O2 -g -DUSE_BOOST ${EXTRA_CXXFLAGS}" -j2
177+
- make -C src "CXX=${COMPILER}" "CXXFLAGS=-Wall -Werror -pedantic -O2 -g ${EXTRA_CXXFLAGS}" -j2 clobber.dir memory-models.dir
169178

170179
script:
171180
- if [ -e bin/gcc ] ; then export PATH=$PWD/bin:$PATH ; fi ;
172-
COMMAND="env UBSAN_OPTIONS=print_stacktrace=1 make -C regression test CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -Werror -pedantic -O2 -g $EXTRA_CXXFLAGS\"" &&
173-
eval ${PRE_COMMAND} ${COMMAND}
174-
- COMMAND="make -C unit CXX=\"$COMPILER\" CXXFLAGS=\"-Wall -Werror -pedantic -O2 -g $EXTRA_CXXFLAGS\" -j2" &&
175-
eval ${PRE_COMMAND} ${COMMAND}
176-
- COMMAND="make -C unit test" && eval ${PRE_COMMAND} ${COMMAND}
181+
- env UBSAN_OPTIONS=print_stacktrace=1 make -C regression test "CXX=${COMPILER}" "CXXFLAGS=-Wall -Werror -pedantic -O2 -g ${EXTRA_CXXFLAGS}"
182+
- make -C unit "CXX=${COMPILER}" "CXXFLAGS=-Wall -Werror -pedantic -O2 -g ${EXTRA_CXXFLAGS}" -j2
183+
- make -C unit test
177184

178185
before_cache:
179186
- ccache -s

CMakeLists.txt

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
cmake_minimum_required(VERSION 3.2)
2+
3+
find_program(CCACHE_PROGRAM ccache)
4+
if(CCACHE_PROGRAM)
5+
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
6+
message(STATUS "Rule launch compile: ${CCACHE_PROGRAM}")
7+
endif()
8+
9+
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
10+
11+
include(GNUInstallDirs)
12+
13+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
14+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
15+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
16+
17+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
18+
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"
19+
)
20+
# Ensure NDEBUG is not set for release builds
21+
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
22+
# Enable lots of warnings
23+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wpedantic -Werror")
24+
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
25+
# This would be the place to enable warnings for Windows builds, although
26+
# config.inc doesn't seem to do that currently
27+
endif()
28+
29+
set(enable_cbmc_tests on CACHE BOOL "Whether CBMC tests should be enabled")
30+
31+
set(sat_impl "minisat2" CACHE STRING
32+
"This setting controls the SAT library which is used. Valid values are 'minisat2' and 'glucose'"
33+
)
34+
35+
add_subdirectory(src)
36+
37+
if(${enable_cbmc_tests})
38+
enable_testing()
39+
endif()
40+
add_subdirectory(unit)
41+
add_subdirectory(regression)

COMPILING

+48-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ Follow these instructions:
171171
BUILD_ENV = MSVC
172172

173173
Open the Visual Studio Command prompt, and then bash.exe -login from
174-
Cygwin from in there.
174+
Cygwin from in there.
175175

176176
3) Type cd src; make - that should do it.
177177

@@ -183,6 +183,53 @@ can be used for building with MSBuild. Note that you still need to run
183183
flex/bison using "make generated_files" before opening the project.
184184

185185

186+
WORKING WITH CMAKE (EXPERIMENTAL)
187+
---------------------------------
188+
189+
There is an experimental build based on CMake instead of hand-written
190+
makefiles. It should work on a wider variety of systems than the standard
191+
makefile build, and can integrate better with IDEs and static-analysis tools.
192+
193+
0) Run `cmake --version`. If you get a command-not-found error, or the installed
194+
version is lower than 3.2, go and install a new version. Most Linux
195+
distributions have a package for CMake, and Mac users can get it through
196+
Homebrew. Windows users should download it manually from cmake.org.
197+
198+
1) Create a directory to store your build:
199+
`mkdir build`
200+
Run this from the *top level* folder of the project. This is different from
201+
the other builds, which require you to `cd src` first.
202+
203+
2) Generate build files with CMake:
204+
`cmake -H. -Bbuild`
205+
This command tells CMake to use the configuration in the current directory,
206+
and to generate build files into the `build` directory.
207+
This is the point to specify custom build settings, such as compilers and
208+
build back-ends. You can use clang (for example) by adding the argument
209+
`-DCMAKE_CXX_COMPILER=clang++` to the command line. You can also tell
210+
CMake to generate IDE projects by supplying the `-G` flag.
211+
Run `cmake -G` for a comprehensive list of supported back-ends.
212+
213+
Generally it is not necessary to manually specify individual compiler or
214+
linker flags, as CMake defines a number of "build modes" including Debug
215+
and Release modes. To build in a particular mode, add the flag
216+
`-DCMAKE_BUILD_TYPE=Debug` (or `Release`) to the initial invocation.
217+
218+
If you *do* need to manually add flags, use `-DCMAKE_CXX_FLAGS=...` and
219+
`-DCMAKE_EXE_LINKER_FLAGS=...`. This is useful for enabling clang's
220+
sanitizers.
221+
222+
Finally, to enable building universal binaries on macOS, you can pass the
223+
flag `-DCMAKE_OSX_ARCHITECTURES=i386;x86_64`. If you don't supply this flag,
224+
the build will just be for the architecture of your machine.
225+
226+
3) Run the build:
227+
`cmake --build build`
228+
This command tells CMake to invoke the correct tool to run the build in the
229+
`build` directory. You can also use the build back-end directly by invoking
230+
`make`, `ninja`, or opening the generated IDE project as appropriate.
231+
232+
186233
WORKING WITH ECLIPSE
187234
--------------------
188235

appveyor.yml

+19-12
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,21 @@ build_script:
6060
test_script:
6161
- cmd: |
6262
cd regression
63-
sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" ansi-c/Makefile
64-
sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" cpp/Makefile
65-
sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-instrument/chain.sh
66-
sed -i "15s/.*/$goto_cc $name.c/" goto-instrument/chain.sh
67-
sed -i "16i mv $name.exe $name.gb" goto-instrument/chain.sh
68-
sed -i "23s/.*/ $goto_cc ${name}-mod.c/" goto-instrument/chain.sh
69-
sed -i "24i mv ${name}-mod.exe $name-mod.gb" goto-instrument/chain.sh
70-
cat goto-instrument/chain.sh
7163
72-
sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-instrument-typedef/chain.sh || true
73-
sed -i "12s/.*/$GC $NAME.c --function fun/" goto-instrument-typedef/chain.sh || true
74-
sed -i "13i mv $NAME.exe $NAME.gb" goto-instrument-typedef/chain.sh || true
75-
cat goto-instrument-typedef/chain.sh || true
64+
sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-cc-cbmc/chain.sh || true
65+
sed -i "11s/.*/$GC $NAME.c/" goto-cc-cbmc/chain.sh || true
66+
sed -i "12i mv $NAME.exe $NAME.gb" goto-cc-cbmc/chain.sh || true
67+
cat goto-cc-cbmc/chain.sh || true
68+
69+
sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-cc-goto-analyzer/chain.sh || true
70+
sed -i "11s/.*/$gc $name.c/" goto-cc-goto-analyzer/chain.sh || true
71+
sed -i "12i mv $name.exe $name.gb" goto-cc-goto-analyzer/chain.sh || true
72+
cat goto-cc-goto-analyzer/chain.sh || true
73+
74+
sed -i "s/goto-cc\/goto-cc/goto-cc\/goto-cl/" goto-cc-symex/chain.sh || true
75+
sed -i "11s/.*/$gc $name.c/" goto-cc-symex/chain.sh || true
76+
sed -i "12i mv $name.exe $name.gb" goto-cc-symex/chain.sh || true
77+
cat goto-cc-symex/chain.sh || true
7678
7779
rem HACK disable failing tests
7880
rmdir /s /q ansi-c\arch_flags_mcpu_bad
@@ -111,6 +113,11 @@ test_script:
111113
rmdir /s /q cbmc-java\tableswitch2
112114
rmdir /s /q goto-gcc
113115
rmdir /s /q goto-instrument\slice08
116+
rmdir /s /q symex\va_args_10
117+
rmdir /s /q symex\va_args_2
118+
rmdir /s /q symex\va_args_3
119+
rmdir /s /q symex\va_args_5
120+
rmdir /s /q symex\va_args_6
114121
115122
make test
116123

regression/CMakeLists.txt

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
set(CMAKE_CXX_STANDARD 11)
2+
set(CMAKE_CXX_STANDARD_REQUIRED true)
3+
4+
set(test_pl_path "${CMAKE_CURRENT_SOURCE_DIR}/test.pl")
5+
6+
macro(add_test_pl_profile name cmdline flag profile)
7+
add_test(
8+
NAME "${name}-${profile}"
9+
COMMAND ${test_pl_path} -c ${cmdline} ${flag}
10+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
11+
)
12+
set_tests_properties("${name}-${profile}" PROPERTIES
13+
LABELS "${profile}"
14+
)
15+
endmacro(add_test_pl_profile)
16+
17+
macro(add_test_pl_tests name cmdline)
18+
add_test_pl_profile("${name}" "${cmdline}" -C CORE)
19+
add_test_pl_profile("${name}" "${cmdline}" -T THOROUGH)
20+
add_test_pl_profile("${name}" "${cmdline}" -F FUTURE)
21+
add_test_pl_profile("${name}" "${cmdline}" -K KNOWNBUG)
22+
endmacro(add_test_pl_tests)
23+
24+
add_subdirectory(ansi-c)
25+
add_subdirectory(cbmc)
26+
add_subdirectory(cbmc-java)
27+
add_subdirectory(cbmc-java-inheritance)
28+
add_subdirectory(cpp)
29+
add_subdirectory(goto-analyzer)
30+
add_subdirectory(goto-diff)
31+
add_subdirectory(goto-instrument)
32+
add_subdirectory(goto-instrument-typedef)
33+
add_subdirectory(invariants)
34+
add_subdirectory(strings)
35+
add_subdirectory(strings-smoke-tests)
36+
add_subdirectory(test-script)

regression/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ DIRS = ansi-c \
55
cbmc-java-inheritance \
66
cpp \
77
goto-analyzer \
8+
goto-cc-cbmc \
9+
goto-cc-goto-analyzer \
10+
goto-cc-goto-symex \
811
goto-diff \
912
goto-gcc \
1013
goto-instrument \
1114
goto-instrument-typedef \
1215
invariants \
1316
strings \
1417
strings-smoke-tests \
18+
symex \
1519
test-script \
1620
# Empty last line
1721

regression/ansi-c/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_test_pl_tests(
2+
"ansi-c"
3+
"$<TARGET_FILE:goto-cc>"
4+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
int main()
2+
{
3+
int A[(sizeof((int[]){1, 2, 3})==3*sizeof(int))?1:-1];
4+
5+
return 0;
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^CONVERSION ERROR$

regression/ansi-c/Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
default: tests.log
22

3+
include ../../src/config.inc
4+
include ../../src/common
5+
6+
ifeq ($(BUILD_ENV_),MSVC)
7+
exe=../../../src/goto-cc/goto-cl
8+
else
9+
exe=../../../src/goto-cc/goto-cc
10+
endif
11+
312
test:
4-
@if ! ../test.pl -c ../../../src/goto-cc/goto-cc ; then \
13+
@if ! ../test.pl -c $(exe) ; then \
514
../failed-tests-printer.pl ; \
615
exit 1 ; \
716
fi
817

918
tests.log: ../test.pl
10-
@if ! ../test.pl -c ../../../src/goto-cc/goto-cc ; then \
19+
@if ! ../test.pl -c $(exe) ; then \
1120
../failed-tests-printer.pl ; \
1221
exit 1 ; \
1322
fi
Binary file not shown.
34 Bytes
Binary file not shown.

regression/ansi-c/arch_flags_mcpu_good/test.desc

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ command line:
1414

1515
goto-cc --native-compiler=arm-none-eabi-gcc -mcpu=cortex-a15 -c source.c
1616

17+
On Ubuntu, you can get a suitable compiler using:
18+
19+
sudo apt install gcc-arm-none-eabi
20+
1721
preproc.i is already pre-processed so that it can be linked in without
1822
needing to invoke a pre-processor from a cross-compile toolchain on your
1923
local machine. Linking it together with the ARM object file, while
Binary file not shown.
Binary file not shown.

regression/ansi-c/arch_flags_mthumb_good/test.desc

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ line:
1414

1515
goto-cc --native-compiler=arm-none-eabi-gcc -mthumb -c source.c
1616

17+
On Ubuntu, you can get a suitable compiler using:
18+
19+
sudo apt install gcc-arm-none-eabi
20+
1721
preproc.i is already pre-processed so that it can be linked in without
1822
needing to invoke a pre-processor from a cross-compile toolchain on your
1923
local machine. Linking it together with the ARM object file, while
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#define STATIC_ASSERT_sizeof(condition) \
2+
int[(condition) ? 1 : -1]
3+
4+
int A[];
5+
int B[];
6+
7+
int A[1]={sizeof(A)};
8+
int B[1]={sizeof(STATIC_ASSERT_sizeof(sizeof(B)==sizeof(int)))};
9+
10+
int main()
11+
{
12+
return 0;
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

regression/ansi-c/sizeof5/main.c

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#define STATIC_ASSERT(condition) \
2+
int some_array##__LINE__[(condition) ? 1 : -1];
3+
4+
struct S
5+
{
6+
int x;
7+
};
8+
9+
int main()
10+
{
11+
struct S s;
12+
__typeof__(*((void *)&s.x)) *_s=&s.x;
13+
STATIC_ASSERT(sizeof(*_s)==1);
14+
return 0;
15+
}

0 commit comments

Comments
 (0)