riscv交叉编译ports软件@FreeBSD15

当前FreeBSD的riscv版本下,软件包还很贫乏,再加上RISCV的板子有很多种,大部分时候都需要自己动手编译。但是在RISCV环境下编译太慢了,所以我们要使用交叉编译,在很快的AMD64服务器上交叉编译RISCV的软件包。

这里使用了poudriere和jail技术,让我们可以建立riscv的隔离的编译环境。

参考官方文档:riscv/ports - FreeBSD Wiki

poudriere的详细文档:Chapter 4. Installing Applications: Packages and Ports | FreeBSD Documentation Portal 

前期经验文档:使用poudriere安装jail基础的FreeBSD内核来编译软件包-CSDN博客 

 详细过程

首先安装qemu-user-static包并启动服务:

pkg install -y qemu-user-static
service qemu_user_static enable
service qemu_user_static start

生成一个新的poudriere jail容器

如果没有安装poudriere的话就先pkg安装

 pkg install poudriere

如果poundriere服务没有起来的话,手动启动服务:

service poudriered onestart

生成新的jail容器

sudo poudriere jail -c -a riscv.riscv64 -x -j 15rscv64 -m ftp -v 15.0-CURRENT -x

当然,因为FreeBSD15只能去官网,所以生成jail的速度受限于下载速度,需要一些时间。

显示输出:

sudo poudriere jail -c -a riscv.riscv64 -x -j 15riscv64 -m ftp -v 15.0-CURRENT -x
Password:
[00:00:01] Cross-building ports for riscv.riscv64 on amd64 requires QEMU
[00:00:01] Creating 15riscv64 fs at /usr/local/poudriere/jails/15riscv64... done
[00:00:03] FREEBSD_HOST from config invalid; defaulting to https://download.FreeBSD.org
[00:00:04] Fetching MANIFEST for FreeBSD 15.0-CURRENT riscv.riscv64
MANIFEST                                               783  B 1079 kBps    00s
[00:00:04] Fetching base for FreeBSD 15.0-CURRENT riscv.riscv64
base.txz                                               171 MB  456 kBps 06m25s
[00:06:34] Extracting base...

整个过程非常耗时,我怀疑它想把所有的ports都编译一遍?  是不是因为-x参数用了两次?  

更新jail 

poudriere jail -j 15riscv64 -u -x

英文文档附上:

Cross-Building Ports

There is some support for cross-compiling ports via poudriere(8) and qemu-user-static. This method works by emulating a RISC-V userspace with QEMU, so it is faster than building within an emulated system, but slower than building natively. The QEMU userspace emulation is imperfect.

Install and start qemu-user-static first:

pkg install -y qemu-user-static
service qemu_user_static enable
service qemu_user_static start

Please refer to the FreeBSD Handbook entry about poudriere if you are unfamiliar with the tool or need to set it up.

The following command will create a new poudriere jail set up to cross-compile ports for the riscv.riscv64 target:

$ poudriere jail -c -a riscv.riscv64 -x -j 14riscv64 -m ftp -v 14.0-CURRENT -x

The -x argument instructs poudriere(8) to build native cross-toolchain. Make sure to specify it when updating the jail as well, like so:

$ poudriere jail -j 14riscv64 -u -x

更高效交叉编译:只编译一部分ports

前面的例子我怀疑把内核和ports全编译了一遍,其实我们是不需要的,我们可以直接使用现成的FreeBSD内核,而且只编译需要的ports

先创建一个15.0-CURRENT riscv jail

执行命令:

poudriere jail -c -a riscv.riscv64 -j 15riscv64 -v 15.0-CURRENT

下载ports

poudriere ports -c -p local -m git+https

写代编译的ports列表

写一个config列表文件15riscv64 -local-workstation-pkglist,内容如下:

editors/emacs
devel/git
devel/php-composer2@php82
ports-mgmt/pkg

这里面的内容就是我们需要交叉编译的ports软件。可以根据需要添加修改删除。

执行配置和编译工作: 

poudriere options -j 15riscv64 -p local -z workstation -f 15riscv64-local-workstation-pkglist
poudriere bulk -j 15riscv64 -p local -z workstation -f 15riscv64-local-workstation-pkglist

 这样效率更高。

调试

poudriere创建jail报错

poudriere jail -c -a riscv.riscv64 -x -j 14riscv64 -m ftp -v 14.0-CURRENT -x
=>> Error: ZPOOL variable is not set 

原因是:

This error is caused by the fact, when the poudriere.conf configuration file is located in /usr/local/etc/poudriere.d/ (as it is allowed according to the manpage) with no oudriere.conf  in /usr/local/etc/.

The problem can temporarily solved by copying/moving the configuration file to /usr/local/etc/.

学着上面讲的 cp /usr/local/etc/poudriere.conf /usr/local/etc/poudriere.d/ ,还是没有解决。

最终看以前的文档,找到解决方案,就是在poudriere.conf文件里,去掉NO_ZFS=yes 的注释。

vi /usr/local/etc/poudriere.conf ,去掉NO_ZFS=yes 前面的井号。

另外一种方法就是在/usr/local/etc/poudriere.conf文件里加入ZPOOL的名字,比如很多都用默认名字:ZPOOL=zroot

相关推荐

  1. 在Ubuntu上搭建RiscV交叉编译环境

    2024-05-12 22:04:03       241 阅读
  2. FreeBSD RISCV 在QEME中实践

    2024-05-12 22:04:03       14 阅读
  3. 构建 aarch64 以及 riscv64 交叉编译工具链(裸机)

    2024-05-12 22:04:03       34 阅读
  4. 交叉编译

    2024-05-12 22:04:03       17 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-05-12 22:04:03       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-05-12 22:04:03       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-05-12 22:04:03       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-05-12 22:04:03       20 阅读

热门阅读

  1. 从C向C++17——常见算法

    2024-05-12 22:04:03       11 阅读
  2. Kubernetes 文档 / 概念 / Kubernetes 架构 / 控制器

    2024-05-12 22:04:03       14 阅读
  3. QSharedPointer的使用

    2024-05-12 22:04:03       12 阅读
  4. 2024.5.12 Pandas 基础语法day02

    2024-05-12 22:04:03       10 阅读
  5. Dockerfile中的CMD和ENTRYPOINT

    2024-05-12 22:04:03       11 阅读
  6. 给数据库贴标签

    2024-05-12 22:04:03       9 阅读
  7. docker————容器的管理

    2024-05-12 22:04:03       8 阅读
  8. Spring AOP和IOC

    2024-05-12 22:04:03       9 阅读