gcc iussue or ... ?

Gianmarco Giovannelli gmarco at scotty.masternet.it
Sat Apr 12 13:39:03 PDT 2003

At 12/04/2003, you wrote:
> > So the point is why Linux/mingw have a lot of things in bss while 4.8 
> (with
> > the same gcc of linux debian 3.0 and 5.0 with the same gcc 3.2.1 of mingw)
> > put them in Data ?
>Maybe Linux is using the "-fconserve-space" g++ option.  From the
>info pages:
>      Put uninitialized or runtime-initialized global variables into the
>      common segment, as C does.  This saves space in the executable at
>      the cost of not diagnosing duplicate definitions.  If you compile
>      with this flag and your program mysteriously crashes after
>      `main()' has completed, you may have an object that is being
>      destroyed twice because two definitions were merged.
>      This option is no longer useful on most targets, now that support
>      has been added for putting variables into BSS without making them
>      common.
>That last paragraph suggests that maybe FreeBSD's compiler is
>configured slightly wrong, such that it does not do what the
>paragraph says.  In any case, try adding this option to your
>compiles on FreeBSD and see if it helps.

This exactly solve the problem :-)

The compilation is fine, the exe is now 2mb (like linux).

/source_of_lonejoy/src# ll -h lonewolf
-rwxr-xr-x  1 root  wheel       2M Apr 12 22:24 lonewolf

Using such lines in Makefile.unix:
CFLAGS  =       -pipe -funsigned-char -fconserve-space -O -DNO_DEBUG
CXXFLAGS=       -pipe -funsigned-char -fconserve-space -O -DNO_DEBUG

did the job.
Now we have to understand why the Linux version of the same gcc doesn't 
need this option to make the exe so small :-)

  Thanks very much.

Best Regards,
Gianmarco Giovannelli ,  "Unix expert since yesterday"

More information about the freebsd-hackers mailing list