feat: more rust in trampoline (#5750)

## Summary

This is an experimental PR to replace more unsafe calls with more rust
while still trying to keep the binary size small enough. These changes
roughly increase the size of the trampolines to about 40kb~. This is a
alternate PR to https://github.com/astral-sh/uv/pull/5751.

The primary changes here include
* Switch to use rust path components for ease of path management
* Leverage `std::process::exit` for process exit and cleanup
* Use `std::io::Error::last_os_error` for IO Errors to remove
`FormatMessage` complexity
* Use `std::env::current_exe` to get the current executable instead of
`GetModuleFileNameA`

## Test Plan

Added one more existing test case to trampoline tests.
Still need to verify dunce::canonicalize is desired or not on
find_python_exe.

---------

Co-authored-by: konstin <konstin@mailbox.org>
This commit is contained in:
samypr100
2024-08-07 04:19:38 -04:00
committed by GitHub
parent d0b16f9018
commit 2cd63f06dc
13 changed files with 109 additions and 210 deletions

View File

@@ -347,6 +347,7 @@ jobs:
if: matrix.target-arch == 'x86_64'
run: |
cargo xwin bloat --release --target x86_64-pc-windows-msvc | \
grep -v -i -E 'core::fmt::write|core::fmt::getcount' | \
grep -q -E 'core::fmt|std::panicking|std::backtrace_rs' && exit 1 || exit 0
env:
XWIN_ARCH: "x86_64"