Closed ym1234 closed 4 years ago
Actually I'm developing alass
on Arch Linux and cross-compile the Windows version from there. The problem is that each Linux distribution is different. An alass binary for one distribution might not work on another.
AppImage, FlatPak and Snap alleviate this problem, but need a build setup which I haven't come around to do yet.
The "standard way" of distribution in the Linux world is finding a package maintainer which compiles the binary for you. I'm only going to create an Arch Linux AUR package at most.
On most distributions however, something like this should do it for now (less than ideal, but not the worst):
sudo apt/yum/pacman install gcc cargo rust
cargo install alass-cli
The only c library that alass currently dynamically links against is libc, so it is easy to create a fully static binary.
On arch that would be by installing the musl
package and then following the instructions here the resulting binary will work on all linux distros.
You can't fully statically link against glibc because of this, so we have to use musl.
cargo build --release --target x86_64-unknown-linux-musl
ldd target/release/alass-cli
prints
linux-vdso.so.1 (0x00007ffdb2dec000)
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fd0ab7f0000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007fd0ab7e5000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fd0ab7c4000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fd0ab7aa000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fd0ab5e7000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fd0ab4a1000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007fd0ab9f3000)
Creating an new empty cargo project with musl and then running ldd
prints
not a dynamic executable
So there are probably some dependencies that pull in dynamic libraries. If there's an easy fix for that (like a magic cargo flag that will always not link these libraries no matter the dependencies), I will provide a linux binary. But: as soon as problems occur with running this binary on some distributions or building it, it will have to go.
In my opinion, the proper Linux way is using the package manager with trusted repositories.
$ ldd target/x86_64-unknown-linux-musl/release/alass-cli
not a dynamic executable
There it is! I didn't know alass-cli with musl was only generated in target/x86_64-unknown-linux-musl
and not in target/release
(but it makes sense, since it might be a totally different architecture). Let's hope the static binary is indeed portable.
It is portable :p It won't fail unless the person is using some really really old linux kernel
I think so too. But that's just a thing I have to see with my own eyes :)
The static linux binary for alass
2 is now available.
Thanks!
Installing rust to build this is kind of a pain