Skip to content

Rollup of 6 pull requests #118744

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

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ad6dd6c
Add new x86_64-win7-windows-msvc target
roblabla Nov 14, 2023
85e73c1
Add i686-win7-windows-msvc target
roblabla Nov 14, 2023
e836561
Improve -win7-windows-msvc documentation
roblabla Nov 21, 2023
1a0829c
Add unstable `-Zdefault-hidden-visibility` cmdline flag for `rustc`.
anforowicz Nov 28, 2023
4c9e842
Add instance evaluation and methods to read alloc
celinval Dec 6, 2023
9cb6463
Fix conversion to StaticDef and add test
celinval Dec 7, 2023
0a0e7e6
Add tests to allocation methods and fix is_null()
celinval Dec 7, 2023
9e15c49
Add a test to evaluate type intrinsic.
celinval Dec 7, 2023
4b64fbf
remove redundant imports
surechen Nov 10, 2023
5d16c54
Extend tidy alphabetical checking to `tests/`.
nnethercote Dec 8, 2023
a002814
Strengthen well known check-cfg names and values test
Urgau Dec 7, 2023
5a17ee7
Avoid target_os and target_arch in some check-cfg tests
Urgau Dec 7, 2023
9c60306
Rollup merge of #118150 - roblabla:new-win7-targets, r=davidtwco
GuillaumeGomez Dec 8, 2023
5a0b572
Rollup merge of #118417 - anforowicz:default-hidden-visibility, r=TaK…
GuillaumeGomez Dec 8, 2023
84e9ec6
Rollup merge of #118692 - surechen:remove_unused_imports, r=petrochenkov
GuillaumeGomez Dec 8, 2023
c1c30f4
Rollup merge of #118694 - celinval:smir-alloc-methods, r=ouz-a
GuillaumeGomez Dec 8, 2023
2c4af70
Rollup merge of #118702 - Urgau:check-cfg-strengthen-well-known, r=nn…
GuillaumeGomez Dec 8, 2023
e3f52c5
Rollup merge of #118737 - nnethercote:tidy-alphabetical-in-testsa, r=…
GuillaumeGomez Dec 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1600,8 +1600,10 @@ supported_targets! {
("aarch64-uwp-windows-msvc", aarch64_uwp_windows_msvc),
("x86_64-pc-windows-msvc", x86_64_pc_windows_msvc),
("x86_64-uwp-windows-msvc", x86_64_uwp_windows_msvc),
("x86_64-win7-windows-msvc", x86_64_win7_windows_msvc),
("i686-pc-windows-msvc", i686_pc_windows_msvc),
("i686-uwp-windows-msvc", i686_uwp_windows_msvc),
("i686-win7-windows-msvc", i686_win7_windows_msvc),
("i586-pc-windows-msvc", i586_pc_windows_msvc),
("thumbv7a-pc-windows-msvc", thumbv7a_pc_windows_msvc),
("thumbv7a-uwp-windows-msvc", thumbv7a_uwp_windows_msvc),
Expand Down
32 changes: 32 additions & 0 deletions compiler/rustc_target/src/spec/targets/i686_win7_windows_msvc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use crate::spec::{base, LinkerFlavor, Lld, Target};

pub fn target() -> Target {
let mut base = base::windows_msvc::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);

base.add_pre_link_args(
LinkerFlavor::Msvc(Lld::No),
&[
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
// space available to x86 Windows binaries on x86_64.
"/LARGEADDRESSAWARE",
// Ensure the linker will only produce an image if it can also produce a table of
// the image's safe exception handlers.
// https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers
"/SAFESEH",
],
);
// Workaround for #95429
base.has_thread_local = false;

Target {
llvm_target: "i686-pc-windows-msvc".into(),
pointer_width: 32,
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
i64:64-f80:128-n8:16:32-a:0:32-S32"
.into(),
arch: "x86".into(),
options: base,
}
}
18 changes: 18 additions & 0 deletions compiler/rustc_target/src/spec/targets/x86_64_win7_windows_msvc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use crate::spec::{base, Target};

pub fn target() -> Target {
let mut base = base::windows_msvc::opts();
base.cpu = "x86-64".into();
base.plt_by_default = false;
base.max_atomic_width = Some(64);
base.vendor = "win7".into();

Target {
llvm_target: "x86_64-win7-windows-msvc".into(),
pointer_width: 64,
data_layout: "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
.into(),
arch: "x86_64".into(),
options: base,
}
}
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
- [\*-unknown-uefi](platform-support/unknown-uefi.md)
- [wasm32-wasi-preview1-threads](platform-support/wasm32-wasi-preview1-threads.md)
- [wasm64-unknown-unknown](platform-support/wasm64-unknown-unknown.md)
- [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md)
- [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)
- [x86_64-unknown-none](platform-support/x86_64-unknown-none.md)
- [x86_64h-apple-darwin](platform-support/x86_64h-apple-darwin.md)
Expand Down
2 changes: 2 additions & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ target | std | host | notes
[`i686-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 32-bit OpenBSD [^x86_32-floats-return-ABI]
`i686-uwp-windows-gnu` | ? | | [^x86_32-floats-return-ABI]
`i686-uwp-windows-msvc` | ? | | [^x86_32-floats-return-ABI]
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI]
`i686-wrs-vxworks` | ? | | [^x86_32-floats-return-ABI]
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
Expand Down Expand Up @@ -352,6 +353,7 @@ target | std | host | notes
[`x86_64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | 64-bit OpenBSD
`x86_64-uwp-windows-gnu` | ✓ | |
`x86_64-uwp-windows-msvc` | ✓ | |
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support
`x86_64-wrs-vxworks` | ? | |
[`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell)

Expand Down
80 changes: 80 additions & 0 deletions src/doc/rustc/src/platform-support/win7-windows-msvc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# *-win7-windows-msvc

**Tier: 3**

Windows targets continuing support of windows7.

## Target maintainers

- @roblabla

## Requirements

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

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

Like any other Windows target, the created binaries are in PE format.

## Building the target

You can build Rust with support for the targets by adding it to the target list in config.toml:

```toml
[build]
build-stage = 1
target = [ "x86_64-win7-windows-msvc" ]
```

## Building Rust programs

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

## Testing

Created binaries work fine on Windows or Wine using native hardware. Remote
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).

## Cross-compilation toolchains and C code

Compatible C code can be built with either MSVC's `cl.exe` or LLVM's clang-cl.

Cross-compilation is possible using clang-cl/lld-link. It also requires the
Windows SDK, which can be acquired using [`xwin`](https://github.com/Jake-Shadle/xwin).

- Install `clang-cl` and `lld-link` on your machine, and make sure they are in
your $PATH.
- Install `xwin`: `cargo install xwin`
- Use `xwin` to install the Windows SDK: `xwin splat --output winsdk`
- Create an `xwin-lld-link` script with the following content:

```bash
#!/usr/bin/env bash
set -e
XWIN=/path/to/winsdk
lld-link "$@" /libpath:$XWIN/crt/lib/x86_64 /libpath:$XWIN/sdk/lib/um/x86_64 /libpath:$XWIN/sdk/lib/ucrt/x86_64
```

- Create an `xwin-clang-cl` script with the following content:

```bash
#!/usr/bin/env bash
set -e
XWIN=/path/to/winsdk
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" "$@"
```

- In your config.toml, add the following lines:

```toml
[target.x86_64-win7-windows-msvc]
linker = "path/to/xwin-lld-link"
cc = "path/to/xwin-clang-cl"
```

You should now be able to cross-compile the Rust std, and any rust program.