[fpc-pascal] Defining sonames?

Sven Barth pascaldragon at googlemail.com
Wed Aug 16 19:14:32 CEST 2017


On 14.08.2017 15:19, Fred van Stappen wrote:
> A concrete example.
> 
> A Linux/FreeBSD fpc release was compiled using the pascal headers for
> libX11.so.6 and using symlink libX11.so >> libX11.so.6.0.8.
> 
> This release was installed on a system (with libX11-dev too to make it
> work).
> 
> If, some time later, a system-update was done to the brand new version
> libX11.so.7.0.1,
> this will update also libX11-dev >> libX11.so >> libX11.so.7.0.1.
> 
> And using fpc, there will be a error because libX11.so does not point to
> a libX11.so.6 version.

Wrong. Take an empty program that includes the X unit:

=== code begin ===

program tsoname;

uses
  X;

begin

end.

=== code end ===

The X unit simply contains a "$linklib x11" which is equivalent to
importing specific functions using "external 'x11' name ...".

My system looks like this:

=== listing begin ===

lrwxrwxrwx 1 root root      15 27. Feb 17:54 /usr/lib/libX11.so ->
libX11.so.6.3.0
lrwxrwxrwx 1 root root      15 27. Feb 17:54 /usr/lib/libX11.so.6 ->
libX11.so.6.3.0
-rwxr-xr-x 1 root root 1306096 27. Feb 17:54 /usr/lib/libX11.so.6.3.0

=== listing end ===

And the resulting binary links this (objdump -x output)

=== listing begin ===

(...)
Dynamic Section:
  NEEDED               libX11.so.6
  NEEDED               libc.so.6
(...)

=== listing end ===

As you can see the program will work correctly as long as the
libX11.so.6 file exists (even though that is a symlink itself, but the
X11 project guarantees that different libX11.so.6.x.y are compatible to
eachother), because the linker picks the SONAME that is set inside the
binary. And the libX11.so.6 symlink is part of the non-devel package.

> But if the same Linux/FreeBSD fpc release was compiled using symlink
> libX11.so.6, there, no problem, it will use the still installed symlink
> libX11.so.6.
> 
> Or, if libX11.so.6 is no more installed, fpc could say "libX11.so.6 not
> found" (because fpc knows now what version of libX11 he needs).

Neither FPC nor the linker know anything about library versions. They
only know the filenames and the SONAMEs. If either can't find the
filename it needs than though luck. And the SONAME is the one that's
used for the real lookup, but the linker needs the file for that.

> Other thing.
> 
> If your way *is* the way to do, why fpc does not use libc6-dev (that
> will create symlink libc.so) but uses LIBC_SO = 'libc.so.6' instead of
> LIBC_SO = 'libc.so' ?

And did you even look at the code?

1. the libc unit is deprecated and only exists for Kylix compatibility
2. the LIBC_SO constant is used nowhere (the library constant is "clib"
and has the value 'c')

The only other use of "libc.so.6" is in iconvenc_dyn.pas, but that is
because it is loading the library dynamically and there the real file
*must* be used as the development symlink might not exist after all.

Regards,
Sven



More information about the fpc-pascal mailing list