Sinono3 / souvlaki

A cross-platform library for handling OS media controls and metadata.
MIT License
79 stars 15 forks source link

Miscompile when cross-compiling to Windows from Linux using MinGW-w64 #20

Closed Beinsezii closed 2 years ago

Beinsezii commented 2 years ago

Compiling to x86_64-pc-windows-gnu on Linux using the MinGW-w64 toolchain produces this lovely error with -Z macro-backtrace

error: couldn't read /home/beinsezii/Rust/ompl/target/x86_64-pc-windows-gnu/release/build/souvlaki-0ea84c42cbb27be4/out/windows.rs: No such file or directory (os error 2)
    --> /home/beinsezii/.cargo/registry/src/github.com-1ecc6299db9ec823/windows-0.17.2/src/macros.rs:5:9
     |
3    | / macro_rules! include_bindings {
4    | |     () => {
5    | |         ::std::include!(::std::concat!(::std::env!("OUT_DIR"), "/windows.rs"));
     | |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation (#2)
6    | |     };
7    | | }
     | |_- in this expansion of `::windows::include_bindings!` (#1)
     |
    ::: /home/beinsezii/.cargo/registry/src/github.com-1ecc6299db9ec823/souvlaki-0.4.4/src/platform/windows/mod.rs:4:5
     |
4    |       ::windows::include_bindings!();
     |       ------------------------------ in this macro invocation (#1)

Seems it's part of windows-rs 638 and 1128. Given that these have had progress dating as recent as September, and souvlaki uses a windows-rs version from July, it's possible that updating the windows-rs dependency will resolve or at least progress the issue.

I would try this myself, but windows-rs has changed it's structure so much since I'm not sure what the current equivalent of things like windows::factory are.

Sinono3 commented 2 years ago

It should be fixed in the windows_update branch. Cross-compilation to x86-64-pc-windows-gnu works for me on Void Linux. Though I didn't test running binaries on a real Windows machine yet. I'll merge the changes into master and release a patch when I confirm it's working :)

Beinsezii commented 2 years ago

Using the branch, cross-compiled my music player on Arch and successfully ran on my Windows 10 partition. Haven't found any issues yet.

Sinono3 commented 2 years ago

Good! I'll merge the branch then. Thanks.