Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lean] Rename user-facing options from Aeneas to Lean #3630

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions kani-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ tracing-tree = "0.4.0"

# Future proofing: enable backend dependencies using feature.
[features]
default = ['aeneas', 'cprover']
aeneas = ['charon']
default = ['cprover', 'llbc']
llbc = ['charon']
cprover = ['cbmc', 'num', 'serde']
write_json_symtab = []

Expand Down
10 changes: 5 additions & 5 deletions kani-compiler/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ use tracing_subscriber::filter::Directive;
#[derive(Debug, Default, Display, Clone, Copy, AsRefStr, EnumString, VariantNames, PartialEq, Eq)]
#[strum(serialize_all = "snake_case")]
pub enum BackendOption {
/// Aeneas (LLBC) backend
#[cfg(feature = "aeneas")]
Aeneas,

/// CProver (Goto) backend
#[cfg(feature = "cprover")]
#[strum(serialize = "cprover")]
#[default]
CProver,

/// LLBC backend (Aeneas's IR)
#[cfg(feature = "llbc")]
Llbc,
}

#[derive(Debug, Default, Clone, Copy, AsRefStr, EnumString, VariantNames, PartialEq, Eq)]
Expand Down Expand Up @@ -87,7 +87,7 @@ pub struct Arguments {
/// Option name used to select which backend to use.
#[clap(long = "backend", default_value_t = BackendOption::CProver)]
pub backend: BackendOption,
/// Print the final LLBC file to stdout. This requires `-Zaeneas`.
/// Print the final LLBC file to stdout.
zhassan-aws marked this conversation as resolved.
Show resolved Hide resolved
#[clap(long)]
pub print_llbc: bool,
}
Expand Down
20 changes: 10 additions & 10 deletions kani-compiler/src/kani_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! `-C llvm-args`.

use crate::args::{Arguments, BackendOption};
#[cfg(feature = "aeneas")]
#[cfg(feature = "llbc")]
use crate::codegen_aeneas_llbc::LlbcCodegenBackend;
#[cfg(feature = "cprover")]
use crate::codegen_cprover_gotoc::GotocCodegenBackend;
Expand Down Expand Up @@ -44,11 +44,11 @@ pub fn run(args: Vec<String>) -> ExitCode {
}
}

/// Configure the Aeneas backend that generates LLBC.
fn aeneas_backend(_queries: Arc<Mutex<QueryDb>>) -> Box<dyn CodegenBackend> {
#[cfg(feature = "aeneas")]
/// Configure the LLBC backend (Aeneas's IR).
fn llbc_backend(_queries: Arc<Mutex<QueryDb>>) -> Box<dyn CodegenBackend> {
#[cfg(feature = "llbc")]
return Box::new(LlbcCodegenBackend::new(_queries));
#[cfg(not(feature = "aeneas"))]
#[cfg(not(feature = "llbc"))]
unreachable!()
}

Expand All @@ -60,21 +60,21 @@ fn cprover_backend(_queries: Arc<Mutex<QueryDb>>) -> Box<dyn CodegenBackend> {
unreachable!()
}

#[cfg(any(feature = "aeneas", feature = "cprover"))]
#[cfg(any(feature = "cprover", feature = "llbc"))]
fn backend(queries: Arc<Mutex<QueryDb>>) -> Box<dyn CodegenBackend> {
let backend = queries.lock().unwrap().args().backend;
match backend {
#[cfg(feature = "aeneas")]
BackendOption::Aeneas => aeneas_backend(queries),
#[cfg(feature = "cprover")]
BackendOption::CProver => cprover_backend(queries),
#[cfg(feature = "llbc")]
BackendOption::Llbc => llbc_backend(queries),
}
}

/// Fallback backend. It will trigger an error if no backend has been enabled.
#[cfg(not(any(feature = "aeneas", feature = "cprover")))]
#[cfg(not(any(feature = "cprover", feature = "llbc")))]
fn backend(queries: Arc<Mutex<QueryDb>>) -> Box<CodegenBackend> {
compile_error!("No backend is available. Use `aeneas` or `cprover`.");
compile_error!("No backend is available. Use `cprover` or `llbc`.");
}

/// This object controls the compiler behavior.
Expand Down
2 changes: 1 addition & 1 deletion kani-compiler/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ extern crate stable_mir;
extern crate tempfile;

mod args;
#[cfg(feature = "aeneas")]
#[cfg(feature = "llbc")]
mod codegen_aeneas_llbc;
#[cfg(feature = "cprover")]
mod codegen_cprover_gotoc;
Expand Down
15 changes: 7 additions & 8 deletions kani-driver/src/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ pub struct VerificationArgs {
#[arg(long, hide_short_help = true)]
pub coverage: bool,

/// Print final LLBC for Aeneas backend. This requires the `-Z aeneas` option.
/// Print final LLBC for Lean backend. This requires the `-Z lean` option.
#[arg(long, hide = true)]
pub print_llbc: bool,

Expand Down Expand Up @@ -621,21 +621,20 @@ impl ValidateArgs for VerificationArgs {
));
}

