This is an archive of the discontinued LLVM Phabricator instance.

Add option to add command-line options and version info to output file
Needs ReviewPublic

Authored by christof on Apr 7 2017, 9:45 AM.

Details

Summary

Added new pair of Driver options -mcomment-section and -mno-comment-section that add the full command-line used for the invocation to the output file.

-mcomment-section is the default, and enables the feature.

For C/C++ files, the information is added to:

  • The .comment section of the ELF file for ELF format output
  • As .ident directives for -S output
  • As llvm.ident tags for LLVM IR output

For assembly source files, the information is added to the .comment section of the ELF file for ELF format outputs only.

Having the feature on by default requires modifying several clang tests that use -### to check the command-line, and replacing -### with -### -mno-comment-section to avoid false positive and false negative checks.

An alternative implementation would be to have -mno-comment-section as the default. This would avoid the need to modify a large number of tests.

Python has been added to the config file for the clang tests, as helper scripts are required to make sure that the command-line options added using this feature match the input, and to check that the version information string is correct.

Diff Detail

Event Timeline

salari01 created this revision.Apr 7 2017, 9:45 AM
rogfer01 added inline comments.
lib/CodeGen/CodeGenModule.cpp
4222

I wonder if this also works if the original compiler invokation included a ";" ? Something like (in a Unix like shell)

clang -DFOO="\";\"" -c file.c
christof commandeered this revision.Aug 2 2017, 8:13 AM
christof added a reviewer: salari01.
christof added a subscriber: christof.

With the ok of the author, I'll try to get some movement on this work again.