Skip to main content

Module driver

Module driver 

Source
Expand description

Run the rustc compiler with our custom options and hooks.

Re-exportsΒ§

use crate::CharonFailure; πŸ”’
use crate::toolchain::CHARON_SYSROOT_VAR; πŸ”’
use crate::translate::translate_crate; πŸ”’
use charon_lib::errors::ErrorCtx; πŸ”’
use charon_lib::options; πŸ”’
use charon_lib::options::CliOpts; πŸ”’
use charon_lib::options::MirLevel; πŸ”’
use charon_lib::options::selected_crate_var; πŸ”’
use charon_lib::transform::TransformCtx; πŸ”’
use charon_lib::utils::arg_value; πŸ”’
use itertools::Itertools; πŸ”’
use rustc_driver::Callbacks; πŸ”’
use rustc_driver::Compilation; πŸ”’
use rustc_interface::Config; πŸ”’
use rustc_interface::interface::Compiler; πŸ”’
use rustc_middle::ty::InstanceKind; πŸ”’
use rustc_middle::ty::TyCtxt; πŸ”’
use rustc_middle::util::Providers; πŸ”’
use rustc_session::config::JobsMode; πŸ”’
use rustc_session::output::OutputType; πŸ”’
use rustc_session::output::OutputTypes; πŸ”’
use rustc_span::ErrorGuaranteed; πŸ”’
use rustc_span::Symbol; πŸ”’
use rustc_structures::CrateType; πŸ”’
use std::num::NonZero; πŸ”’
use std::sync::atomic::AtomicBool; πŸ”’
use std::sync::atomic::Ordering; πŸ”’
use std::env; πŸ”’
use std::env; πŸ”’
use std::fmt; πŸ”’

StructsΒ§

CharonCallbacks
The callbacks for Charon
RunCompilerNormallyCallbacks
Dummy callbacks used to run the compiler normally when we shouldn’t be analyzing the crate.

StaticsΒ§

SKIP_BORROWCK πŸ”’

FunctionsΒ§

check_late_rustc_errors πŸ”’
Run rustc checks that normally happen close to codegen, so that we get all the post-mono errors etc.
def_id_debug πŸ”’
Custom DefId debug routine that doesn’t print unstable values like ids and hashes.
precheck_rustc_errors πŸ”’
Run a couple of rustc queries that don’t involve MIR (so that they don’t steal it). Returns whether rustc reported errors. This lets us avoid running Charon translation on crates rustc already rejects.
prefetch_local_mir πŸ”’
Compute, in parallel, the MIR of the local bodies at the level the translation reads them. rustc computes them after the translation anyway.
run_compiler_with_callbacks πŸ”’
Helper that runs the compiler and catches its fatal errors.
run_rustc_driver
Run the rustc driver with our custom hooks. Returns None if the crate was not compiled with charon (e.g. because it was a dependency). Otherwise returns the translated crate, ready for post-processing transformations.
set_mir_options πŸ”’
Tweak options to get usable MIR even for foreign crates.
set_parallel_frontend πŸ”’
Enable rustc’s parallel front-end.
set_skip_borrowck πŸ”’
setup_compiler πŸ”’
skip_borrowck_if_set πŸ”’