It is currently Mon Dec 17, 2018 10:45 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: PB5.20B20 Linker takes also unreferenced procedures into exe
PostPosted: Tue Sep 17, 2013 8:28 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Dec 03, 2011 5:54 pm
Posts: 734
Location: Oldenburg (Germany)
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:
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 - Antergos Linux 64-Bit, Wayland Display Server


Top
 Profile  
Reply with quote  
 Post subject: Re: PB5.20B20 Linker takes also unreferenced procedures into
PostPosted: Tue Sep 17, 2013 8:35 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13436
Location: France
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: PB5.20B20 Linker takes also unreferenced procedures into
PostPosted: Tue Sep 17, 2013 10:55 am 
Offline
Addict
Addict

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


Top
 Profile  
Reply with quote  
 Post subject: Re: PB5.20B20 Linker takes also unreferenced procedures into
PostPosted: Tue Sep 17, 2013 11:51 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3307
Location: Berlin, Germany
I bet this wish is already somewhere on this list. :-)

Anyway, +1 from me, too.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: PB5.20B20 Linker takes also unreferenced procedures into
PostPosted: Tue Sep 17, 2013 5:31 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Mon Jan 12, 2009 10:33 am
Posts: 461
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)


Top
 Profile  
Reply with quote  
 Post subject: Re: PB5.20B20 Linker takes also unreferenced procedures into
PostPosted: Tue Sep 17, 2013 5:59 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2760
Location: Boston, MA
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


Top
 Profile  
Reply with quote  
 Post subject: Re: PB5.20B20 Linker takes also unreferenced procedures into
PostPosted: Tue Sep 17, 2013 6:44 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1603
Location: Uttoxeter, UK
+1

_________________
DE AA EB


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye