Skip to content

Commit 019a7d1

Browse files
committed
Improve -win7-windows-msvc documentation
1 parent 398fb83 commit 019a7d1

File tree

1 file changed

+45
-9
lines changed

1 file changed

+45
-9
lines changed

src/doc/rustc/src/platform-support/win7-windows-msvc.md

+45-9
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ Windows targets continuing support of windows7.
1010

1111
## Requirements
1212

13-
This target supports full the entirety of std. This is automatically tested
14-
every night on private infrastructure. Host tools may also work, though those
15-
are not currently tested.
13+
This target supports all of core, alloc, std and test. This is automatically
14+
tested every night on private infrastructure hosted by the maintainer. Host
15+
tools may also work, though those are not currently tested.
1616

1717
Those targets follow Windows calling convention for extern "C".
1818

19-
Like with any other Windows target created binaries are in PE format.
19+
Like any other Windows target, the created binaries are in PE format.
2020

2121
## Building the target
2222

@@ -30,15 +30,51 @@ target = [ "x86_64-win7-windows-msvc" ]
3030

3131
## Building Rust programs
3232

33-
Rust does not yet ship pre-compiled artifacts for this target. To compile for
34-
this target, you will either need to build Rust with the target enabled (see
35-
"Building the target" above), or build your own copy of `core` by using
36-
`build-std` or similar.
33+
Rust does not ship pre-compiled artifacts for this target. To compile for this
34+
target, you will either need to build Rust with the target enabled (see
35+
"Building the target" above), or build your own copy by using `build-std` or
36+
similar.
3737

3838
## Testing
3939

40-
Created binaries work fine on Windows or Wine using native hardware.
40+
Created binaries work fine on Windows or Wine using native hardware. Remote
41+
testing is possible using the `remote-test-server` described [here](https://rustc-dev-guide.rust-lang.org/tests/running.html#running-tests-on-a-remote-machine).
4142

4243
## Cross-compilation toolchains and C code
4344

4445
Compatible C code can be built with either MSVC's `cl.exe` or LLVM's clang-cl.
46+
47+
Cross-compilation is possible using clang-cl/lld-link. It also requires the
48+
Windows SDK, which can be acquired using [`xwin`](https://github.com/Jake-Shadle/xwin).
49+
50+
- Install `clang-cl` and `lld-link` on your machine, and make sure they are in
51+
your $PATH.
52+
- Install `xwin`: `cargo install xwin`
53+
- Use `xwin` to install the Windows SDK: `xwin splat --output winsdk`
54+
- Create an `xwin-lld-link` script with the following content:
55+
56+
```bash
57+
#!/usr/bin/env bash
58+
set -e
59+
XWIN=/path/to/winsdk
60+
lld-link "$@" /libpath:$XWIN/crt/lib/x86_64 /libpath:$XWIN/sdk/lib/um/x86_64 /libpath:$XWIN/sdk/lib/ucrt/x86_64
61+
```
62+
63+
- Create an `xwin-clang-cl` script with the following content:
64+
65+
```bash
66+
#!/usr/bin/env bash
67+
set -e
68+
XWIN=/path/to/winsdk
69+
clang-cl /imsvc "$XWIN/crt/include" /imsvc "$XWIN/sdk/include/ucrt" /imsvc "$XWIN/sdk/include/um" /imsvc "$XWIN/sdk/include/shared" --target="x86_64-pc-windows-msvc" "$@"
70+
```
71+
72+
- In your config.toml, add the following lines:
73+
74+
```toml
75+
[target.x86_64-win7-windows-msvc]
76+
linker = "path/to/xwin-lld-link"
77+
cc = "path/to/xwin-clang-cl"
78+
```
79+
80+
You should now be able to cross-compile the Rust std, and any rust program.

0 commit comments

Comments
 (0)