llvm-project/lld/test/COFF/linkrepro-pdb.test
Nico Weber e6d1f261a5 [lld-link] Add /reproduce: support for several flags
/reproduce: now works correctly with:
- /call-graph-ordering-file:
- /def:
- /natvis:
- /order:
- /pdbstream:

I went through all instances of MemoryBuffer::getFile() and made sure
everything that didn't already do so called takeBuffer().

For natvis, that wasn't possible since DebugInfo/PDB wants to take
owernship of the natvis buffer. For that case, I'm manually adding the
tar file entry.

/natvis: and /pdbstream: is slightly awkward, since createResponseFile()
always adds these flags to the response file but createPDB() (which
ultimately adds the files referenced by the flags) is only called if
/debug is also passed. So when using /natvis: without /debug with
/reproduce:, lld won't warn, but when linking using the response
file from the archive, it won't find the natvis file since it's not
in the tar. This isn't a new issue though, and after this patch things
at least work with using /natvis: _with_ debug with /reproduce:.
(Same for /pdbstream:)

Differential Revison: https://reviews.llvm.org/D97212
2021-02-22 16:52:49 -05:00

35 lines
1.2 KiB
Plaintext

REQUIRES: x86, gnutar
RUN: rm -rf %t && mkdir -p %t && cd %t
RUN: yaml2obj %S/Inputs/pdb-type-server-simple-a.yaml -o a.obj
RUN: yaml2obj %S/Inputs/pdb-type-server-simple-b.yaml -o b.obj
RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-simple-ts.yaml -pdb ts.pdb
RUN: cp %p/Inputs/natvis-1.natvis %t.natvis
RUN: cp %p/Inputs/stream.txt %t.txt
RUN: lld-link a.obj b.obj -entry:main -debug -out:%t.exe -pdb:%t.pdb \
RUN: -nodefaultlib -linkrepro:. -natvis:%t.natvis \
RUN: -pdbstream:srcsrv=%t.txt
RUN: tar tf repro.tar | FileCheck --check-prefix=LIST %s
RUN: tar xf repro.tar
RUN: diff ts.pdb repro/%:t/ts.pdb
RUN: diff %t.natvis repro/%:t.natvis
RUN: diff %t.txt repro/%:t.txt
RUN: cat repro/response.txt | FileCheck -check-prefix=RSP %s
LIST: .obj
LIST: response.txt
LIST: .natvis
RSP: -out:linkrepro-pdb.test.tmp.exe
RSP-NEXT: -pdb:linkrepro-pdb.test.tmp.pdb
RSP-NEXT: -nodefaultlib
RSP-NOT: -natvis:/
RSP-NOT: -pdbstream:srcsrv=/
RUN: yaml2obj %p/Inputs/export.yaml -o %t1.obj
RUN: lld-link /out:%t1.dll /dll %t1.obj /implib:%t1.lib /export:exportfn1 /export:exportfn2 /reproduce:repro2.tar
RUN: tar xf repro2.tar
RUN: cat repro2/response.txt | FileCheck -check-prefix=IMP %s
IMP: /implib:linkrepro-pdb.test.tmp1.lib