riscv-tools icon indicating copy to clipboard operation
riscv-tools copied to clipboard

error in runing ./bulid.sh

Open JunnanLi opened this issue 5 years ago • 14 comments

Hi, I meet an error in runing "./bulid.sh"

Building project riscv-isa-sim ../spike_main/disasm.cc: In constructor ‘disassembler_t::disassembler_t(int)’: ../spike_main/disasm.cc:275:1: note: variable tracking size limit exceeded with -fvar-tracking-assignments, retrying without disassembler_t::disassembler_t(int xlen) ^~~~~~~~~~~~~~ Installing project riscv-isa-sim mkdir /home/lijunnan/code/riscv-tools/riscv-tools/include mkdir /home/lijunnan/code/riscv-tools/riscv-tools/include/fesvr mkdir /home/lijunnan/code/riscv-tools/riscv-tools/lib mkdir /home/lijunnan/code/riscv-tools/riscv-tools/lib/pkgconfig

Removing existing riscv-pk/build directory Configuring project riscv-pk Building project riscv-pk gcc: error: unrecognized argument in option ‘-mcmodel=medany’ gcc: note: valid arguments to ‘-mcmodel=’ are: 32 kernel large medium small; did you mean ‘medium’? make: *** [file.o] Error 1

JunnanLi avatar Jul 11 '19 08:07 JunnanLi

You need a riscv64-unknown-elf-gcc cross compiler before you can build riscv-tools. You can build one from riscv/riscv-gnu-toolchain, or from crosstool-ng if you enable experimental support, or from FSF sources if you know how to do that. Or you can download a pre-built one from various places such as sifive.com/boards.

jim-wilson avatar Jul 11 '19 08:07 jim-wilson

@jim-wilson Hi, I have installed "riscv64-unknow-elf-gcc compiler" (according to the readme of riscv/riscv-gnu-toolchain) before building riscv-tools. Do I need to export some commands?

from Junnan Li

JunnanLi avatar Jul 11 '19 11:07 JunnanLi

build.common has PATH="$RISCV/bin:$PATH" So you must set RISCV to point at the prefix where the compiler was installed such that $RISCV/bin/riscv64-unknown-elf-gcc exists and is a working cross compiler.

jim-wilson avatar Jul 12 '19 02:07 jim-wilson

Another error from build.sh. What a bloody mess, leads to colossal waste of time. Appreciate Jim's lone-soldier approach in supporting this collegiate toolset, but it is not in publically usable form, to put it kindly. Surprising, given that RiscV seems to getting promoted widely.

On the other hand I found a very clean, cool, lightweight open-source toolset RISCV OVPSIM from Imperas Software. Builds and runs examples from hello_world to linpack on an ISA simulator right off the bat, with clean trace output. Doesn't need all this baggage of full system simulation infrastructure and gcc cross compiler etc, just to get started. Comes in Windows and Linux forms. Good stuff. I recommend people switching to using that.

snat99-hub avatar Oct 22 '19 19:10 snat99-hub

I meet the same problem with ubuntu 18. But I have compiled successfully with ubuntu 16.

zhuzhizhan avatar Dec 03 '19 14:12 zhuzhizhan

build.common has PATH="$RISCV/bin:$PATH" So you must set RISCV to point at the prefix where the compiler was installed such that $RISCV/bin/riscv64-unknown-elf-gcc exists and is a working cross compiler.

So we must build riscv-gnu-toolchain first?

zhuzhizhan avatar Dec 04 '19 09:12 zhuzhizhan

Yes, you must build riscv-gnu-toolchain first, and it must be a riscv64-unknown-elf toolchain. Or you might be able to download a pre-built one. There are some prebuilt toolchains at sifive.com/boards for instance.

jim-wilson avatar Dec 05 '19 18:12 jim-wilson

Yes, you must build riscv-gnu-toolchain first, and it must be a riscv64-unknown-elf toolchain. Or you might be able to download a pre-built one. There are some prebuilt toolchains at sifive.com/boards for instance.

Got it, thanks.

zhuzhizhan avatar Dec 06 '19 01:12 zhuzhizhan

Hi @jim-wilson ,

I am facing the same issue as the OP. I would like to give it a try with the gnu-toolchain before going to a prebuilt toolchain. I have followed the instructions for installing the https://github.com/riscv/riscv-gnu-toolchain, more specifically I installed the Linux multilib, using the following commands:

./configure --prefix=/opt/riscv --enable-multilib
make linux

This created a ./bin folder inside the installation folder that contains the following:

