Recent

Author Topic: Linker does not exclude unused procs if FPC option -g used (64-bit only!)  (Read 7398 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
For the external linker plz examine man ld, because I suspect you can pass certain options to the linker from fpc with fpc -k-<-ld options> to keep debug info.
Specialize a type, not a var.

Hartmut

  • Hero Member
  • *****
  • Posts: 739
Hello Thaddy, thanks for this suggestion.
I searched "man ld" for something like enabling debug infos but found nothing.
I searched "man ld" for something like smart linking but found nothing.

I searched "man ld" for all command line parameters which had anything to do with "debug" or "DWARF" or "Stabs" and got this matches:
 --traditional-format
 --compress-debug-sections=none
 --compress-debug-sections=zlib
 --compress-debug-sections=zlib-gnu
 --compress-debug-sections=zlib-gabi
 --enable-long-section-names
 --disable-long-section-names
 --enable-extra-pe-debug     
 
I did not understand most of their explanations (it's the 1st time where I have anything to do with a linker) so I tried them all for 64-bit one by one like:
<path>/fpc.sh -B -CX -XX -g -gl -k--traditional-format demo1.pas

Unfortunately this did not help: The last 3 parameters leeded to an error "/usr/bin/ld: unknown Option". The first 5 parameters showed a "Note: DWARF debug information cannot be used with smart linking on this target, switching to static linking" and unused procs were not excluded (as before).

Did I make something wrong?

Thaddy

  • Hero Member
  • *****
  • Posts: 14157
  • Probably until I exterminate Putin.
Two remarks:
// linker specidic:
If the options are really omitted or error, check if you are not using the gold linker as default. This works but currently only for the llvm back-end. (this is by trial and error!, be aware it can be something else..)
I write this because you state you have exanined that man, so it should accept these options. The gold linker has fewer options.
// fpc specific:
If you want to compile as inefficient as possible, use fpc -O-. This should prevent FPC's optimizing stages from removing information before the link stage.
« Last Edit: May 16, 2020, 06:16:01 pm by Thaddy »
Specialize a type, not a var.

Hartmut

  • Hero Member
  • *****
  • Posts: 739
Hello Thaddy, thanks for your help. But as often it is difficult for me to understand you.

// linker specidic:
If the options are really omitted or error, check if you are not using the gold linker as default. This works but currently only for the llvm back-end. (this is by trial and error!, be aware it can be something else..)
I write this because you state you have exanined that man, so it should accept these options. The gold linker has fewer options.

I tried to find out if my system uses the "gold linker". Above error message said "/usr/bin/ld: unknown Option". So I started
   /usr/bin/ld -v
and got
   GNU ld (GNU Binutils for Ubuntu) 2.30
and started
   /usr/bin/ld -V
and got
GNU ld (GNU Binutils for Ubuntu) 2.30
Supported Emulations:
   elf_x86_64
   elf32_x86_64
   elf_i386
   elf_iamcu
   i386linux
   elf_l1om
   elf_k1om
   i386pep
   i386pe

Does this answer your question?

// fpc specific:
If you want to compile as inefficient as possible, use fpc -O-. This should prevent FPC's optimizing stages from removing information before the link stage.

So I started <path>/fpc.sh -B -CX -XX -g -gl -O- demo1.pas
This showed a "Note: DWARF debug information cannot be used with smart linking on this target, switching to static linking" and unused procs were not excluded (as before). So it made no difference.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
// fpc specific:
If you want to compile as inefficient as possible, use fpc -O-. This should prevent FPC's optimizing stages from removing information before the link stage.

Hartmut does not want to keep information, he wants procedures that aren't used to be excluded. And that is currently simply not possible with DWARF on targets that use ld.

Hartmut

  • Hero Member
  • *****
  • Posts: 739
Hello PascalDragon, thanks for this post.
Do I understand you correctly? In reply #11 you wanted to check, if smartlinking with debug infos enabled is impossible on Linux 64-bit or not. Is this post now the definite result of your check, that it is not possible?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
I've not yet found the time to look which is why I wrote that it's currently not possible. Cause the status quo is definitely that.

Hartmut

  • Hero Member
  • *****
  • Posts: 739
Thank you PascalDragon for that clarification. I will wait until you found the time to check it more detailed.

Hartmut

  • Hero Member
  • *****
  • Posts: 739
Hello PascalDragon,
3 month ago you friendly offered that you could find out, if smartlinking with debug infos enabled is possible or impossible on Linux 64-bit (please see reply #11).

I see from time to time that you are active in this Forum and hope that you did not forget me.
I would be very happy, if you could find the time to get a definitive answer for this open question on Linux 64-bit.

You would help me very much with this. Thanks a lot in advance.

process_1

  • Guest
3 month ago you friendly offered that you could find out, if smartlinking with debug infos enabled is possible or impossible on Linux 64-bit (please see reply #11).

It is probably long time ago forgotten, 3 months is a lot of time... :)

Is this work as should be with new FPC version?

Hartmut

  • Hero Member
  • *****
  • Posts: 739
Is this work as should be with new FPC version?
I did not plan to switch to FPC 3.2.0 in the next future *if there is no concrete need*.
And I want this feature - if possible - to use with FPC 3.0.4, because most of my programs use this version.

Do you have any informations, that this feature (smartlinking with debug infos enabled on Linux 64-bit) will definitely work with FPC 3.2.0 (in the release notes I found nothing about this)?

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
No, nothing changed there. If it didn't work with 3.0.4 then it won't work with 3.2.0 or trunk as it stands now. Only if a newer version of ld is more "intelligent" then things would improve there.

Hartmut

  • Hero Member
  • *****
  • Posts: 739
Hello PascalDragon,
3 month ago you friendly offered that you could find out, if smartlinking with debug infos enabled is possible or impossible on Linux 64-bit (please see your reply #11).

I see from time to time that you are active in this Forum and hope that you did not forget me.
I would be very happy, if you could find the time to get a definitive answer for this open question on Linux 64-bit.

You would help me very much with this. Thanks a lot in advance.

If you would decide that you dont want to look after this, please let me know, I would have to respect this.

Many greetinx from Germany, Hartmut.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5444
  • Compiler Developer
3 month ago you friendly offered that you could find out, if smartlinking with debug infos enabled is possible or impossible on Linux 64-bit (please see your reply #11).

Yes, I know, the problem is to find the time. My free time (which is also the time when I work on FPC) is quite full including many topics that are not even remotely related to software development.

 

TinyPortal © 2005-2018