Re: MinGW generates large executable files

Eli Zaretskii <eliz-mXXj517/[email protected]> Sat, 21 Mar 2020 10:00:36 +0200
Newsgroups gmane.comp.gnu.mingw.user
Message-ID <[email protected]>
> From: Charles Bailey <[email protected]>
> Date: Fri, 20 Mar 2020 17:15:09 -0500
> 
> When I compile this with TCC I get a .exe file that is just 1,536 
> bytes.  With gcc from MinGW I get a .exe that is 42,035 bytes long.  
> Executing the strip command on it to remove debug symbols brings it down 
> to 19,470 bytes, which is still more than 12 times the size of the 
> TCC-produced file.

TCC is "Tiny C".  The "tiny" part is there for a reason.  You get
smaller executables, but also less functional executables.

> I recently learned how to use the dumpbin command from Microsoft to 
> analyze an .exe file.

No need to use proprietary tools.  If you can build MinGW programs,
you have GNU Binutils installed, and if you have Binutils, you have a
program named objdump.exe, which is the moral equivalent of dumpbin.
E.g., "objdump -x small.exe" will show you the information you posted.

> What is all that extra stuff that MinGW is inserting?  Why is it 
> referencing tons of functions that I'm not even using?  Are there some 
> gcc options I can specify to eliminate that extra stuff?

I suggest to install the MinGW runtime sources, and look at the MinGW
startup code there.  You will find the answers to all your questions.
In a nutshell, the MinGW startup code does more than the TCC one does,
for example it includes a saner expansion of wildcards specified on
the command line.

_______________________________________________
MinGW-Users mailing list
[email protected]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.osdn.me/mailman/listinfo/mingw-users
Also: mailto:[email protected]?subject=unsubscribe