LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 5004 - Bootstrap failure "Error: can not do 8 byte pc-relative relocation"
Summary: Bootstrap failure "Error: can not do 8 byte pc-relative relocation"
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-gcc (show other bugs)
Version: trunk
Hardware: PC FreeBSD
: P normal
Assignee: Anton Korobeynikov
URL:
Keywords:
: 5977 (view as bug list)
Depends on:
Blocks: 3696
  Show dependency tree
 
Reported: 2009-09-17 19:48 PDT by Pawel Worach
Modified: 2010-02-15 18:58 PST (History)
13 users (show)

See Also:
Fixed By Commit(s):


Attachments
eh_alloc.bc (16.24 KB, application/octet-stream)
2009-09-20 07:58 PDT, Pawel Worach
Details
eh_alloc.s (39.33 KB, application/octet-stream)
2009-09-20 07:59 PDT, Pawel Worach
Details
eh_alloc.bc from trunk (12.52 KB, application/octet-stream)
2009-09-24 01:44 PDT, Pawel Worach
Details
eh_alloc.s from trunk (41.13 KB, application/octet-stream)
2009-09-24 01:44 PDT, Pawel Worach
Details
eh_alloc.bc from 2.6 (16.17 KB, application/octet-stream)
2009-09-24 16:59 PDT, Pawel Worach
Details
eh_alloc.s from 2.6 (108.51 KB, application/octet-stream)
2009-09-24 16:59 PDT, Pawel Worach
Details
patch to fix LSDA encoding in the CIE generated by the LLVM JIT. (888 bytes, patch)
2010-01-28 18:19 PST, Zoltan Varga
Details
Preliminary patch (49.29 KB, text/plain)
2010-01-29 20:39 PST, Anton Korobeynikov
Details
Updated patch (49.57 KB, text/plain)
2010-01-30 12:53 PST, Anton Korobeynikov
Details
Patch against ToT (48.42 KB, text/plain)
2010-02-09 03:16 PST, Anton Korobeynikov
Details
Updated patch with layering problems fixes (131.82 KB, patch)
2010-02-09 17:10 PST, Anton Korobeynikov
Details
check-g++ run with the updated patch. (57.43 KB, application/octet-stream)
2010-02-12 03:36 PST, Bill Wendling
Details
check-g++ run without thepatch. (56.88 KB, application/octet-stream)
2010-02-12 03:36 PST, Bill Wendling
Details
Updated patrch with darwin fixes (132.13 KB, patch)
2010-02-12 12:09 PST, Anton Korobeynikov
Details
Check-g++ run with pr5004-4 patch (56.91 KB, application/x-gzip)
2010-02-12 15:08 PST, Bill Wendling
Details
Updated patch, try 5 (132.15 KB, patch)
2010-02-13 11:39 PST, Anton Korobeynikov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Worach 2009-09-17 19:48:20 PDT
Using llvm r82173 and gcc 4.2.1 20070719 as the host compiler the bootstrap of llvm-gcc r82176 fails to bootstrap on FreeBSD/amd64 8.0

/usr/src-local/llvm-gcc/obj/./gcc/xgcc -shared-libgcc -B/usr/src-local/llvm-gcc/obj/./gcc -nostdinc++ -L/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/src -L/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/src/.libs -B/opt/llvm-gcc/x86_64-unknown-freebsd8.0/bin/ -B/opt/llvm-gcc/x86_64-unknown-freebsd8.0/lib/ -isystem /opt/llvm-gcc/x86_64-unknown-freebsd8.0/include -isystem /opt/llvm-gcc/x86_64-unknown-freebsd8.0/sys-include -I/usr/src-local/llvm-gcc/libstdc++-v3/../gcc -I/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/include/x86_64-unknown-freebsd8.0 -I/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/include -I/usr/src-local/llvm-gcc/libstdc++-v3/libsupc++ -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g -O2 -c ../../../../libstdc++-v3/libsupc++/eh_alloc.cc -o eh_alloc.o
/var/tmp//ccEBSLfL.s: Assembler messages:
/var/tmp//ccEBSLfL.s:757: Error: can not do 8 byte pc-relative relocation
/var/tmp//ccEBSLfL.s:772: Error: can not do 8 byte pc-relative relocation
/var/tmp//ccEBSLfL.s:793: Error: can not do 8 byte pc-relative relocation
gmake[4]: *** [eh_alloc.lo] Error 1
gmake[4]: Leaving directory `/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/libsupc++'
Comment 1 Anton Korobeynikov 2009-09-18 03:54:06 PDT
Please attach the LLVM IR. I doubt anyone who can look ino the problem has FreeBSD around.
Comment 2 Chris Lattner 2009-09-18 12:29:49 PDT
Please attach both the LLVM IR and the .s file, thanks.
Comment 3 Pawel Worach 2009-09-20 07:58:55 PDT
Created attachment 3534 [details]
eh_alloc.bc
Comment 4 Pawel Worach 2009-09-20 07:59:51 PDT
Created attachment 3535 [details]
eh_alloc.s
Comment 5 Pawel Worach 2009-09-20 08:01:06 PDT
This bug is now also seen with the 2.6-PRE2 release, PRE1 did not have this problem.

I've attached both the assembly and LLVM IR.
Comment 6 Tanya Lattner 2009-09-21 19:01:04 PDT
This is a 2.6 release blocker. Is someone working on it or do we need to recruit more people?
Comment 7 Chris Lattner 2009-09-22 14:12:01 PDT
Pawel, please include the output of running 'gcc -c eh_alloc.s' on the .s file.  The line numbers above don't line up.
Comment 8 Chris Lattner 2009-09-22 14:15:23 PDT
Actually, running  'gcc -m64 eh_alloc.s -c' on a linux system assembled the file just fine.  Are you sure there is a problem here?
Comment 9 Tanya Lattner 2009-09-23 11:56:07 PDT
Pawel - Any updates?
Comment 10 Pawel Worach 2009-09-23 15:37:21 PDT
Expect an update within two hours, I'm updating my trunk build of llvm now.
The IR and ASM was the output from 2.6, sorry for not attaching the output, this was the reason the lines probably didn't line up.
Comment 11 Pawel Worach 2009-09-24 01:41:48 PDT
# gcc -c eh_alloc.s 
eh_alloc.s: Assembler messages:
eh_alloc.s:774: Error: can not do 8 byte pc-relative relocation
eh_alloc.s:789: Error: can not do 8 byte pc-relative relocation

binutils is 2.15

Build output from trunk:
/usr/src-local/llvm-gcc/obj/./gcc/xgcc -shared-libgcc -B/usr/src-local/llvm-gcc/obj/./gcc -nostdinc++ -L/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/src -L/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/src/.libs -B/opt/llvm-gcc/x86_64-unknown-freebsd8.0/bin/ -B/opt/llvm-gcc/x86_64-unknown-freebsd8.0/lib/ -isystem /opt/llvm-gcc/x86_64-unknown-freebsd8.0/include -isystem /opt/llvm-gcc/x86_64-unknown-freebsd8.0/sys-include -I/usr/src-local/llvm-gcc/libstdc++-v3/../gcc -I/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/include/x86_64-unknown-freebsd8.0 -I/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/include -I/usr/src-local/llvm-gcc/libstdc++-v3/libsupc++ -fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -fdiagnostics-show-location=once -ffunction-sections -fdata-sections -g -O2 -c ../../../../libstdc++-v3/libsupc++/eh_alloc.cc -o eh_alloc.o
/var/tmp//ccM0T20x.s: Assembler messages:
/var/tmp//ccM0T20x.s:774: Error: can not do 8 byte pc-relative relocation
/var/tmp//ccM0T20x.s:789: Error: can not do 8 byte pc-relative relocation
gmake[4]: *** [eh_alloc.lo] Error 1
gmake[4]: Leaving directory `/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3/libsupc++'
gmake[3]: *** [all-recursive] Error 1
gmake[3]: Leaving directory `/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3'
gmake[2]: *** [all] Error 2
gmake[2]: Leaving directory `/usr/src-local/llvm-gcc/obj/x86_64-unknown-freebsd8.0/libstdc++-v3'
gmake[1]: *** [all-target-libstdc++-v3] Error 2
gmake[1]: Leaving directory `/usr/src-local/llvm-gcc/obj'
gmake: *** [bootstrap] Error 2
Comment 12 Pawel Worach 2009-09-24 01:44:16 PDT
Created attachment 3552 [details]
eh_alloc.bc from trunk
Comment 13 Pawel Worach 2009-09-24 01:44:57 PDT
Created attachment 3553 [details]
eh_alloc.s from trunk
Comment 14 Chris Lattner 2009-09-24 15:01:43 PDT
It looks like freebsd (or that version of gas) doesn't support that relocation type.  This code seems to be to blame in DwarfException.cpp:

    // If there is a personality and landing pads then point to the language
    // specific data area in the exception table.
    if (MMI->getPersonalities()[0] != NULL) {
      bool is4Byte = TD->getPointerSize() == sizeof(int32_t);

      Asm->EmitULEB128Bytes(is4Byte ? 4 : 8);
      Asm->EOL("Augmentation size");

      if (EHFrameInfo.hasLandingPads)
        EmitReference("exception", EHFrameInfo.Number, true, false);


Pawel, if you force "is4Byte" to true, does it work for you?

Comment 15 Pawel Worach 2009-09-24 16:59:34 PDT
Created attachment 3557 [details]
eh_alloc.bc from 2.6
Comment 16 Pawel Worach 2009-09-24 16:59:57 PDT
Created attachment 3558 [details]
eh_alloc.s from 2.6
Comment 17 Pawel Worach 2009-09-24 17:01:07 PDT
I should have said that the last two attachments are from 2.6-PRE1 that builds ok.
Comment 18 Anton Korobeynikov 2009-10-11 09:58:15 PDT
This is generic problem in our dwarf asmprinting, which seems currently to be pretty darwin-centric.

The problem is that we're emitting pcrel reference to EH frame. This is ok only for darwin. For linux we should use absptr / udata4 depending on the codemodel. 8 byte pcrel relocations should be used only for large / kernel code models (and in PIC mode only). This is actually both optimization & correctness stuff.

Optimization: the section is placed at zero address, thus pcrel relocations are generally not neeeded. Also they are quite big...
Correctness: 8 byte pcrel relocations were added only in binutils 2.17

The deleted EHFreferredDataFormat hooks returned proper encoding in all the cases. We need to restore them and implement generic reference printing routine (for given encoding).
Comment 19 Anton Korobeynikov 2009-10-11 10:12:52 PDT
Proposed solution:

1. Implement MAI hooks for returning target-specific personality / fde / lsda encodings
2. Extend EmitReference stuff to work with encodings, not with bunch of flags (indirect / force32 bit)
3. Use encodings consistently across the code (currently we're emitting encodings & handle reference printing separately effectively duplicating the stuff)

Estimated time to implement: 2-4 hours
Pros: Obvious
Cons: need extra round of tests :(
Comment 20 Anton Korobeynikov 2009-10-11 13:10:18 PDT
(In reply to comment #19)
> Proposed solution:
> 
> 1. Implement MAI hooks for returning target-specific personality / fde / lsda
> encodings
Actually, we need to think about proper way, since encoding (at least on linux) depends on relocation model & code model. This should not be exposed via MAI
Comment 21 Chris Lattner 2009-10-11 14:04:00 PDT
Ok, this is no longer blocking 2.6.  This is going to require some invasive surgery and needs to be baked.  For 2.6 we should recommend that people upgrade their binutils if they run into this.  I'll update the release notes to mention it.
Comment 22 Jonathan Gray 2009-11-02 06:41:53 PST
llvm-gcc also has this problem on OpenBSD/amd64 for what it's worth.  Currently an older version of binutils (2.15) is used which doesn't have R_X86_64_SIZE64.

There are plans to update binutils but this is a lot of work to catch breakage
on all the supported platforms and fix it.
Comment 23 Roman Divacky 2009-12-07 14:48:23 PST
recently I started seeing this with clang++:

pes ~$ cat catch.cc
void bar(void);
void foo(void) {
   try {
      bar();
   }
   catch (...) {
   }
}
pes ~$ clang++ catch.cc
/tmp/cc-wXOL0W.s: Assembler messages:
/tmp/cc-wXOL0W.s:138: Error: can not do 8 byte pc-relative relocation
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
pes ~$ 

is it the same issue as described here? if so is there any progress with this? (this is blocking llvm compilation with clang for example)
Comment 24 Anton Korobeynikov 2010-01-08 11:40:05 PST
*** Bug 5977 has been marked as a duplicate of this bug. ***
Comment 25 Zoltan Varga 2010-01-28 18:19:38 PST
Created attachment 4136 [details]
patch to fix LSDA encoding in the CIE generated by the LLVM JIT.
Comment 26 Anton Korobeynikov 2010-01-29 20:39:25 PST
Created attachment 4141 [details]
Preliminary patch

Here is preliminary patch to try. It implements:
 - Hooks to return Personality / FDE / LSDA / TType encoding depending on target / options (e.g. code model / relocation model)
 - MCIzation of Dwarf EH printer to use encoding information
 - Stub generation for ELF target (needed for indirect references)
 - Some other small changes here and there

Tested on x86-32 and x86-64 linux. Not tested on darwin.
Comment 27 Pawel Worach 2010-01-29 22:34:11 PST
The patch looks pretty good, llvm-gcc bootstraps (c,c++), a lot of previously broken c++ apps in FreeBSD now build. clang self-builds to the point of a link failure.
Comment 28 David Chisnall 2010-01-30 09:11:35 PST
(In reply to comment #26)
> Created an attachment (id=4141) [details]
> Preliminary patch

This patch is close:

$ cat picfail.m
#import <objc/Object.h>
#import <objc/NXConstStr.h>

int main(void)
{
	@try {
		@throw(@"foo");
	}
	@catch(Object *a) {}
	return 0;
}
$ clang -fPIC picfail.m 
/tmp/cc-Qugv3L.s: Assembler messages:
/tmp/cc-Qugv3L.s:311: Error: symbol `.L__unnamed_1' is already defined
clang: error: assembler command failed with exit code 1 (use -v to see invocation)

