Skip to content

Commit d09ca22

Browse files
committed
Merge branch 'master' into 2114-coverage-version-bump
This brings in the recent CI changes and particularly #2118.
2 parents 69394af + 2684385 commit d09ca22

File tree

20 files changed

+388
-40
lines changed

20 files changed

+388
-40
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,21 @@ jobs:
187187
prover_tests
188188
dest: dist-tests
189189

190-
- uses: actions/upload-artifact@v2
191-
if: "matrix.ghc == '9.4.8'"
190+
# In the next 2 steps, we upload to different names depending on whether
191+
# the binaries were compiled using HPC or not. This is done to ensure that
192+
# the HPC-enabled binaries do not clobber the non-HPC-enabled binaries.
193+
- uses: actions/upload-artifact@v4
194+
if: matrix.ghc == '9.4.8' && matrix.hpc == false
192195
with:
193196
path: dist-tests
194197
name: dist-tests-${{ matrix.os }}
195198

199+
- uses: actions/upload-artifact@v4
200+
if: matrix.ghc == '9.4.8' && matrix.hpc == true
201+
with:
202+
path: dist-tests
203+
name: dist-tests-${{ matrix.os }}-hpc
204+
196205
- shell: bash
197206
run: .github/ci.sh setup_dist_bins
198207

@@ -238,23 +247,23 @@ jobs:
238247
# distribution version matches the HPC version, the HPC build artifacts do
239248
# not clobber the non-HPC distribution artifacts.
240249
- if: matrix.ghc == '9.4.8' && matrix.hpc == false
241-
uses: actions/upload-artifact@v2
250+
uses: actions/upload-artifact@v4
242251
with:
243252
name: ${{ steps.config.outputs.name }} (GHC ${{ matrix.ghc }})
244253
path: "${{ steps.config.outputs.name }}.tar.gz*"
245254
if-no-files-found: error
246255
retention-days: ${{ needs.config.outputs.retention-days }}
247256

248257
- if: matrix.ghc == '9.4.8' && matrix.hpc == false
249-
uses: actions/upload-artifact@v2
258+
uses: actions/upload-artifact@v4
250259
with:
251260
name: ${{ steps.config.outputs.name }}-with-solvers (GHC ${{ matrix.ghc }})
252261
path: "${{ steps.config.outputs.name }}-with-solvers.tar.gz*"
253262
if-no-files-found: error
254263
retention-days: ${{ needs.config.outputs.retention-days }}
255264

256265
- if: matrix.ghc == '9.4.8' && matrix.run-tests && matrix.hpc == false
257-
uses: actions/upload-artifact@v2
266+
uses: actions/upload-artifact@v4
258267
with:
259268
path: dist/bin
260269
name: ${{ matrix.os }}-bins
@@ -264,7 +273,7 @@ jobs:
264273
run: .github/ci.sh collect_hpc_files
265274

266275
- if: matrix.hpc == true
267-
uses: actions/upload-artifact@v2
276+
uses: actions/upload-artifact@v4
268277
with:
269278
path: hpc.tar.gz
270279
name: ${{ matrix.os }}-hpc.tar.gz
@@ -296,7 +305,7 @@ jobs:
296305
BUILD_TARGET_OS: ${{ matrix.os }}
297306
BUILD_TARGET_ARCH: ${{ runner.arch }}
298307

299-
- uses: actions/download-artifact@v2
308+
- uses: actions/download-artifact@v4
300309
with:
301310
name: "${{ matrix.os }}-bins"
302311
path: dist/bin
@@ -331,7 +340,7 @@ jobs:
331340
BUILD_TARGET_OS: ${{ matrix.os }}
332341
BUILD_TARGET_ARCH: ${{ runner.arch }}
333342

334-
- uses: actions/download-artifact@v2
343+
- uses: actions/download-artifact@v4
335344
with:
336345
name: "${{ matrix.os }}-bins"
337346
path: dist/bin
@@ -398,7 +407,7 @@ jobs:
398407
BUILD_TARGET_OS: ${{ matrix.os }}
399408
BUILD_TARGET_ARCH: ${{ runner.arch }}
400409

401-
- uses: actions/download-artifact@v2
410+
- uses: actions/download-artifact@v4
402411
with:
403412
name: "${{ matrix.os }}-bins"
404413
path: dist/bin
@@ -461,7 +470,7 @@ jobs:
461470
BUILD_TARGET_OS: ${{ matrix.os }}
462471
BUILD_TARGET_ARCH: ${{ runner.arch }}
463472

464-
- uses: actions/download-artifact@v2
473+
- uses: actions/download-artifact@v4
465474
with:
466475
name: "${{ matrix.os }}-bins"
467476
path: dist/bin
@@ -474,7 +483,7 @@ jobs:
474483
if: runner.os != 'Windows'
475484
run: chmod +x bin/*
476485

477-
- uses: actions/download-artifact@v2
486+
- uses: actions/download-artifact@v4
478487
with:
479488
name: dist-tests-${{ matrix.os }}
480489
path: dist-tests
@@ -554,12 +563,12 @@ jobs:
554563
BUILD_TARGET_OS: ${{ matrix.os }}
555564
BUILD_TARGET_ARCH: ${{ runner.arch }}
556565

557-
- uses: actions/download-artifact@v2
566+
- uses: actions/download-artifact@v4
558567
with:
559-
name: dist-tests-${{ matrix.os }}
568+
name: dist-tests-${{ matrix.os }}-hpc
560569
path: dist-tests
561570

562-
- uses: actions/download-artifact@v2
571+
- uses: actions/download-artifact@v4
563572
with:
564573
name: "${{ matrix.os }}-hpc.tar.gz"
565574

@@ -609,7 +618,7 @@ jobs:
609618
run: |
610619
./compute-coverage.sh
611620
612-
- uses: actions/upload-artifact@v2
621+
- uses: actions/upload-artifact@v4
613622
with:
614623
path: hpc-html
615624
name: coverage-html-${{ github.event.number }}
@@ -755,7 +764,7 @@ jobs:
755764
mkdir -p s2nTests/bin
756765
757766
- name: Download previously-built SAW
758-
uses: actions/download-artifact@v2
767+
uses: actions/download-artifact@v4
759768
with:
760769
name: "${{ matrix.os }}-bins"
761770
path: ./s2nTests/bin
@@ -809,7 +818,7 @@ jobs:
809818
mkdir -p exercises/bin
810819
811820
- name: Download previously-built SAW
812-
uses: actions/download-artifact@v2
821+
uses: actions/download-artifact@v4
813822
with:
814823
name: "${{ matrix.os }}-bins"
815824
path: ./exercises/bin

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@
4949
[submodule "deps/lmdb"]
5050
path = deps/lmdb
5151
url = https://github.com/GaloisInc/lmdb.git
52+
[submodule "deps/mir-json"]
53+
path = deps/mir-json
54+
url = https://github.com/GaloisInc/mir-json.git

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# next -- TBA
2+
3+
## Bug fixes
4+
5+
* Counterexamples including SMT arrays are now printed with the array
6+
contents instead of placeholder text.
7+
18
# Version 1.2 -- 2024-08-30
29

310
## New Features

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,26 @@ will be possible for all language constructs. There are various
8888
instructions that are not supported during verification. However,
8989
any failure during `llvm_load_module` should be considered a bug.
9090

91+
## Notes on Rust
92+
93+
SAW has experimental support for analyzing Rust programs. To do so, one must
94+
compile Rust code using [`mir-json`](https://github.com/GaloisInc/mir-json), a
95+
tool which compiles Rust code to a machine-readable, JSON-based format.
96+
Note that:
97+
98+
* Each version of SAW understands the JSON output of a particular version of
99+
`mir-json`, so make sure that you build the version `mir-json` that is
100+
included in the `mir-json` submodule (located in `deps/mir-json`).
101+
* Moreover, SAW requires slightly modified versions of the Rust standard
102+
libraries that are suited to verification purposes. SAW consults the value
103+
of the `SAW_RUST_LIBRARY_PATH` environment variable to determine where to
104+
look for these modified standard libraries.
105+
106+
For complete instructions on how to install `mir-json`, the modified Rust
107+
standard libraries, and how to defined the `SAW_RUST_LIBRARY_PATH` environment
108+
variable, follow the instructions
109+
[here](https://github.com/GaloisInc/mir-json#installation-instructions).
110+
91111
## Notes on Windows
92112

93113
If you have trouble loading the SAW REPL on Windows, try invoking it

deps/mir-json

Submodule mir-json added at 131980a

doc/manual/manual.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1812,15 +1812,62 @@ In order to verify Rust code, SAW analyzes Rust's MIR (mid-level intermediate
18121812
representation) language. In particular, SAW analyzes a particular form of MIR
18131813
that the [`mir-json`](https://github.com/GaloisInc/mir-json) tool produces. You
18141814
will need to intall `mir-json` and run it on Rust code in order to produce MIR
1815-
JSON files that SAW can load (see [this section](#loading-mir)).
1815+
JSON files that SAW can load (see [this section](#loading-mir)). You will also
1816+
need to use `mir-json` to build custom versions of the Rust standard libraries
1817+
that are more suited to verification purposes.
1818+
1819+
If you are working from a checkout of the `saw-script` repo, you can install
1820+
the `mir-json` tool and the custom Rust standard libraries by performing the
1821+
following steps:
1822+
1823+
1. Clone the [`crucible`](https://github.com/GaloisInc/crucible) and `mir-json`
1824+
submodules like so:
1825+
1826+
```
1827+
$ git submodule update deps/crucible deps/mir-json
1828+
```
1829+
1830+
2. Navigate to the `mir-json` submodule:
1831+
1832+
```
1833+
$ cd deps/mir-json
1834+
```
1835+
1836+
3. Follow the instructions laid out in the [`mir-json` installation
1837+
instructions](https://github.com/GaloisInc/mir-json#installation-instructions)
1838+
in order to install `mir-json`.
1839+
1840+
4. Navigate to the
1841+
[`crux-mir`](https://github.com/GaloisInc/crucible/tree/master/crux-mir)
1842+
subdirectory of the `crucible` submodule:
1843+
1844+
```
1845+
$ cd ../crucible/crux-mir/
1846+
```
1847+
1848+
5. Run the `translate_libs.sh` script:
1849+
1850+
```
1851+
$ ./translate_libs.sh
1852+
```
1853+
1854+
This will compile the custom versions of the Rust standard libraries using
1855+
`mir-json`, placing the results under the `rlibs` subdirectory.
1856+
1857+
6. Finally, define a `SAW_RUST_LIBRARY_PATH` environment variable that points
1858+
to the newly created `rlibs` subdirectory:
1859+
1860+
```
1861+
$ export SAW_RUST_LIBRARY_PATH=<...>/crucible/crux-mir/rlibs
1862+
```
18161863

18171864
For `cargo`-based projects, `mir-json` provides a `cargo` subcommand called
18181865
`cargo saw-build` that builds a JSON file suitable for use with SAW. `cargo
18191866
saw-build` integrates directly with `cargo`, so you can pass flags to it like
18201867
any other `cargo` subcommand. For example:
18211868

18221869
```
1823-
$ export SAW_RUST_LIBRARY_PATH=<...>
1870+
# Make sure that SAW_RUST_LIBRARY_PATH is defined, as described above
18241871
$ cargo saw-build <other cargo flags>
18251872
<snip>
18261873
linking 11 mir files into <...>/example-364cf2df365c7055.linked-mir.json
@@ -1840,7 +1887,7 @@ Note that:
18401887
`rustc` accepts. For example:
18411888

18421889
```
1843-
$ export SAW_RUST_LIBRARY_PATH=<...>
1890+
# Make sure that SAW_RUST_LIBRARY_PATH is defined, as described above
18441891
$ saw-rustc example.rs <other rustc flags>
18451892
<snip>
18461893
linking 11 mir files into <...>/example.linked-mir.json

doc/manual/manual.pdf

1.83 KB
Binary file not shown.

intTests/test2049/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.rawlog
2+
*.log
3+
*.diff

intTests/test2049/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# The current checked-in test.bc was generated by:
2+
# Apple clang version 15.0.0 (clang-1500.1.0.2.5)
3+
# Target: arm64-apple-darwin22.6.0
4+
# Thread model: posix
5+
# InstalledDir: /Library/Developer/CommandLineTools/usr/bin
6+
# but neither the target nor the clang/llvm version is expected to be
7+
# significant.
8+
CC = clang
9+
CFLAGS = -g -O0
10+
11+
all: test.bc
12+
13+
test.bc: test.c
14+
$(CC) $(CFLAGS) -c -emit-llvm $< -o $@
15+
16+
.PHONY: clean
17+
clean:
18+
rm -f test.bc

intTests/test2049/Test.cry

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import Array
2+
type Table = Array [8] [8]

intTests/test2049/test.bc

3.44 KB
Binary file not shown.

intTests/test2049/test.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <stdint.h>
2+
3+
static uint8_t table[256];
4+
5+
void assign(uint8_t k, uint8_t v) {
6+
table[k] = v;
7+
}
8+
9+
void zero(uint8_t k) {
10+
assign(k, 0);
11+
}
12+

intTests/test2049/test.log.1.good

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Loading file "test.saw"
2+
Assume override assign
3+
Verifying zero ...
4+
Simulating zero ...
5+
Registering overrides for `assign`
6+
variant `Symbol "assign"`
7+
Matching 1 overrides of assign ...
8+
Branching on 1 override variants of assign ...
9+
Applied override! assign
10+
Checking proof obligations zero ...
11+
Subgoal failed: zero test.saw:60:1: error: in ghost_value
12+
Literal equality postcondition
13+
14+
SolverStats {solverStatsSolvers = fromList ["W4 ->z3"], solverStatsGoalSize = 334}
15+
----------Counterexample----------
16+
zero::table: [1 := 1, <default> := 0]
17+
zero::k: 1
18+
----------------------------------
19+
Stack trace:
20+
"llvm_verify" (test.saw:60:1-60:12)
21+
Proof failed.
22+
23+
FAILED

intTests/test2049/test.log.2.good

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Loading file "test.saw"
2+
Assume override assign
3+
Verifying zero ...
4+
Simulating zero ...
5+
Registering overrides for `assign`
6+
variant `Symbol "assign"`
7+
Matching 1 overrides of assign ...
8+
Branching on 1 override variants of assign ...
9+
Applied override! assign
10+
Checking proof obligations zero ...
11+
Subgoal failed: zero test.saw:60:1: error: in ghost_value
12+
Literal equality postcondition
13+
14+
SolverStats {solverStatsSolvers = fromList ["W4 ->z3"], solverStatsGoalSize = 334}
15+
----------Counterexample----------
16+
zero::table: [0 := 0, <default> := 1]
17+
zero::k: 1
18+
----------------------------------
19+
Stack trace:
20+
"llvm_verify" (test.saw:60:1-60:12)
21+
Proof failed.
22+
23+
FAILED

0 commit comments

Comments
 (0)