PB5.20B20 Linker takes also unreferenced procedures into exe

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

PB5.20B20 Linker takes also unreferenced procedures into exe

Post 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
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Fred
Administrator
Administrator
Posts: 16681
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post 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.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

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

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Little John
Addict
Addict
Posts: 4527
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

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

Post by Little John »

I bet this wish is already somewhere on this list. :-)

Anyway, +1 from me, too.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

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

Post by Olby »

I always thought such optimisations were already implemented.

+1
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
skywalk
Addict
Addict
Posts: 3996
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

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

Post by skywalk »

Good to know. I didn't think about referenced functions in unused Procedures.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

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

Post by davido »

+1
DE AA EB
Post Reply