nickbeth / wsl-usb-manager

A fast and light GUI for usbipd-win. Manage connecting USB devices to WSL.
MIT License
29 stars 2 forks source link

Release build is crashing on startup #8

Open JPHutchins opened 2 hours ago

JPHutchins commented 2 hours ago

I was working on the MSI. It's working OK, but I've discovered that --release builds are crashing on startup, whether installed via MSI or not. Debug builds work fine both with and without the installer.

cargo run --release
warning: field `stub_instance_id` is never read
  --> src\usbipd.rs:71:9
   |
51 | pub struct UsbDevice {
   |            --------- field in this struct
...
71 |     pub stub_instance_id: Option<String>,
   |         ^^^^^^^^^^^^^^^^
   |
   = note: `UsbDevice` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default

warning: `wsl-usb-manager` (bin "wsl-usb-manager") generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.15s
     Running `target\release\wsl-usb-manager.exe`
error: process didn't exit successfully: `target\release\wsl-usb-manager.exe` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)
JPHutchins commented 2 hours ago

I've add this .cargo/config.toml

[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

[profile.release]
codegen-units = 1
lto = true
opt-level = 0
debug = false
rpath = false
panic = 'unwind'
incremental = false
overflow-checks = true

It crashes on anything but opt-level 0.

JPHutchins commented 2 hours ago

I think it makes sense to leave optimizations at 0 for now. It's not like the code is huge or taking up a bunch of resources.