m1guelpf / plz-cli

Copilot for your terminal
MIT License
1.59k stars 78 forks source link

Add a statically-linked musl file to releases #19

Closed juan-leon closed 1 year ago

juan-leon commented 1 year ago

Having a statically linked binary is useful for being able to use tool in systems with old glibc versions.

m1guelpf commented 1 year ago

@juan-leon Could you elaborate a bit more on why this is useful?

juan-leon commented 1 year ago

The current releases have a binary dinamically linked. That is: binary reuses libraries supposedly present in the system and cannot be used in those systems without those libraries.

Github actions run in a modern Ubuntu (runs-on: ubuntu-latest, as per your workflow file). So linker assumes a modern version of those libraries present in the systems where tool will execute.

Unfortunately this is not always the case (for instance, in older versions of Ubuntu like I use).

This is the output of ldd on my system for the plz I downloaded fro your releases page

$ ldd plz
./plz: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by ./plz)
./plz: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./plz)
./plz: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./plz)
./plz: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.29' not found (required by ./plz)
./plz: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by ./plz)
./plz: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./plz)
        linux-vdso.so.1 (0x00007ffe2774b000)
        libgtk3-nocsd.so.0 => /usr/lib/x86_64-linux-gnu/libgtk3-nocsd.so.0 (0x00007f04f6ad2000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f04f68ba000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f04f651c000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f04f612b000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f04f73b9000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f04f5f27000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f04f5d08000)

(and of course the binary does not work)

This is the output of ldd with the musl binary I generated with my fork of your project:

$ ldd /home/juanleon/bin/plz
        statically linked

File is somewhat bigger (14M vs 13M), but it can run in every linux system with arch amd64/i686.

Often widely used tools built with rust politely include a musl version in the releases page (in addition to the dynamically linked version) for those that have old (or not so mainstream) linux systems. Examples:

Hope it helps. Please let me know if you need more info.

GitHub
Releases · sharkdp/bat
A cat(1) clone with wings. Contribute to sharkdp/bat development by creating an account on GitHub.
GitHub
Releases · BurntSushi/ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore - BurntSushi/ripgrep