Skip to content

RFC: Language mode for Rust  #6219

Open
@danielsn

Description

@danielsn

RMC is a new Rust front-end for CBMC. Currently, it uses the C mode in the symbol-table. We propose adding a Rust mode to symbols. For now, this mode would have the same semantics as C, but would allow us to distinguish rust code from C code. This is particularly important as Rust support linking C code using a FFI, which we need to support in RMC.

Benefits

  1. Allows tools which consume CBMC output to know which language the initial source code was in. For example, when giving a failure trace that includes both Rust and C code, it would be valuable to the trace visualizer to know which language the statements originally came from
  2. Allows the backend to implement different semantics for the different languages. For example (maybe not the best one), one could imagine a case where one language wants unsigned addition to wrap around, while another wants it to saturate.
  3. Allows the addition of language specific checks. For example, Rust has areas of UB which are not defined as such in C - it may be useful to have checks which are only automatically inserted into the Rust side of a linked Rust/C binary.

Design considerations

Rust is not the only language that would benefit from this. Any new language front-end will likely see the same issues we are, and could benefit from a principled mechanism to alleviate them.

Links and documentation

irep_idt mode;

Currently, CBMC appears to have the following langauges:

void cbmc_parse_optionst::register_languages()
{
register_language(new_ansi_c_language);
register_language(new_statement_list_language);
register_language(new_cpp_language);
register_language(new_json_symtab_language);
#ifdef HAVE_JSIL
register_language(new_jsil_language);
#endif
}

Metadata

Metadata

Assignees

Labels

KaniBugs or features of importance to Kani Rust VerifierawsBugs or features of importance to AWS CBMC users

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions