Skip to content

Commit f635f7b

Browse files
authored
Remove --legacy-linker support (rust-lang#2127)
I updated the firecracker codegen test to use `cargo kani assess` instead and I removed the old scripts to collect info on the top X crates since we no longer use them. I kept the compiler option `--reachability=legacy` since we still use it to test the std library code generation. I also kept the `--mir-linker` option as a no-op for now.
1 parent d2ae8af commit f635f7b

File tree

13 files changed

+42
-266
lines changed

13 files changed

+42
-266
lines changed

kani-driver/src/args.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#[cfg(feature = "unsound_experiments")]
55
use crate::unsound_experiments::UnsoundExperimentArgs;
6+
use crate::util::warning;
67

78
use clap::{error::Error, error::ErrorKind, CommandFactory, ValueEnum};
89
use std::ffi::OsString;
@@ -98,7 +99,7 @@ pub struct KaniArgs {
9899
/// Generate C file equivalent to inputted program.
99100
/// This feature is unstable and it requires `--enable-unstable` to be used
100101
#[arg(long, hide_short_help = true, requires("enable_unstable"),
101-
conflicts_with_all(&["function", "legacy_linker"]))]
102+
conflicts_with_all(&["function"]))]
102103
pub gen_c: bool,
103104

104105
/// Directory for all generated artifacts.
@@ -135,17 +136,12 @@ pub struct KaniArgs {
135136
#[arg(long, hide_short_help = true)]
136137
pub only_codegen: bool,
137138

138-
/// Disable the new MIR Linker. Using this option may result in missing symbols from the
139-
/// `std` library. See <https://github.com/model-checking/kani/issues/1213> for more details.
140-
#[arg(long, hide = true)]
139+
/// Deprecated flag. This is a no-op since we no longer support the legacy linker and
140+
/// it will be removed in a future Kani release.
141+
#[arg(long, hide = true, conflicts_with("mir_linker"))]
141142
pub legacy_linker: bool,
142-
143-
/// Enable the new MIR Linker. This is already the default option and it will be removed once
144-
/// the linker is stable.
145-
/// The MIR Linker affects how Kani prunes the code to be analyzed. It also fixes previous
146-
/// issues with missing `std` function definitions.
147-
/// See <https://model-checking.github.io/kani/rfc/rfcs/0001-mir-linker.html> for more details.
148-
#[arg(long, conflicts_with("legacy_linker"), hide = true)]
143+
/// Deprecated flag. This is a no-op since we no longer support any other linker.
144+
#[arg(long, hide = true)]
149145
pub mir_linker: bool,
150146

151147
/// Specify the value used for loop unwinding in CBMC
@@ -472,6 +468,14 @@ impl KaniArgs {
472468
);
473469
}
474470

471+
if self.mir_linker {
472+
self.print_deprecated("--mir-linker");
473+
}
474+
475+
if self.legacy_linker {
476+
self.print_deprecated("--legacy-linker");
477+
}
478+
475479
// TODO: these conflicting flags reflect what's necessary to pass current tests unmodified.
476480
// We should consider improving the error messages slightly in a later pull request.
477481
if natives_unwind && extra_unwind {
@@ -535,6 +539,14 @@ impl KaniArgs {
535539

536540
Ok(())
537541
}
542+
543+
fn print_deprecated(&self, option: &str) {
544+
if !self.quiet {
545+
warning(&format!(
546+
"The `{option}` option is deprecated. This option no longer has any effect and should be removed"
547+
))
548+
}
549+
}
538550
}
539551

540552
#[cfg(test)]

