This is an archive of the discontinued LLVM Phabricator instance.

[Driver][MSVC] Support DWARF fission when using LTO on Windows
ClosedPublic

Authored by HaohaiWen on Jul 1 2023, 9:10 PM.

Details

Summary

D154070 has added /dwodir to lld/COFF to tells LTO backend to create dwo
directory and files. This patch makes clang to emit /dwodir to lld when
user specify -gsplit-dwarf with LTO. This behavior is simiar to DWARF
fission with LTO for ELF.

A simple use case:
$clang-cl -c -flto -gdwarf main.c -o main.o
$clang-cl -c -flto -gdwarf a.c -o a.o
$clang-cl -flto -fuse-ld=lld -gdwarf -gsplit-dwarf main.o a.o

This'll generate a dwo file: main.exe_dwo/0.dwo

Diff Detail

Event Timeline

HaohaiWen created this revision.Jul 1 2023, 9:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2023, 9:10 PM
HaohaiWen requested review of this revision.Jul 1 2023, 9:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2023, 9:10 PM
mstorsjo accepted this revision.Jul 5 2023, 2:46 PM
mstorsjo added subscribers: hans, rnk.

I think this looks reasonable, unless e.g. @hans or @rnk would disagree.

This revision is now accepted and ready to land.Jul 5 2023, 2:46 PM
MaskRay accepted this revision.Jul 5 2023, 2:56 PM
hans accepted this revision.Jul 6 2023, 6:09 AM

Looks reasonable to me too.

It would be nice to have some documentation for this feature though.

This revision was landed with ongoing or failed builds.Jul 6 2023, 7:19 AM
This revision was automatically updated to reflect the committed changes.

Thanks everyone.

It would be nice to have some documentation for this feature though.

This feature is same as Linux -gsplit-dwarf.

hans added a comment.Jul 6 2023, 7:36 AM

It would be nice to have some documentation for this feature though.

This feature is same as Linux -gsplit-dwarf.

Right, but it would be nice to document that clang-cl supports it (which is not obvious since it's mostly trying to be cl.exe compatible).

It would be nice to have some documentation for this feature though.

This feature is same as Linux -gsplit-dwarf.

Right, but it would be nice to document that clang-cl supports it (which is not obvious since it's mostly trying to be cl.exe compatible).

Do you know which doc file should be updated? I haven't found a doc describe -gdwarf for Windows.

hans added a comment.Jul 11 2023, 7:00 AM

It would be nice to have some documentation for this feature though.

This feature is same as Linux -gsplit-dwarf.

Right, but it would be nice to document that clang-cl supports it (which is not obvious since it's mostly trying to be cl.exe compatible).

Do you know which doc file should be updated? I haven't found a doc describe -gdwarf for Windows.

I'd suggest putting it under https://clang.llvm.org/docs/UsersManual.html#clang-cl

But it seems we might not even have any docs for -gsplit-dwarf on non-Windows either, I suppose this is already as documented as it was before :)