[cfe-dev] Option -mtune

David Greene via cfe-dev cfe-dev at lists.llvm.org
Sun Apr 26 15:25:36 PDT 2020

Fangrui Song via cfe-dev <cfe-dev at lists.llvm.org> writes:

>>>> * -mcpu implies -target (based on host machine), -march and -mtune
>>>>   Example: -mcpu=skylake-avx512 sets
>>>>     -target=x86_64-unknown-linux-gnu (when run on a Debian system)
>>>>     -march=skylake-avx512
>>>>     -mtune=skylake-avx512
>>> This is just wrong. The CPU name has no 1:1 mapping to target
>>> architectures. skylake-avx512 can still be happily used for
>>> i386-unknown-linux-gnu to completement your example. The reverse is
>>> somewhat true: the target triple can provide the default CPU
>>> (-march/-mcpu).
>>Fair enough, but for my own education, in what situation would
>>skylake-avx512 be used with i386-unknown-linux-gnu?
> CPU->target triple mapping gets more complex when more "OSes" and "environments" are concerned.
> For example, on ARM there are eabi, gnueabi, gnueabihf, musleabi, musleabihf, etc.
> If LLVM_DEFAULT_TARGET_TRIPLE says the environment is currently
> "powerpc64le-linux-musl",
> it might make sense to use {i686,x86_64}-linux-musl if -mcpu specifies an x86 cpu.

That's what I was trying to get at.  I didn't cover all possible
scenarios since it would be very long list.  :) The basic idea would be
to set the target triple to whatever the host machine's target triple is
with the architecture substituted by whatever -mcpu implies.  The rules
for "what -mcpu implies" would of course have to be thoroughly

Again, the user should be able to override the defaults by passing
-target explicitly.  This is just a convenience function for common
cases (cross-compiling to the same kind of OS environment).


More information about the cfe-dev mailing list