Hello Rui,
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.
$ cat main.c
void assembly_fun();
int main()
{
int Index1;
for (Index1 = 0; Index1 == 0; assembly_fun(), Index1++){
assembly_fun();
}
assembly_fun();
}
$ cat assembly.nasm
DEFAULT REL
SECTION .text
global assembly_fun
assembly_fun:
ret
$ cat makefile_clanglto_Oz
CC_FLAGS= -g -m64 -mcmodel=small -target x86_64-unknown-windows -gcodeview -flto -Oz
CC = /home/jshi19/llvm/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang
DLINK_FLAGS = /Machine:X64 /DLL /ENTRY:main /DEBUG:GHASH /lldmap
DLINK = /home/jshi19/llvm/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/lld-link
SLINK = /home/jshi19/llvm/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/llvm-lib
build:
“$(CC)” $(CC_FLAGS) -c -o main.obj main.c
“nasm” -f win64 -o assembly.obj assembly.nasm
“$(SLINK)” /OUT:main.lib main.obj
“$(SLINK)” /OUT:assembly.lib assembly.obj
“$(DLINK)” /OUT:main.dll $(DLINK_FLAGS) main.lib assembly.lib
clean:
rm -f *.obj *.lib *.pdb *.dll *.map
$ make -f makefile_clanglto_Oz
$ llvm-pdbutil dump -l main.pdb
Lines
lld_PDB_issue_4_rui.zip (2.13 KB)