Skip to content

Commit

Permalink
make binary export the default and keep json export as an option
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi Delmas committed Mar 2, 2023
1 parent 6b5457b commit 489a88f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/kani.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Execute Kani regression
run: ./scripts/kani-regression.sh

write-goto-binary-regression:
write-json-symtab-regression:
runs-on: ubuntu-20.04
steps:
- name: Checkout Kani
Expand All @@ -49,7 +49,7 @@ jobs:

- name: Execute Kani regression
env:
KANI_ENABLE_WRITE_GOTO_BINARY: 1
KANI_ENABLE_WRITE_JSON_SYMTAB: 1
run: ./scripts/kani-regression.sh

experimental-features-regression:
Expand Down
17 changes: 8 additions & 9 deletions kani-compiler/kani_queries/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ pub trait UserInput {
fn set_ignore_global_asm(&mut self, global_asm: bool);
fn get_ignore_global_asm(&self) -> bool;

fn set_write_goto_binary(&mut self, write_goto_binary: bool);
fn get_write_goto_binary(&self) -> bool;
fn set_write_json_symtab(&mut self, write_json_symtab: bool);
fn get_write_json_symtab(&self) -> bool;

fn set_reachability_analysis(&mut self, reachability: ReachabilityType);
fn get_reachability_analysis(&self) -> ReachabilityType;
Expand All @@ -66,8 +66,7 @@ pub struct QueryDb {
emit_vtable_restrictions: bool,
json_pretty_print: bool,
ignore_global_asm: bool,
/// When set, instructs the compiler to produce the symbol table for CBMC in goto binary format instead of JSON format.
write_goto_binary: bool,
write_json_symtab: bool,
reachability_analysis: ReachabilityType,
stubbing_enabled: bool,
#[cfg(feature = "unsound_experiments")]
Expand All @@ -81,7 +80,7 @@ impl QueryDb {
emit_vtable_restrictions: false,
json_pretty_print: false,
ignore_global_asm: false,
write_goto_binary: false,
write_json_symtab: false,
reachability_analysis: ReachabilityType::None,
stubbing_enabled: false,
#[cfg(feature = "unsound_experiments")]
Expand Down Expand Up @@ -139,12 +138,12 @@ impl UserInput for QueryDb {
self.stubbing_enabled
}

fn set_write_goto_binary(&mut self, write_goto_binary: bool) {
self.write_goto_binary = write_goto_binary;
fn set_write_json_symtab(&mut self, write_json_symtab: bool) {
self.write_json_symtab = write_json_symtab;
}

fn get_write_goto_binary(&self) -> bool {
self.write_goto_binary
fn get_write_json_symtab(&self) -> bool {
self.write_json_symtab
}

#[cfg(feature = "unsound_experiments")]
Expand Down
9 changes: 5 additions & 4 deletions kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,16 @@ impl CodegenBackend for GotocCodegenBackend {
let pretty = self.queries.lock().unwrap().get_output_pretty_json();
write_file(&base_filename, ArtifactType::PrettyNameMap, &pretty_name_map, pretty);

if gcx.queries.get_write_goto_binary() {
if gcx.queries.get_write_json_symtab() {
write_file(&base_filename, ArtifactType::SymTab, &gcx.symbol_table, pretty);
symbol_table_to_gotoc(&tcx, &base_filename);
} else {
write_goto_binary_file(
&base_filename.with_extension(ArtifactType::SymTabGoto),
&gcx.symbol_table,
);
} else {
write_file(&base_filename, ArtifactType::SymTab, &gcx.symbol_table, pretty);
symbol_table_to_gotoc(&tcx, &base_filename);
}

write_file(&base_filename, ArtifactType::TypeMap, &type_map, pretty);
write_file(&base_filename, ArtifactType::Metadata, &metadata, pretty);
// If they exist, write out vtable virtual call function pointer restrictions
Expand Down
2 changes: 1 addition & 1 deletion kani-compiler/src/kani_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl Callbacks for KaniCompiler {
.set_check_assertion_reachability(matches.get_flag(parser::ASSERTION_REACH_CHECKS));
queries.set_output_pretty_json(matches.get_flag(parser::PRETTY_OUTPUT_FILES));
queries.set_ignore_global_asm(matches.get_flag(parser::IGNORE_GLOBAL_ASM));
queries.set_write_goto_binary(matches.get_flag(parser::WRITE_GOTO_BINARY));
queries.set_write_json_symtab(matches.get_flag(parser::WRITE_JSON_SYMTAB));
queries.set_reachability_analysis(matches.reachability_type());

#[cfg(feature = "unsound_experiments")]
Expand Down
10 changes: 5 additions & 5 deletions kani-compiler/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ pub const PRETTY_OUTPUT_FILES: &str = "pretty-json-files";
/// Option used for suppressing global ASM error.
pub const IGNORE_GLOBAL_ASM: &str = "ignore-global-asm";

/// Option used to write GOTO binaries instead of JSON symtabs.
pub const WRITE_GOTO_BINARY: &str = "write-goto-binary";
/// Option used to write JSON symbol tables instead of GOTO binaries.
pub const WRITE_JSON_SYMTAB: &str = "write-json-symtab";

/// Option name used to select which reachability analysis to perform.
pub const REACHABILITY: &str = "reachability";
Expand Down Expand Up @@ -126,9 +126,9 @@ pub fn parser() -> Command {
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(WRITE_GOTO_BINARY)
.long(WRITE_GOTO_BINARY)
.help("Instruct the compiler to produce GOTO binaries instead of JSON symtabs.")
Arg::new(WRITE_JSON_SYMTAB)
.long(WRITE_JSON_SYMTAB)
.help("Instruct the compiler to produce CBMC symbol tables in JSON format instead of GOTO binary format.")
.action(ArgAction::SetTrue),
)
.arg(
Expand Down
6 changes: 3 additions & 3 deletions kani-driver/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ pub struct KaniArgs {
#[arg(long, hide_short_help = true, requires("enable_unstable"))]
pub ignore_global_asm: bool,

/// Write the GotoC symbol table to file in goto binary format instead of JSON.
#[arg(long, hide_short_help = true, requires("enable_unstable"))]
pub write_goto_binary: bool,
/// Write the GotoC symbol table to a file in JSON format instead of goto binary format.
#[arg(long, hide_short_help = true)]
pub write_json_symtab: bool,

/// Execute CBMC's sanity checks to ensure the goto-program we generate is correct.
#[arg(long, hide_short_help = true, requires("enable_unstable"))]
Expand Down
19 changes: 10 additions & 9 deletions kani-driver/src/call_single_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,17 @@ impl KaniSession {
flags.push("--ignore-global-asm".into());
}

// When running regression runs, the write_goto_binary option is enabled
// by defining an environment variable.
// The value must be non-empty and different from zero.
let enable_write_goto_binary = match std::env::var_os("KANI_ENABLE_WRITE_GOTO_BINARY") {
Some(str) => !str.is_empty() && str != "0",
None => false,
};
// // When running regression runs, the write_json_symtab option is enabled
// // by defining an environment variable.
// // The value must be non-empty and different from zero.
// let enable_write_json_symtab = match std::env::var_os("KANI_ENABLE_WRITE_JSON_SYMTAB") {
// Some(str) => !str.is_empty() && str != "0",
// None => false,
// };
let enable_write_json_symtab = false;
// Users activate it via the command line switch
if self.args.write_goto_binary || enable_write_goto_binary {
flags.push("--write-goto-binary".into());
if self.args.write_json_symtab || enable_write_json_symtab {
flags.push("--write-json-symtab".into());
}

if self.args.enable_stubbing {
Expand Down

0 comments on commit 489a88f

Please sign in to comment.