-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootstrap failure "Error: can not do 8 byte pc-relative relocation" #5376
Comments
assigned to @asl |
Please attach the LLVM IR. I doubt anyone who can look ino the problem has FreeBSD around. |
Please attach both the LLVM IR and the .s file, thanks. |
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. |
This is a 2.6 release blocker. Is someone working on it or do we need to recruit more people? |
Pawel, please include the output of running 'gcc -c eh_alloc.s' on the .s file. The line numbers above don't line up. |
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? |
Pawel - Any updates? |
Expect an update within two hours, I'm updating my trunk build of llvm now. |
gcc -c eh_alloc.seh_alloc.s: Assembler messages: binutils is 2.15 Build output from trunk: |
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:
Pawel, if you force "is4Byte" to true, does it work for you? |
I should have said that the last two attachments are from 2.6-PRE1 that builds ok. |
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... 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). |
Proposed solution:
Estimated time to implement: 2-4 hours |
|
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. |
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 |
recently I started seeing this with clang++: pes ~$ cat catch.cc 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) |
*** Bug llvm/llvm-bugzilla-archive#5977 has been marked as a duplicate of this bug. *** |
Preliminary patch
Tested on x86-32 and x86-64 linux. Not tested on darwin. |
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. |
This patch is close: $ cat picfail.m int main(void) The EH data seems correct, the address is now:
This is what gcc emits, while clang previously generated this:
(Where .L__unnamed_1 is "Object") However, at the end of the file I find this:
.L__gnu_objc_personality_v0: 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:
After:
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. |
|
|
|
Updated patch with layering problems fixes |
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". |
|
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! |
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"). |
|
|
Sorry. Attached. :-) I hope that it was just me running the test incorrectly. How did you run it? |
|
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. |
There were 10 regressions in the check-g++. I added the pr5004-4.sum file as an attachment. |
|
Updated patch, try 5 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! :-) |
|
... 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? |
|
So... finally fixed in commit series r96285-96290 |
Could you apply the patch from |
Done: Sending lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp |
mentioned in issue llvm/llvm-bugzilla-archive#5977 |
Extended Description
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++'
The text was updated successfully, but these errors were encountered: