[llvm-dev] Targeting old glibc

Fangrui Song via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 28 10:07:48 PDT 2020


On 2020-10-28, Alexandre Bique via llvm-dev wrote:
>Hi,
>
>I wonder what is the right way to target an old glibc?
>
>I have a machine which is up to date (glibc 2.32 and clang+lld 10.0.1).
>
>So far I've been able to target older glibc by having a C file containing:
>
>__asm__(".symver powf,powf at GLIBC_2.2.5");
>__asm__(".symver expf,expf at GLIBC_2.2.5");
>__asm__(".symver exp2f,exp2f at GLIBC_2.2.5");
>__asm__(".symver log2f,log2f at GLIBC_2.2.5");
>__asm__(".symver logf,logf at GLIBC_2.2.5");
>
>__asm__(".symver log,log at GLIBC_2.2.5");
>__asm__(".symver log2,log2 at GLIBC_2.2.5");
>__asm__(".symver exp,exp at GLIBC_2.2.5");
>__asm__(".symver exp2,exp2 at GLIBC_2.2.5");
>__asm__(".symver pow,pow at GLIBC_2.2.5");

This works. This approach is used by https://github.com/wheybags/glibc_version_header

>But after updating clang and re-creating the cmake build directory it
>does not work anymore and I have dependencies toward glibc 2.29:
>
>nm -D /home/abique/.u-he/Zebra2/Zebra2.64.so  | grep GLIBC.*29
>                 U exp@@GLIBC_2.29
>                 U exp2@@GLIBC_2.29
>                 U log@@GLIBC_2.29
>                 U pow@@GLIBC_2.29

I reported a display problem. top-of-trunk binutils will display
undefined versioned symbols as @ instead of @@.

>At first I thought that it was due to LTO, but even after disabling
>LTO the problem still occurs.
>
>How to solve it?
>Is there a better approach to this problem?
>
>Maybe lld never supported it, and now it is using lld to link instead
>of the GNU linker?

LLD has good support for version symbols (you need a commit after https://reviews.llvm.org/D80059 (in 11.0.0, but not in 10.x)).

There is insufficient information to form a solution.
You may add -Wl,-y,exp,-y,exp at GLIBC_2.29,-y,exp at GLIBC_2.2.5 to figure
out why exp at GLIBC_2.29 instead of exp at GLIBC_2.2.5 is picked.

>Anyway, I'd like to solve this with the LLVM tools while full LTO is
>enabled, which requires lld right?
>
>Many thanks.
>
>Regards,
>Alexandre Bique
>_______________________________________________
>LLVM Developers mailing list
>llvm-dev at lists.llvm.org
>https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list