Open
Description
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
- 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
- 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.
- 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
Line 49 in 1ab5de1
Currently, CBMC appears to have the following langauges:
cbmc/src/cbmc/cbmc_languages.cpp
Lines 25 to 35 in 4889328