Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2004-11

linking issues

6 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Santhoff

Hi,

I've got two questions on linking:

1.
If -XX is used ("try to link smart"), is there any risk of losing needed code?

The word "try" in this context irritates me ... don't understand if this says "try and see if it works" or "try but your result might get corrupted.

2.
When using ressourcestrings and thus linking to gettext, dynamic linking with -XD fails. The gettext library is linked statically any time, although gtk is linked dynamically. The small test program "restest" from the sources is about 350kB big.

Is it possible to link libgettext in dynamically?

TIA,
Marc

Reply by email

Jonas Maebe
to Marc Santhoff
Marc Santhoff wrote
1. If -XX is used ("try to link smart"), is there any risk of losing needed code?

No.

The word "try" in this context irritates me ... don't understand if this says "try and see if it works" or "try but your result might get corrupted.

It means that if no smartlinkable version of a particular unit is available, you won't get an error, but the non-smartlinkable version will be used.

I don't know the answer to your second question.

Jonas

Reply by email

Peter Vreman
to Marc Santhoff: I've got two questions on linking: 1. If -XX is used ("try to link smart"), is there any…
Show quoted text 11 lines
Hi, I've got two questions on linking: 1. If -XX is used ("try to link smart"), is there any risk of losing needed code? The word "try" in this context irritates me ... don't understand if this says "try and see if it works" or "try but your result might get corrupted.

When a unit is not smartlinked then it'll be linked using the normal object file.

Show quoted text 7 lines
2. When using ressourcestrings and thus linking to gettext, dynamic linking with -XD fails. The gettext library is linked statically any time, although gtk is linked dynamically. The small test program "restest" from the sources is about 350kB big. Is it possible to link libgettext in dynamically?

-XD only has influence the linking of code in fpc units. How libgettext is linked by default depends on your OS installation. Only when using -Xt then every library will be staticly linked (-static is passed to ld)

Reply by email

Marco van de Voort
to Marc Santhoff: I've got two questions on linking: 1. If -XX is used ("try to link smart"), is there any…
Show quoted text 5 lines
I've got two questions on linking: 1. If -XX is used ("try to link smart"), is there any risk of losing needed code?

Not likely. Only if you open the binary and read data from it.

The word "try" in this context irritates me ... don't understand if this says "try and see if it works" or "try but your result might get corrupted.

No, this is more that some units in the past were not smartlinkable. Moreover, already compiled units (RTL etc) might not be compiled with smartlinking enabled.

The only real problem with smartlinking that I'm aware of is that smartlinking as currently done on _huge_ binaries (>5-10MB code) eats up massive (GB+) amounts of mem. On a new system for smartlinking is being worked on (this will be used in paralel, since not all OSes support the new system)

Show quoted text 7 lines
2. When using ressourcestrings and thus linking to gettext, dynamic linking with -XD fails. The gettext library is linked statically any time, although gtk is linked dynamically. The small test program "restest" from the sources is about 350kB big. Is it possible to link libgettext in dynamically?

No real idea. Does libgettext.so exist btw? Maybe it can't find the dynamical lib.

Reply by email

Marc Santhoff
to Peter Vreman: When a unit is not smartlinked then it'll be linked using the normal object file. -XD…

Am Fr, den 26.11.2004 schrieb Peter Vreman um 10:32: [...]

Show quoted text 11 lines
> 2. > When using ressourcestrings and thus linking to gettext, dynamic linking > with -XD fails. The gettext library is linked statically any time, > although gtk is linked dynamically. The small test program "restest" > from the sources is about 350kB big. > > Is it possible to link libgettext in dynamically? -XD only has influence the linking of code in fpc units. How libgettext is linked by default depends on your OS installation. Only when using -Xt then every library will be staticly linked (-static is passed to ld)

I don't get that. Do you want to say every X program is linked statically? Or when linking directly to libXt instead of indirectly e.g. via libgtk the program is linked statically by default?

Marc

Reply by email

Marc Santhoff
to Marc Santhoff: I've got two questions on linking: 1. If -XX is used ("try to link smart"), is there any…

Hi,

I'm putting my answer here, thank you all so far.

Using -XX is okay, I understood that (and it works, more than one third in space is omitted from the target program :).

But with dynamic linking theres something left...

For testing purposes I used "restest.pp" again:

$ fpc -k-dynamic -s restest

Linker script:
#!/bin/sh
DoExitAsm ()
{ echo "An error occurred while assembling $1"; exit 1; } DoExitLink ()
{ echo "An error occurred while linking $1"; exit 1; } echo Linking restest
/usr/bin/ld -L/usr/local/lib -L/usr/X11R6/lib -dynamic -s -L. -o restest link.res
if [ $? != 0 ]; then DoExitLink restest; fi

$ locate libgettext
/usr/local/lib/libgettextlib-0.12.1.so
/usr/local/lib/libgettextlib.so
/usr/local/lib/libgettextpo.a
/usr/local/lib/libgettextpo.so
/usr/local/lib/libgettextpo.so.0
/usr/local/lib/libgettextsrc-0.12.1.so
/usr/local/lib/libgettextsrc.so

$ ll restest
-rwxr-xr-x  1 marc  wheel  562867 26 Nov 12:31 restest
$ ldd restest
ldd: restest: not a dynamic executable

That does not do it. There are only some similar named libs, but not "libgettext.so".

So I have to assume, the unit getext.ppu has to be recompiled for dynamic linking?

Marc

Reply by email