Commit 5be645a introduces the support of --with-cpu.  The current
implementation specifies an `-march` option based on the default cpu
value.  This behavior is not consistent with how the `-mcpu` option
works, however, as the `-mcpu` option involves both `-march` and
`-mtune`.  Only setting the `-march` value can be confusing for users,
who may expect the --with-cpu option to act the same way as an explicit
`-mcpu` option.

If it is some design choice, though, I would be glad to know.

Thanks,
Bohan

gcc/ChangeLog:

        * config/riscv/riscv.h (riscv_arch_help):
        (OPTION_DEFAULT_SPECS): Specify -mcpu instead of -march when
--with-cpu is used.
---
 gcc/config/riscv/riscv.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 195012f216b..6ff3e09ecc7 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -60,7 +60,8 @@ extern const char *riscv_arch_help (int argc, const char 
**argv);
   { "riscv_arch_help", riscv_arch_help },
 
 /* Support for a compile-time default CPU, et cetera.  The rules are:
-   --with-arch and --with-cpu are ignored if -march or -mcpu is specified.
+   --with-cpu is ignored if -mcpu is specified.
+   --with-arch is ignored if -march or -mcpu is specified.
    --with-abi is ignored if -mabi is specified.
    --with-tune is ignored if -mtune or -mcpu is specified.
    --with-isa-spec is ignored if -misa-spec is specified.
@@ -68,10 +69,10 @@ extern const char *riscv_arch_help (int argc, const char 
**argv);
 
    Uses default values if -mcpu doesn't have a valid option.  */
 #define OPTION_DEFAULT_SPECS \
+  {"cpu", "%{!mcpu=*:-mcpu=%(VALUE)}" },                               \
   {"tune", "%{!mtune=*:"                                               \
           "  %{!mcpu=*:-mtune=%(VALUE)}"                               \
           "  %{mcpu=*:-mtune=%:riscv_default_mtune(%* %(VALUE))}}" },  \
-  {"cpu", "%{!march=*:%{!mcpu=*:%:riscv_expand_arch_from_cpu(%(VALUE))}}" }, \
   {"arch", "%{!march=*|march=unset:"                                   \
           "  %{!mcpu=*:-march=%(VALUE)}"                               \
           "  %{mcpu=*:%:riscv_expand_arch_from_cpu(%* %(VALUE))}}" },  \
-- 
2.46.0

Reply via email to