This is an archive of the discontinued LLVM Phabricator instance.

[Driver] Error for -gsplit-dwarf with RISC-V linker relaxation
ClosedPublic

Authored by MaskRay on Jul 20 2022, 11:46 AM.

Details

Summary

-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: https://github.com/llvm/llvm-project/issues/56642

Diff Detail

Event Timeline

MaskRay created this revision.Jul 20 2022, 11:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 11:46 AM
MaskRay requested review of this revision.Jul 20 2022, 11:46 AM
MaskRay updated this revision to Diff 446239.Jul 20 2022, 12:51 PM

incompatible => unsupported

since it is implementable (but difficult).

compnerd added inline comments.Jul 20 2022, 1:26 PM
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
10

This feels like a layering violation. I suppose that as long as modular builds are okay ...

clang/test/Driver/riscv-features.c
40

Did you mean to add -### to these two?

MaskRay added inline comments.Jul 20 2022, 1:28 PM
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
10

lib/Driver/ToolChains/Arch does not form a module or library. Arch/ is just a subdirectory containing these arch-specific files. So I think this is fine.

clang/test/Driver/riscv-features.c
40

No. In the presence of errors, without -### the clang command exists with 1 and does not write to the output. I feel that this behavior is better for error testing.

compnerd requested changes to this revision.Jul 20 2022, 1:32 PM
compnerd added inline comments.
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
146

This should be hoisted out, this will occur with or without relaxation. That is, -mrelax and -mno-relax are both problematic.

clang/test/Driver/riscv-features.c
41

Can you please add a -mno-relax check as well?

This revision now requires changes to proceed.Jul 20 2022, 1:32 PM
MaskRay marked 2 inline comments as done.Jul 20 2022, 2:20 PM
MaskRay added inline comments.
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
146

No. -mno-relax is supported with -gsplit-dwarf. I think the current code is correct.

clang/test/Driver/riscv-features.c
41

The line you reference has -mno-relax :)

MaskRay marked 3 inline comments as done.Jul 20 2022, 2:20 PM
MaskRay requested review of this revision.Jul 20 2022, 3:48 PM
compnerd added inline comments.Jul 21 2022, 10:16 AM
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
146

No, that is the point, it is not. Building with -mno-relax and -gsplit-dwarf will fail with the same behaviour.

MaskRay added inline comments.Jul 21 2022, 10:30 AM
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
146

OK, I confirm. -mno-relax -gsplit-dwarf should be compatible and can be fixed separated (e.g. by your D130206, I suspect it doesn't cover all cases).

-mrelax -gsplit-dwarf will likely stay unsupported for a while so the driver error will not hurt.

compnerd accepted this revision.Jul 21 2022, 11:33 AM
This revision is now accepted and ready to land.Jul 21 2022, 11:33 AM
MaskRay edited the summary of this revision. (Show Details)Jul 22 2022, 5:15 PM
This revision was landed with ongoing or failed builds.Jul 22 2022, 5:16 PM
This revision was automatically updated to reflect the committed changes.