Bug 11350 - [3.3/3.4 regression] undefined labels with -Os -fPIC
Summary: [3.3/3.4 regression] undefined labels with -Os -fPIC
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 3.3
: P2 critical
Target Milestone: 3.3.3
Assignee: Richard Henderson
URL:
Keywords: link-failure, patch
: 10934 11920 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-06-27 12:13 UTC by Debian GCC Maintainers
Modified: 2005-12-11 21:31 UTC (History)
5 users (show)

See Also:
Host: i386-linux
Target: i386-linux
Build: i386-linux
Known to work:
Known to fail:
Last reconfirmed: 2003-10-26 21:52:36


Attachments
preprocessed source (33.94 KB, application/gzip-compresss)
2003-06-27 12:14 UTC, Debian GCC Maintainers
Details
generated .s file (56.39 KB, text/plain)
2003-06-27 12:15 UTC, Debian GCC Maintainers
Details
Reduced one but not all the way (25.72 KB, text/plain)
2003-06-27 13:12 UTC, Andrew Pinski
Details
still not all the way but only 143 left (932 bytes, text/plain)
2003-06-27 14:56 UTC, Andrew Pinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2003-06-27 12:13:26 UTC
[forwarded from http://bugs.debian.org/195911]

rechecked with 3.3 CVS 20030626 and HEAD CVS 20030531

While compiling XFree86 CVS with gcc-3.3 it compiles fine with default
optimization flags; but trying to compile with -Os results in undefined
symbols in shared libraries (i.e. this problem is only seen with -fPIC
and not otherwise) such as .L99. The problem was narrowed down to the
compilation of a few files e.g. xc/lib/Xaw/SimpleMenu.c, xc/lib/dps/dpsXclient.c
A check of assembly code shows that .L99 was being called with it being
absent; with -O2 it was present. Same problem comes with undefined .L92 in
xc/lib/Xaw6/SimpleMenu.c

Attaching the preprocessed source (.i and .s) in a followup.
Comment 1 Debian GCC Maintainers 2003-06-27 12:14:39 UTC
Created attachment 4291 [details]
preprocessed source
Comment 2 Debian GCC Maintainers 2003-06-27 12:15:19 UTC
Created attachment 4292 [details]
generated .s file
Comment 3 Debian GCC Maintainers 2003-06-27 12:16:25 UTC
command line used:

gcc -save-temps -c -g -Os -g -ansi -pedantic -Wall -Wpointer-arith
-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
-Wredundant-decls -Wnested-externs -Wundef  -I../../lib/Xaw  -I../..
-I../../exports/include   -Dlinux -D__i386__ -D_POSIX_C_SOURCE=199309L
-D_POSIX_SOURCE -D_XOPEN_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE  -D_GNU_SOURCE  
-DFUNCPROTO=15 -DNARROWPROTO   -DHAS_WCHAR_H -DHAS_WCTYPE_H -DNO_WIDEC_H
-DOLDXAW     -fPIC SimpleMenu.c
Comment 4 Andrew Pinski 2003-06-27 13:12:45 UTC
Created attachment 4293 [details]
Reduced one but not all the way

A reduced one which removes all the functions that is not used but keeps
PositionMenuAction where the problem is. This should be reduced more but I can
confirm this has a problem on the mainline (20030626).
Comment 5 Andrew Pinski 2003-06-27 14:56:05 UTC
Created attachment 4295 [details]
still not all the way but only 143 left

Almost a reduced case but still needs some work.
Comment 6 Andrew Pinski 2003-06-27 15:19:13 UTC
I cannot cut it down lower than 34 lines (removing any thing more will just cause gcc to 
produce the right code:
typedef struct { short x, y; } XPoint;
typedef struct {  int type;  int x_root, y_root; } XEvent;
typedef struct _WidgetRec *Widget;
Widget FindMenu(Widget);
void PositionMenu(Widget, XPoint*);
void PositionMenuAction(Widget, XEvent*);
void PositionMenuAction(Widget w, XEvent *event)
{
    Widget menu;
    XPoint loc;

    if ((menu = FindMenu(w)) == ((void *)0))
        return;

    switch (event->type) {
        case 4:
        case 5:
            loc.x = event->x_root;
            loc.y = event->y_root;
            PositionMenu(menu, &loc);
            break;
        case 7:
        case 8:
            loc.x = event->x_root;
            loc.y = event->y_root;
            PositionMenu(menu, &loc);
            break;
        case 6:
            loc.x = event->x_root;
            loc.y = event->y_root;
            PositionMenu(menu, &loc);
            break;
    }
}
Comment 7 Andrew Pinski 2003-06-30 15:18:23 UTC
*** Bug 10934 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2003-07-15 23:33:25 UTC
Should have been for target 3.3.1 (I had forgot to move it).  Another thing is it fails with 
3.2.2 but does not with 3.2.3.
Comment 9 Richard Henderson 2003-07-17 22:34:11 UTC
Yet another lost tablejump.
Comment 10 Mark Mitchell 2003-08-03 16:02:17 UTC
Postponed until GCC 3.3.2.
Comment 11 Debian GCC Maintainers 2003-08-13 07:42:58 UTC
It looks like this is fixed with Jim Wilson's alias.c patch(?), at least I am
unable to reproduce the failure on the 20030812 3.3 branch.
Comment 12 Debian GCC Maintainers 2003-08-13 08:14:47 UTC
please ignore the last comment, wrong PR ...
Comment 13 Andrew Pinski 2003-08-14 13:08:39 UTC
*** Bug 11920 has been marked as a duplicate of this bug. ***
Comment 14 Mark Mitchell 2003-10-16 09:42:19 UTC
Postponed until GCC 3.3.3.
Comment 15 Gabriel Dos Reis 2003-12-21 20:25:44 UTC
RTH --

You've been assigned this bug. Do you have plan for it?

-- Gaby
Comment 16 Andrew Pinski 2003-12-26 05:41:54 UTC
The reduced case does not fail on the mainline any more but the non reduced case does 
at -O1 -fPIC.
Comment 17 Andrew Pinski 2004-01-10 22:07:53 UTC
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-01/msg00791.html>.
Comment 18 Gabriel Dos Reis 2004-01-14 08:15:09 UTC
(In reply to comment #17)
> Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-01/msg00791.html>.

So RTH, what is your final word?
Comment 19 Richard Henderson 2004-01-14 20:04:04 UTC
Subject: Re:  [3.3/3.4 regression] undefined labels with -Os -fPIC

On Wed, Jan 14, 2004 at 08:15:12AM -0000, gdr at gcc dot gnu dot org wrote:
> > Patch here: <http://gcc.gnu.org/ml/gcc-patches/2004-01/msg00791.html>.
> 
> So RTH, what is your final word?

Not having a test case on hand that will fail because of this patch,
I guess I'll approve it.  I do seem to recall problems in the other
direction but I can't point to them.o

r~
Comment 20 CVS Commits 2004-01-16 11:07:33 UTC
Subject: Bug 11350

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	rth@gcc.gnu.org	2004-01-16 11:07:19

Modified files:
	gcc            : ChangeLog cfgcleanup.c cfgrtl.c 

Log message:
	PR opt/11350
	* cfgcleanup.c (try_optimize_cfg): Suppress tablejump removal
	after reload.
	* cfgrtl.c (try_redirect_by_replacing_branch): Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.883&r2=1.16114.2.884
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgcleanup.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.68.2.9&r2=1.68.2.10
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgrtl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.61.2.13&r2=1.61.2.14

Comment 21 CVS Commits 2004-01-16 11:30:56 UTC
Subject: Bug 11350

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	rth@gcc.gnu.org	2004-01-16 11:30:51

Modified files:
	gcc            : ChangeLog cfgcleanup.c cfgrtl.c 

Log message:
	PR opt/11350
	* cfgcleanup.c (try_optimize_cfg): Suppress tablejump removal
	after reload.
	* cfgrtl.c (rtl_can_merge_blocks, cfglayout_can_merge_blocks,
	rtl_try_redirect_by_replacing_branch): Likewise.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2320&r2=2.2321
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgcleanup.c.diff?cvsroot=gcc&r1=1.98&r2=1.99
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cfgrtl.c.diff?cvsroot=gcc&r1=1.102&r2=1.103

Comment 22 Richard Henderson 2004-01-16 11:32:28 UTC
Committed Jan's patch to both mainline and 3.3.