On Wed, Jan 13, 2021 at 6:26 PM Fangrui Song via Phabricator < revi...@reviews.llvm.org> wrote:
> 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=`) ^ this I would consider to be a bug. -g should be needed to generate debug info into the IR, and -gsplit-dwarf should be needed to choose how debug info already in the IR should be placed into object files or dwo files. Usually (non-LTO) these two steps are in the same compile, so -g and -gsplit-dwarf go together. But for LTO cases, I think it's suitable for -g to be needed for IR generation, and -gsplit-dwarf to be needed for object code generation, without needing -g as well in that latter step (the -g was already specified at IR generation time, and that shoul be enough). We can see that behavior I'm describing as desirable in implicit ThinLTO I showed earlier in the thread. I suggest this should be the desired behavior, because -g generally has no effect on IR->object code generation, so it seems strange/unnecessary to me to gate -gsplit-dwarf behind -g in that case. The -g was already specified and used during IR generation (& the -gN level, -gmlt behavior-etc has all been handled in IR generation (or embedded in the IR for use later) - so to me, specifying -g again during object code generation would be/is strange, because any special values would be ignored (-g1/g2/g3/etc would not be respected - the N value would only be respected when passed to the IR generation step)) > : > > 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 > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits