On 11/7/19 4:13 PM, Nick Clifton wrote:
Hi Egeyar,

Thanks for including me in this discussion.

This option is similar to -frecord-gcc-switches.
For the record I will also note that there is -fverbose-asm which
does almost the same thing, but only records the options as comments
in the assembler.  They are never converted into data in the actual
object files.

Right.

It is also worth noting that if your goal is to record how a binary
was produced, possibly with an eye to reproducibility, then you may
also need to record some environment variables too.

That is an important point and in fact, such a need might arise. Even in that case, I would like to keep the options of GCC as modular as possible so that we can pick and drop as the specific use cases require. This one is the one that saves the command line for now.

If we implement the aliases you suggested at the end, we can even create aliases that combine them for the user.

One thing I found with annobin is that capturing preprocessor options
(eg -D_FORTIFY_SOURCE) can be quite hard from inside gcc, since often
they have already been processed and discarded.  I do not know if this
affects your actual patch though.

Yes, this was one of Martin's points as well. It is not the case for this patch, though. I have noticed that the current options aim to capture more than the command line, dive into GCC, and therefore miss or discard some options given by the user. This patch only stores *argv* as the driver receives and writes it to the object file blindly. Therefore, capturing options such as -D_FORTIFY_SOURCE is no special case. Really, this patch only answers the simple question of "How did you call GCC?".

Speaking of annobin, I will bang the gcc plugin gong again here and say
that if your patch is rejected then you might want to consider turning
it into a plugin instead.  In that way you will not need approval from
the gcc maintainers.  But of course you will have to maintain and
publicise the plugin yourself.

Thanks for the suggestion. That will always be in my mind for more ambitious cases. In the case of this specific 160-line patch though, I believe it wouldn't bother us to maintain one more small patch in the GCC packages we distribute. It can be "only at Oracle!". However, for me this is really a basic functionality. Intel's icc has the most similar -sox option too. Thinking back on how many times I said "now, how did we compile this?" in the past, I would like this to be available for all GCC users too, in the spirit of sharing.

One other thought occurs to me, which is that if the patch is acceptable,
or at least the idea of it, then maybe it would be better to amalgamate
all of the current command line recording options into a single version.
Eg:

   --frecord-options=[dwarf,assembler,object]

where:

   --frecord-options=dwarf      is a synonym for -grecord-switches
   --frecord-options=assembler  is a synonym for -fverbose-asm
   --frecord-options=object     is a synonym for your option

The user could supply one or more of the selectors to have the recording
happen in multiple places.

Just an idea.

This is a very good idea for the user experience! I already pass an argument to cc1; however, we can always simplify the arguments of the driver so that these similar functionalities can be called via one common name plus an option. I really like the idea.

Cheers
   Nick


Thanks Nick!

Regards
Egeyar

Reply via email to