The EH data seems correct, the address is now:

    .long   .L__unnamed_1-.

This is what gcc emits, while clang previously generated this:

    .long    .L__unnamed_1

(Where .L__unnamed_1 is "Object")

However, at the end of the file I find this:

    .section    .note.GNU-stack,"",@progbits
    .section    .data.rel,"aw",@progbits
.L__gnu_objc_personality_v0:
    .long   __gnu_objc_personality_v0
.L__unnamed_1:
    .long   .L__unnamed_1

This second definition of .L__unnamed_1 is breaking things.

The reference to the personality function also looks very different.  This appears to be a regression; the unwind library was correctly finding the personality function with the old version, now it is failing to.  There seem to be a number of changes to the EH frame.  Before the change:

    .byte   0x1B
    .long   __gnu_objc_personality_v0-.

After:

    .byte   155
    .long   .L__gnu_objc_personality_v0-.

It's a bit difficult to play spot the difference because you've made it emit decimal, rather than hex, values for the constants, however, note that the value of the byte immediately preceding the address of the personality function changed from 27 to 155 as a result of this patch.  I'm not sure what this change means - I can't find the ABI docs - but reverting this in the generated assembly cause it to enter the personality routine.  Unfortunately, it still crashes in the part of the personality function that tries to read .L__unnamed_1.  

