Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion analysis/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"

[dependencies]
libc = "0.2"
c2rust-analysis-rt = { path = "../../analysis/runtime", optional = true }
c2rust-analysis-rt = { path = "../runtime", optional = true, version = "0.1.0" }
22 changes: 22 additions & 0 deletions dynamic_instrumentation/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ struct Args {
#[clap(long, value_parser)]
metadata: PathBuf,

/// Path to the `c2rust-analysis-rt` crate if you want to use a local version of it (vs. the crates.io one).
/// This is not used unless `--set-runtime` is also passed.
#[clap(long, value_parser)]
runtime: Option<PathBuf>,

/// Add the runtime as an optional dependency to the instrumented crate using `cargo add`.
#[clap(long)]
set_runtime: bool,

/// `cargo` args.
cargo_args: Vec<OsString>,
}
Expand Down Expand Up @@ -286,6 +295,8 @@ fn set_rust_toolchain() -> anyhow::Result<()> {
fn cargo_wrapper(rustc_wrapper: &Path) -> anyhow::Result<()> {
let Args {
metadata,
runtime,
set_runtime,
mut cargo_args,
} = Args::parse();

Expand All @@ -312,6 +323,17 @@ fn cargo_wrapper(rustc_wrapper: &Path) -> anyhow::Result<()> {
cmd.args(&["clean", "--package", root_package.name.as_str()]);
})?;

if set_runtime {
cargo.run(|cmd| {
cmd.args(&["add", "--optional", "c2rust-analysis-rt"]);
if let Some(runtime) = runtime {
// Since it's a local path, we don't need the internet,
// and running it offline saves a slow index sync.
cmd.args(&["--offline", "--path"]).arg(runtime);
}
})?;
}

// Create and truncate the metadata file for the [`rustc_wrapper`]s to append to.
OpenOptions::new()
.create(true)
Expand Down
2 changes: 2 additions & 0 deletions scripts/pdg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ main() {
local c2rust="${CWD}/${profile_dir}/c2rust"
local c2rust_instrument="${CWD}/${profile_dir}/${instrument}"
local metadata="${CWD}/${test_dir}/metadata.bc"
local runtime="${CWD}/analysis/runtime"

(cd "${test_dir}"
unset RUSTFLAGS # transpiled code has tons of warnings; don't allow `-D warnings`
Expand All @@ -52,6 +53,7 @@ main() {

time "${c2rust_instrument}" \
--metadata "${metadata}" \
--runtime "${runtime}" \
-- run "${profile_args[@]}" \
-- "${args[@]}" \
1> instrument.out.log
Expand Down