Open vlovich opened 4 years ago
This seems to be an issue of the bootimage
tool and not of cargo-xbuild
. Let me try to transfer the issue to the bootimage
repository.
Which version of bootimage are you using? Does the issue also occur on the latest version (0.8.0)?
I think the absolute path is obtained through the Path::canonicalize
function of the standard library. It would be very unfortunate if that method really returns an invalid path…
This is with 0.8.0
I looked into this a bit more and I think that this behavior comes from cargo itself. For cargo xrun
, cargo invokes the runner executable with a relative path. You can see this when executing cargo xrun --verbose
and looking at the line just before the "Building bootloader" message:
Running `bootimage runner target/x86_64-blog_os/debug/blog_os`
We see that cargo invokes the bootimage
tool with a relative path to the binary.
For cargo xtest --verbose
, we see that cargo passes absolute paths for test executables, e.g.:
Running `bootimage runner /home/username/blog_os/post-01/target/x86_64-blog_os/debug/deps/blog_os-7e5190da4ac3ce5c`
So we don't do anything special with these paths in bootimage
. It's cargo itself that passes relative paths for normal runs and absolute paths for test binaries. Unfortunately, this also means that we can't really do anything to "fix" this in bootimage
.
As a side note, I don't think that cargo's behavior is problematic. If your system environment cannot deal with absolute paths this sounds more like a problem of the environment. I would expect that there is some way to translate WSL paths to native Windows paths. Maybe it's possible to do such a translation in your ~/bin/qemu-system-x86_64
before invoking the native QEMU executable?
~/bin/qemu-system-x86_64
putexec /mnt/c/Program\ Files/qemu/qemu-system-x86_64.exe "$@"
and make the file executablecargo xrun
cargo xtest
The xrun command works because it provides a relative path to the target to run to qemu. However xtest fails because it provides an absolute path which native QEMU doesn't understand. Passing a relative path just like xrun does should fix the issue.