From: pavenis AT lanet DOT lv Message-ID: To: "Rob Kramer" , djgpp-workers AT delorie DOT com Date: Fri, 10 Sep 1999 11:04:27 +0300 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: Bug in CPP_CPU_SPECS for i[3456]86 [Was: Re: GCC 2.95 global string crashes on 386..] CC: gcc-bugs AT gcc DOT gnu DOT org In-reply-to: <199909100328.LAA11335@westgate.cyberway.com.sg> References: X-mailer: Pegasus Mail for Win32 (v3.12a) Reply-To: djgpp-workers AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On 10 Sep 99, at 11:27, Rob Kramer wrote: > I've disassembled the executable, and it seems the compiler issues a locked > 'xaddl' instruction. I couldn't find opcode 'c1' in my 386 reference manual, > so this may be a 486++ instruction? (I can't find anything but Intel's 386 > manual online, sigh) > > 2052: f0 0f c1 02 lock xaddl %eax,(%edx) It's from libstdc++. File bastring.h (for DJGPP it's lang/cxx/std/bastring.h) uses such inline assembler when __i486__, __i586__ or __i686__ is defined > > > Confirmed with DJGPP ports of egcs-1.1.2 and gcc-2.95.1 (I don't more > > gcc-2.95 installed, but that doesn't matter). 2 possible cures: > > - currently use option '-march=i386' on 386, it should help > > I tried that already, to no avail.. Tried again, and the compiler outputs the > same 'xaddl' at a slighty different location (other parts of the code are > different) One can use -march=i386 -mcpu=i386 now. It seems to be bug in gcc. I built gcc-2.95.1 for DJGPP with -march=pentium -mcpu=pentium as default (target=i586-pc- msdosdjgpp). Specifying -march=i386 doesn't prevent macros __i486__, __i586__, __pentium__ from being defined, so bastring.h from libstdc++ uses inline assembler incorrect for i386. If I'm specifying -mcpu=i386 then these macros are not defined. The reason is that CPP_CPU_SPEC in gcc/config/i386/i386.h is broken -------------------------------------------------------------------------- #ifndef CPP_CPU_SPEC #define CPP_CPU_SPEC "\ -Acpu(i386) -Amachine(i386) \ %{!ansi:-Di386} -D__i386 -D__i386__ \ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} \ %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} \ %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} \ %{mcpu=k6:%(cpp_k6)} \ %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}}" #endif -------------------------------------------------------------------------- There are at least following problems: 1) no check is done for -m386 so option -m386 is silently ignored if the default is something else (for example I have built gcc for i586-*) 2) I think we should check for -march=foo instead of -mcpu=foo in CPP_CPU_SPEC > > - in future: I must rebuild gcc-2.95.1 for target i386-pc-msdosdjgpp > > Hmm. How come that in thousands of lines of code, the compiler only fails in > a global string definition.. > Andris