The rest of the exception frame looks totally different in GCC.  I can provide you with the assembled versions of both if you like, or you can generate them by compiling the trivial example from above with gcc and clang.  
Comment 29 Anton Korobeynikov 2010-01-30 09:34:28 PST
(In reply to comment #28)
> This second definition of .L__unnamed_1 is breaking things.
Ok, this makes sense. Stub generation should be improved to honour private symbols properly.

> changed from 27 to 155 as a result of this patch.  I'm not sure what this
> change means - I can't find the ABI docs
That's correct change. We need to use indirect pcrel encoding in general.

> The rest of the exception frame looks totally different in GCC.
This is surely expected.
Comment 30 David Chisnall 2010-01-30 10:42:56 PST
(In reply to comment #29)
> (In reply to comment #28)
> > changed from 27 to 155 as a result of this patch.  I'm not sure what this
> > change means - I can't find the ABI docs
> That's correct change. We need to use indirect pcrel encoding in general.

Yes, you're right, the problem is elsewhere.

Looking at the GCC output, it uses the same value, then:

     .long   DW.ref.__gnu_objc_personality_v0-.

This is basically the same as clang is now emitting:

    .long   .L__gnu_objc_personality_v0-.

However, the definition looks quite different  GCC emits this:

    .hidden DW.ref.__gnu_objc_personality_v0
    .weak   DW.ref.__gnu_objc_personality_v0
    .section    .gnu.linkonce.d.DW.ref.__gnu_objc_personality_v0,"aw",@progbits
    .align 4
    .type   DW.ref.__gnu_objc_personality_v0, @object
    .size   DW.ref.__gnu_objc_personality_v0, 4
DW.ref.__gnu_objc_personality_v0:
    .long   __gnu_objc_personality_v0


LLVM emits this:

    .section    .note.GNU-stack,"",@progbits
    .section    .data.rel,"aw",@progbits
.L__gnu_objc_personality_v0:
    .long   __gnu_objc_personality_v0

I'm not sure what the two .section directives are supposed to be for, but deleting them fixes the problem.  If I rename the second L__unnamed_1 to L__unnamed_2 in both places where it is used, then after deleting the two section directives (are they C++ specific?) the catch handler finds the correct object and the test program exits correctly.

So, removing the section stuff and correctly naming new variables should fix this patch.
Comment 31 Anton Korobeynikov 2010-01-30 12:49:52 PST
(In reply to comment #30)
> So, removing the section stuff
The section shouldn't matter at all! Both are emitted into data section. What if you add type/size stuff to llvm-generated one?
Comment 32 Anton Korobeynikov 2010-01-30 12:53:21 PST
Created attachment 4147 [details]
Updated patch

Here is updated patch. It contains two additional fixes:
 - Suffix is added for stubs, so we don't have name clash with private symbols anymore
 - I realized that we emitted invalid common eh frame since the early beginning - augmentation size uleb was emitted even if augmentation string indicated that there was no such word. This lead to invalid frame moves emission.
Comment 33 David Chisnall 2010-01-30 13:51:20 PST
(In reply to comment #32)
> Created an attachment (id=4147) [details]
> Updated patch
> 
> Here is updated patch. It contains two additional fixes:
>  - Suffix is added for stubs, so we don't have name clash with private symbols
> anymore
>  - I realized that we emitted invalid common eh frame since the early beginning
> - augmentation size uleb was emitted even if augmentation string indicated that
> there was no such word. This lead to invalid frame moves emission.
> 

This version works perfectly for me (FreeBSD, IA32).  Exceptions can now be caught in both PIC code and non-PIC code.

Thanks!

> The section shouldn't matter at all! Both are emitted into data section. What
> if you add type/size stuff to llvm-generated one?

They don't seem to matter in the new version.
Comment 34 Eric Christopher 2010-02-02 20:06:55 PST
We should test this on darwin before committing. If anyone can that would be
appreciated, otherwise i'll look at it shortly.
Comment 35 Bill Wendling 2010-02-09 02:01:41 PST
Applying the patch (and cleaning it up a bit to resolve some patch rejections and removing some "const"s) results in this cyclic dependency during compilation:

llvm[1]: Checking for cyclic dependencies between LLVM libraries.
find-cycles.pl: Circular dependency between *.a files:
find-cycles.pl:   libLLVMAnalysis.a libLLVMCodeGen.a libLLVMTarget.a
Comment 36 Anton Korobeynikov 2010-02-09 03:16:52 PST
Created attachment 4207 [details]
Patch against ToT

Here is new patch against ToT. Chris changes MC-related stuff too fast ;)
Comment 37 Anton Korobeynikov 2010-02-09 03:21:05 PST
(In reply to comment #35)
> llvm[1]: Checking for cyclic dependencies between LLVM libraries.
> find-cycles.pl: Circular dependency between *.a files:
> find-cycles.pl:   libLLVMAnalysis.a libLLVMCodeGen.a libLLVMTarget.a
Seems to be bogus. No Analysis code is touched. Which symbol(s) causes the cycle?

Comment 38 Bill Wendling 2010-02-09 05:43:07 PST
(In reply to comment #37)
> (In reply to comment #35)
> > llvm[1]: Checking for cyclic dependencies between LLVM libraries.
> > find-cycles.pl: Circular dependency between *.a files:
> > find-cycles.pl:   libLLVMAnalysis.a libLLVMCodeGen.a libLLVMTarget.a
> Seems to be bogus. No Analysis code is touched. Which symbol(s) causes the
> cycle?
> 
No clue. How do I find this out?

There is a genuine cycle:

libLLVMAnalysis.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a

libLLVMCodeGen.a: libLLVMAnalysis.a libLLVMCore.a libLLVMMC.a libLLVMScalarOpts.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMTransformUtils.a

libLLVMTarget.a: libLLVMCodeGen.a libLLVMCore.a libLLVMMC.a libLLVMSupport.a
Comment 39 Bill Wendling 2010-02-09 05:46:27 PST
(In reply to comment #38)
> There is a genuine cycle:
> 
> libLLVMAnalysis.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a
> libLLVMTarget.a
> 
> libLLVMCodeGen.a: libLLVMAnalysis.a libLLVMCore.a libLLVMMC.a
> libLLVMScalarOpts.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a
> libLLVMTransformUtils.a
> 
> libLLVMTarget.a: libLLVMCodeGen.a libLLVMCore.a libLLVMMC.a libLLVMSupport.a
> 
Without the change, here are the dependencies:

libLLVMAnalysis.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a

libLLVMCodeGen.a: libLLVMAnalysis.a libLLVMCore.a libLLVMMC.a libLLVMScalarOpts.a libLLVMSupport.a libLLVMSystem.a libLLVMTarget.a libLLVMTransformUtils.a

libLLVMTarget.a: libLLVMCore.a libLLVMMC.a libLLVMSupport.a

So the libLLVMTarget.a is picking up libLLVMCodeGen.a stuff.
Comment 40 Anton Korobeynikov 2010-02-09 06:28:59 PST
(In reply to comment #38)
> No clue. How do I find this out?
iirc there was some option -why of that script which shows the symbol...

> There is a genuine cycle:
> 
> libLLVMAnalysis.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a
> libLLVMTarget.a
This seems to be strange... Why would analysis require codegen?
Comment 41 Anton Korobeynikov 2010-02-09 06:32:20 PST
(In reply to comment #39)
> So the libLLVMTarget.a is picking up libLLVMCodeGen.a stuff.
Well, this is definitely expected, since target uses MMI (via TargetObjectLowering). 

But... I have this on linux:
libLLVMTarget.a: libLLVMCore.a libLLVMMC.a libLLVMSupport.a :(
Comment 42 Anton Korobeynikov 2010-02-09 06:46:09 PST
(In reply to comment #40)
> > libLLVMAnalysis.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a
> > libLLVMTarget.a
> This seems to be strange... Why would analysis require codegen?
Seems to be due to profile stuff, which pulls MachineBasicBlock and MachineFunction. Should that pass really be there?
Comment 43 Bill Wendling 2010-02-09 15:58:38 PST
(In reply to comment #42)
> (In reply to comment #40)
> > > libLLVMAnalysis.a: libLLVMCore.a libLLVMSupport.a libLLVMSystem.a
> > > libLLVMTarget.a
> > This seems to be strange... Why would analysis require codegen?
> Seems to be due to profile stuff, which pulls MachineBasicBlock and
> MachineFunction. Should that pass really be there?
> 
I'm confused. Where do you see it requiring codegen?

Here's what I get for libLLVMTarget.a's requirement:

libLLVMTarget.a:
 libLLVMCodeGen.a
  __ZTVN4llvm20MachineModuleInfoELFE
  __ZTVN4llvm21MachineModuleInfoImplE

which I think is what causes the loop.
Comment 44 Bill Wendling 2010-02-09 16:04:11 PST
(In reply to comment #43)
> Here's what I get for libLLVMTarget.a's requirement:
> 
> libLLVMTarget.a:
>  libLLVMCodeGen.a
>   __ZTVN4llvm20MachineModuleInfoELFE
>   __ZTVN4llvm21MachineModuleInfoImplE
> 
> which I think is what causes the loop.
> 
It's the code in TargetLoweringObjectFile.cpp for this method:

const MCExpr *TargetLoweringObjectFileELF::
getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
                             MachineModuleInfo *MMI, unsigned Encoding) const {

You need to figure out a different way of doing this:

    MachineModuleInfoELF &ELFMMI = MMI->getObjFileInfo<MachineModuleInfoELF>();

      ...

    MCSymbol *&StubSym = ELFMMI.getGVStubEntry(Sym);
Comment 45 Anton Korobeynikov 2010-02-09 16:15:19 PST
(In reply to comment #44)
> I'm confused. Where do you see it requiring codegen?
Yeah, sorry, I looked into wrong line.
Comment 46 Anton Korobeynikov 2010-02-09 16:17:38 PST
(In reply to comment #44)
> You need to figure out a different way of doing this:
Basically, we need to figure out how to resolve this layering violation. It's funny why this problem didn't trigger before - the only reason is that stub emission code is broken on non-x86 darwin (e.g. ppc),
It pretends to emit stub, but doesn't do this, all necessary code is moved to X86MachoTargetObjectLowering, otherwise (if implemented correctly) we'd have macho MMI use inside this file as well...
Comment 47 Anton Korobeynikov 2010-02-09 17:10:40 PST
Created attachment 4209 [details]
Updated patch with layering problems fixes

Bill, please try this file, it should have all layering problems fixed.
Comment 48 Bill Wendling 2010-02-09 17:24:13 PST
(In reply to comment #47)
> Created an attachment (id=4209) [details]
> Updated patch with layering problems fixes
> 
> Bill, please try this file, it should have all layering problems fixed.
> 
Thanks. That compiled. I did get an error in this test case, though:

CodeGen/Generic/2007-05-05-Personality.ll -mtriple=i686-pc-linux-gnu

It turns out that the CIE augmentation is this:

.asciz	 "zPL"                # CIE Augmentation

It's expecting it to be "zPLR".
Comment 49 Anton Korobeynikov 2010-02-09 17:29:34 PST
(In reply to comment #48)
> It's expecting it to be "zPLR".
"R" means that we're using non-default (non-absptr) FDE encoding. For x86-32/linux in non-PIC mode we're using absptr FDEs, so, the output is correct, I'll check the test twice & fix it.

Comment 50 Bill Wendling 2010-02-11 17:15:41 PST
(In reply to comment #49)
> (In reply to comment #48)
> > It's expecting it to be "zPLR".
> "R" means that we're using non-default (non-absptr) FDE encoding. For
> x86-32/linux in non-PIC mode we're using absptr FDEs, so, the output is
> correct, I'll check the test twice & fix it.
> 
Could you run the llvm-gcc "check-g++" testsuite on this first? If that passes, then you can go ahead and submit the patch with the change to the test mentioned above.

Thanks!
Comment 51 Bill Wendling 2010-02-11 17:39:35 PST
Oops! Spoke too soon. There were a large number of new failures with this patch in the g++ testsuite. I'm attaching the "new.g++.sum", which is run with your patch, against TOT ("old.g++.sum").
Comment 52 Anton Korobeynikov 2010-02-11 17:51:26 PST
(In reply to comment #50)
> Could you run the llvm-gcc "check-g++" testsuite on this first? If that passes,
> then you can go ahead and submit the patch with the change to the test
> mentioned above.
I did this, it passed. Duncan also tested it on Ada ACATS, which uses EH alot.
Comment 53 Anton Korobeynikov 2010-02-11 17:51:50 PST
(In reply to comment #51)
> Oops! Spoke too soon. There were a large number of new failures with this patch
> in the g++ testsuite. I'm attaching the "new.g++.sum", which is run with your
> patch, against TOT ("old.g++.sum").
-ENOATTACH :)
Comment 54 Bill Wendling 2010-02-12 03:36:23 PST
Created attachment 4215 [details]
check-g++ run with the updated patch.
Comment 55 Bill Wendling 2010-02-12 03:36:57 PST
Created attachment 4216 [details]
check-g++ run without thepatch.
Comment 56 Bill Wendling 2010-02-12 03:37:50 PST
(In reply to comment #53)
> -ENOATTACH :)
> 
Sorry. Attached. :-)

I hope that it was just me running the test incorrectly. How did you run it?
Comment 57 Anton Korobeynikov 2010-02-12 09:35:05 PST
(In reply to comment #56)
> (In reply to comment #53)
> > -ENOATTACH :)
> > 
> Sorry. Attached. :-)
Just to make sure - where did you run the testsuite? On SL?
Comment 58 Anton Korobeynikov 2010-02-12 12:07:01 PST
(In reply to comment #56)
> I hope that it was just me running the test incorrectly. How did you run it?
Ok, it turned out to be a silly typo for x86-64 darwin, which leads to assertion you're seeing during test run.

I didn't run the test on darwin - I just compared several assembler outputs to make sure that nothing changed insanely.

Updated patch attached.

Comment 59 Anton Korobeynikov 2010-02-12 12:09:02 PST
Created attachment 4218 [details]
Updated patrch with darwin fixes
Comment 60 Bill Wendling 2010-02-12 13:21:28 PST
(In reply to comment #58)
> Ok, it turned out to be a silly typo for x86-64 darwin, which leads to
> assertion you're seeing during test run.
> 
> I didn't run the test on darwin - I just compared several assembler outputs to
> make sure that nothing changed insanely.
> 
> Updated patch attached.
> 
Thanks! I'll test this out.
Comment 61 Bill Wendling 2010-02-12 15:08:33 PST
Created attachment 4219 [details]
Check-g++ run with pr5004-4 patch
Comment 62 Bill Wendling 2010-02-12 15:09:16 PST
(In reply to comment #58) 
> Updated patch attached.
> 
There were 10 regressions in the check-g++. I added the pr5004-4.sum file as an attachment.
Comment 63 Anton Korobeynikov 2010-02-12 15:14:36 PST
(In reply to comment #62)
> (In reply to comment #58) 
> > Updated patch attached.
> > 
> There were 10 regressions in the check-g++. I added the pr5004-4.sum file as an
> attachment.
Thanks! I'll investigate
Comment 64 Anton Korobeynikov 2010-02-13 11:39:01 PST
Created attachment 4223 [details]
Updated patch, try 5

Ok, yet another try with one more typo fixed :)

I verified - cp_compat now works :)
Comment 65 Bill Wendling 2010-02-14 22:20:18 PST
(In reply to comment #64)
> Created an attachment (id=4223) [details]
> Updated patch, try 5
> 
> Ok, yet another try with one more typo fixed :)
> 
> I verified - cp_compat now works :)
> 
It looks good. The only problem I saw was with the "FAIL: g++.dg/eh/cleanup1.C" test. But I've been noticing that it's been compiling *really* slowly lately. Like, on the order of 36 minutes. So it's basically timing out.

It seems to happen in the front end before it gets to the EH stuff in the llvm-convert.cpp file. I don't have an explanation for it.

I'm going to say that your last patch works for Darwin. Thanks! :-)
Comment 66 Anton Korobeynikov 2010-02-15 02:58:56 PST
(In reply to comment #65)
> (In reply to comment #64)
> > Created an attachment (id=4223) [details] [details]
> > Updated patch, try 5
> > 
> > Ok, yet another try with one more typo fixed :)
> > 
> > I verified - cp_compat now works :)
> > 
> It looks good. The only problem I saw was with the "FAIL: g++.dg/eh/cleanup1.C"
cleanup1 is nasty - it contains 'just' 4000 cleanups, so, yes, it will definitely time out.

> I'm going to say that your last patch works for Darwin. Thanks! :-)
Awesome! I'll apply it then.
Comment 67 Eric Christopher 2010-02-15 12:36:42 PST
... It wasn't timing out last time I worked on it. What happened?
Comment 68 Bill Wendling 2010-02-15 13:34:52 PST
(In reply to comment #67)
> ... It wasn't timing out last time I worked on it. What happened?
> 
I'm stumped myself. It's not timing out all of the time. And I even have a build which doesn't time out. Maybe it's a "debug" verses "release" build thing?
Comment 69 Anton Korobeynikov 2010-02-15 16:47:40 PST
(In reply to comment #68)
> I'm stumped myself. It's not timing out all of the time. And I even have a
> build which doesn't time out. Maybe it's a "debug" verses "release" build
> thing?
debug also timeouts for me, release - not
Comment 70 Anton Korobeynikov 2010-02-15 16:48:46 PST
So... finally fixed in commit series r96285-96290
Comment 71 Zoltan Varga 2010-02-15 18:54:42 PST
Could you apply the patch from
http://llvm.org/bugs/attachment.cgi?id=4136
as well ?
Comment 72 Bill Wendling 2010-02-15 18:58:28 PST
(In reply to comment #71)
> Could you apply the patch from
> http://llvm.org/bugs/attachment.cgi?id=4136
> as well ?
> 
Done:

Sending        lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp
Transmitting file data .
Committed revision 96304.