riscv64-unknown-linux-gnu-addr2line
riscv64-unknown-linux-gnu-ar
riscv64-unknown-linux-gnu-as
riscv64-unknown-linux-gnu-c++
riscv64-unknown-linux-gnu-c++filt
riscv64-unknown-linux-gnu-cpp
riscv64-unknown-linux-gnu-elfedit
riscv64-unknown-linux-gnu-g++
riscv64-unknown-linux-gnu-gcc
riscv64-unknown-linux-gnu-gcc-10.1.0
riscv64-unknown-linux-gnu-gcc-ar
riscv64-unknown-linux-gnu-gcc-nm
riscv64-unknown-linux-gnu-gcc-ranlib
riscv64-unknown-linux-gnu-gcov
riscv64-unknown-linux-gnu-gcov-dump
riscv64-unknown-linux-gnu-gcov-tool
riscv64-unknown-linux-gnu-gdb
riscv64-unknown-linux-gnu-gdb-add-index
riscv64-unknown-linux-gnu-gfortran
riscv64-unknown-linux-gnu-gprof
riscv64-unknown-linux-gnu-ld
riscv64-unknown-linux-gnu-ld.bfd
riscv64-unknown-linux-gnu-lto-dump
riscv64-unknown-linux-gnu-nm
riscv64-unknown-linux-gnu-objcopy
riscv64-unknown-linux-gnu-objdump
riscv64-unknown-linux-gnu-ranlib
riscv64-unknown-linux-gnu-readelf
riscv64-unknown-linux-gnu-run
riscv64-unknown-linux-gnu-size
riscv64-unknown-linux-gnu-strings
riscv64-unknown-linux-gnu-strip

I have included the above folder to $PATH. Neverthelss, I am still getting the same error. Did I do something wrong with my installation instructions of the riscv-gnu-toolchain? How should I modify them in order to build the riscv64-unknown-elf toolchain?

Thank you in advance for your response and your help.

Kind regards, Nassos

0ena avatar Jul 31 '20 18:07 0ena

My eye overpassed the last sentence in the https://github.com/riscv/riscv-gnu-toolchain#installation-newlib. I should have installed Newlib for the riscv64-unknown-elf toolchain and not the Linux one. I am reconfiguring and remaking the toolchain inside the same installation folder using the following commands:

make clean 
../configure --prefix=INSTALLATION_PATH_NAME --enable-multilib 
make newlib

The installation seems to continue without any problem so far (it takes some time to be completed). If it fails, I will completely delete the installation folder and make the installation from scratch.

0ena avatar Jul 31 '20 19:07 0ena

What @jim-wilson said is maybe true, you need to compile all the components separately. For the error which is due to riscv-pk, I was able to remove it and compile it perfectly by following the follow steps:

  1. Compile 64-bit toolchain from riscv-gnu-toolchain repo.
  2. Add gcc to you PATH by adding following lines to your ~/.<shell>rc
export example1=/path/to/bin/of/toolchain
export example2=/path/to/toolchain
export PATH="$example1:$PATH"
export PATH="$example2:$PATH"
  1. Restart bash.
  2. Now try to build it again by following instructions in the standard riscv-pk repo.

Hope this helps. If you have any more issues, do reach out. Thanks.

m-salman-afzal avatar Dec 14 '20 05:12 m-salman-afzal

i has had "riscv64-unknown-elf-gcc" in "/opt/riscv/bin" and also export RISCV=/opt/riscv. but i meet the error "/pk/pk.c:139:3: error: both arguments to '__builtin___clear_cache' must be pointers 139 | __clear_cache(0,0);". please tell me the way to resolve the problem if you met or do it

ShanShuiXiLiu avatar Jul 25 '21 15:07 ShanShuiXiLiu

riscv-tools is not maintained and is not expected to build. I don't recommend using it.

If you really want to try, then updating submodules may make it buildable. cd into riscv-pk and run git log and you will see that you have a March 2019 version of riscv-pk which is why it doesn't build. This problem was fixed Apr 28 2021 in riscv-pk, but since you have a 2+ year old version of it you don't have the fix. If you cd into riscv-pk, then do "git checkout master" and then "git pull" you can get an up to date copy of riscv-pk. Likewise in the other subdirs. Just don't update submodules at the toplevel or you will get the old broken versions of subdirs again.

jim-wilson avatar Jul 25 '21 17:07 jim-wilson

@jim-wilson说的可能是真的,你需要单独编译所有组件。对于由于riscv-pk引起的错误,我能够按照以下步骤将其删除并完美地编译它:

  1. riscv-gnu-toolchain 存储库编译 64 位工具链。
  2. 通过将以下行添加到 ~/.rc 中,将 gcc 添加到 PATH
export example1=/path/to/bin/of/toolchain
export example2=/path/to/toolchain
export PATH="$example1:$PATH"
export PATH="$example2:$PATH"
  1. 重新启动 bash。
  2. 现在尝试按照标准riscv-pk存储库中的说明再次构建它。

希望这有帮助。如果您还有其他问题,请与我们联系。谢谢。

Thanks,my problem was solved by using your method

ZhaoZiHao1998 avatar May 11 '22 12:05 ZhaoZiHao1998