Mail archive
alpine-devel

Re: [alpine-devel] Bunch of questions about Alpine's gcc package

From: Dubiousjim <lists+alpine-devel_at_jimpryor.net>
Date: Sun, 19 May 2013 14:15:32 -0400

On Sun, May 19, 2013 at 01:08:29PM +0200, Natanael Copa wrote:
>
> > --enable-cld
>
> http://en.wikipedia.org/wiki/Direction_flag
> I think this was the reason:
> http://lwn.net/Articles/272048/


http://gcc.gnu.org/install/configure.html
says:
--enable-cld
    This option enables -mcld by default for 32-bit x86 targets. See
?i386 and x86-64 Options? in the main manual

That is, this reverts to the behavior that GCC implemented before
v3.4.0. (Explained in the LWN article linked above.) The cross-reference
in "the main manual" says:

http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/i386-and-x86_002d64-Options.html
says:

-mcld
    This option instructs GCC to emit a cld instruction in the prologue
of functions that use string instructions. String instructions depend on
the DF flag to select between autoincrement or autodecrement mode. While
the ABI specifies the DF flag to be cleared on function entry, some
operating systems violate this specification by not clearing the DF flag
in their exception dispatchers. The exception handler can be invoked
with the DF flag set, which leads to wrong direction mode when string
instructions are used. This option can be enabled by default on 32-bit
x86 targets by configuring GCC with the --enable-cld configure option.
Generation of cld instructions can be suppressed with the -mno-cld
compiler option in this case.


Reading the comments on the LWN article, it looks like this issue was
fixed in the Linux kernel soon after it arose. See
http://marc.info/?l=git-commits-head&m=120492000901739&w=2
(committed in 2008).

And indeed, the 3.9.2 kernel sources have:
./arch/x86/kernel/signal.c-678- * Clear the direction flag as
per the ABI for function entry.
./arch/x86/kernel/signal.c-679- */
./arch/x86/kernel/signal.c:680: regs->flags &= ~X86_EFLAGS_DF;

So as far as I can see, we can drop this configure flag on GCC and go
with the behavior introduced in gcc 4.3.0 (conforming to the ABI
spec). People using GCC with non-Linux kernels, or 2008-or-older
versions of the Linux kernel, are the ones who may need it.

This judgment is based on my reading the above sources, and some things
they link to. Others may be better-informed.



---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Sun May 19 2013 - 14:15:32 UTC