Implement -frecord-command-line (-frecord-gcc-switches)
authorScott Linder <scott@scottlinder.com>
Fri, 14 Dec 2018 15:38:15 +0000 (15:38 +0000)
committerScott Linder <scott@scottlinder.com>
Fri, 14 Dec 2018 15:38:15 +0000 (15:38 +0000)
commitde6beb02a530a8da6e0525e99b9c1ab24252064e
tree23a53e12d9046af6eb2e210c8cf2b20816819193
parenteed7b2eeca6ee764ee3560c66f496cead2247b39
Implement -frecord-command-line (-frecord-gcc-switches)

Implement options in clang to enable recording the driver command-line
in an ELF section.

Implement a new special named metadata, llvm.commandline, to support
frontends embedding their command-line options in IR/ASM/ELF.

This differs from the GCC implementation in some key ways:

* In GCC there is only one command-line possible per compilation-unit,
  in LLVM it mirrors llvm.ident and multiple are allowed.
* In GCC individual options are separated by NULL bytes, in LLVM entire
  command-lines are separated by NULL bytes. The advantage of the GCC
  approach is to clearly delineate options in the face of embedded
  spaces. The advantage of the LLVM approach is to support merging
  multiple command-lines unambiguously, while handling embedded spaces
  with escaping.

Differential Revision: https://reviews.llvm.org/D54487
Clang Differential Revision: https://reviews.llvm.org/D54489

llvm-svn: 349155
24 files changed:
clang/docs/ClangCommandLineReference.rst
clang/include/clang/Basic/CodeGenOptions.h
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/clang_f_opts.c
clang/test/Driver/debug-options.c
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
llvm/include/llvm/Target/TargetLoweringObjectFile.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/IR/Verifier.cpp
llvm/test/CodeGen/X86/commandline-metadata.ll [new file with mode: 0644]
llvm/test/Linker/Inputs/commandline.a.ll [new file with mode: 0644]
llvm/test/Linker/Inputs/commandline.b.ll [new file with mode: 0644]
llvm/test/Linker/commandline.ll [new file with mode: 0644]
llvm/test/Verifier/commandline-meta1.ll [new file with mode: 0644]
llvm/test/Verifier/commandline-meta2.ll [new file with mode: 0644]
llvm/test/Verifier/commandline-meta3.ll [new file with mode: 0644]
llvm/test/Verifier/commandline-meta4.ll [new file with mode: 0644]