Skip to content
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

Using in Windows #1509

Open
thewh1teagle opened this issue Jul 7, 2024 · 5 comments
Open

Using in Windows #1509

thewh1teagle opened this issue Jul 7, 2024 · 5 comments

Comments

@thewh1teagle
Copy link

It's unclear how can I use this codegen in Windows.
I would like to use it both locally and on Github actions for faster build with Rust on Windows.
Does it improve speed for release builds?

rustup default nightly

What should I do after installing nightly rust and set it as deafult?

@bjorn3
Copy link
Member

bjorn3 commented Jul 7, 2024

Does it improve speed for release builds?

Cranelift doesn't support enough optimizations to make it useful in release mode.

It's unclear how can I use this codegen in Windows.

It isn't distibuted with rustup on Windows yet. You can download the latest version from https://github.com/rust-lang/rustc_codegen_cranelift/releases/tag/dev instead, extract it somewhere and then run the contained cargo-clif.exe in the place of cargo.exe.

@mikkelens
Copy link

mikkelens commented Jul 18, 2024

I think it would be beneficial if there was a bigger notice in README.md that the usage instructions above the section mentioning precompiled binaries (for Windows) don't all easily transfer. I at least can't get rustc to accept the rustc_codegen_cranelift.dll in the "codegen-backends" in "sysroot" (mentioned in error when trying to use codegen-backend = "cranelift" without using rustup). I tried doing a few things to get it working per profile, including mirroring the layout that appears when using the rustup method on Linux. Only by passing -Zcodegen-backend=<absolute-path-to-dll> wholesale in a crate-wide rust flag can I get it working on Windows.

@thewh1teagle
Copy link
Author

and then run the contained cargo-clif.exe in the place of cargo.exe.

I added cargo-clif to PATH and changed the default toolchain to nightly but it give me error:

C:\Users\User\Documents\code\rustduck\src-tauri>rustup default
nightly-x86_64-pc-windows-msvc (default)

C:\Users\User\Documents\code\rustduck\src-tauri>cargo-clif build
warning: `C:\Users\User\.cargo\config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
warning: `C:\Users\User\.cargo\config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Cpanic=abort -Zpanic-abort-tests -Zcodegen-backend=C:\apps\bin\cargo-clif\bin\rustc_codegen_cranelift.dll --sysroot C:\apps\bin\cargo-clif --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit code: 1)
  --- stderr
  error: the option `Z` is only accepted on the nightly compiler

  help: consider switching to a nightly toolchain: `rustup default nightly`

  note: selecting a toolchain with `+toolchain` arguments require a rustup proxy; see <https://rust-lang.github.io/rustup/concepts/index.html>

  note: for more information about Rust's stability policy, see <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html#unstable-features>

  error: 1 nightly option were parsed

@thewh1teagle
Copy link
Author

That was an issue with rustc. I reinstalled it and it got fixed.


I compared build time with cargo vs cargo-clif:

  1. With cargo-clif
    $start = Get-Date; cargo-clif build ; $elapsed = (Get-Date) - $start; Write-Output "Elapsed time: $elapsed"
    Elapsed time: 00:01:35.74

  2. With cargo
    $start = Get-Date; cargo build ; $elapsed = (Get-Date) - $start; Write-Output "Elapsed time: $elapsed"
    Elapsed time: 00:02:01.69

@bjorn3
Copy link
Member

bjorn3 commented Jul 20, 2024

Sorry for the late reply @mikkelens. With the precompiled binaries from the releases page you probably want to use cargo-clif.exe instead of using the cargo configs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants