Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于riscv编译工具链的问题 #21

Closed
codetang-2417 opened this issue Mar 5, 2023 · 7 comments
Closed

关于riscv编译工具链的问题 #21

codetang-2417 opened this issue Mar 5, 2023 · 7 comments
Labels
environment Build environment issue

Comments

@codetang-2417
Copy link

codetang-2417 commented Mar 5, 2023

在文件./build.sh中,有以下几条路径

GLIB_ELF_CROSS_COMPILE_DIR=/opt/gcc-riscv64-unknown-linux-gnu
GLIB_ELF_CROSS_PREFIX=$GLIB_ELF_CROSS_COMPILE_DIR/bin/riscv64-unknown-linux-gnu
GLIB_ELF_CROSS_PREFIX_SYSROOT_DIR=$GLIB_ELF_CROSS_COMPILE_DIR/sysroot
NEWLIB_ELF_CROSS_COMPILE_DIR=/home/tc/Desktop/riscv-tool/riscv/
NEWLIB_ELF_CROSS_PREFIX=$NEWLIB_ELF_CROSS_COMPILE_DIR/bin/riscv64-unknown-elf

我在文档中没有找到对应的编译器安装路径的描述,也去官方的仓库(ch22章节提到了换源码编译工具)尝试自己编译源码看看能不能出现对应的文件夹,但是仓库中包含的子仓库太大,导致没法下载,甚至因此自己搭了个vps,但是很遗憾,有一些子库好像并未开放,没法完全clone下来。
我想问问您是怎么将仓库clone下来的?
下面是clone报错代码

Cloning into '/home/tc/Desktop/riscv-gnu-toolchain/musl'...
fatal: remote error: access denied or repository not exported: /git/musl
fatal: clone of 'git://git.musl-libc.org/git/musl' into submodule path '/home/tc/Desktop/riscv-gnu-toolchain/musl' failed
Failed to clone 'musl'. Retry scheduled
Cloning into '/home/tc/Desktop/riscv-gnu-toolchain/pk'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://github.com/riscv-software-src/riscv-pk.git' into submodule path '/home/tc/Desktop/riscv-gnu-toolchain/pk' failed
Failed to clone 'pk'. Retry scheduled
Cloning into '/home/tc/Desktop/riscv-gnu-toolchain/qemu'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://gitlab.com/qemu-project/qemu.git' into submodule path '/home/tc/Desktop/riscv-gnu-toolchain/qemu' failed
Failed to clone 'qemu'. Retry scheduled
Cloning into '/home/tc/Desktop/riscv-gnu-toolchain/spike'...
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
fatal: clone of 'git://github.com/riscv-software-src/riscv-isa-sim.git' into submodule path '/home/tc/Desktop/riscv-gnu-toolchain/spike' failed
Failed to clone 'spike'. Retry scheduled
Cloning into '/home/tc/Desktop/riscv-gnu-toolchain/musl'...
fatal: remote error: access denied or repository not exported: /git/musl
fatal: clone of 'git://git.musl-libc.org/git/musl' into submodule path '/home/tc/Desktop/riscv-gnu-toolchain/musl' failed
Failed to clone 'musl' a second time, aborting
@QQxiaoming
Copy link
Owner

关于工具链你也可以在这两个地址下载预构建的版本,这也是我在github action中使用的版本。

https://github.com/riscv/riscv-gnu-toolchain/releases/download/2021.08.07/riscv64-glibc-ubuntu-20.04-nightly-2021.08.07-nightly.tar.gz
https://static.dev.sifive.com/dev-tools/freedom-tools/v2020.12/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14.tar.gz

关于ch22章节工具链源码你无法clone的问题可能只是你的网络环境的问题,我无法帮你解决它,不过你如果你需要可以通过邮件的方式联系到我,我可以用其他的方式把我clone的副本发送给你。

@QQxiaoming QQxiaoming added the environment Build environment issue label Mar 8, 2023
@codetang-2417
Copy link
Author

谢谢!

@QQxiaoming QQxiaoming pinned this issue Mar 10, 2023
@adrain-yu
Copy link

用于裸机带newlib的gcc

./configure --prefix=/opt/gcc-riscv64-unknown-elf --with-cmodel=medany
make -j16

用于linux带glibc的gcc

./configure --prefix=/opt/gcc-riscv64-unknown-linux-gnu
make linux -j16

使用ch22 的指令编译出来的工具链 编译 mask rom会报错:
unrecognized opcode fence.i', extension zifencei' required

@QQxiaoming
Copy link
Owner

QQxiaoming commented Mar 22, 2024

用于裸机带newlib的gcc

./configure --prefix=/opt/gcc-riscv64-unknown-elf --with-cmodel=medany make -j16

用于linux带glibc的gcc

./configure --prefix=/opt/gcc-riscv64-unknown-linux-gnu make linux -j16

使用ch22 的指令编译出来的工具链 编译 mask rom会报错: unrecognized opcode fence.i', extension zifencei' required

@adrain-yu 我当初使用的是tag 2021.08.07 版本的工具链源码,提交哈希码:c98135b7edfa5356f92c6146c1622f683e90d177
最新版本我还没适配更新

@adrain-yu
Copy link

好的 我在尝试一次 不行 就直接用上面的工具链了

@adrain-yu
Copy link

使用发布的工具联可以compile了

@sunmin89
Copy link

sunmin89 commented Nov 12, 2024

  • wsl ubuntu 20.04 ,我这样配置编译基本能过
GLIB_ELF_CROSS_PREFIX=/home/sunmin/bins/Xuantie-900-gcc-linux-6.6.0-glibc-x86_64-V2.10.1/bin/riscv64-unknown-linux-gnu
GLIB_ELF_CROSS_PREFIX_SYSROOT_DIR=/home/sunmin/bins/Xuantie-900-gcc-linux-6.6.0-glibc-x86_64-V2.10.1/sysroot
NEWLIB_ELF_CROSS_PREFIX=/home/sunmin/bins/Xuantie-900-gcc-elf-newlib-x86_64-V2.10.2/bin/riscv64-unknown-elf
  • 编译 kernel 之前,似乎还需要额外装两个依赖
sudo apt install -y libgmp-dev libmpc-dev
  • 快结束的时候报错了,看起来是 wsl 的问题,不确定物理机会不会遇到这个问题
- ----------------------------- 合成文件系统映像 -----------------------------
4096+0 records in
4096+0 records out
4294967296 bytes (4.3 GB, 4.0 GiB) copied, 2.75411 s, 1.6 GB/s
Error getting authority: Error initializing authority: Could not connect: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
environment Build environment issue
Projects
None yet
Development

No branches or pull requests

4 participants