Closed seritools closed 9 months ago
Added with the update to 1.76-beta.
Hi! I would like to ask a question about cross-compiling with --target=x86_64-rust9x-windows-msvc
.
After adding the precompiled rust9x as rust9x-1.76.0-beta-v2
in my toolchain list, I run cargo +rust9x-1.76.0-beta-v2 build --target=x86_64-rust9x-windows-msvc ....
compilation command on my project.
I got errors like error[E0463]: can't find crate for
std`,
error: cannot find macro println
in this scope` or something else related to std library.
Do I miss anything else for compiling on x86_64-rust9x-windows-msvc? Thanks in advance!
EDIT: I'm adding additional log from errors:
@LordRibblesdale Thank you, I just fixed it in v3, I forgot to add x86_64-pc-windows-msvc
(regular target) to the list of the supported targets. Without it, build scripts and such don't compile (since they miss std
).
Let me know if it works!
Hello!
Yes, v3 is working well for compilation! Thank you :)
I've got only this error while linking: note: LINK : fatal error LNK1181: cannot open input file 'windows.0.48.5.lib'
@LordRibblesdale Yeah, windows-rs needs a patch to get working, as it checks for the specific target triple. The easiest way to quickly get it working is to remove these lines: https://github.com/microsoft/windows-rs/blob/6f04b5a50bcc60b062849e94398df8f22ecec7b4/crates/targets/x86_64_msvc/build.rs#L2-L5
I'll also fix this and 9x/ME compat as far as possible in #16.
@LordRibblesdale Check out this branch: https://github.com/rust9x/windows-rs/tree/rust9x-windows-0.52.0-nt Should be easy to backport if you need it for 0.48.5 as well 👍
Thanks for the comments!
I've tried both attempts but, when editing build.rs files (I have in the project windows_x86_64_msvc 0.42.2, 0.48.5 and 0.52.0, I've tried first the 0.48.5, then all of them), I have the following error:
= note: LINK : fatal error LNK1181: cannot open input file 'windows.lib'
I've also tried to apply a patch like the following:
[patch.crates-io]
windows_x86_64_msvc = { git = "https://github.com/rust9x/windows-rs", branch = "rust9x-windows-0.52.0-nt" }
but without success, nothing changed.
I've tried with the deprecated "replace" TOML entry, as the following:
[replace]
"windows_x86_64_msvc:0.48.5" = {git = "https://github.com/rust9x/windows-rs", branch = "rust9x-windows-0.52.0-nt"}
and I've got a different error (for version matching):
stdout : Updating git repository `https://github.com/rust9x/windows-rs`
error: failed to get `windows_x86_64_msvc` as a dependency of package `windows-targets v0.48.5`
... which satisfies dependency `windows-targets = "^0.48"` (locked to 0.48.5) of package `chrono v0.4.31`
... which satisfies dependency `chrono = "^0.4.31"` (locked to 0.4.31) of package `project v2.2.2 (D:\Project)`
Caused by:
no matching package for override `https://github.com/rust-lang/crates.io-index#windows_x86_64_msvc@0.48.5` found
location searched: https://github.com/rust9x/windows-rs?branch=rust9x-windows-0.52.0-nt
version required: =0.48.5
Obviously I'm trying to compile a personal project, but right now I'll try your sample application right now (which compiles)
@LordRibblesdale try this:
[patch.crates-io]
windows = { git = 'https://github.com/rust9x/windows-rs', branch = "rust9x-windows-0.52.0-nt" }
windows-sys = { git = 'https://github.com/rust9x/windows-rs', branch = "rust9x-windows-0.52.0-nt" }
they should automatically pull in the patched subcrates as well.
Otherwise, https://github.com/microsoft/windows-rs/pull/2774 was merged, so the next official build should work as well :)
Right now it didn't work either. I'll just wait for an update of the dependencies and test again. Meanwhile I'll try in the near future to test other combinations in order to force the latest version
@LordRibblesdale a new official build would effectively run into the same problems I think. I've just tested it as well on my project at it seems to work fine. Maybe your dependencies have more/other versions of windows-rs in there? check cargo tree
to find out.
Another way to brute-force it into making it work is to use -Zlink-native-libraries=no
. This prevents rust from adding any libs to the linker command line. You'll have to manually link libcmt.lib
(for statically linked runtime) and all other libraries you or the rust stdlib needs, but it'll prevent adding that stray windows.lib
(probably from an old windows-rs version).
The regular target would mostly work as the stdlib impl is shared, however it might be useful to be able to do conditional compilation based on
cfg(target_vendor = "rust9x")
.