When linking the pr110812 units with lto after compiling them with a
riscv(32?) compiler that defaults to the medlow code model, the
compiler uses HI20 relocations that overflow with our linker scripts.

I suppose the test expects PC-relative relocations for symbol
resolution, as in the medany code model, so select that explicitly.

Regstrapped on x86_64-linux-gnu along with other patches in this batch;
also tested with targets riscv64-elf and riscv32-elf on the same host,
both trunk and gcc-15.  Ok to install?


for  gcc/testsuite/ChangeLog

        * gcc.target/riscv/lto/pr110812_0.c: Set cmodel explicitly.
        * gcc.target/riscv/lto/pr110812_1.c: Likewise.
---
 gcc/testsuite/gcc.target/riscv/lto/pr110812_0.c |    2 +-
 gcc/testsuite/gcc.target/riscv/lto/pr110812_1.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/lto/pr110812_0.c 
b/gcc/testsuite/gcc.target/riscv/lto/pr110812_0.c
index a2f70928b1621..ab745e5ffec38 100644
--- a/gcc/testsuite/gcc.target/riscv/lto/pr110812_0.c
+++ b/gcc/testsuite/gcc.target/riscv/lto/pr110812_0.c
@@ -1,5 +1,5 @@
 /* { dg-lto-do link } */
-/* { dg-lto-options { { -flto -march=rv64gc -mabi=lp64d } } } */
+/* { dg-lto-options { { -flto -march=rv64gc -mabi=lp64d -mcmodel=medany } } } 
*/
 /* { dg-extra-ld-options "-nostdlib" } */
 
 void foo();
diff --git a/gcc/testsuite/gcc.target/riscv/lto/pr110812_1.c 
b/gcc/testsuite/gcc.target/riscv/lto/pr110812_1.c
index 34d7cbbbcbbb1..a84f92c6627d6 100644
--- a/gcc/testsuite/gcc.target/riscv/lto/pr110812_1.c
+++ b/gcc/testsuite/gcc.target/riscv/lto/pr110812_1.c
@@ -1,4 +1,4 @@
-/* { dg-options { -flto -march=rv64gcv -mabi=lp64d } } */
+/* { dg-options { -flto -march=rv64gcv -mabi=lp64d -mcmodel=medany } } */
 
 #include "riscv_vector.h"
 uint8_t *x, *y;

-- 
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!

Reply via email to