Should I compile on an old Ubuntu version for maximum `glibc` portability?

Viewed 410

I am compiling my Rust code to be used as a CLI.

I want it installable on the widest possible range of x86_64-unknown-linux-gnu based systems, particularly Ubuntu's.

I am using a docker base image FROM rust:latest for builds, but this compile-host has glibc v2.29.

When I try to run the binary on another Debian system with (Debian GLIBC 2.28-10) 2.28 it exits with an error:

clix: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.29' not found (required by clix)

So does this mean I need to compile on an old Ubuntu (ubuntu:16.04) to support Ubuntu 16 and newer?

Is there a an alternative where I can compile on rust:latest and have my binary work on old Ubuntu OS's?

Related:

1 Answers

So does this mean I need to compile on an old Ubuntu (ubuntu:16.04) to support Ubuntu 16 and newer?

This is the simplest solution.

Is there a an alternative where I can compile on rust:latest and have my binary work on old Ubuntu OS's?

Yes: you can build yourself a Linux-to-older-Linux cross-compiler, and use it to build your binary on rust:latest. This isn't entirely trivial thing to do, and usually "build on older" is the more straightforward solution.

Related