First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 36079
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Uros Bizjak <ubizjak@gmail.com>
Add CC:
CC:
Remove selected CCs
Build:
Patch URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 36079 depends on: Show dependency tree
Show dependency graph
Bug 36079 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2008-04-29 14:46 Opened: 2008-04-29 12:53
This bug is opened to track the issue with cld insn.

gcc-4.3.0 does not emit cld instruction anymore in front of string instruction.
Due to this, OSes that does not clear direction flag in task switch can enter
exception handler with D flag set. This is ABI violation since ABI requires D
flag to be cleared on function entry.

Proposed patch (with a lot of follow-up discussion) is here:

http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00417.html

and further discussion here:

http://gcc.gnu.org/ml/gcc-patches/2008-04/msg02026.html

------- Comment #1 From Uros Bizjak 2008-04-29 13:15 -------
Since there are many workarounds for this problem I think that this problem
should be fixed elsewhere by either (a) fixing the kernel or (b) fixing the
application that is affected by the problem

a) A two-liner patch to the kernel. This is the approach that major
distribution have taken.

b) The fix is to add explicit cld at the beginning of the function that can be
called from exception handler and uses string operations.

Due to the nature of the problem, it is very unlikely that this problem will
hit real word applications. OTOH, cld instruction has non-negligible
performance impact. Adding -mcld to compile flags in order to emit cld at the
beginning of every function that uses stringops will introduce certain
performance hit. 

------- Comment #2 From littlestar 2008-04-29 13:36 -------
This PR 36079 can't appear on buglist.

target_milestone=4.3.1
short_desc=4.3

?

------- Comment #3 From Richard Guenther 2008-04-29 14:46 -------
ISVs usually build with compilers from the stone-age to be able to run their
applications on all still supported OS versions.  So it is very unlikely that
they will hit this problem.  In fact if we enable this workaround in 4.3 we
give them a false sense of security that this "feature" is maintained.  It also
gives them a false sense of the severity of this problem which is very low,
very much lower than any other random wrong-code bug we discover.

Marking as ABI issue, but not wrong-code (it is not).  Marking as regression.

I vote for "RESOVED INVALID".

------- Comment #4 From Uros Bizjak 2008-05-20 05:46 -------
This bug should not block the release.

I agree fully with comment #3, the impact of this issue is very minor. Also,
gcc is not the place to fix/paper over kernel bugs, and the two-line fix
already propagated into all stable kernel updates. After a lot of thought and
discussion, I'm closing this bug (under my responsibility) as INVALID.

------- Comment #5 From littlestar 2008-05-20 07:08 -------
>>>
>>>ISVs usually build with compilers from the stone-age to be able to run their
>>>applications on all still supported OS versions.  
I agree!

--------------------------------------
which Linux Kernel version has the bug?
Kernel Version >=2.4.20, 2.6.4, ?

Whe use Rehat AS 3.0 update2 for development enviroment.
We compile all programs on Rehat AS 3.0 update2.(gcc 4.2.2 or newer).
It can run well on all AS 3.0/4.0/5.0, or other OS versions...

How to reopen the bug? Thanks!

------- Comment #6 From littlestar 2008-05-20 08:48 -------
How to reopen bug 36079? Thanks!

------- Comment #7 From Uros Bizjak 2008-05-20 12:51 -------
Patch v2 (with --enable-cld configure option) at:
http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01178.html

------- Comment #8 From littlestar 2008-05-20 15:17 -------
if configure gcc 4.3.1 with --enable-cld on Redhat AS 3.0 U2.
The programs build with gcc 4.3.1 run well on all Redhat AS 3.0/4.0/5.0, SUSE
9/10 or other Linux OS versions, is it right?

If no --enable-cld with gcc 4.3.1, what will happen with my programs, Thanks!

GCC 4.2.4 works well on Rehat AS 3.0 U3.

------- Comment #9 From littlestar 2008-05-20 15:23 -------
GCC 4.2.4 works well on Rehat AS 3.0 U2.

How can I use gcc 4.3.1 instead of gcc 4.2.X?
I want to build my programs on Rehat AS 3.0 U2 with newer gcc, 4.2.4 or 4.3.1.
At the same time, I want the compiled programs run well on all Redhat AS
3.0/4.0/5.0, SUSE 9/10, and other Linux OS versions(>=2.4.20, >=2.6.4).

Thanks!

------- Comment #10 From rguenther@suse.de 2008-05-20 15:27 -------
Subject: Re:  [4.3/4.4 Regression] cld instruction is not
 emitted anymore.

On Tue, 20 May 2008, cnstar9988 at gmail dot com wrote:

> ------- Comment #8 from cnstar9988 at gmail dot com  2008-05-20 15:17 -------
> if configure gcc 4.3.1 with --enable-cld on Redhat AS 3.0 U2.
> The programs build with gcc 4.3.1 run well on all Redhat AS 3.0/4.0/5.0, SUSE
> 9/10 or other Linux OS versions, is it right?
> 
> If no --enable-cld with gcc 4.3.1, what will happen with my programs, Thanks!

Nothing will happen.

Richard.

------- Comment #11 From uros@gcc.gnu.org 2008-05-21 08:54 -------
Subject: Bug 36079

