Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: use statically linked libssl #546

Merged
merged 1 commit into from
Jul 25, 2023
Merged

build: use statically linked libssl #546

merged 1 commit into from
Jul 25, 2023

Conversation

therapon
Copy link
Contributor

@therapon therapon commented Jul 24, 2023

We build our binaries on ubuntu:20 which uses libssl1.1 (through our direct dependency of reqwest). Libssl is dynamically linked and with systems moving to ubuntu:22 that has libssl3.0 our binary breaks. An example is Google's Collab.

We also build multiplatform linux docker image using cross-rs. cross-rs currently builds for ubuntu:20 on their master branch and there is currently an open PR (cross-rs/cross#973) to move to ubuntu:22.

The proposed solution with this PR is to enable the feature on reqwest that builds the libssl crate (and the libssl library) statically in the sparrow binaries rather than relying on dynamic linking to pick the system's libssl library.

We are not moving our CI to use ubuntu:22 until there we have a solution for building multiarch images on ubuntu:22 (through cross-rs or otherwise). Otherwise, if we move to ubuntu:22 today with out any other changes our docker image will break on linux on arm (anyone on a Mac with an M chip running a docker container).

  1. sparrow depends on reqwest which brings in libssl.
  2. added an if condition on the release CI that we missed

I verified that the binaries

Before:

❯ ldd sparrow-main
	linux-vdso.so.1 (0x00007fff56643000)
	libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f3387ee8000)
	libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f3383e00000)
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3383a00000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3387ec8000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3384321000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3383c1f000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f3387fa4000)

After

❯ ldd sparrow-main
        linux-vdso.so.1 (0x00007ffc7d3f2000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3989800000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f398d9aa000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3989b21000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f398961f000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f398d9dd000)

The final release binary size increases by 2MB

Before:

❯ ls -lh sparrow-main
-rwxr-xr-x 2 therapon therapon 85M Jul 24 13:09 sparrow-main

After

❯ ls -lh sparrow-main             
-rwxr-xr-x 2 therapon therapon 87M Jul 24 13:06 sparrow-main

@cla-bot cla-bot bot added the cla-signed Set when all authors of a PR have signed our CLA label Jul 24, 2023
Copy link
Collaborator

@kerinin kerinin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome

Copy link
Collaborator

@epinzur epinzur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fantastic. thank you!

@epinzur
Copy link
Collaborator

epinzur commented Jul 25, 2023

I think this fixes: #538

@therapon
Copy link
Contributor Author

I think this fixes: #538

I think so too. Was going to commit, release and verify before closing the issue.

@therapon therapon enabled auto-merge July 25, 2023 15:15
@therapon therapon added this pull request to the merge queue Jul 25, 2023
Merged via the queue into main with commit fafdf58 Jul 25, 2023
31 checks passed
@therapon therapon deleted the tsk-libssl-static branch July 25, 2023 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build cla-signed Set when all authors of a PR have signed our CLA sparrow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants