Author Topic: interesting discovery  (Read 880 times)

jcfuller

  • Member
  • **
  • Posts: 175
interesting discovery
« on: September 21, 2016, 03:40:55 AM »
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

  • Member
  • ****
  • Posts: 748
Re: interesting discovery
« Reply #1 on: September 21, 2016, 03:57:23 AM »
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
« Last Edit: September 21, 2016, 10:25:51 PM by TWell »

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4807
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: interesting discovery
« Reply #2 on: September 21, 2016, 12:11:17 PM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

TWell

  • Member
  • ****
  • Posts: 748
Re: interesting discovery
« Reply #3 on: September 21, 2016, 04:32:13 PM »
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 :(
« Last Edit: September 21, 2016, 10:00:11 PM by TWell »

jcfuller

  • Member
  • **
  • Posts: 175
Re: interesting discovery
« Reply #4 on: September 21, 2016, 09:18:40 PM »
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

  • Member
  • ****
  • Posts: 748
Re: interesting discovery
« Reply #5 on: September 21, 2016, 09:35:42 PM »
Thanks James.

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