a-scie / ptex

Ship gouged out scies that repair their base on 1st run by fetching missing files.
Apache License 2.0
7 stars 2 forks source link

Release a musl binary for Linux #15

Closed jsirois closed 1 year ago

jsirois commented 1 year ago

The existing gnu libc binary:

$ cargo run --release -p package .
    Finished release [optimized] target(s) in 0.02s
     Running `target/release/package .`
Wrote the ptex to ./ptex-linux-x86_64
$ file ptex-linux-x86_64
ptex-linux-x86_64: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=528c3e1235c9aebdf6fc7783db656cfb5d7c61e4, for GNU/Linux 3.2.0, stripped
$ wc -c ptex-linux-x86_64
4387456 ptex-linux-x86_64
$ ldd ptex-linux-x86_64
        linux-vdso.so.1 (0x00007ffc42946000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f579239c000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f57922b5000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f579208d000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f57927fd000)

Vs musl:

$ cargo build --target x86_64-unknown-linux-musl --release
    Finished release [optimized] target(s) in 0.01s
$ file target/x86_64-unknown-linux-musl/release/ptex
target/x86_64-unknown-linux-musl/release/ptex: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), static-pie linked, BuildID[sha1]=45d390063d3be4527614f224d24af5770aa31f42, stripped
$ wc -c target/x86_64-unknown-linux-musl/release/ptex
3505904 target/x86_64-unknown-linux-musl/release/ptex
$ ldd target/x86_64-unknown-linux-musl/release/ptex
        statically linked

The only detail to tackle is that getting the --target to stick for cargo run -p package-style builds has, so far, proved a mystery. May need to re-jigger how package works or come up with something else.

jsirois commented 1 year ago

Released in 0.2.0: https://github.com/a-scie/ptex/releases/tag/v0.2.0