Closed nihilscire closed 6 years ago
On Tue, Mar 27, 2018 at 5:23 AM, nihilscire notifications@github.com wrote:
Building project riscv-pk In file included from ../pk/file.h:6:0, from ../pk/file.c:3: /usr/include/x86_64-linux-gnu/sys/stat.h:25:10: fatal error: features.h: No such file or directory
include
^~~~~~~~~~~~
compilation terminated. make: *** [file.o] Error 1
The error message suggests that you are using an x86 compiler to build riscv-pk.
riscv64-unknown-elf-gcc -MMD -MP -Wall -Werror -D__NO_INLINE__ -mcmodel=medany -O2 -std=gnu99 -Wno-unused -Wno-attributes -fno-delete-null-pointer-checks -DBBL_PAYLOAD=\"bbl_payload\" -DBBL_LOGO_FILE=\"bbl_logo_file\" -I. -I../pk -I../bbl -I../softfloat -I../dummy_payload -I../machine -I../util -c ../pk/file.c Makefile:302: recipe for target 'file.o' failed
But the build log says it is a riscv64 compiler. So there appears to be something funny going on with your riscv64 compiler. I'd suggest manually running this command adding a -v option to look at the directories that the compiler searches for header files. You should see something like:
. ../pk ../bbl ../softfloat ../dummy_payload ../machine ../util /scratch/jimw/riscv-tools/riscv-tools/build-install/lib/gcc/riscv64-unknown-elf/7.2.0/include /scratch/jimw/riscv-tools/riscv-tools/build-install/lib/gcc/riscv64-unknown-elf/7.2.0/include-fixed /scratch/jimw/riscv-tools/riscv-tools/build-install/lib/gcc/riscv64-unknown-elf/7.2.0/../../../../riscv64-unknown-elf/include End of search list.
and there should be no x86 dirs in there. If there are, then your riscv64 compiler was configured wrong. Maybe you have some environment variables set that are confusing the gcc configure?
Jim
Thanks for the prompt reply. I ran the compilation command with -v option and here's the thing:
riscv64-unknown-elf-gcc -MMD -MP -Wall -Werror -D__NO_INLINE__ -mcmodel=medany -O2 -std=gnu99 -Wno-unused -Wno-attributes -fno-delete-null-pointer-checks -DBBL_PAYLOAD=\"bbl_payload\" -DBBL_LOGO_FILE=\"bbl_logo_file\" -I. -I../pk -I../bbl -I../softfloat -I../dummy_payload -I../machine -I../util -c -v ../pk/file.c
Using built-in specs.
COLLECT_GCC=riscv64-unknown-elf-gcc
Target: riscv64-unknown-elf
Configured with: /home/***/polito/riscv-tools/riscv-gnu-toolchain/build/../riscv-gcc/configure --target=riscv64-unknown-elf --prefix=/home/***/riscv/toolchain --disable-shared --disable-threads --enable-languages=c,c++ --with-system-zlib --enable-tls --with-newlib --with-sysroot=/home/***/riscv/toolchain/riscv64-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --src=../../riscv-gcc --enable-checking=yes --disable-multilib --with-abi=lp64d --with-arch=rv64imafdc 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow'
Thread model: single
gcc version 7.2.0 (GCC)
COLLECT_GCC_OPTIONS='-MMD' '-MP' '-Wall' '-Werror' '-D' '__NO_INLINE__' '-mcmodel=medany' '-O2' '-std=gnu99' '-Wno-unused' '-Wno-attributes' '-fno-delete-null-pointer-checks' '-D' 'BBL_PAYLOAD="bbl_payload"' '-D' 'BBL_LOGO_FILE="bbl_logo_file"' '-I' '.' '-I' '../pk' '-I' '../bbl' '-I' '../softfloat' '-I' '../dummy_payload' '-I' '../machine' '-I' '../util' '-c' '-v' '-march=rv64imafdc' '-mabi=lp64d'
/home/***/riscv/toolchain/libexec/gcc/riscv64-unknown-elf/7.2.0/cc1 -quiet -v -I . -I ../pk -I ../bbl -I ../softfloat -I ../dummy_payload -I ../machine -I ../util -MMD file.d -MP -D __NO_INLINE__ -D BBL_PAYLOAD="bbl_payload" -D BBL_LOGO_FILE="bbl_logo_file" ../pk/file.c -quiet -dumpbase file.c -mcmodel=medany -march=rv64imafdc -mabi=lp64d -auxbase file -O2 -Wall -Werror -Wno-unused -Wno-attributes -std=gnu99 -version -fno-delete-null-pointer-checks -o /tmp/cct8ZLgz.s
GNU C99 (GCC) version 7.2.0 (riscv64-unknown-elf)
compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
ignoring nonexistent directory "/home/***/riscv/toolchain/riscv64-unknown-elf/usr/local/include"
ignoring duplicate directory "/home/***/riscv/toolchain/riscv64-unknown-elf/include"
#include "..." search starts here:
#include <...> search starts here:
.
../pk
../bbl
../softfloat
../dummy_payload
../machine
../util
/usr/include/x86_64-linux-gnu
/home/***/riscv/toolchain/lib/gcc/riscv64-unknown-elf/7.2.0/include
/home/***/riscv/toolchain/lib/gcc/riscv64-unknown-elf/7.2.0/include-fixed
/home/***/riscv/toolchain/lib/gcc/riscv64-unknown-elf/7.2.0/../../../../riscv64-unknown-elf/include
End of search list.
GNU C99 (GCC) version 7.2.0 (riscv64-unknown-elf)
compiled by GNU C version 5.4.0 20160609, GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: b6af61774b69a27cf551f822e31e3613
In file included from ../pk/file.h:6:0,
from ../pk/file.c:3:
/usr/include/x86_64-linux-gnu/sys/stat.h:25:10: fatal error: features.h: No such file or directory
#include <features.h>
^~~~~~~~~~~~
compilation terminated.
So the problem is in /usr/include/x86_64-linux-gnu
which clearly shouldn't be there.
I took a look at the environmental variables searching for that include directory with
$ env | grep -e "/usr/include/x86_64-linux-gnu"
CPLUS_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu
At this point I think you're right, the riscv64 compiler has been configured wrong. What can I do about it? If I build it once again, I am pretty sure the problem will come up as well...
It looks like you set environment variables pointing at the x86 header files which should be unnecessary. Just unset those environment variables and the riscv compiler should start working.
It also looks like you are on a debian or ubuntu system using multiarch. When building a compiler for this target, you have to use --enable-multiarch when configuring gcc to get it to look in the right directories. Maybe you built your own gcc, didn't know that --enable-multiarch was required, and then set the environment variables to make it work?
Just unset those environment variables and the riscv compiler should start working.
Unsetting those variables, the toolchain compilation works fine.
Maybe you built your own gcc, didn't know that --enable-multiarch was required, and then set the environment variables to make it work?
Yes, that's exactly what happened. I didn't know that --enable-multiarch was required, so my gcc hasn't been configured for multiarch support. Maybe I am going to re-compile gcc with that option, as I will need it in the future.
You may close the issue. Thanks for your help.
Hi, I've been trying to build the whole toolchain but the title error keeps coming up. It shows up when it's compiling
riscv-pk
, here's the detailsLaunching the build:
Console output:
Build.log:
uname -a
:with
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609