{"id":15440302,"url":"https://github.com/paul-hansen/wsl2windows-runner","last_synced_at":"2025-07-14T19:45:22.922Z","repository":{"id":188365543,"uuid":"678602516","full_name":"paul-hansen/wsl2windows-runner","owner":"paul-hansen","description":"A cargo target runner for use on Windows to build in WSL2 and run the output .exe in Windows.","archived":false,"fork":false,"pushed_at":"2024-02-29T19:23:46.000Z","size":8,"stargazers_count":15,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T12:22:00.626Z","etag":null,"topics":["bevy-engine","cargo","rust","wsl","wsl2"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paul-hansen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-08-15T00:00:28.000Z","updated_at":"2025-01-02T04:03:16.000Z","dependencies_parsed_at":"2024-02-29T20:31:08.987Z","dependency_job_id":"5339bdaa-6ac4-42bf-b351-5b519633cb2f","html_url":"https://github.com/paul-hansen/wsl2windows-runner","commit_stats":null,"previous_names":["paul-hansen/wsl2windows-runner"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paul-hansen%2Fwsl2windows-runner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paul-hansen%2Fwsl2windows-runner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paul-hansen%2Fwsl2windows-runner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paul-hansen%2Fwsl2windows-runner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paul-hansen","download_url":"https://codeload.github.com/paul-hansen/wsl2windows-runner/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249780603,"owners_count":21324586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bevy-engine","cargo","rust","wsl","wsl2"],"created_at":"2024-10-01T19:12:24.018Z","updated_at":"2025-04-19T19:34:50.404Z","avatar_url":"https://github.com/paul-hansen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wsl2windows-runner\n\nA [cargo target runner](https://nexte.st/book/target-runners.html) for use on Windows to build in WSL2 and run the output .exe in Windows.\n\nOnce it's setup you can just run `cargo run` while in WSL. It will build in WSL2 as usual but then run in Windows.\n\n[Get started](#first-time-setup)\n\n## Why?\nRust compilation on Windows is slower than on linux even when building exe files with the msvc toolchain, \nand it's a pain (impossible?) to get some graphical applications like [Bevy](https://bevyengine.org) to run in WSL2. \nThis allows you to have some of the build speed improvements of building on linux while still being able to have the output .exe run in Windows automatically. Works great with RustRover/Clion (or other IDEs that support using Rust with WSL and expect to be able to use cargo run).\n\n## Performance comparison\n\nThese numbers will vary greatly and should only be used to get a rough idea of the performance gain you _might_ get. The numbers varied greatly even between runs on the same machine in some cases. I recommend comparing with your own setup to make sure it's benefiting you with your setup and project.\n\n### Clean Build\n\n```shell\ncargo clean\ncargo run --features bevy/dynamic_linking\n```\n\n| Windows | WSL    |\n|---------|--------|\n| 2m 35s  | 2m 10s |\n\n### Incremental Build\n\nMade a single line change between each run.\n\n```shell\ncargo run --features bevy/dynamic_linking\n```\n\n| Windows | WSL   |\n|---------|-------|\n| 5.71s   | 4.05s |\n\n### Clippy\n\nMade a single line change between each run.\n\n```shell\ncargo clippy --features bevy/dynamic_linking\n```\n\n| Windows | WSL   |\n|---------|-------|\n| 2.96s   | 2.69s |\n\n#### Test machine\n- AMD Ryzen 9 7950X (32 threads 5.20 GHz all cores)\n- 64 GB DDR5\n- 4 TB NVME SSD 4900/3500 MB/s\n\n#### Test project\n- [Bevy](https://bevyengine.org) 0.11.0\n- 15,131 lines of Rust in the project \n- Installed in WSL for WSL tests e.g. `\\\\wsl.localhost\\Ubuntu\\home\\paul\\project\\`\n- Installed in Windows for Windows tests e.g. `C:\\Users\\paul\\project\\`\n- Exclusions for the project directory in Windows Defender for both projects\n- Closed source sorry\n\n# First Time Setup\n\n## Install WSL2 and Rust\n\n```shell\nwsl --install\nwsl\ncurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nrustup target add x86_64-pc-windows-msvc\n```\n\n## Install wsl2windows-runner\n\nWhile still in wsl:\n\n```shell\ncargo install --git https://github.com/paul-hansen/wsl2windows-runner.git\n```\n\n## Install Windows SDK for MSVC inside WSL2 \n\nSee https://bevy-cheatbook.github.io/setup/cross/linux-windows.html for less condensed instructions.\n\nReplace `/home/me/.xwin` in the next command with the path you want to install the SDK to. Remember this path for the next step.\n```shell\ncargo install xwin\nxwin --accept-license splat --output /home/me/.xwin\n```\n\nAdd this to your project's `.cargo/config.toml` (or create it) replacing `/home/me/.xwin` with the path you installed to in the previous step.\n```toml\n[build]\ntarget = \"x86_64-pc-windows-msvc\"\n\n[target.x86_64-pc-windows-msvc]\nrunner = \"wsl2windows-runner\"\nlinker = \"rust-lld\"\nrustflags = [\n    \"-Lnative=/home/me/.xwin/crt/lib/x86_64\",\n    \"-Lnative=/home/me/.xwin/sdk/lib/um/x86_64\",\n    \"-Lnative=/home/me/.xwin/sdk/lib/ucrt/x86_64\"\n]\n```\n\nI recommend adding `./cargo/config.toml` to your .gitignore file if you are collaborating as not everyone will want to use this.\n\n## Other/additional ways to reduce compile times\n\nIf you are looking at this project these resources may be useful to you as well:\n- https://davidlattimore.github.io/working-on-rust-iteration-time.html\n- https://benw.is/posts/how-i-improved-my-rust-compile-times-by-seventy-five-percent\n- https://matklad.github.io/2021/09/04/fast-rust-builds.html\n\n## Alternatives\n\n- [cross](https://github.com/cross-rs/cross) Building in docker containers. Didn't fit my needs because it uses `cross run` instead of `cargo run` and Clion doesn't play well with that.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaul-hansen%2Fwsl2windows-runner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaul-hansen%2Fwsl2windows-runner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaul-hansen%2Fwsl2windows-runner/lists"}