<div dir="ltr">This looks like it was fixed in October:<div><a href="http://github.com/llvm/llvm-project/commit/9d8f0b3519c4e9e4e2a3d3b19ea0caf9ef3f85ce">http://github.com/llvm/llvm-project/commit/9d8f0b3519c4e9e4e2a3d3b19ea0caf9ef3f85ce</a><br></div><div>See <a href="https://llvm.org/PR43530">https://llvm.org/PR43530</a> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 9, 2020 at 10:01 AM David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">+rnk who works on COFF debugging things.<br><br> My understanding is that this has nothing to do with the linker - but is a function of LLVM optimizations creating line zero debug locations. I believe rnk & folks have disabled line zero emission for CodeView debug info in some manner - perhaps that needs a flag? or Steven hasn't got a release with that change in it?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 9, 2020 at 4:47 AM Shi, Steven via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div>
<p class="MsoNormal">Hello Rui,<u></u><u></u></p>
<p class="MsoNormal">We meet an LLD PDB issue that if we link assembly code with C code and set >= -O1 level optimization in LTO, the executable’s PDB will contain wrong zero Lines for the assembly code in DEBUG_S_LINES subsection, and then our COFF source
debuggers will fail to do the source-level debug on the executable. This issue is same in both Linux and Windows, and I figure out a simple case in Linux to reproduce this issue as below. Please help to give us some advices on how to solve the zero Lines
issue.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat main.c<u></u><u></u></p>
<p class="MsoNormal">void assembly_fun();<u></u><u></u></p>
<p class="MsoNormal">int main()<u></u><u></u></p>
<p class="MsoNormal">{<u></u><u></u></p>
<p class="MsoNormal"> int Index1;<u></u><u></u></p>
<p class="MsoNormal"> for (Index1 = 0; Index1 == 0; assembly_fun(), Index1++){<u></u><u></u></p>
<p class="MsoNormal"> assembly_fun();<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal"> assembly_fun();<u></u><u></u></p>
<p class="MsoNormal">}<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat assembly.nasm<u></u><u></u></p>
<p class="MsoNormal"> DEFAULT REL<u></u><u></u></p>
<p class="MsoNormal"> SECTION .text<u></u><u></u></p>
<p class="MsoNormal">global assembly_fun<u></u><u></u></p>
<p class="MsoNormal">assembly_fun:<u></u><u></u></p>
<p class="MsoNormal"> ret<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat makefile_clanglto_Oz<u></u><u></u></p>
<p class="MsoNormal">CC_FLAGS= -g -m64 -mcmodel=small -target x86_64-unknown-windows -gcodeview -flto -Oz<u></u><u></u></p>
<p class="MsoNormal">CC = /home/jshi19/llvm/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang<u></u><u></u></p>
<p class="MsoNormal">DLINK_FLAGS = /Machine:X64 /DLL /ENTRY:main /DEBUG:GHASH /lldmap<u></u><u></u></p>
<p class="MsoNormal">DLINK = /home/jshi19/llvm/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/lld-link<u></u><u></u></p>
<p class="MsoNormal">SLINK = /home/jshi19/llvm/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/llvm-lib<u></u><u></u></p>
<p class="MsoNormal">build:<u></u><u></u></p>
<p class="MsoNormal"> "$(CC)" $(CC_FLAGS) -c -o main.obj main.c<u></u><u></u></p>
<p class="MsoNormal"> "nasm" -f win64 -o assembly.obj assembly.nasm<u></u><u></u></p>
<p class="MsoNormal"> "$(SLINK)" /OUT:main.lib main.obj<u></u><u></u></p>
<p class="MsoNormal"> "$(SLINK)" /OUT:assembly.lib assembly.obj<u></u><u></u></p>
<p class="MsoNormal"> "$(DLINK)" /OUT:main.dll $(DLINK_FLAGS) main.lib assembly.lib<u></u><u></u></p>
<p class="MsoNormal">clean:<u></u><u></u></p>
<p class="MsoNormal"> rm -f *.obj *.lib *.pdb *.dll *.map<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ make -f makefile_clanglto_Oz<u></u><u></u></p>
<p class="MsoNormal">$ llvm-pdbutil dump -l main.pdb<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> Lines<u></u><u></u></p>
<p class="MsoNormal">============================================================<u></u><u></u></p>
<p class="MsoNormal">Mod 0000 | `assembly.obj`:<u></u><u></u></p>
<p class="MsoNormal">Mod 0001 | `/home/jshi19/llvm/wrongcode/lld-link5/lto.tmp`:<u></u><u></u></p>
<p class="MsoNormal">/home/jshi19/llvm/wrongcode/lld-link5/main.c (MD5: 5F82BB79FE2DA0B0549B784CFDC37D05)<u></u><u></u></p>
<p class="MsoNormal"> 0001:00000004-0000001E, line/addr entries = 5<u></u><u></u></p>
<p class="MsoNormal"> 3 00000004 ! <b><span style="color:red">0</span></b> 00000008 ! 5 0000000D !
<b><span style="color:red">0 </span></b>00000012 ! 9 00000017 !<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">If we disable the optimization in the CC_FLAGS with -O0 as below, the PDB Lines will become correct non-zero numbers.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">CC_FLAGS= -g -m64 -mcmodel=small -target x86_64-unknown-windows -gcodeview -flto
<span style="color:red">-O0<u></u><u></u></span></p>
<p class="MsoNormal">$ llvm-pdbutil dump -l main.pdb<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> Lines<u></u><u></u></p>
<p class="MsoNormal">============================================================<u></u><u></u></p>
<p class="MsoNormal">Mod 0000 | `assembly.obj`:<u></u><u></u></p>
<p class="MsoNormal">Mod 0001 | `/home/jshi19/llvm/wrongcode/lld_PDB_issue/lto.tmp`:<u></u><u></u></p>
<p class="MsoNormal">/home/jshi19/llvm/wrongcode/lld_PDB_issue/main.c (MD5: 5F82BB79FE2DA0B0549B784CFDC37D05)<u></u><u></u></p>
<p class="MsoNormal"> 0001:00000010-00000050, line/addr entries = 6<u></u><u></u></p>
<p class="MsoNormal"> 3 00000010 ! 5 0000001C ! 6 0000002B ! 5 00000030 ! 8 00000042 ! 9 00000047 !<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks<u></u><u></u></p>
<p class="MsoNormal">Steven Shi<u></u><u></u></p>
<p class="MsoNormal"><b><span style="font-size:12pt;font-family:Arial,sans-serif"><u></u> <u></u></span></b></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>