This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
RE: different flags for different files
- To: 'Roderick Bloem' <roderick dot bloem at colorado dot edu>, gcc-help at gcc dot gnu dot org
- Subject: RE: different flags for different files
- From: David Korn <dkorn at pixelpower dot com>
- Date: Fri, 23 Mar 2001 09:56:38 -0000
>-----Original Message-----
>From: Roderick Bloem [mailto:roderick.bloem@colorado.edu]
>Sent: 23 March 2001 00:20
>We had this horrible bug in our software package which in the end was
>traced down to the following. Our Makefile used to have `CFLAGS= -O',
>and then we changed it to `CFLAGS = -g -O6 -mcpu=pentiumpro
>-malign-double". Hence, some of the files were compiled with the first
>set of flags, and some with the second. This led to a core dump very
>early on in the executable.
From the manual:
`-malign-double'
`-mno-align-double'
Control whether GCC aligns `double', `long double', and `long
long' variables on a two word boundary or a one word boundary.
Aligning `double' variables on a two word boundary will produce
code that runs somewhat faster on a `Pentium' at the expense of
more memory.
*Warning:* if you use the `-malign-double' switch, structures
containing the above types will be aligned differently than the
published application binary interface specifications for the 386.
In general, there is no way you can intermingle binaries that adhere
to different ABIs and in particular, it isn't going to work if data items
are aligned to different boundaries in memory: the different modules are
going to have different notions of how a function's arguments are laid
out on the stack frame, and the most likely consequence is that when a
function compiled one way calls a function compiled the other way, the
callee will get the double arguments off the stack in a way that ends up
fetching one word from the double and one word from the previous or
next stack parameter; this in turn is likely not to be a valid IEEE
format float and could easily end up being a Nan or Inf which would lead
to an exception when you try and use it in calculation.
>If it is the latter, let me point out that it would be more
>user-friendly if files compiled with different flags could be linked
>together, or if gcc would refuse to link files that have been compiled
>with different flags.
Now that's not a bad idea overall. Would you care to submit a patch to
implement it ? <gd&r> Alas, the standard advice is simply DDTT; if you
want to change ABI in the middle of a project, well, you've only got to
delete all the .o files and rebuild the whole thing *once*, after all.
DaveK
--
All your base are belong to us!
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************