Skip to content

Commit

Permalink
scripts/pdg.sh: also run analysis
Browse files Browse the repository at this point in the history
this is fairly hacky and best-effort, but until c2rust-analyze is a rustc wrapper for cargo, it's hard to do better, and this avoids duplicating the work of figuring out these hacks
  • Loading branch information
fw-immunant committed Jun 29, 2023
1 parent 58c0263 commit 4da6b95
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions scripts/pdg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ main() {
local event_log="${test_dir}/log.bc"
local runtime="analysis/runtime"

local crate_name="$(cargo pkgid --manifest-path "${test_dir}/Cargo.toml" | grep -P -o '(?<=#)[^@]+(?=@)' | tr '-' '_')"
(
unset RUSTFLAGS # transpiled code has tons of warnings; don't allow `-D warnings`
export RUST_BACKTRACE=1
Expand Down Expand Up @@ -77,6 +78,32 @@ main() {
--output "${pdg}" \
> "${test_dir}/pdg.log"
)
(
export RUST_BACKTRACE=full # print sources w/ color-eyre
export RUST_LOG=error
export PDG_FILE="${pdg}"
local deps_dir="${CARGO_TARGET_DIR:-target}/${profile_dir_name}/deps"
local libc_dep="$(ls -1 --sort=time -r ${deps_dir}/liblibc-*.rlib | head -n1)"
cargo run \
--bin c2rust-analyze \
"${profile_args[@]}" \
-- \
--crate-name "${crate_name}" \
--edition 2021 \
--crate-type bin \
--sysroot $(rustc --print sysroot) \
"-C" \
"opt-level=3" \
"-C" \
"embed-bitcode=no" \
"--cfg" \
"feature=\"c2rust-analysis-rt\"" \
"-C" \
"metadata=4095517b1921578c" \
"-L" "dependency=${deps_dir}" \
"--extern" "libc=${libc_dep}" \
"${test_dir}/src/main.rs"
)
}

main "${@}"

0 comments on commit 4da6b95

Please sign in to comment.