Support Requests item #2809222, was opened at 2009-06-19 22:18
Message generated for change (Comment added) made by bughunter2
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=202435&aid=2809222&group_id=2435
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: mingw runtime
Group: None
Status: Closed
Priority: 5
Private: No
Submitted By: bughunter2 (bughunter2)
Assigned to: Nobody/Anonymous (nobody)
Summary: -ansi flags increases file size
Initial Comment:
Host System: Windows XP Professional SP3 (build 5.1.2600.xpsp_sp3_gdr.090206-1234)
Build Environment: cmd.exe
Bug reproducable with:
"GNU ld version 2.17.50 20060824" in combination with "gcc (GCC) 3.4.5 (mingw-vista special r3)"
"GNU ld (GNU Binutils) 2.19.1" in combination with "gcc (GCC) 4.3.0 20080305 (alpha-testing) mingw-20080502"
snippet:
<<<<<<<<<<<<<<<<<<<<<<
#include <stdio.h>
int main(void)
{
printf("hello, world\n");
return 0;
}
>>>>>>>>>>>>>>>>>>>>>>
If we compile this with `gcc -ansi -s -o test.exe test.c', the output sizes are as follows:
26112 bytes for "gcc 4.3.0 + ld 2.19.1"
27136 bytes for "gcc 3.4.5 + ld 2.17.50"
If we compile this with `gcc -s -o test.exe test.c' (no -ansi flag), the output sizes are as follows:
5120 bytes for "gcc 4.3.0 + ld 2.19.1"
5632 bytes for "gcc 3.4.5 + ld 2.17.50"
Trying to reproduce the same bug on other platforms (e.g. Linux) doesn't yield the same results, so I expect that this anomaly should be fixed...
----------------------------------------------------------------------
Comment By: bughunter2 (bughunter2)
Date: 2009-06-24 12:28
Message:
@keithmarshall: I understand the problem. Though, I'd be interested to get
to know more about which functions from MSVCRT.DLL are replaced by mingwrt,
and the details about what to look out for when using the MSVCRT.DLL
functions instead of the ANSI-C compliant ones. Is there any documentation
about this? I haven't found a lot so far.
----------------------------------------------------------------------
Comment By: Keith Marshall (keithmarshall)
Date: 2009-06-24 11:44
Message:
Neither a bug, nor an anomaly. What effect do you expect, when you specify
options, if not to modify the generated code?
When generated code is modified, a change in size is almost inevitable.
When you specify -ansi, you select alternative implementations of a
(possibly significant) number of functions, which Microsoft have failed to
implement in an ANSI-C conforming manner; the replacement functions are
mostly furnished by libmingwex.a, and *statically* linked to your
executable, replacing *dynamically* linked references to code in
MSVCRT.DLL. Obviously, the inclusion of statically linked code *must*
result in a perhaps substantial, but ultimately finite, increment in
executable size.
If we didn't statically link these replacement functions, then *you* would
be required to distribute the additional code anyway, in the form of
free-standing DLLs. The majority of MinGW users seem to be allergic to
that concept, so we don't provide a dynamically linked mingwex.dll;
however, there is nothing to preclude you from deriving your own DLL,
exporting the libmingwex.a functions you actually require, and distributing
it along with your executable, if you prefer that approach.
There is no issue to be addressed here, so I am closing this ticket.
----------------------------------------------------------------------
Comment By: bughunter2 (bughunter2)
Date: 2009-06-23 18:05
Message:
Not a bug, but an anomaly, I'd say? Is there a good reason as to why the
compiled executable increases in size with the -ansi flag? The observed
differences can be quite significant.
----------------------------------------------------------------------
Comment By: Earnie Boyd (earnie)
Date: 2009-06-23 17:58
Message:
Definitely not a bug.
----------------------------------------------------------------------
Comment By: bughunter2 (bughunter2)
Date: 2009-06-23 10:44
Message:
Well, the differences are even larger for an application I wrote, which,
when compiled without -ansi, compiled to a size of roughly ~11KiB, and with
-ansi to a size of roughly ~33KiB.
----------------------------------------------------------------------
Comment By: Aaron W. LaFramboise (aaronwl)
Date: 2009-06-23 08:26
Message:
This is a mingwrt issue. For this simple testcase, it is caused by using a
different printf() routine. This is related to Keith's printf
improvements.
I'm not sure if this is really a bug.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=202435&aid=2809222&group_id=2435
|