Skip to content

Commit 705f44b

Browse files
nwetzlerNathan Wetzler
and
Nathan Wetzler
authored
Remove litani submodule and update CBMC starter kit to 2.5 (#3385)
Co-authored-by: Nathan Wetzler <[email protected]>
1 parent e990601 commit 705f44b

File tree

5 files changed

+95
-15
lines changed

5 files changed

+95
-15
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
[submodule "tests/cbmc/aws-verification-model-for-libcrypto"]
22
path = tests/cbmc/aws-verification-model-for-libcrypto
33
url = https://github.com/awslabs/aws-verification-model-for-libcrypto.git
4-
[submodule "tests/litani"]
5-
path = tests/litani
6-
url = https://github.com/awslabs/aws-build-accumulator

tests/cbmc/proofs/Makefile-template-defines

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
SRCDIR ?= $(abspath $(PROOF_ROOT)/../../..)
55

66

7-
# Absolute path to the litani script.
7+
# How to invoke litani.
8+
# Use "litani" when litani is present in PATH.
9+
# Use an absolute path when litani is included as a git submodule.
810
#
9-
LITANI ?= $(abspath $(PROOF_ROOT)/../../litani/litani)
11+
LITANI ?= litani
1012

1113

1214
# Name of this proof project, displayed in proof reports. For example,

tests/cbmc/proofs/Makefile.common

+85-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
55
# SPDX-License-Identifier: MIT-0
66

7-
CBMC_STARTER_KIT_VERSION = CBMC starter kit 2.4
7+
CBMC_STARTER_KIT_VERSION = CBMC starter kit 2.5
88

99
################################################################
1010
# The CBMC Starter Kit depends on the files Makefile.common and
@@ -309,6 +309,7 @@ NONDET_STATIC ?=
309309
# Flags to pass to goto-cc for compilation and linking
310310
COMPILE_FLAGS ?= -Wall
311311
LINK_FLAGS ?= -Wall
312+
EXPORT_FILE_LOCAL_SYMBOLS ?= --export-file-local-symbols
312313

313314
# Preprocessor include paths -I...
314315
INCLUDES ?=
@@ -439,6 +440,7 @@ CBMC ?= cbmc
439440
GOTO_ANALYZER ?= goto-analyzer
440441
GOTO_CC ?= goto-cc
441442
GOTO_INSTRUMENT ?= goto-instrument
443+
CRANGLER ?= crangler
442444
VIEWER ?= cbmc-viewer
443445
MAKE_SOURCE ?= make-source
444446
VIEWER2 ?= cbmc-viewer
@@ -484,14 +486,92 @@ endif
484486
CBMC_REMOVE_FUNCTION_BODY := $(patsubst %,--remove-function-body %, $(REMOVE_FUNCTION_BODY))
485487
CBMC_RESTRICT_FUNCTION_POINTER := $(patsubst %,--restrict-function-pointer %, $(RESTRICT_FUNCTION_POINTER))
486488

489+
################################################################
490+
# Targets for rewriting source files with crangler
491+
492+
# Construct crangler configuration files
493+
#
494+
# REWRITTEN_SOURCES is a list of crangler output files source.i.
495+
# This target assumes that for each source.i
496+
# * source.i_SOURCE is the path to a source file,
497+
# * source.i_FUNCTIONS is a list of functions (may be empty)
498+
# * source.i_OBJECTS is a list of variables (may be empty)
499+
# This target constructs the crangler configuration file source.i.json
500+
# of the form
501+
# {
502+
# "sources": [ "/proj/code.c" ],
503+
# "includes": [ "/proj/include" ],
504+
# "defines": [ "VAR=1" ],
505+
# "functions": [ {"function_name": ["remove static"]} ],
506+
# "objects": [ {"variable_name": ["remove static"]} ],
507+
# "output": "source.i"
508+
# }
509+
# to remove the static attribute from function_name and variable_name
510+
# in the source file source.c and write the result to source.i.
511+
#
512+
# This target assumes that filenames include no spaces and that
513+
# the INCLUDES and DEFINES variables include no spaces after -I
514+
# and -D. For example, use "-DVAR=1" and not "-D VAR=1".
515+
#
516+
# Define *_SOURCE, *_FUNCTIONS, and *_OBJECTS in the proof Makefile.
517+
# The string source.i is usually an absolute path $(PROOFDIR)/code.i
518+
# to a file in the proof directory that contains the proof Makefile.
519+
# The proof Makefile usually includes the definitions
520+
# $(PROOFDIR)/code.i_SOURCE = /proj/code.c
521+
# $(PROOFDIR)/code.i_FUNCTIONS = function_name
522+
# $(PROOFDIR)/code.i_OBJECTS = variable_name
523+
# Because these definitions refer to PROOFDIR that is defined in this
524+
# Makefile.common, these definitions must appear after the inclusion
525+
# of Makefile.common in the proof Makefile.
526+
#
527+
$(foreach rs,$(REWRITTEN_SOURCES),$(eval $(rs).json: $($(rs)_SOURCE)))
528+
$(foreach rs,$(REWRITTEN_SOURCES),$(rs).json):
529+
echo '{'\
530+
'"sources": ['\
531+
'"$($(@:.json=)_SOURCE)"'\
532+
'],'\
533+
'"includes": ['\
534+
'$(subst $(SPACE),$(COMMA),$(patsubst -I%,"%",$(strip $(INCLUDES))))' \
535+
'],'\
536+
'"defines": ['\
537+
'$(subst $(SPACE),$(COMMA),$(patsubst -D%,"%",$(subst ",\",$(strip $(DEFINES)))))' \
538+
'],'\
539+
'"functions": ['\
540+
'{'\
541+
'$(subst ~, ,$(subst $(SPACE),$(COMMA),$(patsubst %,"%":["remove~static"],$($(@:.json=)_FUNCTIONS))))' \
542+
'}'\
543+
'],'\
544+
'"objects": ['\
545+
'{'\
546+
'$(subst ~, ,$(subst $(SPACE),$(COMMA),$(patsubst %,"%":["remove~static"],$($(@:.json=)_OBJECTS))))' \
547+
'}'\
548+
'],'\
549+
'"output": "$(@:.json=)"'\
550+
'}' > $@
551+
552+
# Rewrite source files with crangler
553+
#
554+
$(foreach rs,$(REWRITTEN_SOURCES),$(eval $(rs): $(rs).json))
555+
$(REWRITTEN_SOURCES):
556+
$(LITANI) add-job \
557+
--command \
558+
'$(CRANGLER) [email protected]' \
559+
--inputs $($@_SOURCE) \
560+
--outputs $@ \
561+
--stdout-file $(LOGDIR)/crangler-$(subst /,_,$(subst .,_,$@))-log.txt \
562+
--interleave-stdout-stderr \
563+
--pipeline-name "$(PROOF_UID)" \
564+
--ci-stage build \
565+
--description "$(PROOF_UID): removing static"
566+
487567
################################################################
488568
# Build targets that make the relevant .goto files
489569

490570
# Compile project sources
491-
$(PROJECT_GOTO)1.goto: $(PROJECT_SOURCES)
571+
$(PROJECT_GOTO)1.goto: $(PROJECT_SOURCES) $(REWRITTEN_SOURCES)
492572
$(LITANI) add-job \
493573
--command \
494-
'$(GOTO_CC) $(CBMC_VERBOSITY) --export-file-local-symbols $(COMPILE_FLAGS) $(INCLUDES) $(DEFINES) $^ -o $@' \
574+
'$(GOTO_CC) $(CBMC_VERBOSITY) $(COMPILE_FLAGS) $(EXPORT_FILE_LOCAL_SYMBOLS) $(INCLUDES) $(DEFINES) $^ -o $@' \
495575
--inputs $^ \
496576
--outputs $@ \
497577
--stdout-file $(LOGDIR)/project_sources-log.txt \
@@ -503,7 +583,7 @@ $(PROJECT_GOTO)1.goto: $(PROJECT_SOURCES)
503583
$(PROOF_GOTO)1.goto: $(PROOF_SOURCES)
504584
$(LITANI) add-job \
505585
--command \
506-
'$(GOTO_CC) $(CBMC_VERBOSITY) --export-file-local-symbols $(COMPILE_FLAGS) $(INCLUDES) $(DEFINES) $^ -o $@' \
586+
'$(GOTO_CC) $(CBMC_VERBOSITY) $(COMPILE_FLAGS) $(EXPORT_FILE_LOCAL_SYMBOLS) $(INCLUDES) $(DEFINES) $^ -o $@' \
507587
--inputs $^ \
508588
--outputs $@ \
509589
--stdout-file $(LOGDIR)/proof_sources-log.txt \
@@ -836,6 +916,7 @@ clean:
836916
-$(RM) $(DEPENDENT_GOTOS)
837917
-$(RM) TAGS*
838918
-$(RM) *~ \#*
919+
-$(RM) $(REWRITTEN_SOURCES) $(foreach rs,$(REWRITTEN_SOURCES),$(rs).json)
839920

840921
veryclean: clean
841922
-$(RM) -r html report

tests/cbmc/proofs/run-cbmc-proofs.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def get_args():
153153
}, {
154154
"flags": ["--version"],
155155
"action": "version",
156-
"version": "CBMC starter kit 2.4",
156+
"version": "CBMC starter kit 2.5",
157157
"help": "display version and exit"
158158
}]:
159159
flags = arg.pop("flags")
@@ -219,17 +219,18 @@ def run_build(litani, jobs, fail_on_proof_failure, summarize):
219219

220220
logging.debug(" ".join(cmd))
221221
proc = subprocess.run(cmd, check=False)
222-
if proc.returncode:
223-
if fail_on_proof_failure:
224-
logging.error("One or more proofs failed")
225-
sys.exit(10)
222+
223+
if proc.returncode and not fail_on_proof_failure:
226224
logging.critical("Failed to run litani run-build")
227225
sys.exit(1)
228226

229227
if summarize:
230228
print_proof_results(out_file)
231229
out_file.unlink()
232230

231+
if proc.returncode:
232+
logging.error("One or more proofs failed")
233+
sys.exit(10)
233234

234235
def get_litani_path(proof_root):
235236
cmd = [

tests/litani

-1
This file was deleted.

0 commit comments

Comments
 (0)