if self.print_llbc && !self.common_args.unstable_features.contains(UnstableFeature::Aeneas)
{
if self.print_llbc && !self.common_args.unstable_features.contains(UnstableFeature::Lean) {
return Err(Error::raw(
ErrorKind::MissingRequiredArgument,
"The `--print-llbc` argument is unstable and requires `-Z aeneas` to be used.",
"The `--print-llbc` argument is unstable and requires `-Z lean` to be used.",
));
}

// TODO: error out for other CBMC-backend-specific arguments
if self.common_args.unstable_features.contains(UnstableFeature::Aeneas)
if self.common_args.unstable_features.contains(UnstableFeature::Lean)
&& !self.cbmc_args.is_empty()
{
return Err(Error::raw(
ErrorKind::ArgumentConflict,
"The `--cbmc-args` argument cannot be used with -Z aeneas.",
"The `--cbmc-args` argument cannot be used with -Z lean.",
));
}
Ok(())
Expand Down Expand Up @@ -930,8 +929,8 @@ mod tests {
}

#[test]
fn check_cbmc_args_aeneas_backend() {
let args = "kani input.rs -Z aeneas --enable-unstable --cbmc-args --object-bits 10"
fn check_cbmc_args_lean_backend() {
let args = "kani input.rs -Z lean --enable-unstable --cbmc-args --object-bits 10"
.split_whitespace();
let err = StandaloneArgs::try_parse_from(args).unwrap().validate().unwrap_err();
assert_eq!(err.kind(), ErrorKind::ArgumentConflict);
Expand Down
8 changes: 4 additions & 4 deletions kani-driver/src/call_single_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ impl KaniSession {
) -> Result<()> {
let mut kani_args = self.kani_compiler_flags();
kani_args.push(format!("--reachability={}", self.reachability_mode()));
if self.args.common_args.unstable_features.contains(UnstableFeature::Aeneas) {
kani_args.push("--backend=aeneas".into());
if self.args.common_args.unstable_features.contains(UnstableFeature::Lean) {
kani_args.push("--backend=llbc".into());
}

let lib_path = lib_folder().unwrap();
Expand Down Expand Up @@ -99,8 +99,8 @@ impl KaniSession {
}

pub fn backend_arg(&self) -> Option<String> {
if self.args.common_args.unstable_features.contains(UnstableFeature::Aeneas) {
Some(to_rustc_arg(vec!["--backend=aeneas".into()]))
if self.args.common_args.unstable_features.contains(UnstableFeature::Lean) {
Some(to_rustc_arg(vec!["--backend=llbc".into()]))
} else {
None
}
Expand Down
4 changes: 2 additions & 2 deletions kani_metadata/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ pub enum UnstableFeature {
/// Automatically check that no invalid value is produced which is considered UB in Rust.
/// Note that this does not include checking uninitialized value.
ValidValueChecks,
/// Aeneas/LLBC
Aeneas,
/// Enabled Lean backend (Aeneas/LLBC)
Lean,
/// Ghost state and shadow memory APIs.
GhostState,
/// Automatically check that uninitialized memory is not used.
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/llbc/basic0/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Zaeneas --print-llbc
// kani-flags: -Zlean --print-llbc

//! This test checks that Kani's LLBC backend handles basic expressions, in this
//! case an equality between a variable and a constant
Expand Down
2 changes: 1 addition & 1 deletion tests/expected/llbc/basic1/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright Kani Contributors
// SPDX-License-Identifier: Apache-2.0 OR MIT
// kani-flags: -Zaeneas --print-llbc
// kani-flags: -Zlean --print-llbc

//! This test checks that Kani's LLBC backend handles basic expressions, in this
//! case an if condition
Expand Down
Loading