DataDog / datadog-static-analyzer

Datadog Static Analyzer
https://docs.datadoghq.com/static_analysis/
Apache License 2.0
100 stars 12 forks source link

[STAL-2781] Build release Linux binary on Ubuntu 20.04 #516

Closed jasonforal closed 1 week ago

jasonforal commented 2 weeks ago

What problem are you trying to solve?

We currently compile our Linux release binaries on GitHub's ubuntu-latest runner, which resolves to ubuntu 24.04. Because 24.04 uses a newer version of glibc, it compiles binaries that expect more recent versions of glibc (currently, v8 expects pthread_getattr_np@GLIBC_2.32). This leads to an error when trying to run the binary on older versions of Linux (specifically Ubuntu 20.04, which ships with glibc 2.31)

Image of a failed attempt to execute the binary on Ubuntu 20.04

What is your solution?

Building on Ubuntu 20.04 generates a binary that now expects glibc 2.2.5:

❯ greadelf -a datadog-static-analyzer-server | grep pthread_getattr_np
000003efe688  011700000006 R_X86_64_GLOB_DAT 0000000000000000 pthread_getattr_np@GLIBC_2.2.5 + 0

And thus the binaries now work on Ubuntu 20.04.

You can confirm that this modification to the release workflow functions correctly by looking at a pre-release that I just generated to test it:

image image

We need to add an extra step to set up the container, as the base image is missing the packages that GitHub installs by default on a non-containerized runner (curl, gh, etc).

Alternatives considered

What the reviewer should know

jasonforal commented 2 weeks ago

Special thanks to @robertohuertasm for debugging this and identifying the solution

robertohuertasm commented 2 weeks ago

Thank you @jasonforal for your nice words ❤️ and for your thorough work on this issue 🙌🏻 . It's always a pleasure to collaborate with you!

jasonforal commented 2 weeks ago

Yes, for the APIs we're using, newer versions of glibc have backwards-compatibility. So it works on 22.04, 24.04, etc.