Oh, yeah, I got your point, I was just misreading, the march is
rv32imac rather than rv32imafc, that is because of the complicated
implication rule.

So I think maybe we should mark C-ext as a EXT_FLAG_MACRO

Then skip all EXT_FLAG_MACRO during riscv_subset_list::match_score?

something like that:

diff --git a/gcc/common/config/riscv/riscv-common.cc
b/gcc/common/config/riscv/riscv-common.cc
index 6b5440365e3..b536d3758ce 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -410,10 +410,14 @@ riscv_subset_list::match_score
(riscv_subset_list *list) const
          be complicated.
     TODO: We might consider the version of each extension.  */
  for (s = list->m_head; s != NULL; s = s->next)
-    if (this->lookup (s->name.c_str ()) != NULL)
-      score++;
-    else
-      return 0;
+    {
+      if (this-ext-is-macro-ext)
+       continue;
+      if (this->lookup (s->name.c_str ()) != NULL)
+       score++;
+      else
+       return 0;
+    }

  return score;
}
diff --git a/gcc/config/riscv/riscv-ext.def b/gcc/config/riscv/riscv-ext.def
index 816acaa34f4..b7d443b0c27 100644
--- a/gcc/config/riscv/riscv-ext.def
+++ b/gcc/config/riscv/riscv-ext.def
@@ -179,7 +179,7 @@ DEFINE_RISCV_EXT(
  /* FLAG_GROUP */ base,
  /* BITMASK_GROUP_ID */ 0,
  /* BITMASK_BIT_POSITION*/ 2,
-  /* EXTRA_EXTENSION_FLAGS */ 0)
+  /* EXTRA_EXTENSION_FLAGS */ EXT_FLAG_MACRO)

DEFINE_RISCV_EXT(
  /* NAME */ b,


Could you give a try in this direction?


On Mon, Jun 9, 2025 at 5:19 PM yunzezhu <yunze...@linux.alibaba.com> wrote:
>
> > But rv32imaf_zca means we don't have zcf, so it can not select
> > rv32imac, otherwise that means the final binary will have zcf
> > instruction and that won't be able to run on env that only have
> > rv32imaf_zca.
>
> In my opinion the arch of multilib is the arch used when compiling the lib,
> that is the binary of lib rv32imac does not contain zcf instructions.
> Since none of binaries to be link contain zcf instructions, I think
> the final binary generated by linking does not contain zcf instructions when
> select rv32imac.

Reply via email to