taiki-e / upload-rust-binary-action

GitHub Action for building and uploading Rust binary to GitHub Releases.
Apache License 2.0
235 stars 20 forks source link

Support (or document) fully-static builds with 'musl' #29

Closed chshersh closed 1 year ago

chshersh commented 1 year ago

First of all, thanks a lot for working on this GitHub Action! šŸ™šŸ» It's amazing how smoothly it works šŸ¤Æ I was able to configure binary releases with GitHub Actions in a matter of minutes and everything worked even better than I expected.

When creating a release of my tool, I've noticed that the asset has name tool-x86_64-unknown-linux-gnu.tar.gz and that the binary is actually dynamically linked:

$ ldd tool 
    linux-vdso.so.1 (0x00007fff1e19e000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f89aa7ac000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f89aa7a7000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f89aa6c0000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f89aa6bb000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f89aa493000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f89aaaee000)

Is there a way to create statically linked binaries with musl?

Here is my release workflow:


I've noticed an example usage of musl in the following repository:

          - target: x86_64-unknown-linux-gnu
          - target: x86_64-unknown-linux-musl

But I'm not quite sure how it works šŸ¤” Could you explain how can I use this workflow to link my binary statically?

Thanks a lot! šŸ™šŸ»

taiki-e commented 1 year ago

*-unknown-linux-musl* except for mips uses static-linking by default, so (basically) you only need to specify the *-unknown-linux-musl* target.

See also cross-compilation example.

chshersh commented 1 year ago

@taiki-e Thanks a lot for the quick response! This is exactly what I was looking for šŸ’