By default Clang outputs its version (including git commit hash, in
case of trunk builds) into object and assembly files. It might be
useful to have an option to disable this, especially for debugging
purposes.
This patch implements new command line flags -Qn and -Qy (the names
are chosen for compatibility with GCC). -Qn disables output of
the 'llvm.ident' metadata string and the 'producer' debug info. -Qy
(enabled by default) does the opposite.
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
What's your use-case for this?
test/CodeGen/no-ident-version.c | ||
---|---|---|
5 | You'll also want to check for something positive, otherwise this test will succeed even if clang is symlinked to /bin/true :-) |
One use case for this is debugging: this flag makes it easier to find out which revisions of LLVM introduce changes in codegen and/or debug information without having to filter out .ident/producer metadata manually. Some users can also use this flag (or an equivalent, -fno-ident) to reduce code size: https://github.com/niXman/mingw-builds/issues/412 (.ident strings are embedded into each object file and don't get merged during linking, so the difference can be noticeable).
There is a flag -fno-ident that has the same effect in GCC https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-ident although it involves also ignoring the #ident.
A quick look seems to suggest that #ident is just ignored in the usual PP callbacks used by the parser so in practice -fno-ident would be the same as -Qn
test/CodeGen/no-ident-version.c | ||
---|---|---|
2 | Please test both -Qy and -Qn as well as the default case. |
Does gcc's Qy/Qn option also affect the generated debug information? Clang is embedding the version number also into the DICompileUnit's producer string; I wonder if that should be affected by this option, too.
No, it does not. Do you think it would be better to leave debug information unchanged as well?
I'm not sure. Compatibility with GCC and getting identical output for debugging purposes seem to be at odds here. I personally lean slightly towards stripping it from the debug info as well.
I’m happy with the test, thanks!
If it were the other way around I’d agree with you, but given that -Qn becomes the default, I think we should not strip it from the debug info.
Ah, right, I was confused by the CHECK-NONE prefix, I would have merged it with the default case. In that case I agree with Adrian. :-)
Please test both -Qy and -Qn as well as the default case.