Bug 97324 - -mcpu=<value> isn't validated on x86
Summary: -mcpu=<value> isn't validated on x86
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 10.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2020-10-07 17:38 UTC by Kip Warner
Modified: 2020-10-08 17:09 UTC (History)
2 users (show)

See Also:
Host:
Target: i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kip Warner 2020-10-07 17:38:10 UTC
On amd64 I see the following:

$ gcc-10 -Q --help=param -mcpu=sdfdsf
gcc-10: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
The following options control parameters:
  --param=align-loop-iterations= 	4
(...)

On my POWER9 machine I see the following:

$ gcc-10 -Q --help=param -mcpu=sdfdsf
gcc-10: error: unrecognized argument in option ‘-mcpu=sdfdsf’
gcc-10: note: valid arguments to ‘-mcpu=’ are: 401 403 405 405fp 440 440fp 464 464fp 476 476fp 505 601 602 603 603e 604 604e 620 630 740 7400 7450 750 801 821 823 8540 8548 860 970 G3 G4 G5 a2 cell e300c2 e300c3 e500mc e500mc64 e5500 e6500 ec603e native power10 power3 power4 power5 power5+ power6 power6x power7 power8 power9 powerpc powerpc64 powerpc64le rs64 titan

Note that on amd64 the CPU value's nonsensical value was not validated.
Comment 1 Richard Biener 2020-10-08 07:43:08 UTC
it works for me with GCC 11
Comment 2 Martin Liška 2020-10-08 11:58:53 UTC
Well for GCC 11 we provide:

gcc: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead
cc1: error: bad value (‘sdfdsf’) for ‘-mtune=’ switch
cc1: note: valid arguments to ‘-mtune=’ switch are: nocona core2 nehalem corei7 westmere sandybridge corei7-avx ivybridge core-avx-i haswell core-avx2 broadwell skylake skylake-avx512 cannonlake icelake-client icelake-server cascadelake tigerlake cooperlake sapphirerapids alderlake bonnell atom silvermont slm goldmont goldmont-plus tremont knl knm intel x86-64 eden-x2 nano nano-1000 nano-2000 nano-3000 nano-x2 eden-x4 nano-x4 k8 k8-sse3 opteron opteron-sse3 athlon64 athlon64-sse3 athlon-fx amdfam10 barcelona bdver1 bdver2 bdver3 bdver4 znver1 znver2 btver1 btver2 generic native

So -mcpu is deprecated and we print valid values for -mtune argument.
Fixed on master with r11-2755-ga7bbb5b1b1eb09db.
Comment 3 Kip Warner 2020-10-08 16:30:45 UTC
Martin, is -mcpu deprecated for all architectures or just x86?
Comment 4 Jakub Jelinek 2020-10-08 16:36:06 UTC
-m* options are target specific, so each target can and often does have its own.
-mcpu= is deprecated just on x86, but many other targets don't even have -mcpu= and never had, etc.  On the other side, some targets like powerpc do use -mcpu= where other targets use -march= instead, or some have even more complicated handling (arm/aarch64).
Comment 5 Kip Warner 2020-10-08 16:43:26 UTC
The reason I asked is because of that inconsistency in the -mcpu usage on targets. Thanks for clarifying.
Comment 6 Jakub Jelinek 2020-10-08 16:57:18 UTC
There is no consistency.
Targets that have all of -march=, -mcpu= and -mtune=:
aarch64, arm, cris, i386 (-mcpu= deprecated and treated as -mtune=), m68k
Targets that have just -march= and -mtune=:
gcn, mips, riscv, s390
Targets that have just -march= and -mcpu=:
csky, iq2000, nds32
Targets that have just -mcpu= and -mtune=:
alpha, arc, rs6000, sparc, visium
Targets that have just -mcpu=:
bfin, frv, m32c, microblaze, msp430, rl78, rx, tilegx, tilepro
Targets that have just -mtune=:
ia64, mn10300
Targets that have just -march=:
c6x, nios2, pa
Comment 7 Kip Warner 2020-10-08 17:03:12 UTC
I understand what you mean from a maintainer's standpoint. But from a user's standpoint, that's an inconsistency.
Comment 8 Jakub Jelinek 2020-10-08 17:08:32 UTC
Except for native supported on a subset of the architectures, no values are the same, so this is highly target specific anyway.  And yes, were it designed all now, we'd use the same options, but some of these choices are 33 years old, others 10, 20, 30 etc., so it is difficult to adjust it now without breaking stuff too much.
Comment 9 Kip Warner 2020-10-08 17:09:33 UTC
Yup. Agreed.