-
Notifications
You must be signed in to change notification settings - Fork 12k
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
MC: "error: A dwo section may not contain relocations" when building with fission + RISCV64 #56642
Comments
https://maskray.me/blog/2021-03-14-the-dark-side-of-riscv-linker-relaxation#split-dwarf
Let me send a Clang driver patch to disallow |
@llvm/issue-subscribers-backend-risc-v |
So GCC just silently produces broken .dwo files? |
@MaskRay - note that this will occur regardless of the state of @jrtc27 I can't say so definitely, but from a quick look, it seemed like gcc will just do |
Yes, GCC -mrelax -gsplit-dwarf output is currently silently broken. It uses a constant in Correction to myself: -gsplit-dwarf and linker relaxation is not incompatible. It's just unsupported in GCC and LLVM's debug info generator. Using address ranges/location description forms which are based on |
@llvm/issue-subscribers-debuginfo |
-gsplit-dwarf produces a .dwo file which will not be processed by the linker. If .dwo files contain relocations, they will not be resolved. Therefore the practice is that .dwo files do not contain relocations. Address ranges and location description need to use forms/entry kinds indexing into .debug_addr (DW_FORM_addrx/DW_RLE_startx_endx/etc), which is currently not implemented. There is a difficult-to-read MC error with -gsplit-dwarf with RISC-V for both -mrelax and -mno-relax. ``` % clang --target=riscv64-linux-gnu -g -gsplit-dwarf -c a.c error: A dwo section may not contain relocations ``` We expect to fix -mno-relax soon, so report a driver error for -mrelax for now. Link: #56642 Reviewed By: compnerd, kito-cheng Differential Revision: https://reviews.llvm.org/D130190
Yep, that sounds busted to me, which is why we have that check in LLVM to ensure no relocations are produced in .dwo sections. It sounds like what's needed is some way to check if a label difference is computable at compile-time (in which case we can use the high_pc-relative-to-low_pc encoding - and if it's not possible, we can use another address for high_pc) - is there such a hook/query already that we could use to fix the DWARF generation? |
Force eager evaluation of symbolic difference on debug_info which is required to be resolved eagerly for fission as dwo sections may not contain relocations. Fixes: llvm#56642
@dwblaikie hmm, well, it is possible to compute that in the case that relaxations are disabled. Given that |
Yeah, if we had/have a way to detect if a range will be known at compile time (ie: not subject to linker relaxation) then we could use that in the |
I think that we should be able to compute that from the SubtargetInfo. |
Another reduced test case failure:
|
yeah, looks like the minimize-addr-in-v5 isn't needed? & it reproduces with standalone debug, not just with constructor or limited debug info (and in v4). Hard to dump the dwo file (if I modify LLVM to still produce the relocations, so I might see where the relocations are) - since the relocations are invalid/refer to sections not in the dwo file. But looking at the output... it complains 4 times, though I only see 2 relocations that should be problematic. (the The issue does reproduce with a simpler file: In any case if there's some way to test whether
A similar check would be needed somewhere...
else clause that emits begin/end pairs, rather than any relative references). We'll need to add another parameter for the DWARFv5 encoding to allow it to use the DW_LLE/RLE_startx_endx encoding.
|
Oh, the interesting thing about that reproduction (and the use of the |
Oh, OK - yeah, so the reproduction that doesn't require minimize-addr-in-v5 but does hit the other codepath (the second one linked above) would require a non-contiguous scope inside a function - I usually do that by hand crafting/modifying IR, though there's probably some way to force reordering with the right instructions/transforms. So something like this:
Perform inlining, then reorder the non-inlined f1 call in between the inlined ones, then you'll get a range list in the dwo file that'll use an offset_pair that'll end up requiring relocations on RISCV, I think. |
-gsplit-dwarf produces a .dwo file which will not be processed by the linker. If .dwo files contain relocations, they will not be resolved. Therefore the practice is that .dwo files do not contain relocations. Address ranges and location description need to use forms/entry kinds indexing into .debug_addr (DW_FORM_addrx/DW_RLE_startx_endx/etc), which is currently not implemented. There is a difficult-to-read MC error with -gsplit-dwarf with RISC-V for both -mrelax and -mno-relax. ``` % clang --target=riscv64-linux-gnu -g -gsplit-dwarf -c a.c error: A dwo section may not contain relocations ``` We expect to fix -mno-relax soon, so report a driver error for -mrelax for now. Link: llvm/llvm-project#56642 Reviewed By: compnerd, kito-cheng Differential Revision: https://reviews.llvm.org/D130190
On riscv64gc linux, with rust > 1.64, building a crate(
|
Don’t do that then? Split dwarf doesn’t work with linker relaxations, and clang will stop you enabling it. If rustc lets you do it then that’s rustc’s problem. |
Split DWARF isn't fundamentally incapable of handling linker relaxation - it's bugs that can be fixed & would be true without split DWARF too... - that we can't use absolute values to represent the distance from one label to another in cases where that difference may be subject to relaxation. |
I think the assembler architecture for linker relaxation needs more work to not become a bottleneck fixing debug information issues. After |
-gsplit-dwarf produces a .dwo file which will not be processed by the linker. If .dwo files contain relocations, they will not be resolved. Therefore the practice is that .dwo files do not contain relocations. Address ranges and location description need to use forms/entry kinds indexing into .debug_addr (DW_FORM_addrx/DW_RLE_startx_endx/etc), which is currently not implemented. There is a difficult-to-read MC error with -gsplit-dwarf with RISC-V for both -mrelax and -mno-relax. ``` % clang --target=riscv64-linux-gnu -g -gsplit-dwarf -c a.c error: A dwo section may not contain relocations ``` We expect to fix -mno-relax soon, so report a driver error for -mrelax for now. Link: llvm/llvm-project#56642 Reviewed By: compnerd, kito-cheng Differential Revision: https://reviews.llvm.org/D130190
Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option. The packed/unpacked options might be supported in the future. See upstream issue for more details: llvm/llvm-project#56642 Fixes rust-lang#110224
…piler-errors riscv only supports split_debuginfo=off for now Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option. The packed/unpacked options might be supported in the future. See upstream issue for more details: llvm/llvm-project#56642 Fixes rust-lang#110224
…piler-errors riscv only supports split_debuginfo=off for now Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option. The packed/unpacked options might be supported in the future. See upstream issue for more details: llvm/llvm-project#56642 Fixes rust-lang#110224
…piler-errors riscv only supports split_debuginfo=off for now Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option. The packed/unpacked options might be supported in the future. See upstream issue for more details: llvm/llvm-project#56642 Fixes rust-lang#110224
…piler-errors riscv only supports split_debuginfo=off for now Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option. The packed/unpacked options might be supported in the future. See upstream issue for more details: llvm/llvm-project#56642 Fixes rust-lang#110224
Rollup merge of rust-lang#120518 - kxxt:riscv-split-debug-info, r=compiler-errors riscv only supports split_debuginfo=off for now Disable packed/unpacked options for riscv linux/android. Other riscv targets already only have the off option. The packed/unpacked options might be supported in the future. See upstream issue for more details: llvm/llvm-project#56642 Fixes rust-lang#110224
…sable-split-debuginfo, r=jieyouxu Disable run-make/split-debuginfo test for RISC-V 64 Together with `@Hoverbear,` we've been improving the state of the riscv64gc-unknown-linux-gnu target. This is in relation to rust-lang#125220 where `tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs` was disabled for RISC-V 64 in that another test, `tests/run-make/split-debuginfo` also needs to be disabled due to llvm/llvm-project#56642 and the changes made in rust-lang#120518. This test appears to be a host test, not a target test, so it isn't seen failing in rust-lang#126641, however, we are in the process of testing host tools for riscv64-gc-unknown-linux-gnu so this test has now been noticed to be a problem.
Rollup merge of rust-lang#127967 - joshua-zivkovic:joshua-zivkovic/disable-split-debuginfo, r=jieyouxu Disable run-make/split-debuginfo test for RISC-V 64 Together with `@Hoverbear,` we've been improving the state of the riscv64gc-unknown-linux-gnu target. This is in relation to rust-lang#125220 where `tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs` was disabled for RISC-V 64 in that another test, `tests/run-make/split-debuginfo` also needs to be disabled due to llvm/llvm-project#56642 and the changes made in rust-lang#120518. This test appears to be a host test, not a target test, so it isn't seen failing in rust-lang#126641, however, we are in the process of testing host tools for riscv64-gc-unknown-linux-gnu so this test has now been noticed to be a problem.
…it-debuginfo, r=jieyouxu Disable run-make/split-debuginfo test for RISC-V 64 Together with `@Hoverbear,` we've been improving the state of the riscv64gc-unknown-linux-gnu target. This is in relation to rust-lang/rust#125220 where `tests/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs` was disabled for RISC-V 64 in that another test, `tests/run-make/split-debuginfo` also needs to be disabled due to llvm/llvm-project#56642 and the changes made in rust-lang/rust#120518. This test appears to be a host test, not a target test, so it isn't seen failing in rust-lang/rust#126641, however, we are in the process of testing host tools for riscv64-gc-unknown-linux-gnu so this test has now been noticed to be a problem.
Hi @MaskRay, I Just wondered what your thoughts are on the current situation for |
FWIW, my take on it would be that MC should be able to answer the question "is this label difference resolvable at assembly-time" and then the DWARF emitter (lib/CodeGen/AsmPrinter/Dwarf*) can use that query to decide which representations to use most efficiently. This could/should/would also be used, for instance ,for PROPELLER (@tmsri FYI, we've talked about this before) if/when it's supporting relaxation. |
Correct. With basic block sections, linker relaxation could shrink branches changing the size of the block. The label differences would not be resolved at assembly-time in that case. |
When building with fission, the
DW_AT_high_pc
field in.debug_info
which is redirected to.debug_info.dwo
will contain a label difference. The field is meant to beDW_AT_low_pc
relative distance, so the difference is unavoidable. Furthermore, with relaxation, the size of the function may change at link time, and thus needs to be resolved at link time.It appears that gcc will emit the object file, duplicate it and then "extract the DWO sections" dropping the associated relocations resulting in the file showing no relocations.
The text was updated successfully, but these errors were encountered: