On Wed, Feb 13, 2019 at 12:43:32AM +0000, Joseph Myers wrote:
> On Wed, 13 Feb 2019, Jakub Jelinek wrote:
> 
> > On Tue, Feb 12, 2019 at 11:21:04PM +0000, Joseph Myers wrote:
> > > I think this is changing architecture-independent code in a way that is 
> > > not clearly safe based on the architecture-independent options design, in 
> > > order to address an architecture-specific problem.  The exclusion of 
> > 
> > Actually, I think it is a problem common to many backends, in particular
> > those where *_host_detect_local_cpu emits for -m*=native sometimes more than
> > one option, so at least i386, s390, rs6000, maybe also those that emit just
> > one option because it likely ends up at a different spot on the command line
> > from where -m{arch,cpu,tune}=native was originally present (that would be
> > aarch64, alpha, arm, mips and sparc).  I guess the user expectations is that
> > -march=native -march=foobar will be handled as
> > -march=foobar, rather than -march=native -march=foobar -march=my_great_cpu 
> > -mfoo -mbar
> 
> It seems right in the march= case to handle that combination as 
> -march=foobar - but it's less clear if that must always be the case for 
> Joined options with negative versions (at least, the semantics would need 
> defining more carefully in options.texi, with an analysis of existing 
> affected options).

We have only a few Joined/JoinedOrMissing options with Negative:
find . -name \*.opt | xargs grep -B1 
'Joined.*[[:blank:]]Negative\|[[:blank:]]Negative.*Joined\|^Negative.*Joined'
./config/s390/s390.opt-mstack-guard=
./config/s390/s390.opt:Target RejectNegative Negative(mno-stack-guard) Joined 
UInteger Var(s390_stack_guard) Save
./common.opt-gdwarf
./common.opt:Common Driver JoinedOrMissing Negative(gdwarf-)
./common.opt-gdwarf-
./common.opt:Common Driver Joined UInteger Var(dwarf_version) Init(4) 
Negative(gstabs)
./common.opt-gstabs
./common.opt:Common Driver JoinedOrMissing Negative(gstabs+)
./common.opt-gstabs+
./common.opt:Common Driver JoinedOrMissing Negative(gvms)
./common.opt-gvms
./common.opt:Common Driver JoinedOrMissing Negative(gxcoff)
./common.opt-gxcoff
./common.opt:Common Driver JoinedOrMissing Negative(gxcoff+)
./common.opt-gxcoff+
./common.opt:Common Driver JoinedOrMissing Negative(gdwarf)
./fortran/lang.opt-cpp=
./fortran/lang.opt:Fortran Joined Negative(nocpp) Undocumented NoDWARFRecord

The patch indeed does change behavior for say:
gcc -c test.s -gstabs2 -gdwarf-4 -gstabs3
gcc: error: debug format ‘dwarf-2’ conflicts with prior selection
gcc: error: debug format ‘stabs’ conflicts with prior selection
(previously the above errors, now accepted as -gstabs3)
but wouldn't that be an advantage here (use the latest option win)?

For s390 (which has it weird, as there is no Negative(mno-stack-size) on
very similar mstack-size= option), I believe it shouldn't change end result,
while the driver will not pass 3 options for
-mno-stack-guard -mstack-guard=64 -mno-stack-guard
but just the last one (similarly for other combinations), the option
handling in cc1 etc. will handle it the same anyway (last option wins)
it seems.

And finally Fortran -cpp= option is internally generated from -cpp which
should have normal Negative processing with -nocpp.

        Jakub

Reply via email to