kaegi / alass

"Automatic Language-Agnostic Subtitle Synchronization"
GNU General Public License v3.0
1.03k stars 52 forks source link

Linux build? #5

Closed ym1234 closed 4 years ago

ym1234 commented 5 years ago

Installing rust to build this is kind of a pain

kaegi commented 5 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
ym1234 commented 5 years ago

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.

ym1234 commented 5 years ago

You can't fully statically link against glibc because of this, so we have to use musl.

kaegi commented 5 years ago
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.

kaegi commented 5 years ago
$ 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.

ym1234 commented 5 years ago

It is portable :p It won't fail unless the person is using some really really old linux kernel

kaegi commented 5 years ago

I think so too. But that's just a thing I have to see with my own eyes :)

kaegi commented 4 years ago

The static linux binary for alass 2 is now available.

ym1234 commented 4 years ago

Thanks!