kani-driver/src/call_cargo.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ impl KaniSession {
9595
// Arguments that will only be passed to the target package.
9696
let mut pkg_args: Vec<OsString> = vec![];
9797
match self.reachability_mode() {
98-
ReachabilityMode::Legacy => {
99-
// For this mode, we change `kani_args` not `pkg_args`
100-
kani_args.push("--reachability=legacy".into());
101-
}
10298
ReachabilityMode::ProofHarnesses => {
10399
pkg_args.extend(["--".into(), "--reachability=harnesses".into()]);
104100
}

kani-driver/src/call_single_file.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ impl KaniSession {
2020
let mut kani_args = self.kani_specific_flags();
2121
kani_args.push(
2222
match self.reachability_mode() {
23-
ReachabilityMode::Legacy => "--reachability=legacy",
2423
ReachabilityMode::ProofHarnesses => "--reachability=harnesses",
2524
ReachabilityMode::AllPubFns => "--reachability=pub_fns",
2625
ReachabilityMode::Tests => "--reachability=tests",

kani-driver/src/project.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@
44
//! The goal is to provide one project view independent on the build system (cargo / standalone
55
//! rustc) and its configuration (e.g.: linker type).
66
//!
7-
//! For `--legacy-linker` and `--function`, we still have a hack in-place that merges all the
8-
//! artifacts together. The reason is the following:
9-
//! - For `--legacy-linker`, the compiler generate one goto file per crate, including each
10-
//! target and all their dependencies. Ideally, the linking be done on a per-target base, but
11-
//! this would require extra logic. Since we are planning to remove the `--legacy-linker` in
12-
//! the near future, we decided not to invest time there.
7+
//! For `--function`, we still have a hack in-place that merges all the artifacts together.
8+
//! The reason is the following:
139
//! - For `--function`, the compiler doesn't generate any metadata that indicates which
1410
//! functions each goto model includes. Thus, we don't have an easy way to tell which goto
1511
//! files are relevant for the function verification. This is also another flag that we don't
16-
//! expect to stabilize, so we also opted to use the same hack of merging everything together.
12+
//! expect to stabilize, so we also opted to use the same hack as implemented before the MIR
13+
//! Linker was introduced to merge everything together.
1714
//!
1815
//! Note that for `--function` we also inject a mock `HarnessMetadata` to the project. This
1916
//! allows the rest of the driver to handle a function under verification the same way it handle
@@ -53,8 +50,8 @@ pub struct Project {
5350
artifacts: Vec<Artifact>,
5451
/// A flag that indicated whether all artifacts have been merged or not.
5552
///
56-
/// This allow us to provide a consistent behavior for `--legacy-linker` and `--function`.
57-
/// For these two options, we still merge all the artifacts together, so the
53+
/// This allow us to provide a consistent behavior for `--function`.
54+
/// For these this option, we still merge all the artifacts together, so the
5855
/// `merged_artifacts` flag will be set to `true`.
5956
/// When this flag is `true`, there should only be up to one artifact of any given type.
6057
/// When this flag is `false`, there may be multiple artifacts for any given type. However,
@@ -152,8 +149,8 @@ pub fn cargo_project(session: &KaniSession) -> Result<Project> {
152149
let outputs = session.cargo_build()?;
153150
let mut artifacts = vec![];
154151
let outdir = outputs.outdir.canonicalize()?;
155-
if session.args.legacy_linker || session.args.function.is_some() {
156-
// For the legacy linker or `--function` support, we still use a glob to link everything.
152+
if session.args.function.is_some() {
153+
// For the `--function` support, we still use a glob to link everything.
157154
// Yes, this is broken, but it has been broken for quite some time. :(
158155
// Merge goto files.
159156
let joined_name = "cbmc-linked";

kani-driver/src/session.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ impl KaniSession {
7474
/// Determine which symbols Kani should codegen (i.e. by slicing away symbols
7575
/// that are considered unreachable.)
7676
pub fn reachability_mode(&self) -> ReachabilityMode {
77-
if self.args.legacy_linker {
78-
ReachabilityMode::Legacy
79-
} else if self.codegen_tests {
77+
if self.codegen_tests {
8078
ReachabilityMode::Tests
8179
} else if self.args.function.is_some() {
8280
ReachabilityMode::AllPubFns
@@ -87,7 +85,6 @@ impl KaniSession {
8785
}
8886

8987
pub enum ReachabilityMode {
90-
Legacy,
9188
ProofHarnesses,
9289
AllPubFns,
9390
Tests,

kani-driver/src/util.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ pub fn specialized_harness_name(linked_obj: &Path, harness_filename: &str) -> Pa
8888
alter_extension(linked_obj, &format!("for-{harness_filename}.out"))
8989
}
9090

91+
/// Print a warning message. This will add a "warning:" tag before the message and style accordinly.
92+
pub fn warning(msg: &str) {
93+
let warning = console::style("warning:").bold().yellow();
94+
let msg_fmt = console::style(msg).bold();
95+
println!("{warning} {msg_fmt}")
96+
}
97+
9198
#[cfg(test)]
9299
mod tests {
93100
use super::*;

scripts/codegen-firecracker.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@ echo
2323

2424
# At the moment, we only test codegen for the virtio module
2525
cd $KANI_DIR/firecracker/src/devices/src/virtio/
26-
# Disable warnings until https://github.com/model-checking/kani/issues/573 is fixed
26+
export KANI_LOG=error
2727
export RUSTC_LOG=error
2828
export RUST_BACKTRACE=1
29-
# Use the legacy linker for now since we want to maximize the code that we are compiling from firecracker.
30-
# The MIR Linker will by default only collect code relevant to proof harnesses, however, firecracker has none.
31-
cargo kani --only-codegen --legacy-linker
29+
# Use cargo assess since this is now our default way of assessing Kani suitability to verify a crate.
30+
cargo kani --enable-unstable --only-codegen assess
3231

3332
echo
3433
echo "Finished Firecracker codegen regression successfully..."

scripts/exps/kani-repos-utils/filter_unsupported_constructs.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

scripts/exps/kani-repos-utils/produce_unsupported_summary.sh

Lines changed: 0 additions & 48 deletions
This file was deleted.

scripts/exps/kani-run-on-repos.sh

Lines changed: 0 additions & 146 deletions
This file was deleted.

0 commit comments

Comments
 (0)