This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC-3.4 reorders asm() with -O2
On Sat, Jan 24, 2004 at 02:23:03AM +0100, Jan Hubicka wrote:
> > On Fri, Jan 23, 2004 at 05:15:24PM -0800, Mike Eager wrote:
> > > GCC-3.4 orders asm() outside of functions differently depending on
> > > whether code is compiled -O1 or -O2. This behavior has changed from
> > > gcc-3.3.1.
> > >
> > > Here's a small piece of C code (extracted from glibc):
> > >
> > > initfini.c:
> > > asm ("\n/*@HEADER_ENDS*/");
> > >
> > > asm ("\n/*@TESTS_BEGIN*/");
> > > void dummy (void) { }
> > > asm ("\n/*@TESTS_END*/");
> > >
> > > asm ("\n/*@_init_PROLOG_BEGINS*/");
> >
> > > So, this is different behavior between gcc-3.3.1 and gcc-3.4.
> > > Is there any guarantee that asm() outside of a function will
> > > not be reordered with respect to functions?
> > > Is there any way to suppress this reordering?
> >
> > No, and -fno-unit-at-a-time (for now, at least). This should probably
> > be in changes.html if it isn't already.
> >
> > Take a look at the glibc CVS; this is handled now. The Linux kernel
> > has or had a number of similar problems.
> >
> > linuxthreads/Makefile:CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
>
> I think Linux kernel compiles completely with unit-at-a-time now. I
> would much prefer glibc to avoid -fno-unit-at-a-time, so it can be
> dropped in the future.
For x86 it does. For MIPS I'm quite sure it doesn't - well, it will
compile, but not work.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer