OpenXiangShan / NEMU

Other
236 stars 90 forks source link

Compile Error #505

Closed figuresudo closed 2 months ago

figuresudo commented 2 months ago

I encountered an issue when trying to compile the NEMU source code from the master branch. I executed the following command:

make riscv64-xs_defconfig However, I received the following error messages:

~/NEMU$ make riscv64-xs_defconfig 正克隆到 'resource/softfloat/repo'... remote: Enumerating objects: 451, done. remote: Counting objects: 100% (451/451), done. remote: Compressing objects: 100% (370/370), done. remote: Total 451 (delta 412), reused 95 (delta 80), pack-reused 0 (from 0) 接收对象中: 100% (451/451), 203.65 KiB | 1.07 MiB/s, 完成. 处理 delta 中: 100% (412/412), 完成. 正克隆到 'resource/gcpt_restore'... remote: Enumerating objects: 145, done. remote: Counting objects: 100% (145/145), done. remote: Compressing objects: 100% (66/66), done. remote: Total 145 (delta 84), reused 135 (delta 79), pack-reused 0 (from 0) 接收对象中: 100% (145/145), 39.70 KiB | 677.00 KiB/s, 完成. 处理 delta 中: 100% (84/84), 完成.

Could you please advise on how to resolve this issue?

cebarobot commented 2 months ago

Your riscv64 cross compiler on your system is a little old. Please follow this document to install newer toolchain.

figuresudo commented 2 months ago

I have updated the riscv64-unknown-linux-gnu toolchain to version 13.2.0, and the make riscv64-xs_defconfig command now runs successfully. However, I still encounter errors when executing make:

It appears that attribute_maybe_unused is not defined. Could you please advise on how to resolve this issue?

cebarobot commented 2 months ago

What is the version of your host gcc compiler and your OS? Please run gcc --version and paste the result.

figuresudo commented 2 months ago

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0 Copyright (C) 2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

cebarobot commented 2 months ago

The key problem is that __attribute_maybe_unused__ is used in C, which is a feature from C++17. That's our problem, we will fix it soon.

By the way, Your host OS and gcc may also be too old. We now recommend using Ubuntu 22.04 or later as well as gcc-11 or later.

figuresudo commented 2 months ago

ok, thanks a lot.

cebarobot commented 2 months ago

fixed in #506 , you could try again.

figuresudo commented 2 months ago

It successfully works. Thanks.