Bug 22099 - builtin_setjmp gives duplicate labels
Summary: builtin_setjmp gives duplicate labels
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.6
: P2 normal
Target Milestone: 4.2.0
Assignee: Andrew Pinski
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: assemble-failure, patch
Depends on:
Blocks:
 
Reported: 2005-06-17 00:08 UTC by hebisch
Modified: 2006-01-19 17:29 UTC (History)
3 users (show)

See Also:
Host:
Target: i686-apple-darwin
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-10 16:50:34


Attachments
patch which needs testing but works for simple testing (452 bytes, patch)
2006-01-13 01:36 UTC, Andrew Pinski
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description hebisch 2005-06-17 00:08:40 UTC
The following program, when compiled with -fPIC option (on by
default on Darwin) gives me duplicate label in assembler
output:
extern int printf(const char *, ...);

struct { int a[5];} jmp_buf;
void
f(void)
{
  void g(void)
  {
  }
  if (__builtin_setjmp(&jmp_buf))
    goto l;
  g();
  printf("failed\n");
l:;
}

int
main(void)
{
  f();
  return 0;
}

I can see duplicate label "L00000000001$pb" in the assemble output.
Note that I have not set up full cross-compile environmet, I just
configured gcc for i686-apple-darwin target. The build failed,
but cc1 is built. 
This is a reduced test case. Original problem appeared in GNU
Pascal in native compiler on i686-apple-darwin host.
The problem is also present in gcc-3.3.6 (the label is called
L1$pb) and in gcc-3.4.4.
Comment 1 Andrew Pinski 2005-06-17 03:46:37 UTC
Confirmed, good to know I did not cause this when I changed the how the PIC label is done on darwin.
What needs to be done is something like what is done for ppc-darwin.
Comment 2 Andrew Pinski 2005-06-17 03:48:14 UTC
This most likely also breaks Ada also until the default exception handling is changed to dwarf-2.

Note you might get better response if you file this with Apple.
Comment 3 Adriaan van Os 2005-12-02 13:59:57 UTC
The bug is solved by recently proposed Darwin x86 fixes <http://gcc.gnu.org/ml/gcc-patches/2005-11/msg02158.html>.
Comment 4 Andrew Pinski 2006-01-12 16:12:02 UTC
It is not fully fixed:
FAIL: gcc.c-torture/compile/20011029-1.c  -O0  (test for excess errors)
Excess errors:
/var/tmp//cc4yx2Rb.s:23:non-relocatable subtraction expression, "L4" minus "L00000000001$pb"
/var/tmp//cc4yx2Rb.s:23:symbol: "L4" can't be undefined in a subtraction expression
/var/tmp//cc4yx2Rb.s:unknown:Undefined local symbol L4
Comment 5 Andrew Pinski 2006-01-12 16:13:34 UTC
FAIL: gcc.c-torture/execute/builtins/memcpy-chk.c compilation,  -O0
UNRESOLVED: gcc.c-torture/execute/builtins/memcpy-chk.c execution,  -O0
Executing on host: /Volumes/HD/ltmp/ssen/gcc-build/gcc/xgcc -B/Volumes/HD/ltmp/ssen/gcc-build/gcc/ /ltmp/ssen/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/memcpy-chk.c /ltmp/ssen/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/memcpy-chk-lib.c /ltmp/ssen/gcc/gcc/testsuite/gcc.c-torture/execute/builtins/lib/main.c  -w  -O1  -fno-show-column  -lm   -o /ltmp/ssen/gcc-build/gcc/testsuite/memcpy-chk.x1    (timeout = 300)
/var/tmp//cc5w2nYV.s:2461:non-relocatable subtraction expression, "L179" minus "L00000000006$pb"^M
/var/tmp//cc5w2nYV.s:2461:symbol: "L179" can't be undefined in a subtraction expression^M
/var/tmp//cc5w2nYV.s:2430:non-relocatable subtraction expression, "L174" minus "L00000000006$pb"^M
/var/tmp//cc5w2nYV.s:2430:symbol: "L174" can't be undefined in a subtraction expression^M
/var/tmp//cc5w2nYV.s:2403:non-relocatable subtraction expression, "L169" minus "L00000000006$pb"^M
/var/tmp//cc5w2nYV.s:2403:symbol: "L169" can't be undefined in a subtraction expression^M
/var/tmp//cc5w2nYV.s:unknown:Undefined local symbol L169^M
/var/tmp//cc5w2nYV.s:unknown:Undefined local symbol L174^M
/var/tmp//cc5w2nYV.s:unknown:Undefined local symbol L179^M

Comment 6 Andrew Pinski 2006-01-12 16:14:34 UTC
FAIL: gcc.c-torture/execute/built-in-setjmp.c compilation,  -O0
UNRESOLVED: gcc.c-torture/execute/built-in-setjmp.c execution,  -O0
Executing on host: /Volumes/HD/ltmp/ssen/gcc-build/gcc/xgcc -B/Volumes/HD/ltmp/ssen/gcc-build/gcc/ /ltmp/ssen/gcc/gcc/testsuite/gcc.c-torture/execute/built-in-setjmp.c  -w  -O1  -fno-show-column  -lm   -o /ltmp/ssen/gcc-build/gcc/testsuite/built-in-setjmp.x1    (timeout = 300)
/var/tmp//ccJXYNJy.s:43:non-relocatable subtraction expression, "L6" minus "L00000000002$pb"^M
/var/tmp//ccJXYNJy.s:43:symbol: "L6" can't be undefined in a subtraction expression^M
/var/tmp//ccJXYNJy.s:unknown:Undefined local symbol L6^M
compiler exited with status 1
Comment 7 Andrew Pinski 2006-01-12 23:53:31 UTC
Ok, I think I will be able to fix this fully, working on it for now.
Comment 8 Andrew Pinski 2006-01-13 01:36:37 UTC
Created attachment 10635 [details]
patch which needs testing but works for simple testing

ChangeLog:
* i386.md (builtin_setjmp_receiver): Don't emit the label.
* i386.c (output_set_got): Output the label if we have one.
Comment 9 Andrew Pinski 2006-01-13 04:29:20 UTC
Patch posted:
http://gcc.gnu.org/ml/gcc-patches/2006-01/msg00685.html
Comment 10 Andrew Pinski 2006-01-19 17:28:56 UTC
Subject: Bug 22099

Author: pinskia
Date: Thu Jan 19 17:28:53 2006
New Revision: 109974

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109974
Log:
2006-01-19  Andrew Pinski  <pinskia@physics.uc.edu>

        PR target/22099
        * config/i386/i386.md (builtin_setjmp_receiver): Don't emit the label.
        * config/i386/i386.c (output_set_got): Output the label if we have one
        for the TARGET_DEEP_BRANCH_PREDICTION case.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/i386/i386.md

Comment 11 Andrew Pinski 2006-01-19 17:29:24 UTC
Fixed in 4.2.0 and above.