Skip to content

Commit 621f6ac

Browse files
alphastrataFirestar99
authored andcommitted
fix: use rust-lld and Zshare-generics=n
1 parent 6d7c1cd commit 621f6ac

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.cargo/config.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
[alias]
22
compiletest = "run --release -p compiletests --"
33

4+
5+
[target.x86_64-pc-windows-msvc]
6+
# Using Rust's LLD linker to avoid MSVC linker limitations
7+
linker = "rust-lld.exe"
8+
rustflags = [
9+
# Generic Code Sharing Control (Nightly-only)
10+
# ------------------------------------------
11+
# Disables cross-crate generic sharing to work around Windows PE export limits.
12+
# Should prevent:
13+
# - LNK1189 (too many objects)
14+
# - LNK1248 (too many exports)
15+
"-Zshare-generics=n", # =off is also an option, but you're going to increase binary size in doing so.
16+
]
17+
418
[target.'cfg(all())']
519
rustflags = [
620
# FIXME(eddyb) update/review these lints.

docs/src/building-rust-gpu.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ build the examples - specifically, x11 and libxkbcommon, as well as gcc/clang wi
2626
called (fedora) `libX11-devel`, `libxkbcommon-x11-devel`, and `gcc-c++`, or (ubuntu) `libxkbcommon-x11-dev`,
2727
`libx11-dev`, and `gcc`.
2828
29+
## Prerequisite windows packages:
30+
Ensure you have `rust-lld.exe` installed with: `rustup component add llvm-tools-preview`, the repo ships with a `rust-lld.exe` configuration to get around the _default_ `msvc` compiler's symbol limit of `65535`, if you're seeing `LNK1189` or `LNK1248` errors suggested reading materials: [LNK1189](LNK1189), [LNK1248](LNK1248) please make an [Issue](Issue) if you see these errors as these problems are supposed to be handled for you in the `.cargo/config.toml` file where the Rust-GPU project explicitly overrides the default linker and passes flags to mitigate the above.
31+
2932
## Using installed SPIRV-Tools
3033
3134
By default, all of the crates and examples in this repo will compile the [`spirv-tools-sys`](https://crates.io/crates/spirv-tools-sys) crate, including a lot of C++ code from [SPIRV-Tools](https://github.com/EmbarkStudios/SPIRV-Tools). If you don't want to build the C++ code because you already have [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools#downloads) installed, or just don't want to spend more time compiling, you can build/run the crate with the `use-installed-tools` feature.
@@ -46,3 +49,6 @@ You should see `warning: use-installed-tools feature on, skipping compilation of
4649
[examples/runners/cpu]: https://github.com/rust-gpu/rust-gpu/tree/main/examples/runners/cpu
4750
[examples/runners/wgpu]: https://github.com/rust-gpu/rust-gpu/tree/main/examples/runners/wgpu
4851
[examples/shaders]: https://github.com/rust-gpu/rust-gpu/tree/main/examples/shaders
52+
[LNK1189](https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1189?view=msvc-170)
53+
[LNK1248](https://learn.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tools-error-lnk1248?view=msvc-170)
54+
[Issue](https://github.com/Rust-GPU/rust-gpu/issues)

0 commit comments

Comments
 (0)