Skip to content

"Fix" the tool not working on Windows #23

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

Merged
merged 1 commit into from
Jun 12, 2020
Merged
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
11 changes: 10 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,16 @@ fn cargo_llvm_lines(filter_cargo: bool, sort_order: SortOrder) -> io::Result<i32
let outdir = TempDir::new("cargo-llvm-lines").expect("failed to create tmp file");
let outfile = outdir.path().join("crate");

run_cargo_rustc(outfile)?;
// There used to be just a `?` operator, but when running this tool on Windows,
// it was mysteriously failing on "System cannot find the file specified. (os error 2)",
// even though the original command succeeded and the output was written to the outfile.
// That's why we don't return early with `?` anymore, we just log the error instead
// and try to read the llvm-ir anyway.
// If some different error occurs, we will probably fail to
// read llvm-ir files later in `read_llvm_ir()` so we don't explicitly handle it here.
if let Err(e) = run_cargo_rustc(outfile) {
eprintln!("Something went wrong during compiler invocation:\n{}", e);
};
let ir = read_llvm_ir(outdir)?;
count_lines(ir, sort_order);

Expand Down