[PATCH] D59025: Add --add-ghashes to llvm-objcopy to append a .debug$H to coff objects

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 08:00:20 PDT 2019


aganea added a comment.

In D59025#1436344 <https://reviews.llvm.org/D59025#1436344>, @santagada wrote:

> I can, but looking at the code for PDBLinker::mergeInPrecompHeaderObj and the code that calls it, seems like lld is adding the precompiled header multiple times on the output pdb, there is no checks to make sure it only emits the data once.


When merging a /Yu OBJ, there's this subtlety <https://github.com/llvm/llvm-project/blob/master/llvm/lib/DebugInfo/CodeView/TypeStreamMerger.cpp#L71> which prevents the prepended PCH stream to be merged in again.

> Also on the --add-ghashes case seems like I would want to find the file in L_precomp, load it but never save the hashes to the pch types to the obj that reference them.

`link.exe` requires that the file(s) referenced by LF_PRECOMP are explicty passed on the cmd-line. So the linker only uses the name, not the path. LLD does that too. We should probably retain that behavior in `llvm-objcopy` as well.
So if `a.obj` was compiled with /Yu, one would have to say: `llvm-objcopy --add-codeview-ghash a.obj precomp.obj`
If `precomp.obj` isn't there on the cmd-line, it should throw `pdb::pdb_error_code::external_cmdline_ref` like LLD does.
If `precomp.obj` has a `.debug$H` stream, it should just skip it (validate maybe if the hash format maches, re-generate hashes otherwise) and only hash `a.obj` in that case.

> For a final question, does clang generates a .debug$H to precompiled headers? Because if so I probably want to support adding .debug$H to pch files as well.

AFAIK, clang does not generate precompiled headers OBJs like Microsoft does. Precompiled headers in clang are only for the compiler front-end. Which means there's no `LF_PRECOMP` / `.debug$P` streams generated either.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59025/new/

https://reviews.llvm.org/D59025





More information about the llvm-commits mailing list