Skip to content

Commit

Permalink
Move symtab2gb to codegen step (#1686)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsn authored Sep 30, 2022
1 parent fbf0533 commit 38ba4b5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
26 changes: 26 additions & 0 deletions kani-compiler/src/codegen_cprover_gotoc/compiler_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use std::fmt::Write;
use std::io::BufWriter;
use std::iter::FromIterator;
use std::path::Path;
use std::process::Command;
use std::rc::Rc;
use tracing::{debug, warn};

Expand Down Expand Up @@ -152,6 +153,7 @@ impl CodegenBackend for GotocCodegenBackend {
if let Some(restrictions) = vtable_restrictions {
write_file(&base_filename, "restrictions.json", &restrictions, pretty);
}
symbol_table_to_gotoc(&tcx, &base_filename);
}
codegen_results(tcx, rustc_metadata, symtab.machine_model())
}
Expand Down Expand Up @@ -388,3 +390,27 @@ fn collect_codegen_items<'tcx>(gcx: &GotocCtx<'tcx>) -> Vec<MonoItem<'tcx>> {
}
}
}

fn symbol_table_to_gotoc(tcx: &TyCtxt, file: &Path) {
let output_filename = file.with_extension("symtab.out");
let input_filename = file.with_extension("symtab.json");

let args = vec![
input_filename.clone().into_os_string(),
"--out".into(),
output_filename.into_os_string(),
];
// TODO get symtab2gb path from self
let mut cmd = Command::new("symtab2gb");
cmd.args(args);
debug!("calling: `{:?} {:?}`", cmd.get_program(), cmd.get_args());

if cmd.status().is_err() {
let err_msg = format!(
"Failed to generate goto model:\n\tsymtab2gb failed on file {}.",
input_filename.display()
);
tcx.sess.err(&err_msg);
tcx.sess.abort_if_errors();
}
}
30 changes: 0 additions & 30 deletions kani-driver/src/call_symtab.rs

This file was deleted.

7 changes: 4 additions & 3 deletions kani-driver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ mod call_cbmc_viewer;
mod call_goto_cc;
mod call_goto_instrument;
mod call_single_file;
mod call_symtab;
mod cbmc_output_parser;
mod concrete_playback;
mod harness_runner;
Expand Down Expand Up @@ -44,7 +43,8 @@ fn cargokani_main(input_args: Vec<OsString>) -> Result<()> {

let mut goto_objs: Vec<PathBuf> = Vec::new();
for symtab in &outputs.symtabs {
goto_objs.push(ctx.symbol_table_to_gotoc(symtab)?);
let goto_obj_filename = symtab.with_extension("out");
goto_objs.push(goto_obj_filename);
}

if ctx.args.only_codegen {
Expand Down Expand Up @@ -81,7 +81,8 @@ fn standalone_main() -> Result<()> {

let outputs = ctx.compile_single_rust_file(&args.input)?;

let goto_obj = ctx.symbol_table_to_gotoc(&outputs.symtab)?;
let goto_obj = outputs.symtab.with_extension("out");
ctx.record_temporary_files(&[&goto_obj]);

if ctx.args.only_codegen {
return Ok(());
Expand Down
1 change: 0 additions & 1 deletion tests/cargo-ui/dry-run/expected
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
KANIFLAGS="--goto-c --log-level=warn --assertion-reach-checks --reachability=legacy -C symbol-mangling-version=v0" RUSTC=
RUSTFLAGS="--kani-flags" cargo rustc
symtab2gb
goto-cc
goto-cc
--function harness
Expand Down
1 change: 0 additions & 1 deletion tests/expected/dry-run/expected
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
kani-compiler --goto-c
symtab2gb
goto-cc
--function harness
goto-instrument
Expand Down

0 comments on commit 38ba4b5

Please sign in to comment.