* Richard Biener:

> On Fri, 14 Mar 2025, Florian Weimer wrote:
>
>> * Richard Biener:
>> 
>> > @@ -3869,6 +3867,18 @@ gen_command_line_string (cl_decoded_option *options,
>> >        case OPT_fchecking_:
>> >    /* Ignore these.  */
>> >    continue;
>> > +      case OPT_D:
>> > +      case OPT_U:
>> > +  if (startswith (options[i].arg, "_FORTIFY_SOURCE")
>> > +      && (options[i].arg[sizeof ("_FORTIFY_SOURCE") - 1] == '\0'
>> > +          || (options[i].opt_index == OPT_D
>> > +              && options[i].arg[sizeof ("_FORTIFY_SOURCE") - 1] == '=')))
>> > +    {
>> > +      switches.safe_push (options[i].orig_option_with_args_text);
>> > +      len += strlen (options[i].orig_option_with_args_text) + 1;
>> > +    }
>> > +  /* Otherwise ignore these. */
>> > +  continue;
>> 
>> Would it be possible to cover -Wp,-D,_FORTIFY_SOURCE… and
>> -Wp,-U_FORTIFY_SOURCE as well?  Some of us used -Wp,-D,_FORTIFY_SOURCE…
>> for compatibility with the GCJ compiler driver, where
>> -D_FORTIFY_SOURCE=2 meant something completely different.  And now we
>> are stuck with those variants because some scrits use sed to remove
>> those flags, assuming the presence -Wp, prefix.
>
> I've tested that it works with -Wp as well without any special further
> handling:
>
>> ./xgcc -B. -g t.c -c -Wp,-D_FORTIFY_SOURCE=2
>> readelf -w t.o | grep DW_AT_producer
>     <d>   DW_AT_producer    : (indirect string, offset: 0): GNU C23 15.0.1 
> 20250314 (experimental) -D_FORTIFY_SOURCE=2 -mtune=generic -march=x86-64 
> -g

Very nice, thank you!

Florian

Reply via email to