diff --git a/.github/workflows/autobuild.yaml b/.github/workflows/autobuild.yaml index 812ee82..4db04ff 100644 --- a/.github/workflows/autobuild.yaml +++ b/.github/workflows/autobuild.yaml @@ -62,7 +62,7 @@ jobs: - name: linux os: ubuntu-latest preinstall: sudo apt-get install ninja-build libz-dev - cflags: -O3 -gline-tables-only -DNDEBUG + cflags: -O3 -gline-tables-only -DNDEBUG -include $GITHUB_WORKSPACE/.github/workflows/lib_compat.h cmake: > "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" diff --git a/.github/workflows/lib_compat.h b/.github/workflows/lib_compat.h new file mode 100644 index 0000000..ceaf504 --- /dev/null +++ b/.github/workflows/lib_compat.h @@ -0,0 +1,18 @@ +// This header forces the use of a particular version of glibc symbols. +// This can make the resulting binary portable to systems with older glibcs. +// +// It must be included in each TU, with CFLAGS="-include glibc_compat.h" etc. +// +// We only list symbols known to be used. This is paired with a test enforcing +// the max glibc symbol version. If the test fails, the list should be extended. +// Find the old alternatives version to target with e.g.: +// objdump -T /lib/x86_64-linux-gnu/lib{c,m,pthread,rt}.so.* | grep "\bexpf\b" + +#define FORCE_SYMBOL_VERSION(sym, version) \ + __asm__(".symver " #sym "," #sym "@" #version) + +FORCE_SYMBOL_VERSION(expf, GLIBC_2.2.5); +FORCE_SYMBOL_VERSION(log, GLIBC_2.2.5); +FORCE_SYMBOL_VERSION(pow, GLIBC_2.2.5); + +#undef FORCE_SYMBOL_VERSION