mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Add windows aarch64 trampolines (#1190)
Lacking windows compatible aarch64 hardware, i cross compiled the trampoline from x86_64 linux to aarch64-pc-windows-msvc; I added the instructions to the puffin-trampoline readme. With some testing on an aarch64 windows machine, this should be sufficient to build working win_arm64 tagged wheels. i686-pc-windows-msvc is failing with an error: ``` error: linking with `lld-link` failed: exit status: 1 = note: lld-link: error: undefined symbol: __aulldiv >>> referenced by libcompiler_builtins-2fb09dee087e9f64.rlib(compiler_builtins-2fb09dee087e9f64.compiler_builtins.597f0152646f1b8-cgu.0.rcgu.o):(compiler_builtins::int::specialized_div_rem::u128_div_rem::h06aed1e23a3f8f5c) >>> referenced by libcompiler_builtins-2fb09dee087e9f64.rlib(compiler_builtins-2fb09dee087e9f64.compiler_builtins.597f0152646f1b8-cgu.0.rcgu.o):(compiler_builtins::int::specialized_div_rem::u128_div_rem::h06aed1e23a3f8f5c) >>> referenced by libcompiler_builtins-2fb09dee087e9f64.rlib(compiler_builtins-2fb09dee087e9f64.compiler_builtins.597f0152646f1b8-cgu.0.rcgu.o):(compiler_builtins::int::specialized_div_rem::u128_div_rem::h06aed1e23a3f8f5c) >>> referenced 4 more times lld-link: error: undefined symbol: __aullrem >>> referenced by libcompiler_builtins-2fb09dee087e9f64.rlib(compiler_builtins-2fb09dee087e9f64.compiler_builtins.597f0152646f1b8-cgu.0.rcgu.o):(compiler_builtins::int::specialized_div_rem::u128_div_rem::h06aed1e23a3f8f5c) >>> referenced by libcompiler_builtins-2fb09dee087e9f64.rlib(compiler_builtins-2fb09dee087e9f64.compiler_builtins.597f0152646f1b8-cgu.0.rcgu.o):(compiler_builtins::int::specialized_div_rem::u128_div_rem::h06aed1e23a3f8f5c) >>> referenced by libcompiler_builtins-2fb09dee087e9f64.rlib(compiler_builtins-2fb09dee087e9f64.compiler_builtins.597f0152646f1b8-cgu.0.rcgu.o):(compiler_builtins::int::specialized_div_rem::u128_div_rem::h06aed1e23a3f8f5c) >>> referenced 4 more times ```
This commit is contained in:
parent
614bb0cf52
commit
4ad0dc8b9e
6 changed files with 62 additions and 17 deletions
|
@ -33,19 +33,21 @@ use crate::{find_dist_info, Error};
|
|||
/// `#!/usr/bin/env python`
|
||||
pub const SHEBANG_PYTHON: &str = "#!/usr/bin/env python";
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, target_arch = "x86_64"))]
|
||||
const LAUNCHER_X86_64_GUI: &[u8] =
|
||||
include_bytes!("../../puffin-trampoline/trampolines/puffin-trampoline-gui.exe");
|
||||
include_bytes!("../../puffin-trampoline/trampolines/puffin-trampoline-x86_64-gui.exe");
|
||||
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, target_arch = "x86_64"))]
|
||||
const LAUNCHER_X86_64_CONSOLE: &[u8] =
|
||||
include_bytes!("../../puffin-trampoline/trampolines/puffin-trampoline-console.exe");
|
||||
include_bytes!("../../puffin-trampoline/trampolines/puffin-trampoline-x86_64-console.exe");
|
||||
|
||||
#[cfg(not(windows))]
|
||||
const LAUNCHER_X86_64_GUI: &[u8] = &[];
|
||||
#[cfg(all(windows, target_arch = "aarch64"))]
|
||||
const LAUNCHER_AARCH64_GUI: &[u8] =
|
||||
include_bytes!("../../puffin-trampoline/trampolines/puffin-trampoline-aarch64-gui.exe");
|
||||
|
||||
#[cfg(not(windows))]
|
||||
const LAUNCHER_X86_64_CONSOLE: &[u8] = &[];
|
||||
#[cfg(all(windows, target_arch = "aarch64"))]
|
||||
const LAUNCHER_AARCH64_CONSOLE: &[u8] =
|
||||
include_bytes!("../../puffin-trampoline/trampolines/puffin-trampoline-aarch64-console.exe");
|
||||
|
||||
/// Wrapper script template function
|
||||
///
|
||||
|
@ -293,6 +295,7 @@ fn get_shebang(location: &InstallLocation<impl AsRef<Path>>) -> String {
|
|||
/// to start the embedded script.
|
||||
///
|
||||
/// <https://github.com/pypa/pip/blob/fd0ea6bc5e8cb95e518c23d901c26ca14db17f89/src/pip/_vendor/distlib/scripts.py#L248-L262>
|
||||
#[allow(unused_variables)]
|
||||
pub(crate) fn windows_script_launcher(
|
||||
launcher_python_script: &str,
|
||||
is_gui: bool,
|
||||
|
@ -303,7 +306,8 @@ pub(crate) fn windows_script_launcher(
|
|||
return Err(Error::NotWindows);
|
||||
}
|
||||
|
||||
let launcher_bin = match env::consts::ARCH {
|
||||
let launcher_bin: &[u8] = match env::consts::ARCH {
|
||||
#[cfg(all(windows, target_arch = "x86_64"))]
|
||||
"x86_64" => {
|
||||
if is_gui {
|
||||
LAUNCHER_X86_64_GUI
|
||||
|
@ -311,9 +315,20 @@ pub(crate) fn windows_script_launcher(
|
|||
LAUNCHER_X86_64_CONSOLE
|
||||
}
|
||||
}
|
||||
#[cfg(all(windows, target_arch = "aarch64"))]
|
||||
"aarch64" => {
|
||||
if is_gui {
|
||||
LAUNCHER_AARCH64_GUI
|
||||
} else {
|
||||
LAUNCHER_AARCH64_CONSOLE
|
||||
}
|
||||
}
|
||||
#[cfg(windows)]
|
||||
arch => {
|
||||
return Err(Error::UnsupportedWindowsArch(arch));
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
arch => &[],
|
||||
};
|
||||
|
||||
let mut payload: Vec<u8> = Vec::new();
|
||||
|
@ -1163,10 +1178,7 @@ mod test {
|
|||
|
||||
use indoc::{formatdoc, indoc};
|
||||
|
||||
use super::{
|
||||
parse_key_value_file, parse_wheel_version, read_record_file, relative_to, Script,
|
||||
LAUNCHER_X86_64_CONSOLE, LAUNCHER_X86_64_GUI,
|
||||
};
|
||||
use super::{parse_key_value_file, parse_wheel_version, read_record_file, relative_to, Script};
|
||||
|
||||
#[test]
|
||||
fn test_parse_key_value_file() {
|
||||
|
@ -1294,17 +1306,34 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(windows, target_arch = "x86_64"))]
|
||||
fn test_launchers_are_small() {
|
||||
// At time of writing, they are 15872 bytes.
|
||||
assert!(
|
||||
LAUNCHER_X86_64_GUI.len() < 20 * 1024,
|
||||
super::LAUNCHER_X86_64_GUI.len() < 20 * 1024,
|
||||
"GUI launcher: {}",
|
||||
LAUNCHER_X86_64_GUI.len()
|
||||
super::LAUNCHER_X86_64_GUI.len()
|
||||
);
|
||||
assert!(
|
||||
LAUNCHER_X86_64_CONSOLE.len() < 20 * 1024,
|
||||
super::LAUNCHER_X86_64_CONSOLE.len() < 20 * 1024,
|
||||
"CLI launcher: {}",
|
||||
LAUNCHER_X86_64_CONSOLE.len()
|
||||
super::LAUNCHER_X86_64_CONSOLE.len()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(windows, target_arch = "aarch64"))]
|
||||
fn test_launchers_are_small() {
|
||||
// At time of writing, they are 14848 and 14336 bytes.
|
||||
assert!(
|
||||
super::LAUNCHER_AArch64_GUI.len() < 20 * 1024,
|
||||
"GUI launcher: {}",
|
||||
super::LAUNCHER_AArch64_GUI.len()
|
||||
);
|
||||
assert!(
|
||||
super::LAUNCHER_AArch64_CONSOLE.len() < 20 * 1024,
|
||||
"CLI launcher: {}",
|
||||
super::LAUNCHER_AArch64_CONSOLE.len()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,3 +112,19 @@ Two approaches that are reasonably likely to work:
|
|||
Hopefully in the future as `#![no_std]` develops, this will get smoother.
|
||||
|
||||
Also, sometimes it helps to fiddle with optimization levels.
|
||||
|
||||
# Cross compiling from linux
|
||||
|
||||
Install [cargo xwin](https://github.com/rust-cross/cargo-xwin). Use your
|
||||
package manager to install LLD and add the rustup targets:
|
||||
|
||||
```shell
|
||||
sudo apt install llvm clang lld
|
||||
rustup target add x86_64-pc-windows-msvc
|
||||
rustup target add aarch64-pc-windows-msvc
|
||||
```
|
||||
|
||||
```shell
|
||||
cargo +nightly xwin build --release -Z build-std=core,panic_abort,alloc -Z build-std-features=compiler-builtins-mem --target x86_64-pc-windows-msvc
|
||||
cargo +nightly xwin build --release -Z build-std=core,panic_abort,alloc -Z build-std-features=compiler-builtins-mem --target aarch64-pc-windows-msvc
|
||||
```
|
||||
|
|
BIN
crates/puffin-trampoline/trampolines/puffin-trampoline-aarch64-console.exe
Executable file
BIN
crates/puffin-trampoline/trampolines/puffin-trampoline-aarch64-console.exe
Executable file
Binary file not shown.
BIN
crates/puffin-trampoline/trampolines/puffin-trampoline-aarch64-gui.exe
Executable file
BIN
crates/puffin-trampoline/trampolines/puffin-trampoline-aarch64-gui.exe
Executable file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue