spacedentist / spr

Submit pull requests for individual, amendable, rebaseable commits to GitHub
https://getcord.github.io/spr/
MIT License
378 stars 33 forks source link

Turn off unused features to reduce the binary's dependencies #62

Closed sven-of-cord closed 2 years ago

sven-of-cord commented 2 years ago

git2 is capable of connecting to remote repositories, but we don't use it for that. This commit switches off these features. It also changes the used TLS implementation from openssl (which is linked dynamically at runtime) to rustls. With these changes, we get rid of the dependency on openssl completely.

Before this commit, I checked the runtime linking dependencies of my spr build:

sven@peppermint:~/code/spr$ ldd target/release/spr
    linux-vdso.so.1 (0x00007ffc68bd0000)
    libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f63fa931000)
    libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f63fa63c000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f63fa61f000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f63fa5ff000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f63fa5de000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f63fa49a000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f63fa492000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f63fa2b9000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f63fb286000)

With this commit:

sven@peppermint:~/code/spr$ ldd target/release/spr
    linux-vdso.so.1 (0x00007fff2e5c3000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f5ba177b000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5ba175b000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5ba173a000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5ba15f6000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5ba15f0000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5ba1417000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f5ba2109000)

So we removed the dependency on libssl and libcrypto.

Test Plan: cargo build, use the spr binary build for submitting this PR to check that spr can still connect to the GitHub API