Closed gsomlo closed 5 years ago
Atomic extension required for Linux/glibc. So you need rv32imac at least.
I am getting something quite similar - have you ever figured out what the problem is:
-MD -MP -MF /home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imc-ilp32/tcb-offsets.h.dT -MT '/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imc-ilp32/tcb-offsets.h.d /home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imc-ilp32/tcb-offsets.h'
In file included from ../sysdeps/nptl/lowlevellock.h:22,
from ../nptl/descr.h:29,
from ../sysdeps/riscv/nptl/tls.h:41,
from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:23,
from
^~~~~ ../Makerules:281: recipe for target '/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imc-ilp32/tcb-offsets.h' failed make[3]: [/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imc-ilp32/tcb-offsets.h] Error 1 make[3]: Leaving directory '/home/bandic/riscv-gnu-toolchain/riscv-glibc/csu' Makefile:215: recipe for target 'csu/subdir_lib' failed make[2]: [csu/subdir_lib] Error 2 make[2]: Leaving directory '/home/bandic/riscv-gnu-toolchain/riscv-glibc' Makefile:9: recipe for target 'all' failed make[1]: [all] Error 2 make[1]: Leaving directory '/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imc-ilp32' Makefile:244: recipe for target 'stamps/build-glibc-linux-rv32imc-ilp32' failed make: [stamps/build-glibc-linux-rv32imc-ilp32] Error 2
The RISC-V glibc port requires the A extension as previously mentioned. You can't build a linux toolchain for rv32imc because that doesn't have the A extension. See the file sysdeps/unix/sysv/linux/riscv/atomic-machine.h.
I also tried with --with-arch=rv32imac, but got the same problem. I also tried newlib - that worked. I am not sure why glibc would not work?
-MD -MP -MF /home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imac-ilp32/tcb-offsets.h.dT -MT '/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imac-ilp32/tcb-offsets.h.d /home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imac-ilp32/tcb-offsets.h'
In file included from ../sysdeps/nptl/lowlevellock.h:22,
from ../nptl/descr.h:29,
from ../sysdeps/riscv/nptl/tls.h:41,
from ../sysdeps/unix/sysv/linux/riscv/sysdep.h:23,
from
^~~~~ ../Makerules:281: recipe for target '/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imac-ilp32/tcb-offsets.h' failed make[3]: [/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imac-ilp32/tcb-offsets.h] Error 1 make[3]: Leaving directory '/home/bandic/riscv-gnu-toolchain/riscv-glibc/csu' Makefile:215: recipe for target 'csu/subdir_lib' failed make[2]: [csu/subdir_lib] Error 2 make[2]: Leaving directory '/home/bandic/riscv-gnu-toolchain/riscv-glibc' Makefile:9: recipe for target 'all' failed make[1]: [all] Error 2 make[1]: Leaving directory '/home/bandic/riscv-gnu-toolchain/build-glibc-linux-rv32imac-ilp32' Makefile:244: recipe for target 'stamps/build-glibc-linux-rv32imac-ilp32' failed make: [stamps/build-glibc-linux-rv32imac-ilp32] Error 2 bandic@bandic-VirtualBox:~/riscv-gnu-toolchain$
The error indicates that the compiler does not have atomic instructions enabled. More specifically, that it isn't defining __riscv_atomic.
rohan:2009$ touch tmp.c rohan:2010$ riscv32-unknown-linux-gnu-gcc -dM -E tmp.c | grep riscv_atomic
rohan:2011$
The riscv-gnu-toolchain rv32imac-ilp32 linux support is tested occasionally and is expected to work. If it didn't work for you, then you probably made a mistake at some point. But since I don't know exactly what you did, I can't say what you might have done wrong. I can't give any meaningful help unless you explain all steps required from the beginning to reproduce the result you got.
Thanks Jim - I am sure I have made a mistake along the way. In my defense, I did follow the steps on the GitHub pretty religiously for the prerequisites (i.e. literally copy/pasted the cmd lines). I will start hunting why compiler does not have A enabled...I am probably the only person on the planet for whom glibc for RISC-V did not work. I will ask my people as well - I wanted to make sure to fairly report here first. Super thanks - Zvonimir
I am getting something quite similar - have you ever figured out what the problem is?
You can't build a linux toolchain without the A (atomic) extension. Either build an embedded elf toolchain, or add the A extension to arch.
If you do have the A extension in arch, then the problem might be that you have another (partial?) toolchain in yout path, or another (partial?) toolchain in the --prefix install dir, and the build is failing because of the other toolchain. You should make sure that there is no other riscv linux toolchain on your path when you start the build. And that there is no riscv linux toolchain in the --prefix install dir when you start the build.
After configuring with
./configure --prefix=$HOME/RiscV --with-arch=rv32imc --with-abi=ilp32
and running
make linux
, I get the error below. Is that a bad arch/abi combo, or is this a bona-fide bug?