[PATCH] D80391: [Driver] Don't make -gsplit-dwarf imply -g2
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 13 18:26:47 PST 2021
MaskRay added a comment.
In D80391#2497018 <https://reviews.llvm.org/D80391#2497018>, @inglorion wrote:
> For Chrome on Chrome OS, this is https://crbug.com/1158215
>
> Here, we saw our links fail with "output file too large". Investigation revealed that debug info was being included in the binary, instead of in .dwo files as expected. That turned out to be caused by this change.
>
> It seems that there are cases where -gsplit-dwarf is passed, but it does not take effect because there isn't also a -g (or -g<level>) option:
>
> clang -c -fthinlto-index=foo.o.thinlto.bc -gsplit-dwarf foo.o -o foo.bin.o
>
> Shows no .dwo file and debug info in foo.bin.o, whereas
>
> clang -c -fthinlto-index=foo.o.thinlto.bc -gsplit-dwarf -g foo.o -o foo.bin.o
>
> shows a .dwo file which is referenced from foo.bin.o
>
> The only thing that is different here is that the latter command has "-g" whereas the former doesn't.
>
> In other words, the new implementation still doesn't make -g and -gsplit-dwarf fully orthogonal; instead of -gsplit-dwarf always turning on debug fission, it *only* turns it on when there is also a -g or -g<level> option - at least in distributed ThinLTO code generation.
>
> It seems that orthogonality was the motivation for this change, and that -gsplit-dwarf without -g is supposed to work in the linker (per MaskRay's comment about -g being ignored by the linker).
>
> Can we make it so that -gsplit-dwarf turns on debug fission and we then use that even if no -g options were passed?
I am still confused what the problem is. I added some comments to the following distributed ThinLTO example.
Both -gsplit-dwarf and -g are needed for the ThinLTO backend compile step (`-fthinlto-index=`):
cat > ./a.c <<eof
int foo();
int main() { return foo();}
eof
echo 'int foo() {return 42; }' > ./b.c
cat > ./Makefile <<eof
clang := /tmp/RelA/bin/clang
all: final_link
compile a.o b.o a.indexing.o b.indexing.o: a.c b.c
# -gsplit-dwarf in the initial compile is a no-op.
$(clang) -gsplit-dwarf -g -O2 -c -flto=thin -fthin-link-bitcode=a.indexing.o a.c
$(clang) -gsplit-dwarf -g -O2 -c -flto=thin -fthin-link-bitcode=b.indexing.o b.c
thin_link lto/a.o.thinlto.bc lto/b.o.thinlto.bc a.rsp: a.indexing.o b.indexing.o
$(clang) -fuse-ld=lld -Wl,--thinlto-index-only=a.rsp -Wl,--thinlto-prefix-replace=';lto/' -Wl,--thinlto-object-suffix-replace='.indexing.o;.o' a.indexing.o b.indexing.o
thinlto_backend lto/a.o lto/b.o: a.o b.o lto/a.o.thinlto.bc lto/b.o.thinlto.bc
# This does not produce lto/a.dwo
# Both -gsplit-dwarf and -g are needed to get lto/a.dwo
$(clang) -g -O2 -c -fthinlto-index=lto/a.o.thinlto.bc a.o -o lto/a.o
$(clang) -g -O2 -c -fthinlto-index=lto/b.o.thinlto.bc b.o -o lto/b.o
final_link exe: lto/a.o lto/b.o a.rsp
$(clang) -fuse-ld=lld @a.rsp -o exe
clean:
$(RM) -f *.o lto/*.o lto/*.bc lto/*.dwo
eof
mkdir -p ./lto
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80391/new/
https://reviews.llvm.org/D80391
More information about the cfe-commits
mailing list