Kobzol / cargo-pgo

Cargo subcommand for optimizing Rust binaries/libraries with PGO and BOLT.
MIT License
573 stars 11 forks source link

cargo pgo optimize: Invalid cross-device link (os error 18) #16

Closed burjui closed 2 years ago

burjui commented 2 years ago

I get this error when I run cargo pgo optimize on a project under /home, which is mounted on a separate partition. If I copy the project to e.g. /tmp and run the command on the copy - no problem whatsoever.

Kobzol commented 2 years ago

Heh, I was wondering whether this error could happen.. it seems that it indeed can happen :) I think that this is probably caused by the usage of std::fs::rename in pgo optimize. Sadly the std::io::ErrorKind::CrossesDevices error kind is still unstable, so I cannot detect this error easily, but I will change the code to just perform a non-atomic copy + delete if a move fails.

Could you please check if https://github.com/Kobzol/cargo-pgo/pull/17 fixes your problem?

$ cargo install --git https://github.com/kobzol/cargo-pgo --branch move-across-devices
burjui commented 2 years ago

Yes, the problem is gone, thank you :)

QuarticCat commented 2 years ago

I met this error as well. I was building https://github.com/Wilfred/difftastic through these commands:

$ cargo pgo run -- sample_files/slow_before.rs sample_files/slow_after.rs
$ cargo pgo optimize run -- sample_files/slow_before.rs sample_files/slow_after.rs

My project is put in home dir. /tmp of my computer is tmpfs, while /home is btrfs.

Kobzol commented 2 years ago

I did not release a new version with the fix yet, I will do it soon.

Does it work for you with

$ cargo install --git https://github.com/kobzol/cargo-pgo --branch main

?

QuarticCat commented 2 years ago

It works perfectly. Thanks!

Kobzol commented 2 years ago

Great :) I just published version 0.2.1 with the fix.