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

Support x86 windows #3873

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ jobs:
RUSTUP_HOME: ${{ env.DEV_DRIVE }}/.rustup
run: |
rustup target add x86_64-pc-windows-msvc
rustup component add clippy rust-src --toolchain nightly-2024-03-19-x86_64-pc-windows-msvc
rustup component add clippy rust-src --toolchain nightly-2024-05-27-x86_64-pc-windows-msvc

- uses: rui314/setup-mold@v1

Expand Down
4 changes: 3 additions & 1 deletion crates/install-wheel-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ pub enum Error {
RecordCsv(#[from] csv::Error),
#[error("Broken virtualenv: {0}")]
BrokenVenv(String),
#[error("Unable to create Windows launcher for {0} (only x64_64 is supported)")]
#[error(
"Unable to create Windows launcher for: {0} (only x86_64, x86, and arm64 are supported)"
)]
UnsupportedWindowsArch(&'static str),
#[error("Unable to create Windows launcher on non-Windows platform")]
NotWindows,
Expand Down
16 changes: 16 additions & 0 deletions crates/install-wheel-rs/src/wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ use crate::{Error, Layout};

const LAUNCHER_MAGIC_NUMBER: [u8; 4] = [b'U', b'V', b'U', b'V'];

#[cfg(all(windows, target_arch = "x86"))]
const LAUNCHER_I686_GUI: &[u8] =
include_bytes!("../../uv-trampoline/trampolines/uv-trampoline-i686-gui.exe");

#[cfg(all(windows, target_arch = "x86"))]
const LAUNCHER_I686_CONSOLE: &[u8] =
include_bytes!("../../uv-trampoline/trampolines/uv-trampoline-i686-console.exe");

#[cfg(all(windows, target_arch = "x86_64"))]
const LAUNCHER_X86_64_GUI: &[u8] =
include_bytes!("../../uv-trampoline/trampolines/uv-trampoline-x86_64-gui.exe");
Expand Down Expand Up @@ -161,6 +169,14 @@ pub(crate) fn windows_script_launcher(
}

let launcher_bin: &[u8] = match env::consts::ARCH {
#[cfg(all(windows, target_arch = "x86"))]
"x86" => {
if is_gui {
LAUNCHER_I686_GUI
} else {
LAUNCHER_I686_CONSOLE
}
}
#[cfg(all(windows, target_arch = "x86_64"))]
"x86_64" => {
if is_gui {
Expand Down
15 changes: 11 additions & 4 deletions crates/uv-trampoline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ package manager to install LLD and add the `rustup` targets:

```shell
sudo apt install llvm clang lld
rustup target add i686-pc-windows-msvc
rustup target add x86_64-pc-windows-msvc
rustup target add aarch64-pc-windows-msvc
```

Then, build the trampolines for both supported architectures:

```shell
cargo +nightly-2024-03-19 xwin build --release --target x86_64-pc-windows-msvc
cargo +nightly-2024-03-19 xwin build --release --target aarch64-pc-windows-msvc
cargo +nightly-2024-05-27 xwin build --xwin-arch x86 --release --target i686-pc-windows-msvc
cargo +nightly-2024-05-27 xwin build --release --target x86_64-pc-windows-msvc
cargo +nightly-2024-05-27 xwin build --release --target aarch64-pc-windows-msvc
```

### Cross-compiling from macOS
Expand All @@ -29,15 +31,17 @@ package manager to install LLVM and add the `rustup` targets:

```shell
brew install llvm
rustup target add i686-pc-windows-msvc
rustup target add x86_64-pc-windows-msvc
rustup target add aarch64-pc-windows-msvc
```

Then, build the trampolines for both supported architectures:

```shell
cargo +nightly-2024-03-19 xwin build --release --target x86_64-pc-windows-msvc
cargo +nightly-2024-03-19 xwin build --release --target aarch64-pc-windows-msvc
cargo +nightly-2024-05-27 xwin build --release --target i686-pc-windows-msvc
cargo +nightly-2024-05-27 xwin build --release --target x86_64-pc-windows-msvc
cargo +nightly-2024-05-27 xwin build --release --target aarch64-pc-windows-msvc
```

### Updating the prebuilt executables
Expand All @@ -49,6 +53,8 @@ cp target/aarch64-pc-windows-msvc/release/uv-trampoline-console.exe trampolines/
cp target/aarch64-pc-windows-msvc/release/uv-trampoline-gui.exe trampolines/uv-trampoline-aarch64-gui.exe
cp target/x86_64-pc-windows-msvc/release/uv-trampoline-console.exe trampolines/uv-trampoline-x86_64-console.exe
cp target/x86_64-pc-windows-msvc/release/uv-trampoline-gui.exe trampolines/uv-trampoline-x86_64-gui.exe
cp target/i686-pc-windows-msvc/release/uv-trampoline-console.exe trampolines/uv-trampoline-i686-console.exe
cp target/i686-pc-windows-msvc/release/uv-trampoline-gui.exe trampolines/uv-trampoline-i686-gui.exe
```

### Testing the trampolines
Expand Down Expand Up @@ -167,6 +173,7 @@ might not realize that, and still emit references to the unwinding helper
exist.

```
cargo build --release --target i686-pc-windows-msvc
cargo build --release --target x86_64-pc-windows-msvc
cargo build --release --target aarch64-pc-windows-msvc
```
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-trampoline/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "nightly-2024-03-19"
channel = "nightly-2024-05-27"
Binary file not shown.
Binary file not shown.
Loading