Recent

Author Topic: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found  (Read 69901 times)

WayneSherman

  • Sr. Member
  • ****
  • Posts: 254
Re: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
« Reply #240 on: January 14, 2025, 07:21:26 pm »
I heard last year that versioned linking would be implemented by one the the compiler devs. That is why I stopped myself in diving deeper into this.
However, I think that the addition of versioned symbols should be done by the compiler. If done like this, all compiled sources will be versioned without changes needed into these sources.

If a project declares its own internal libc declarations, I think they should be left alone and used without modification.  How can that be controlled?

If a project use the RTL provided libc declarations, is there a way that versioned or unversioned libc symbols can be selected simply with a conditional compilation define?

How to handle linking against a precompiled RTL?  In that case libc versioning depends on how the RTL was compiled.
« Last Edit: January 14, 2025, 07:30:14 pm by WayneSherman »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1793
Re: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
« Reply #241 on: January 14, 2025, 09:00:28 pm »
Well. You can see the compiler patch here.
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/blob/master/fpcuptools/glibc/glibc_compat_3_2_2.patch
As the sources show, the patch checks for unversioned symbols and will skip versioned symbols.

TRon

  • Hero Member
  • *****
  • Posts: 4296
Re: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
« Reply #242 on: March 25, 2025, 08:26:08 pm »
Heads up, next version 2.38 coming up.
Today is tomorrow's yesterday.

Fred vS

  • Hero Member
  • *****
  • Posts: 3531
    • StrumPract is the musicians best friend
Re: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
« Reply #243 on: March 26, 2025, 02:04:28 pm »
Question to Gork AI:

Q: libc will release glibc_2.38.  What are the difference vs glicbc_2.2.5? Could it be a problem for fpc using that glibc_2.38? It was ok with glibc_2.34.

A: Your situation involves a complex interplay between the Free Pascal Compiler (FPC), glibc versions, and symbol versioning, so let’s break it down and address your question about whether glibc 2.38 could pose problems when FPC doesn’t explicitly assign a glibc symbol version.

Background: Symbol Versioning and glibc

glibc uses symbol versioning to maintain backward compatibility. Each version of glibc (e.g., 2.2.5, 2.34, 2.38) introduces a symbol table with versioned symbols (e.g., malloc@GLIBC_2.2.5, malloc@GLIBC_2.34). When a program is linked against glibc, the linker (ld) assigns symbol versions to the functions it uses. If the code doesn’t explicitly specify a version (via something like __asm__(".symver malloc,malloc@GLIBC_2.2.5")), the linker defaults to the latest symbol version available in the glibc installed on the build system. This can lead to compatibility issues when the binary runs on a system with a different glibc version.

In your case:

FPC historically built against glibc 2.2.5 and doesn’t explicitly assign symbol versions.

Without explicit versioning, the linker on a system with glibc 2.34 or 2.38 will bind to symbols like malloc@GLIBC_2.34 or
malloc@GLIBC_2.38 if that’s the latest version present during compilation.

The glibc developers recommend explicitly assigning GLIBC_2.2.5 symbols in FPC’s code to ensure compatibility across all glibc versions, as 2.2.5 is the baseline that all later versions support.

Your Observations and Setup

glibc 2.34 Works Fine: You’ve noticed that building with glibc 2.34 doesn’t seem to cause issues. This is likely because glibc maintains strong backward compatibility, and symbols from 2.2.5 are still available in 2.34. Most core functions haven’t changed their ABI significantly, so binaries linked against 2.34 symbols often run fine on systems with 2.34 or newer glibc (as long as the runtime glibc is >= 2.2.5).

Will glibc 2.38 Cause Problems Without Explicit Versioning?

If FPC doesn’t assign symbol versions and you compile on a system with glibc 2.38, the linker will use the latest symbols (e.g., malloc@GLIBC_2.38). Here’s what could happen:

Potential Issues

Running on Older Systems:


If you distribute the binary to a system with glibc < 2.38 (e.g., 2.34 or 2.2.5), it will fail to run if it depends on symbols introduced or modified in 2.38 that aren’t present in earlier versions. For example, glibc 2.38 adds new functions like strlcpy and strlcat, and while these are unlikely to be used implicitly by FPC, any subtle ABI changes could break compatibility.
Historically, glibc avoids breaking ABI compatibility for existing symbols, but edge cases (e.g., changes in behavior or new dependencies) could still arise.

Deprecated Features:

glibc 2.38 deprecates features like libcrypt (requiring explicit enabling) and removes support for old mechanisms like
LD_ASSUME_KERNEL. If FPC’s runtime or generated code implicitly relies on these, you might encounter linker errors or runtime issues when building with 2.38.

Symbol Conflicts:

Without explicit versioning, a binary built with glibc 2.38 might request symbols that have evolved (e.g., improved thread-safety or new semantics). Running on a system with an older glibc could lead to with an older glibc could lead to unexpected behavior if the older symbol doesn’t match the expected implementation.

Why It Might Still Work

glibc’s commitment to backward compatibility means that symbols from 2.2.5 (e.g., malloc@GLIBC_2.2.5) are still provided in 2.38. If FPC only uses basic, stable functions (e.g., malloc, free, printf), the risk of incompatibility is low.

Your success with glibc 2.34 suggests that FPC’s usage of glibc is conservative, sticking to APIs that haven’t changed significantly.

-------------

So my conclusion: maybe it will be ok but maybe not.
« Last Edit: March 26, 2025, 06:27:52 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

TRon

  • Hero Member
  • *****
  • Posts: 4296
Re: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
« Reply #244 on: March 26, 2025, 10:55:08 pm »
Hi Fred,

No need to ask anyone, it is already a fact. 2.38 compiled exe's will not run on 2.36 or below without a solution such as mentioned patch (at least that is what was tested).

I merely mentioned it out of courtesy. We all know how this works in practice: a flood of messages mentioning the issue when  updates are eminent  :)
Today is tomorrow's yesterday.

robert rozee

  • Sr. Member
  • ****
  • Posts: 266
Re: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
« Reply #245 on: March 27, 2025, 06:51:45 am »
No need to ask anyone, it is already a fact. 2.38 compiled exe's [ELF binaries] will not run on 2.36 or below without a solution such as mentioned patch (at least that is what was tested). I merely mentioned it out of courtesy. We all know how this works in practice: a flood of messages mentioning the issue when  updates are eminent  :)

as per usual, everyone who could do something about it will cross their fingers and offer prayers to their preferred deity, hoping that nothing goes wrong beyond but a handful of the Lazarus user-base walk away when their binaries don't run on their customers' systems.

or perhaps this will be the day, when things do go horribly wrong, and blame will be laid at the feet of the Gods of GLIBC. of course, said Gs of G have already provided us with a solution - use BASE versions for all GLIBC symbols (along with creating a symlink to libdl.so.2 so the compile-time linker can find it).


cheers,
rob.
« Last Edit: March 27, 2025, 06:56:51 am by robert rozee »

TRon

  • Hero Member
  • *****
  • Posts: 4296
Re: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found
« Reply #246 on: March 27, 2025, 07:42:00 am »
Thank you for the correction Rob.

Other than that, I agree with the sentiment. Not to blame anything or anyone but the release schedule is of such pace that these kind of things are becoming more and more frightening.
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018