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
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.
This PR 36079 can't appear on buglist. target_milestone=4.3.1 short_desc=4.3 ?
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".
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.
>>> >>>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!
How to reopen bug 36079? Thanks!
Patch v2 (with --enable-cld configure option) at: http://gcc.gnu.org/ml/gcc-patches/2008-05/msg01178.html
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.
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!
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.
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
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!
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
Fixed for 4.3.1 and 4.4.
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
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.