On Feb 6, 2026, Jeffrey Law <[email protected]> wrote:
> On 2/5/2026 9:26 PM, Alexandre Oliva wrote:
>> Unfortunately, it looks like riscv32-elf is not equivalent to
>> riscv64-elf with an explicit -march=*32*: I guess the -mcpu in the tests
>> overrides the base arch in the former case, but not in the latter.
> Right. That's precisely what I'm referring to. IIRC we decided to be
> compatible behavior-wise with LLVM on this and it's caused similar
> surprises/headaches.
And I guess that overriding makes sense, but it suggests to me that the
tests were probably not testing what they were meant to test when -march
was overridden by --target_board settings. Resetting -march is probably
the simplest way for the tests to do their jobs consistently. It will
confirm the -mabi settings added recently, that made them incompatible
with rv32. If there is an intent of exercising these testcases with
rv32 arches and abis, we can go down the other path I suggested upthread
instead.
This change is not suited for backporting to gcc-15, because of the
reliance on -march=unset, not present in gcc-15. A potential backport
would have to name the desired architecture explicitly. -march=unset is
more desirable moving forward IMHO.
The tests fail when --target_board sets -march to a 32-bit
architecture. Override that -march by resetting it, so that the arch
implied by -mcpu prevails.
Tested on riscv32-elf, with and without -march overriders in
--target_board / TOOL_OPTIONS. Ok to install?
for gcc/testsuite/ChangeLog
* gcc.target/riscv/pr114139.c: Reset arch.
* gcc.target/riscv/pr118170.c: Likewise.
---
gcc/testsuite/gcc.target/riscv/pr114139.c | 2 +-
gcc/testsuite/gcc.target/riscv/pr118170.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/gcc.target/riscv/pr114139.c
b/gcc/testsuite/gcc.target/riscv/pr114139.c
index 5aa587f1b6f0f..a2faa680199fd 100644
--- a/gcc/testsuite/gcc.target/riscv/pr114139.c
+++ b/gcc/testsuite/gcc.target/riscv/pr114139.c
@@ -1,5 +1,5 @@
/* { dg-do compile { target { ! riscv_abi_e } } } */
-/* { dg-options "-O2 -fpic -mexplicit-relocs -mcpu=sifive-p450 -mabi=lp64d" }
*/
+/* { dg-options "-O2 -fpic -mexplicit-relocs -mcpu=sifive-p450 -march=unset
-mabi=lp64d" } */
static void *p;
extern void *a[];
diff --git a/gcc/testsuite/gcc.target/riscv/pr118170.c
b/gcc/testsuite/gcc.target/riscv/pr118170.c
index a39c4170ff2f5..7be0edcc99fad 100644
--- a/gcc/testsuite/gcc.target/riscv/pr118170.c
+++ b/gcc/testsuite/gcc.target/riscv/pr118170.c
@@ -1,5 +1,5 @@
/* { dg-do "compile" { target { ! riscv_abi_e } } } */
-/* { dg-options "-O2 -mcpu=tt-ascalon-d8 -mabi=lp64d" } */
+/* { dg-options "-O2 -mcpu=tt-ascalon-d8 -march=unset -mabi=lp64d" } */
_Float16 f;
void
--
Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/
Free Software Activist FSFLA co-founder GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity.
Excluding neuro-others for not behaving ""normal"" is *not* inclusive!