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

Hans Wennborg via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 2 10:25:52 PDT 2020


hans added inline comments.


================
Comment at: clang/include/clang/Basic/CodeGenOptions.h:320
+  /// Executable and command-line used to create a given CompilerInvocation.
+  const char *BuildTool = nullptr;
+  ArrayRef<const char *> CommandLineArgs;
----------------
aganea wrote:
> hans wrote:
> > The name BuildTool makes me think of things like Make or MSBuild rather than the compiler. And in this case we know the compiler is Clang :-) Also since this is for capturing the cc1 arguments, it shouldn't really matter if it's clang-cl, clang++ or just clang. So it seems unfortunate that it has to be piped through all the way like this..
> > 
> > Is there some way we could just grab the path to the current clang binary during the pdb writing?
> There's `sys::fs::getMainExecutable(const char *argv0, void *MainExecAddr)` but that's not guaranteed to work on all platforms, you still need to provide argv[0] to fallback, see https://github.com/llvm/llvm-project/blob/master/llvm/lib/Support/Unix/Path.inc#L232
> I'm not well versed in Unix distros, can this only rarely occur?
> Would you prefer that I used that function instead? (it is ok on Windows though)
> 
I think it can occur for example if the compiler is running in a chroot. And probably other cases as well.
So maybe piping the path through is better. But perhaps we should just call it argv0?
Or could we get away with putting just "clang" there? Does the tool consuming this info actually need the real path to the compiler or could we rely on it finding it on PATH?


================
Comment at: clang/test/CodeGen/debug-info-codeview-buildinfo.c:3
+// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
+
+int main() { return 42; }
----------------
aganea wrote:
> Is there a way to launch an arbitrary program from lit? I started extracting the tool and the cmd-line from the .OBJ, to run it again. But I couldn't figure out how to start the extracted tool pathname? Something along the lines of
> ```
> // RUN: eval $CMD
> ```
Hmm, I can't think of any way to do that with lit. But it's probably enough to check that the the data looks reasonable without actually invoking the tool again?


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