[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

Alexandre Ganea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 31 10:31:54 PST 2021


aganea added a comment.

@dexonsmith The issue with `-grecord-command-line`/`-frecord-command-line` is that it isn't producing a self-standing command-line. For example:

  > clang-cl /c main.cpp /clang:-grecord-command-line /Z7

would record: `d:\\git\\llvm-project\\stage1\\bin\\clang-cl.exe --driver-mode=cl -c main.cpp /clang:-grecord-command-line /Z7 -grecord-command-line`

Whereas our patch records the cc1 command, which is self-standing:

  > stage1\bin\clang-cl /c main.cpp /Z7 -no-canonical-prefixes -fdebug-compilation-dir=.
  > stage1\bin\llvm-pdbutil.exe dump -types .\main.obj | grep -A5 LF_BUILDINFO
  0x1008 | LF_BUILDINFO [size = 28]
           0x1003: `.`
           0x1006: `stage1\bin\clang-cl.exe`
           0x1004: `main.cpp`
           0x1005: ``
           0x1007: `"-cc1" "-fmessage-length=120" "-fdiagnostics-format" "msvc" "-ferror-limit" "19" "-fcolor-diagnostics" "-mllvm" "-x86-asm-syntax=intel" "-disable-free" "-emit-obj" "-x" "c++" "-target-cpu" "x86-64" "-tune-cpu" "generic" "-triple" "x86_64-pc-windows-msvc19.29.30138" "-resource-dir" "stage1\\lib\\clang\\14.0.0" "-isystem" "stage1\\lib\\clang\\14.0.0\\include" "-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\include" "-isystem" "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\atlmfc\\include" "-isystem" "C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\ucrt" "-isystem" "C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\shared" "-isystem" "C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\um" "-isystem" "C:\\Scoop\\global\\apps\\winsdk\\10.0.22000.194\\sdk\\Include\\10.0.22000.0\\winrt" "-std=c++14" "-fmath-errno" "-fms-compatibility" "-fdelayed-template-parsing" "-pic-level" "2" "-stack-protector" "2" "-fvisibility" "default" "-fdeprecated-macro" "-fms-compatibility-version=19.29.30138" "-ffp-contract=on" "-fno-experimental-relative-c++-abi-vtables" "-O0" "-fdebug-compilation-dir=." "-fcoverage-compilation-dir=D:\\git\\llvm-project" "-faddrsig" "-fms-volatile" "-fno-use-cxa-atexit" "-gcodeview" "-gno-column-info" "-mrelax-all" "-mincremental-linker-compatible" "--mrelax-relocations" "-relaxed-aliasing" "-funwind-tables=2" "-mconstructor-aliases" "--dependent-lib=libcmt" "--dependent-lib=oldnames" "-flto-visibility-public-std" "-clear-ast-before-backend" "-debug-info-kind=constructor" "-fdiagnostics-hotness-threshold=0" "-D" "_MT"`

(the LF_BUILDINFO record is replicated unchanged in the .PDB)

Microsoft does something similair:

  > cl /c /Z7 .\main.cpp
  Microsoft (R) C/C++ Optimizing Compiler Version 19.29.30136 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  
  main.cpp
  > llvm-pdbutil.exe dump -types .\main.obj | grep -B4 -A5 LF_BUILDINFO
  0x1009 | LF_SUBSTR_LIST [size = 16]
           0x1007: `-c -Z7 -MT -IC:\Scoop\global\apps\vs_buildtools\16.11.5\VS\VC\Tools\MSVC\14.29.30133\ATLMFC\include -IC:\Scoop\global\apps\vs_buildtools\16.11.5\VS\VC\Tools\MSVC\14.29.30133\include -IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\ucrt`
           0x1008: ` -IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\shared -IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\um -IC:\Scoop\global\apps\winsdk\10.0.22000.194\sdk\include\10.0.22000.0\winrt -IC:\Scoop\global\apps\winsdk\10`
  0x100A | LF_STRING_ID [size = 64] ID: 0x1009, String: .0.22000.194\sdk\include\10.0.22000.0\cppwinrt -TP -X
  0x100B | LF_BUILDINFO [size = 28]
           0x1003: `D:\git\llvm-project`
           0x1004: `C:\Scoop\global\apps\vs_buildtools\16.11.5\VS\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.exe`
           0x1005: `.\main.cpp`
           0x1006: `D:\git\llvm-project\vc140.pdb`
           0x100A: `.0.22000.194\sdk\include\10.0.22000.0\cppwinrt -TP -X`

MSVC splits the command over multiple string records, I suppose to increase the chances of de-duplication in the .PDB, something that we could do later. But the essence is that the command is free-standing (note `-X` and the explicit includes) and can be run without any env.vars set, unlike `-dwarf-debug-flags` or `-record-command-line`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



More information about the cfe-commits mailing list