-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Debuginfo generation is broken with LLVM 3.8 #36774
Comments
This is a regression-from-stable-to-nightly (-beta in a few days) and and I-ICE. |
I'm not sure which stable you meant, but I'm seeing this regression on stable 1.12 while building git2 for cargo, while compiling the same with 1.11 is fine. Here's the excerpt from Fedora's full build.log:
|
I can also reproduce this compiling |
I can confirm the error reported by @cuviper on Mageia too, using Rust 1.12.0 and LLVM 3.8.1, on both x86_64 and i586. The rust and cargo packaging in Mageia are otherwise synced with Fedora. Full build log on x86_64. |
I also just confirmed that 1.12 with |
Tagging as regression. cc @rust-lang/compiler |
Bisecting from LLVM 3.8 to LLVM 3.9 led to r267296. That is, r267295 errors, and r267296 does not. |
Thanks for bisecting @sanxiyn |
Compiler team please triage. |
Backporting an LLVM patch is not an option, as we do not control that LLVM 3.8 which distributions use. Seems to me like there’s exactly two viable fixes:
|
Do we know what we would have to do in order to be "3.8-compatible"? |
FWIW, I've been asked many times if Fedora will keep up to date with the latest Rust, presumably by people who really want that. If we suddenly require LLVM 3.9, this is a serious roadblock to upgrades. Even Fedora Rawhide has not updated LLVM yet! A backported LLVM patch is possible -- if we know it fixes the problem, I can ask our LLVM maintainers to apply it. However, if I'm not mistaken that patch is modifying a couple public headers, which is bad for API compatibility and probably signals ABI changes too. A backport would have to mitigate that. If it's possible for rustc/rustllvm/whatever to make a change for 3.8-compatibility, I'd be much happier backporting that to our rust package. |
triage: P-high assigning to @michaelwoerister to investigate a bit more what is happening here. |
Reduced test case to 60 lines: https://gist.github.com/sanxiyn/b1d666f132d3314cd999bb9b629acc2b |
@sanxiyn Thank you so much for the reduction! That will be very helpful. |
So, I've been able to reproduce this (thanks again, @sanxiyn) but I cannot find any real difference in the debuginfo produced by the working and by the failing versions of LLVM. Type sizes and alignments and field offsets seem to be correct, and they are the same in both versions. |
I'm gonna give rustc 1.11 a try. |
Alright, bisecting Rust between 1.11 and 1.12 has revealed that PR #35197 somehow breaks LLVM 3.8. I don't have a clue as to why that is. Any idea, @eddyb? For reference: I bisected by building Rust against LLVM 3.8.0 and checking whether it could build Cargo with debuginfo+optimizations (Cargo is the project for which building fails in the logs provided above by @cuviper). |
@michaelwoerister For the record, that PR is where MIR trans was turned on. So you'll want to go back further and add |
@michaelwoerister I'm a little confused, because even base 1.11 fails for me when using |
I thought mir-trans was already enabled in #34096? That PR still passes just fine. |
@michaelwoerister #34096 has absolutely no effect for cross-crate MIR because someone broke it. |
@eddyb Can you elaborate? Do you mean that inlined functions were still translated with old-trans by default? |
@michaelwoerister Not just by default, the compiler simply couldn't inline MIR cross-crate because the |
@eddyb So translation fell back to old-trans when it didn't find the MIR in the extern crate? |
@michaelwoerister Right, it never found the MIR cross-crate so it used old trans (like |
So, it's possible that neither MIR-trans nor old-trans never actually worked reliably with LLVM 3.8 with debuginfo+optimizations enabled and MIR-trans is just more likely to run into this bug, right? At least I have no indication so far, that MIR trans generates different or faulty debuginfo. It might just generate code that is more amenable to SROA or something. |
I can't comment on likelihood, but anecdotally I've never seen this issue without MIR. I just tried even older
Whereas 1.9.0 finally fails differently and ICEs on git2:
1.9 also errors on rustc-serialize:
|
Hmm, external LLVM may be a red herring. I just tried with nightly and got a similar error, though it came from a different place.
|
See also: #35547 |
Update: #37153 should help with at least some of these cases, maybe all. I've also filed a bug report with LLVM: https://llvm.org/bugs/show_bug.cgi?id=30703 Also note, that if you don't need full debuginfo, just line tables for profiling and backtraces, then compiling with "-Cdebuginfo=1" is sufficient and will prevent these assertions from being triggered. |
debuginfo: Handle spread_arg case in MIR-trans in a more stable way. Use `VariableAccess::DirectVariable` instead of `VariableAccess::IndirectVariable` in order not to make LLVM's SROA angry. This is a step towards fixing #36774 and #35547. At least, I can build Cargo with optimizations + debuginfo again. r? @eddyb
debuginfo: Handle spread_arg case in MIR-trans in a more stable way. Use `VariableAccess::DirectVariable` instead of `VariableAccess::IndirectVariable` in order not to make LLVM's SROA angry. This is a step towards fixing #36774 and #35547. At least, I can build Cargo with optimizations + debuginfo again. r? @eddyb
Thanks @michaelwoerister! Waiting on backport. |
Yes, I thought so too. The code in the two PRs looks correct. |
PR #37315 seems to run into something like this, after the partial fix. (Note: It was triggered by the flat_map part linked here, the PR was since updated to remove it): piece is larger than or outside of variable
tail call void @llvm.dbg.value(metadata %"ty::FieldDefData"* %2, i64 0, metadata !105417, metadata !6823), !dbg !105421
!105417 = !DILocalVariable(arg: 3, scope: !105386, file: !15, line: 1, type: !105406)
!6823 = !DIExpression(DW_OP_bit_piece, 64, 64)
LLVM ERROR: Broken function found, compilation aborted! The line inside librustc that produced the assertion was here, where |
@bluss |
The issue reported by @bluss in the comment above seems to happen on our in-tree LLVM (our buildbots). Would be good to try minimise the reproduction and see if it also happens on external LLVM first. |
@nagisa I didn't even know where to begin minimizing it, since it was triggered by code in librustc, a pretty large crate. |
Does that suggest that the issue reported by @bluss is a separate issue? |
@nikomatsakis That seems about right. I also feel that the issue reported by @bluss might not be just a regression, but a genuine bug. Either way, a good idea would be to fill a new issue and try to reproduce what @bluss saw. Other than that I can confirm that bootstrapping rustc with LLVM 3.8 does not ICE anymore, so we’re good in that regard. |
@bluss Would you mind opening a new issue for the problem you discovered? You can copy your comment from above, that is informative enough. Closing this issue since the original problem has been solved. |
New issue is #37633 |
Thank you, @bluss! |
Compiling librustc_mir with optimisations on and debuginfo enabled fails with LLVM assertion:
The failure started happening sometime in the past month. Any change related to how we generate debuginfo for variables is a suspect as it likely specifies the size of the variable incorrectly (as per https://llvm.org/bugs/show_bug.cgi?id=23712)
Works fine with LLVM bundled with rust.
The text was updated successfully, but these errors were encountered: