Bug 18912 - FW: gcc 3.3.1 for Powerpc optimzation flag -Os generates bad code
Summary: FW: gcc 3.3.1 for Powerpc optimzation flag -Os generates bad code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-09 21:29 UTC by Atul Sabharwal
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Atul Sabharwal 2004-12-09 21:29:11 UTC
I have been trying to run busybox-1.00  ( also rc3)   on my powerpc board (MPC 
8540 processor ) and about half
the applets do not run and die with the message "Illegal instruction".  I have 
ppc_82xx-gcc Montavista compiler 
for the power pc board.  These compilers are cross compiled version of gcc 
3.3.1 compiler.  We are using the 
cross compiled glibc-2.3.2.
 
Some critical applets which are failing with Illegal instruction message are :
 
ar ash bunzip2 bzcat cat chgrp chown cmp cp cpio crond install ln ls mkdir tty 
wc cut date df du
egrep env expr fgrep find modprobe mount  rm rmdir route uname wget ftpget 
ftpput grep gunzip
halt head httpd id ifconfig inetd sh sort syslogd uniq xargs tee telnetd touch 
tr vi yes zcat.
 
About half the commands are broken.  When I compile with no optimization or 
optimize for speed i.e. -O2
instead for size -Os, everything works fine. 

Seems like an optimzation bug to me.

--
Atul

The configure command for cross compiling gcc was as below ( output of
ppc_82xx-gcc -v ) ::

Reading specs from /opt/montavista/pro/devkit/ppc/82xx/bin/../lib/gcc-
lib/powerpc-hardhat-linux/3.3.1/specs
Configured with: ../configure --host=i686-pc-linux-gnu --target=powerpc-
hardhat-linux 
--prefix=/opt/montavista/devkit/ppc/82xx --exec-
prefix=/opt/montavista/devkit/ppc/82xx 
--bindir=/opt/montavista/devkit/ppc/82xx/bin --
sbindir=/opt/montavista/devkit/ppc/82xx/sbin 
--sysconfdir=/opt/montavista/devkit/ppc/82xx/etc --
datadir=/opt/montavista/devkit/ppc/82xx/share 
--includedir=/opt/montavista/devkit/ppc/82xx/include --
libdir=/opt/montavista/devkit/ppc/82xx/lib 
--libexecdir=/opt/montavista/devkit/ppc/82xx/libexec --
localstatedir=/opt/montavista/devkit/ppc/82xx/var 
--sharedstatedir=/opt/montavista/devkit/ppc/82xx/share --
mandir=/opt/montavista/devkit/ppc/82xx/man 
--infodir=/opt/montavista/devkit/ppc/82xx/info --program-transform-
name=s,^,ppc_82xx-, --enable-cross 
--with-sysroot=/opt/montavista/devkit/ppc/82xx/target --enable-shared --enable-
languages=c,c++ --enable-__cxa_atexit 
--enable-threads=posix --disable-multilib --with-gxx-include-
dir='$'{gcc_tooldir}/../target/usr/include/c++/3.3.1 
--with-cpu=603
Thread model: posix
gcc version 3.3.1 (MontaVista 3.3.1-3.0.10.0300532 2003-12-24)
Comment 1 Andrew Pinski 2004-12-09 21:33:06 UTC
Hmm, you compiled for cpu=603 but the 82xx processor is not fully the same, also do you have a 
simple testcase?  read <http://gcc.gnu.org/bugs.html> also.
Comment 2 atul.sabharwal@exgate.tek.com 2004-12-09 22:01:25 UTC
Subject: RE:  FW: gcc 3.3.1 for Powerpc optimzation flag
	 -Os generates bad code

I do not have a simple test case at this point which triggers this flaw.
A simple busybox applet e.g ls  causes "Illegal instruction".
Its about 1000 lines of code with comments. It has some libraries 
too.

If I am able to isolate further would notify you.
--
Atul

-----Original Message-----
From: pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org] 
Sent: Thursday, December 09, 2004 1:33 PM
To: atul.sabharwal@tek.com
Subject: [Bug target/18912] FW: gcc 3.3.1 for Powerpc optimzation flag -Os
generates bad code



------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-09
21:33 -------
Hmm, you compiled for cpu=603 but the 82xx processor is not fully the same,
also do you have a 
simple testcase?  read <http://gcc.gnu.org/bugs.html> also.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal
             Status|UNCONFIRMED                 |WAITING
          Component|c                           |target


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18912

------- You are receiving this mail because: -------
You reported the bug, or are watching the reporter.
Comment 3 Andrew Pinski 2004-12-09 22:03:55 UTC
Also does -mcpu=8540 fix the problem then when compiling?
Comment 4 atul.sabharwal@exgate.tek.com 2004-12-09 22:28:52 UTC
Subject: RE:  FW: gcc 3.3.1 for Powerpc optimzation flag
	 -Os generates bad code

I tried -mpcu=8540 and it does not fix the problem. Commands like ls or ash
still fail. I checked the build scripts and its using this new flag.

--
Atul

-----Original Message-----
From: pinskia at gcc dot gnu dot org [mailto:gcc-bugzilla@gcc.gnu.org] 
Sent: Thursday, December 09, 2004 2:04 PM
To: atul.sabharwal@tek.com
Subject: [Bug target/18912] FW: gcc 3.3.1 for Powerpc optimzation flag -Os
generates bad code



------- Additional Comments From pinskia at gcc dot gnu dot org  2004-12-09
22:03 -------
Also does -mcpu=8540 fix the problem then when compiling?

Comment 5 Atul Sabharwal 2004-12-14 17:53:43 UTC
This bug is fixed in 3.4.1 version of gcc. I received a cross compiled version 
of gcc for MPC8540 platform with the 3.4.1 gcc based tool chain and all 
busybox apps work correctly.
Comment 6 Andrew Pinski 2004-12-14 17:55:54 UTC
Closing as fixed then.