https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125938
--- Comment #5 from Surya Kumari Jangala <jskumari at gcc dot gnu.org> ---
(In reply to Avinash Jayakar from comment #4)
> (In reply to Richard Biener from comment #3)
> > This isn't documented that way at least. Instead documentation says
> >
> > "If you still run out of space in the TOC even when you specify both of
> > these options, specify @option{-mminimal-toc} instead. This option causes
> > GCC to make only one TOC entry for every file. When you specify this
> > option, GCC produces code that is slower and larger but which
> > uses extremely little TOC space. You may wish to use this option
> > only on files that contain less frequently-executed code."
> >
> > framing -mminimal-toc as safe fallback
>
> Right. In code, i see that no other code model other than small can be used
> if minimal-toc is used.
> if ((rs6000_isa_flags_explicit & OPTION_MASK_MINIMAL_TOC) != 0)
> {
> if (OPTION_SET_P (rs6000_current_cmodel)
> && rs6000_current_cmodel != CMODEL_SMALL)
> error ("%<-mcmodel%> incompatible with other toc options");
> if (TARGET_MINIMAL_TOC)
> SET_CMODEL (CMODEL_SMALL);
> else if (TARGET_PCREL
> || (PCREL_SUPPORTED_BY_OS
> && (rs6000_isa_flags_explicit & OPTION_MASK_PCREL) == 0))
> /* Ignore -mno-minimal-toc. */
> ;
> else
> SET_CMODEL (CMODEL_SMALL);
> }
> Based on the code above, it looks like for mfull-toc and m{no}minimal-toc
> (rs6000_isa_flags_explicit & OPTION_MASK_MINIMAL_TOC) != 0
> this is true, and unless we gave -mno-minimal-toc with power10 (that has
> pcrel support), it sets the code model to small.
This is not correct. The above piece of code says that when -mminimal-toc is
specified, the code model is set to small. It doesn't change the code model
when -mfull-toc is specified (note that -mfull-toc is the default). And the
above code should not be executed if -mno-minimal-toc is specified.