Recent

Author Topic: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue  (Read 16588 times)

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #75 on: October 25, 2023, 04:06:57 pm »
Success !!
Screenshot of app build with FPC 3.2.2 and Lazarus trunk on Manjaro lates with glibc 2.35.
The app runs on Ubuntu 8 dated from 2008 !!

Good news and nice work!

Did you have to modify the fnmatch delcaration?

1. edit fnmatch.inc to remove the reference to gtklib:
Code: Pascal  [Select][+][-]
  1. { Match STRING against the filename pattern PATTERN,
  2.    returning zero if it matches, FNM_NOMATCH if not.   }
  3. function fnmatch(__pattern: char; __string: char;
  4.   __flags: gint): gint; cdecl; external; // gtklib;
« Last Edit: October 25, 2023, 04:13:20 pm by WayneSherman »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1718
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #76 on: October 25, 2023, 04:36:05 pm »
Thanks.
No changes were needed regarding fnmatch. Seems not used anymore.

Extra.
The included screenshot shows fpcupdeluxe (cross-compiled from Windows) running on Ubuntu 5.10 using GTK1.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11280
  • FPC developer.
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #77 on: October 25, 2023, 04:54:21 pm »
Those filenames match the declarations in "lib_namesh.inc":
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/libc/src/lib_namesh.inc?ref_type=heads

Package libc is an historic Kylix emulation package. It is also 32-bit only.  See e.g. https://wiki.freepascal.org/libc_unit

Anything that hardcodes version numbers in source should be avoided as that makes a source prone to breaking over longer times.

This is also why the few things that are hardcoded like the elf loader ld-linux.so etc are overridable using parameters (like the -FD parameter), which can be stashed in the configuration (fpc.cfg)

« Last Edit: October 25, 2023, 04:58:20 pm by marcov »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1718
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #78 on: October 25, 2023, 05:24:25 pm »
Quote
Did the -XLA work?
I think this becomes useful in the future when all libs are merged into libc !
So I did not use it for the backwards compatibility test.

Seenkao

  • Hero Member
  • *****
  • Posts: 539
    • New ZenGL.
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #79 on: October 25, 2023, 08:41:14 pm »
Я заглянул в собранные бинарные файлы и libdl.so нет в новых версиях ELF. Файлы не абсолютно идентичны, но подобны.

Google translate:
I looked at the compiled binaries and libdl is not in the newer versions of ELF. The files are not absolutely identical, but they are similar.
Quote from: old ELF, libdl.so - true
ITM_deregisterTMCloneTable�_ITM_registerTMCloneTable�__errno_location�__gmon_start__�dlclose�dlsym�dladdr�dlopen�XLookupKeysym�XNextEvent�XDestroyWindow�XSync�XMapWindow�XCreatePixmap�XSetWMNormalHints�
XCreateWindow�XQueryPointer�XFree�XResizeWindow�XSetWMProtocols�XCreatePixmapCursor�XSetWMName�XSetClassHint�XInternAtom�XFreeCursor�XSendEvent�XPending�Xutf8TextListToTextProperty�XCreateColormap�XMoveWindow�XSetWMIconName�XOpenDisplay�XCloseDisplay�
XDefineCursor�XRRUpdateConfiguration�XRRSetScreenConfig�XRRConfigCurrentConfiguration�XRRGetScreenInfo�XRRSizes�XRRSelectInput�XRRQueryExtension�XRRFreeScreenConfigInfo�XRRRates�gdk_screen_get_monitor_geometry�gdk_screen_get_default�gdk_screen_get_n_monitors�gtk_init�
gtk_debug_flags�deflate�deflateEnd�glEnable�glGenTextures�glVertex2f�glColor4f�glClearDepth�glColor4ubv�glMatrixMode�glPushMatrix�glHint�glTexEnvi�glPixelStorei�glClearColor�glTexImage2D�glTranslatef�glDepthFunc�glGetIntegerv�glScalef�glPopMatrix�glViewport�glEnd�glDisable�glDeleteTextures�
glOrtho�glBlendFunc�glRotatef�glAlphaFunc�glClear�glBegin�glTexSubImage2D�glLoadIdentity�glShadeModel�glGetString�glTexParameterf�glTexParameteri�glTexCoord2f�glGetTexImage�glBindTexture�gluNewTess�gluGetString�gluBuild2DMipmaps�gluTessCallback�gluDeleteTess�gluPerspective�inflateEnd�
inflateInit2_�crc32�zError�inflate�deflateInit2_�sprintf�_IO_putc�fopen�strrchr�__strdup�realloc�memchr�getpid�chmod�mkstemp�sched_yield�strlen�memcmp�clearerr�memcpy�fclose�strtoul�malloc�umask�strcasecmp�ftello�remove�__ctype_b_loc�__fxstat�fileno�fwrite�fread�gettimeofday�rename�
localtime�mktime�fdopen�qsort�__cxa_finalize�__xstat�strcmp�strerror�__libc_start_main�ferror�fseeko�snprintf�free�libpthread.so.0�libdl.so.2�libX11.so.6�libXrandr.so.2�libgdk-x11-2.0.so.0�libgtk-x11-2.0.so.0�libgobject-2.0.so.0�libglib-2.0.so.0�libgthread-2.0.so.0�libgmodule-2.0.so.0�libgdk_pixbuf-2.0.so.0�
libpango-1.0.so.0�libcairo.so.2�libatk-1.0.so.0�libGL.so.1�libm.so.6�libGLU.so.1�libz.so.1�libc.so.6�_edata�__bss_start�_end�GLIBC_2.2.5�GLIBC_2.3

Quote from: new ELF, libdl.so - False
_ITM_deregisterTMCloneTable�__gmon_start__�_ITM_registerTMCloneTable�XGrabKeyboard�XLookupKeysym�XSetGraphicsExposures�XNextEvent�XGrabPointer�XDestroyWindow�XSync�XMapWindow�XCreatePixmap�XSetWMNormalHints�XCreateWindow�XQueryPointer�XFree�
XResizeWindow�_end�XSetWMProtocols�XCreatePixmapCursor�XSetWMName�XSetClassHint�XInternAtom�XFreeCursor�XClearArea�XSendEvent�XWarpPointer�XPending�Xutf8TextListToTextProperty�XCreateColormap�XMoveWindow�XSynchronize�XSetWMIconName�XOpenDisplay�
XCloseDisplay�XDefineCursor�XGetWindowProperty�XInternAtoms�XRRUpdateConfiguration�XRRSetScreenConfig�XRRConfigCurrentConfiguration�XRRGetScreenInfo�XRRSizes�XRRSelectInput�XRRQueryExtension�XRRFreeScreenConfigInfo�XRRRates�glEnable�glGenTextures�glVertex2f�
glColor4f�glReadPixels�glClearDepth�glColor4ubv�glMatrixMode�glVertex2fv�glPushMatrix�glHint�glTexEnvi�glPixelStorei�glClearColor�glTexImage2D�glTranslatef�glDepthFunc�glDepthMask�glGetIntegerv�glScalef�glScissor�glColorMask�glPopMatrix�glViewport�glEnd�glDisable�
glDeleteTextures�glOrtho�glBlendFunc�glRotatef�glAlphaFunc�glClear�glBegin�glTexCoord2fv�glCopyTexSubImage2D�glTexSubImage2D�glLoadIdentity�glShadeModel�glGetString�glTexParameterf�glTexParameteri�glTexCoord2f�glGetTexImage�glBindTexture�floor�sincosf�atan�log�acosf�
ldexp�pow�sin�sincos�inflateEnd�inflateInit2_�deflate�inflateInit_�crc32�zError�inflate�deflateInit2_�deflateEnd�gluNewTess�gluGetString�gluBuild2DMipmaps�gluTessEndPolygon�gluTessEndContour�gluTessCallback�gluDeleteTess�gluTessVertex�gluPerspective�gluTessBeginPolygon�
gluTessBeginContour�strcpy�snprintf�__xstat�chmod�dladdr�__ctype_toupper_loc�free�fread�exit�__strdup�dlclose�strrchr�ferror�memmove�gettimeofday�clearerr�fopen�strlen�__ctype_b_loc�getpid�mkstemp�umask�realloc�strcat�strcasecmp�malloc�__libc_start_main�sched_yield�
remove�fdopen�mktime�memchr�__fxstat�dlsym�dlopen�__cxa_finalize�sprintf�localtime�ftell�strerror�calloc�memcmp�fclose�_IO_putc�memset�rename�ftello�strtoul�memcpy�fileno�fwrite�strcmp�qsort�fseek�fseeko�__errno_location�libX11.so.6�libXrandr.so.2�libGL.so.1�libm.so.6�
libz.so.1�libGLU.so.1�libc.so.6�_edata�__bss_start�GLIBC_2.29�GLIBC_2.2.5�GLIBC_2.34�GLIBC_2.3

Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Seenkao

  • Hero Member
  • *****
  • Posts: 539
    • New ZenGL.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1718
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #81 on: October 26, 2023, 08:10:55 am »
@Seenkao
For sure that is the recommended way of versioning. But that requires source changes of the app to be compiled.
And the goal here is to use compiler magic to accomplish this. Only apply the -XLC switch and the compiler will do the versioning for you (if all works as expected).

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1718
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #82 on: October 27, 2023, 02:20:08 pm »
As promised, I have included the legacy linking option into fpcupdeluxe 2.4.0bp.

The compiler patch : https://github.com/LongDirtyAnimAlf/fpcupdeluxe/blob/master/patches/patchfpc/glibc_compat_3_2_2.patch
The version file: https://github.com/LongDirtyAnimAlf/fpcupdeluxe/blob/master/patches/patchfpc/glibc.inc

Fpcupdeluxe will do (on Linux):
Get the FPC 3.2.2 sources.
Patch them with the compiler patch. Add the version file.
Build all FPC. All FPC binaries will function as usual.
Rebuild the RTL and Packages with the legacy-switch enabled + -defined FPC_USE_LIBC and install them in a legacy units directory.
Get Lazarus trunk/main.
Patch Lazarus a little bit to work with libc under Linux.
Build the whole of Lazarus under legacy conditions.

If all ok, Lazarus will now produce legacy binaries.
In fact, Lazarus itself is legacy.

To summarize.
All glibc-call are versioned to the lowest version possible.
No syscall are used anymore. All done through libc.
A new compiler switch is added : -XLC.
The linker adds some libraries as needed to allow legacy Linux systems to resolve the libc functions used.

Special for Windows users.
The legacy linking will also work when cross-compiling.
Fpcupdeluxe 2.4.0bp will download libs from Fedora38. Legacy linking should allow you to get a binary that works also on very old systems.

https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/tag/v2.4.0bp

Please test if interested. With FPC 3.2.2 and Lazarus trunk/main.
Thanks

WayneSherman

  • Full Member
  • ***
  • Posts: 243
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #83 on: October 27, 2023, 02:47:31 pm »
As promised, I have included the legacy linking option into fpcupdeluxe 2.4.0bp.
...
Please test if interested. With FPC 3.2.2 and Lazarus trunk/main.

Thank you DonAlfredo for your work on this.

I would like to thank Robert Rozee as well for his research, testing, and persistence on the issue of glibc symbol versioning.
« Last Edit: October 27, 2023, 03:06:32 pm by WayneSherman »

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1718
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #84 on: October 27, 2023, 02:56:46 pm »
Your welcome. And also thanks to Robert Rozee indeed !

As proof and for fun, the screenshot shows fpcupdeluxe running on Ubuntu 6.10, with a fresh install of FPC 2.6.0 and Lazarus 1.0.12.

;-)

TRon

  • Hero Member
  • *****
  • Posts: 2217
Re: FPC 3.2.2 / Lazarus 2.2.6 patch for GLIBC_2.34 versioning issue
« Reply #85 on: October 27, 2023, 07:08:34 pm »
Hi DonAlfredo:

Thank you for the update, and newly introduced feature.

I have but one concern. Using your "default" fpc.cfg file both my normal and legacy directories are searched. That 1) slows down compiling (hardly noticeable on smaller projects but still) and 2) someone not understanding might set the unit directories in the wrong order which would then defeat the purpose and 3) it makes linking in a wrong (lost) unit more likely to happen. I would personally have chosen for an else or ifndef FPC_LINK_COMPAT in the fpc.cfg file.

What are your thoughts on that ?

Other than that, it seems to work for me but I've only tested some simple examples. I want to make sure the FPC side is working 100% before the need to have yet another Lazarus rebuild installed on my system :)
« Last Edit: October 27, 2023, 07:12:03 pm by TRon »

 

TinyPortal © 2005-2018