News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

interesting discovery

Started by jcfuller, September 21, 2016, 03:40:55 AM

Previous topic - Next topic

jcfuller

With all the expertise here and the pursuit of tiny I wonder if any one has any insight on the discovery I made recently: http://www.jose.it-berater.org/smfforum/index.php?topic=5144.0

I only have VS 2015 community so I could not test on earlier versions to see if has always been the case.

One of the big features of PowerBASIC as Hutch has mentioned is the dead code removal. FreeBasic also has basically the same thing by using the PRIVATE key word for func/subs.

Is it just the linker or a combination cl and link?
Can the same thing be done with ML64?

James

TWell

#1
cl.exe /Gy option, COMDAT support ?
look here
i think link.exe isn't smart enought without that support.

jwasm/hjwasm may have that feature?

gcc option -ffunction-sections

hutch--

james,

As far as I can tell there is no trick to do this, if a module is in a library, if its not called its not added but if you either bundle modules together or have unused code in the main source it will be added to the EXE, used or not.

TWell

#3
Those functions have to be in separated object module and compiled with -Gy
, but data still goes to exe/dll as -Gy is for code only.
Try to split main and functions code to different files.

Sadly PellesC don't have that compiler option :(

jcfuller

Tim,
  Thank you very much for your insight.
The results I am seeing is because all the code was in the same source file. This is for VC only.
If I split out the functions to another source file and #include them they are included in the exe.

Your link did not work for me but I did find the info for /Gy on msdn along with a link to:
https://msdn.microsoft.com/en-us/library/bxwfs976.aspx
where it states that /OPT:REF is the default.

I also compiled all the functions  using /Gy and linked the obj file to the main file. Only the F1 function that was called was included in the exe.

Now, why would one NOT use /Gy ? Are there any gotcha's with it??
Is this common knowledge among vc coders that I missed in my education?

James

TWell

Thanks James.

With -Gy it works on one file too.
The map file shows it.