Page 1 of 1

PB5.20B20 Linker takes also unreferenced procedures into exe

Posted: Tue Sep 17, 2013 8:28 am
by uwekel
Hi,

a couple of days ago i noticed an increase of file size of my executables. After some further investigation i found out, that it seems that procedures are linked and compiled into the program file even if they are not referenced at all.

Here is a sample code to point out the problem:

Code: Select all

Procedure UnCalledProc()
  If ExamineDirectory(0, GetHomeDirectory(), "")
    While NextDirectoryEntry(0)
      MessageRequester("Test", DirectoryEntryName(0))
    Wend
  EndIf
EndProcedure

If OpenWindow(0, 0, 0, 400, 300, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  UnCalledProc()
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
When i compile the program, the file size is 55,1 KB.

If you now comment out the procedure call at line 10 (UnCalledProc()) and compile again, the size does not change and is still 55,1 KB.

If you then comment out the whole procedure block, the size reduces to 42,8 KB. This size i did expect when i commented out the procedure call.

In this sample piece of code the effect is very small, but in larger projects the file size increase much more, especially if you use just very less procedures from a big common module.

Best regards
Uwe

Re: PB5.20B20 Linker takes also unreferenced procedures into

Posted: Tue Sep 17, 2013 8:35 am
by Fred
It's not a bug, the code from your procedure isn't included, but the referenced functions are (like ExamineDirectory()). It could be optimized, so I moved it to feature and request.

Re: PB5.20B20 Linker takes also unreferenced procedures into

Posted: Tue Sep 17, 2013 10:55 am
by c4s
Fred wrote:[...] the code from your procedure isn't included, but the referenced functions are (like ExamineDirectory()). It could be optimized [...]
+1 - Would be great if this could be optimized.

Re: PB5.20B20 Linker takes also unreferenced procedures into

Posted: Tue Sep 17, 2013 11:51 am
by Little John
I bet this wish is already somewhere on this list. :-)

Anyway, +1 from me, too.

Re: PB5.20B20 Linker takes also unreferenced procedures into

Posted: Tue Sep 17, 2013 5:31 pm
by Olby
I always thought such optimisations were already implemented.

+1

Re: PB5.20B20 Linker takes also unreferenced procedures into

Posted: Tue Sep 17, 2013 5:59 pm
by skywalk
Good to know. I didn't think about referenced functions in unused Procedures.

Re: PB5.20B20 Linker takes also unreferenced procedures into

Posted: Tue Sep 17, 2013 6:44 pm
by davido
+1