Re: How to produce one ".exe" lower ?
- Posted by mattlewis (admin) Oct 07, 2011
- 1116 views
I wonder if we can use more conditional indicators for removing code that is not needed during compilation to make smaller files?
Matt can correct me if I am wrong but methods not used are not translated to the C files. So it's not a matter of not including Euphoria code, it has to do with the C library that we are linking to. Thus the C compiler would have to do a better job of stripping unused items.
After code is parsed, the translator makes several passes over the resulting code. If you've ever translated, you'll have noticed that the translator prints out numbers. These numbers represent the number of passes made through the code.
Each time through, the translator tracks the values of variables as best it can, and notices which routines are called and which variables are used. When it can definitely say that a routine or variable is never used, that routine or variable is ignored from there after.
Also, if it can prove that a particular variable only ever takes certain values, it tries to use that knowledge to eliminate code branches. So if a variable is always greater than zero, and you had something like the following:
if foo then -- code else -- code end if
The translator will not even bother emitting the else block. No doubt, the C compiler does even more. And I'm sure there are more opportunities to improve the translator optimizations. The difficulty is in finding them. Also, there is a trade off between the optimizations and the time and memory used by the translator itself.
You could additionally strip the resulting binaries of any symbols that are kept after linking. I'm not sure if this is possible with Watcom. I generally wouldn't bother with this sort of thing.
The euphoria code itself has grown a bit (not huge amounts). We now have more functionality, including PCRE. I don't think this difference is very large, though. Certainly not as big as the difference made by compressing with UPX.
Matt