[cfe-dev] Option -mtune
James Y Knight via cfe-dev
cfe-dev at lists.llvm.org
Fri Apr 24 12:06:19 PDT 2020
On Wed, Apr 22, 2020 at 1:49 PM David Greene via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> Sjoerd Meijer via cfe-dev <cfe-dev at lists.llvm.org> writes:
>
> > This is addressing the hard problem of setting optimal compiler
> > options with -target, -march, -mcpu, and -mtune. In this equation
> > -mtune is just a minor annoyance, but if we could get rid of this part
> > of the confusion then that would be a good change to me and avoid the
> > regular question we get what the -mtune options should be.
>
> Honestly, the whole system needs an overhaul:
>
> http://clang-developers.42468.n3.nabble.com/Behavior-of-mcpu-td4064178.html
>
> I noticed this odd difference in behavior based on target. In the end
> the answer was, "We want to behave like gcc," but that is not a very
> compelling argument to me. Yes "-m" options are machine-specific, but
> giving the same option with the same name different behaviors is
> non-intuitive.
>
As mentioned before, being compatible with GCC is a *huge* advantage for
clang. I agree that it's quite unfortunate that the march/mcpu/mtune set of
options are so divergent in behavior between targets.
It doesn't help that these options aren't very well documented:
>
>
> https://clang.llvm.org/docs/UsersManual.html#target-specific-features-and-limitations
>
> -target is barely mentioned for CPUs and there is certainly no
> indication that one needs -target to make -mcpu/-mtune do something
> useful.
Better documentation would definitely be good, in this and many other areas
Clang is entirely dependent upon GCC's documentation.
> Contrast that with gcc's extensive documentation of tuning parameters:
>
> https://gcc.gnu.org/onlinedocs/gcc-9.3.0/gcc/Submodel-Options.html#Submodel-Options
>
> Given the way -target works, we're already incompatible with gcc (gcc
> with happily cross-compile/tune with -mcpu), so why not just do the
> Right Thing and make these options behave uniformly across targets? In
> my mind it should be something like this
GCC does _not_ support using -mcpu to switch the target, you need to
compile an entirely new GCC. Clang follows the same scheme as GCC does,
except that you run:
clang -target $TRIPLE -mcpu $CPU
instead of building a brand new GCC targeting $TRIPLE, called $TRIPLE-gcc,
and then running:
$TRIPLE-gcc -mcpu $CPU
(of course, sometimes using -march instead of -mcpu, depending on the
triple...)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200424/47f6669a/attachment.html>
More information about the cfe-dev
mailing list