[llvm-dev] Targeting old glibc
Alexandre Bique via llvm-dev
llvm-dev at lists.llvm.org
Wed Oct 28 10:23:50 PDT 2020
On Wed, Oct 28, 2020 at 6:07 PM Fangrui Song <maskray at google.com> wrote:
>
> 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
Thank you, that is something useful!
> >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 @@.
Thank you, I wondered why there were two @.
> >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)).
I'm using Archlinux, and llvm 11 is in staging, I'll see if I can install it.
> 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.
Thank you very much. I'll try first with llvm 11 and if it does not
work, I'll come back with more information.
Regards,
Alexandre
More information about the llvm-dev
mailing list