hannobraun / vndf-2020

Von Neumann Defense Force - a game about spaceships
2 stars 0 forks source link

Build a statically linked Linux binary using MUSL #12

Open hannobraun opened 4 years ago

hannobraun commented 4 years ago

The current Linux binaries that are built by the continuous deployment system dynamically link to libc, which will likely cause problems on some Linux systems. It would be better to link them statically using MUSL.

I tried to do it, but there was some problem with libudev-sys, which complained about cross-compiling. I didn't follow up.

hannobraun commented 4 years ago

Now that we no longer use ggez, the libudev-sys dependency is gone. Instead, x11 is complaining:

error: failed to run custom build command for `x11 v2.18.2`

Caused by:
  process didn't exit successfully: `/home/hanno/Projects/vndf/target/release/build/x11-1412353dfb426d46/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CrossCompilation', /home/hanno/.cargo/registry/src/github.com-1ecc6299db9ec823/x11-2.18.2/build.rs:36:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This can be worked around by setting an environment variable: PKG_CONFIG_ALLOW_CROSS=1

However, the resulting binary panics:

$ ./target/release-binaries/vndf-launcher-x86_64-unknown-linux-musl.bin 
thread 'main' panicked at 'Failed to initialize any backend! Wayland status: NoWaylandLib X11 status: LibraryOpenError(OpenError { kind: Library, detail: "opening library failed (Dynamic loading not supported); opening library failed (Dynamic loading not supported); opening library failed (Dynamic loading not supported); opening library failed (Dynamic loading not supported)" })', /home/hanno/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.22.1/src/platform_impl/linux/mod.rs:569:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace