Error while building newlib for arc64-unknown-elf
Closed this issue · 8 comments
yaroslavsadin commented
Got the following error while building arc64-unknown-elf:
$ /home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/bin/arc64-snps-elf-cc -B/home/arcoss/crosstool-ng/.build/arc64-snps-elf/build/build-libc/arc64-snps-elf/fpud/newlib/ -isystem /home/arcoss/crosstool-ng/.build/arc64-snps-elf/build/build-libc/arc64-snps-e
lf/fpud/newlib/targ-include -isystem /home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libc/include -B/home/arcoss/crosstool-ng/.build/arc64-snps-elf/build/build-libc/arc64-snps-elf/fpud/libgloss/arc64 -L/home/arcoss/crosstool-ng/.build/arc64-snps-elf/build/build-libc/ar
c64-snps-elf/fpud/libgloss/libnosys -L/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/libgloss/arc64 -mfpu=fpud -DHAVE_CONFIG_H -I. -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib -D_LIBC -fno-builtin -D_HAVE_INIT_FINI -idirafter /home/arcoss/crosstoo
l-ng/.build/arc64-snps-elf/src/newlib/newlib/../include -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libm/common -g -O2 -ffunction-sections -fdata-sections -mfpu=fpud -MT libm/math/libm_a-k_rem_pio2.o -MD -MP -MF libm/math/.deps/libm_a-k_rem_pio2.Tpo -c -
o libm/math/libm_a-k_rem_pio2.o /home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libm/math/k_rem_pio2.c
/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libm/math/k_rem_pio2.c: In function '__kernel_rem_pio2':
/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libm/math/k_rem_pio2.c:319:1: error: unable to find a register to spill
319 | }
| ^
/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libm/math/k_rem_pio2.c:319:1: error: this is the insn:
(insn 2069 2068 2070 25 (set (reg:DI 815)
(reg:DI 816)) "/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libm/math/k_rem_pio2.c":205:11 16 {*arc64_movdi}
(expr_list:REG_DEAD (reg:DI 816)
(expr_list:REG_EQUAL (const_int 4593671619917905920 [0x3fc0000000000000])
(nil))))
/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/newlib/libm/math/k_rem_pio2.c:319: confused by earlier errors, bailing out
Similar errors while trying to compile following files:
newlib/libm/math/k_rem_pio2.c:319
newlib/libm/math/e_log.c:145
newlib/libm/math/er_lgamma.c:319
newlib/libm/math/e_j1.c:215
newlib/libm/math/e_j0.c:218
newlib/libm/math/e_log10.c:96
newlib/libm/math/e_jn.c:279
All components' branches are arc-2024.06
.
shahab-vahedi commented
Please provide the configure commands for newlib and GCC. Even better is providing the *.i
file.
yaroslavsadin commented
@shahab-vahedi Here's log excerpt with all the configure commands.
[DEBUG] ==> Executing: CC_FOR_BUILD='x86_64-build_pc-linux-gnu-gcc'
CFLAGS_FOR_BUILD='-O2 -g -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
CXXFLAGS_FOR_BUILD='-O2 -g -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
LDFLAGS_FOR_BUILD='-L/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/lib '
CFLAGS='-O2 -g -pipe -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
CXXFLAGS='-O2 -g -pipe -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
LDFLAGS='-L/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/lib '
'/usr/bin/bash'
'/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/binutils/configure'
'--build=x86_64-build_pc-linux-gnu'
'--host=x86_64-build_pc-linux-gnu'
'--target=arc64-snps-elf'
'--prefix=/home/arcoss/crosstool-ng/arc64-unknown-elf'
'--disable-werror'
'--enable-ld=yes'
'--enable-gold=no'
'--enable-deterministic-archives'
'--with-pkgversion=ARCv3 elf toolchain - build 6846'
'--enable-multilib'
'--disable-sim'
'--disable-gdb'
'--disable-nls'
'--without-zstd'
'--with-sysroot=/home/arcoss/crosstool-ng/arc64-unknown-elf/arc64-snps-elf'
[DEBUG] ==> Executing: CC_FOR_BUILD='x86_64-build_pc-linux-gnu-gcc'
CFLAGS='-O2 -g -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
CFLAGS_FOR_BUILD='-O2 -g -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
CXXFLAGS='-O2 -g -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
CXXFLAGS_FOR_BUILD='-O2 -g -I/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/include '
LDFLAGS='-L/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/lib '
CFLAGS_FOR_TARGET='-g -O2 -g -O2 -ffunction-sections -fdata-sections -idirafter /home/arcoss/crosstool-ng/arc64-unknown-elf/arc64-snps-elf/include'
CXXFLAGS_FOR_TARGET='-g -O2 -g -O2 -ffunction-sections -fdata-sections -idirafter /home/arcoss/crosstool-ng/arc64-unknown-elf/arc64-snps-elf/include'
LDFLAGS_FOR_TARGET=' -static'
'/usr/bin/bash'
'/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/gcc/configure'
'--build=x86_64-build_pc-linux-gnu'
'--host=x86_64-build_pc-linux-gnu'
'--target=arc64-snps-elf'
'--prefix=/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools'
'--exec_prefix=/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools'
'--with-local-prefix=/home/arcoss/crosstool-ng/arc64-unknown-elf/arc64-snps-elf'
'--with-sysroot=/home/arcoss/crosstool-ng/arc64-unknown-elf/arc64-snps-elf'
'--with-native-system-header-dir=/include'
'--with-newlib'
'--enable-threads=no'
'--disable-shared'
'--with-pkgversion=ARCv3 elf toolchain - build 6846'
'--enable-__cxa_atexit'
'--disable-libgomp'
'--disable-libmudflap'
'--disable-libmpx'
'--disable-libssp'
'--disable-libquadmath'
'--disable-libquadmath-support'
'--disable-libstdcxx-verbose'
'--disable-libstdcxx'
'--with-gmp=/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools'
'--with-mpfr=/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools'
'--with-mpc=/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools'
'--with-isl=no'
'--with-cloog=no'
'--enable-lto'
'--disable-nls'
'--disable-tls'
'--enable-multiarch'
'--enable-languages=c'
[DEBUG] ==> Executing: CC_FOR_BUILD='x86_64-build_pc-linux-gnu-gcc'
CFLAGS_FOR_TARGET=' -g -O2 -ffunction-sections -fdata-sections '
AR_FOR_TARGET='/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/bin/arc64-snps-elf-gcc-ar'
RANLIB_FOR_TARGET='/home/arcoss/crosstool-ng/.build/arc64-snps-elf/buildtools/bin/arc64-snps-elf-gcc-ranlib'
'/usr/bin/bash'
'/home/arcoss/crosstool-ng/.build/arc64-snps-elf/src/newlib/configure'
'--host=x86_64-build_pc-linux-gnu'
'--target=arc64-snps-elf'
'--prefix=/home/arcoss/crosstool-ng/arc64-unknown-elf'
'--enable-newlib-io-float'
'--disable-newlib-io-long-double'
'--enable-newlib-supplied-syscalls'
'--disable-newlib-io-pos-args'
'--disable-newlib-io-c99-formats'
'--enable-newlib-io-long-long'
'--disable-newlib-register-fini'
'--disable-newlib-nano-malloc'
'--disable-newlib-nano-formatted-io'
'--enable-newlib-atexit-dynamic-alloc'
'--enable-newlib-global-atexit'
'--disable-lite-exit'
'--disable-newlib-reent-small'
'--enable-newlib-multithread'
'--disable-newlib-retargetable-locking'
'--enable-newlib-wide-orient'
'--enable-newlib-fseek-optimization'
'--enable-newlib-fvwrite-in-streamio'
'--enable-newlib-unbuf-stream-opt'
'--disable-target-optspace'
yaroslavsadin commented
@shahab-vahedi *.i
file attached.
shahab-vahedi commented
perfect. thank you!
shahab-vahedi commented
The reduced test case:
$ cat small.c
int *a;
int b, c, d;
double e, g;
double f[0];
double *h;
int i[0];
void l() {
int j;
k:
for (; g; b++, g--)
i[b] = 1.67772160000000000000e07 * e;
if (b) {
for (; b <= d; b++) {
f[b] = a[b];
c = 0.0;
for (; c <= j; c++)
e = h[c] * f[c];
}
goto k;
}
}
$ /bld/2024.06/hs6x/el/build-gcc-newlib-stage1/gcc/cc1 -O2 -mfpu=fpud ...
small.c: In function 'l':
small.c:21:1: error: unable to find a register to spill
21 | }
| ^
small.c:21:1: error: this is the insn:
(insn 197 196 198 4 (set (reg:DI 216)
(reg:DI 217)) "small.c":11:38 16 {*arc64_movdi}
(expr_list:REG_DEAD (reg:DI 217)
(expr_list:REG_EQUAL (const_int 4715268809856909312 [0x4170000000000000])
(nil))))
The toolchain was built with --enable-multilib
configure option.
shahab-vahedi commented
A fix has been pushed to arc-2024.06 and arc64 branches.
Once again, thanks @claziss for you support
From d425fc429e1bf23571ac69c80b872aca2a4912ed Mon Sep 17 00:00:00 2001
From: Shahab Vahedi <shahab@synopsys.com>
Date: Fri, 28 Jun 2024 15:35:50 +0200
Subject: [PATCH] arc64: Handle moving 64-bit constants to FPU_REGS
Fixes
https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/issues/625
---
gcc/config/arc64/arc64.cc | 8 ++++++--
gcc/testsuite/gcc.target/arc64/movf-1.c | 24 ++++++++++++++++++++++++
2 files changed, 30 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/arc64/movf-1.c
diff --git a/gcc/config/arc64/arc64.cc b/gcc/config/arc64/arc64.cc
index f3bc5c09422..cb7ed19f934 100644
--- a/gcc/config/arc64/arc64.cc
+++ b/gcc/config/arc64/arc64.cc
@@ -5129,7 +5129,7 @@ arc64_prepare_move_operands (rtx op0, rtx op1, machine_mode mode)
unsigned HOST_WIDE_INT ival;
scalar_int_mode imode = int_mode_for_mode (mode).require ();
- gcc_assert (mode == DFmode);
+ gcc_assert (imode == DImode && mode == DFmode);
real_to_target (res, CONST_DOUBLE_REAL_VALUE (op1),
REAL_MODE_FORMAT (mode));
@@ -5139,7 +5139,11 @@ arc64_prepare_move_operands (rtx op0, rtx op1, machine_mode mode)
ival = lo | (hi << 32);
tmp = gen_reg_rtx (imode);
emit_move_insn (tmp, gen_int_mode (ival, imode));
- emit_move_insn (op0, gen_lowpart (mode, tmp));
+ /* NOTE:
+ This may not work when we have ARC32 + FPUDF configuration.
+ However, this configuration is not supported as in jun-2024 by
+ this compiler. */
+ emit_insn (gen_floatdidf2 (op0, tmp));
return true;
}
diff --git a/gcc/testsuite/gcc.target/arc64/movf-1.c b/gcc/testsuite/gcc.target/arc64/movf-1.c
new file mode 100644
index 00000000000..687cd62fc93
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc64/movf-1.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcpu=hs6x -mfpu=fpud" } */
+
+int *a;
+int b, c, d;
+double e, g;
+double f[0];
+double *h;
+int i[0];
+void l() {
+ int j;
+k:
+ for (; g; b++, g--)
+ i[b] = 1.67772160000000000000e07 * e;
+ if (b) {
+ for (; b <= d; b++) {
+ f[b] = a[b];
+ c = 0.0;
+ for (; c <= j; c++)
+ e = h[c] * f[c];
+ }
+ goto k;
+ }
+}
--
2.39.4
abrodkin commented
@kolerov may we close this one now, assuming the fix is in arc-2024.06 RC1 already?
kolerov commented
Yes, this issue may be closed.