Author: uros
Date: Wed May 21 08:54:15 2008
New Revision: 135711

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135711
Log:
        PR target/36079
        * configure.ac: Handle --enable-cld.
        * configure: Regenerated.
        * config.gcc: Add USE_IX86_CLD to tm_defines for x86 targets.
        * config/i386/i386.h (struct machine_function): Add needs_cld field.
        (ix86_current_function_needs_cld): New define.
        * config/i386/i386.md (UNSPEC_CLD): New unspec volatile constant.
        (cld): New isns pattern.
        (strmov_singleop, rep_mov, strset_singleop, rep_stos, cmpstrnqi_nz_1,
        cmpstrnqi_1, strlenqi_1): Set ix86_current_function_needs_cld flag.
        * config/i386/i386.opt (mcld): New option.
        * config/i386/i386.c (ix86_expand_prologue): Emit cld insn if
        TARGET_CLD and ix86_current_function_needs_cld.
        (override_options): Use -mcld by default for 32-bit code if
        USE_IX86_CLD.


Modified:
    branches/gcc-4_3-branch/gcc/ChangeLog
    branches/gcc-4_3-branch/gcc/config.gcc
    branches/gcc-4_3-branch/gcc/config/i386/i386.c
    branches/gcc-4_3-branch/gcc/config/i386/i386.h
    branches/gcc-4_3-branch/gcc/config/i386/i386.md
    branches/gcc-4_3-branch/gcc/config/i386/i386.opt
    branches/gcc-4_3-branch/gcc/configure
    branches/gcc-4_3-branch/gcc/configure.ac

------- Comment #12 From littlestar 2008-05-22 02:41 -------
I have read the discussions on gcc-patches.

The patchs:
    --enable-cld used default on x86 and x86_64.

If build gcc 4.3.1 using --enable-cld:
    when use -m32, gcc use -mcld default.
    when use -m64, gcc not use -mcld default.

If build gcc 4.3.1 using --disable-cld:
    when compile 32bit or 64bit app, gcc not use -mcld default.

Both configure, gcc accept -mcld when compile 32bit/64 bit app, and run well.

That's ok for me, Thanks!

------- Comment #13 From uros@gcc.gnu.org 2008-05-23 07:53 -------
Subject: Bug 36079

Author: uros
Date: Fri May 23 07:53:16 2008
New Revision: 135792

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=135792
Log:
        PR target/36079
        * configure.ac: Handle --enable-cld.
        * configure: Regenerated.
        * config.gcc: Add USE_IX86_CLD to tm_defines for x86 targets.
        * config/i386/i386.h (struct machine_function): Add needs_cld field.
        (ix86_current_function_needs_cld): New define.
        * config/i386/i386.md (UNSPEC_CLD): New unspec volatile constant.
        (cld): New isns pattern.
        (strmov_singleop, rep_mov, strset_singleop, rep_stos, cmpstrnqi_nz_1,
        cmpstrnqi_1, strlenqi_1): Set ix86_current_function_needs_cld flag.
        * config/i386/i386.opt (mcld): New option.
        * config/i386/i386.c (ix86_expand_prologue): Emit cld insn if
        TARGET_CLD and ix86_current_function_needs_cld.
        (override_options): Use -mcld by default for 32-bit code if
        USE_IX86_CLD.

        * doc/install.texi (Options specification): Document --enable-cld.
        * doc/invoke.texi (Machine Dependent Options)
        [i386 and x86-64 Options]: Add -mcld option.
        (Intel 386 and AMD x86-64 Options): Document -mcld option.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config.gcc
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/i386/i386.h
    trunk/gcc/config/i386/i386.md
    trunk/gcc/config/i386/i386.opt
    trunk/gcc/configure
    trunk/gcc/configure.ac
    trunk/gcc/doc/install.texi
    trunk/gcc/doc/invoke.texi

------- Comment #14 From Uros Bizjak 2008-05-23 08:39 -------
Fixed for 4.3.1 and 4.4.

------- Comment #15 From littlestar 2008-06-10 10:07 -------
I build gcc 4.3.1 with --with-cld
./src/configure --prefix=/opt/gcc-4.3.1 --with-gmp=/opt/gcc-4.3.1/gmp
--with-mpfr=/opt/gcc-4.3.1/mpfr --enable-languages=c,c++ --disable-nls
--enable-bootstrap --disable-shared --enable-threads=posix
--enable-checking=release --enable-cld --with-system-zlib --enable-__cxa_atexit
--with-cpu=generic

I test it with /opt/gcc-4.3.1/bin/gcc -v test.c
but I can't see any -mcld?

/opt/gcc-4.3.1/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1 -quiet -v test.c -quiet
-dumpbase test.c -mtune=generic -auxbase test -version -o /tmp/ccVgUf0W.s

------- Comment #16 From rguenther@suse.de 2008-06-10 10:56 -------
Subject: Re:  [4.3/4.4 Regression] cld instruction is not
 emitted anymore.

On Tue, 10 Jun 2008, cnstar9988 at gmail dot com wrote:

> ------- Comment #15 from cnstar9988 at gmail dot com  2008-06-10 10:07 -------
> I build gcc 4.3.1 with --with-cld
> ./src/configure --prefix=/opt/gcc-4.3.1 --with-gmp=/opt/gcc-4.3.1/gmp
> --with-mpfr=/opt/gcc-4.3.1/mpfr --enable-languages=c,c++ --disable-nls
> --enable-bootstrap --disable-shared --enable-threads=posix
> --enable-checking=release --enable-cld --with-system-zlib --enable-__cxa_atexit
> --with-cpu=generic
> 
> I test it with /opt/gcc-4.3.1/bin/gcc -v test.c
> but I can't see any -mcld?
> 
> /opt/gcc-4.3.1/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1 -quiet -v test.c -quiet
> -dumpbase test.c -mtune=generic -auxbase test -version -o /tmp/ccVgUf0W.s

It only turns the option on in the backend, it doesn't pass it from
the driver.

Richard.

First Last Prev Next    No search results available      Search page      Enter new bug