使用 docker 容器进行 OpenBMC 构建
尝试在 ArchLinux 上构建 OpenBMC v2.8 版本,发现由于工具链差异太大导致错误太多,最终只得采用 docker 容器的方式进行构建。

错误记录

先记录一下在 ArchLinux 宿主机上构建的几个错误如下。

SIGSTKSZ

| In file included from /usr/include/signal.h:328,
|                  from ./signal.h:52,
|                  from ../../m4-1.4.18/lib/c-stack.c:49:
| ../../m4-1.4.18/lib/c-stack.c:55:26: error: missing binary operator before token "("
|    55 | #elif HAVE_LIBSIGSEGV && SIGSTKSZ < 16384
|       |                          ^~~~~~~~
| make[3]: *** [Makefile:1915: c-stack.o] Error 1
❯ wget https://raw.githubusercontent.com/keyfour/openwrt/2722d51c5cf6a296b8ecf7ae09e46690403a6c3d/tools/m4/patches/011-fix-sigstksz.patch
❯ devtool modify m4-native
cd build/romulus/workspace/sources/m4-native
❯ git apply ~/working/bmc/011-fix-sigstksz.patch

It looks like you have hit a change in GNU C Library version 2.34 that can make SIGSTKSZ non-constant.

Buildroot error when building with Ubuntu 21.10
https://stackoverflow.com/questions/69719688/buildroot-error-when-building-with-ubuntu-21-10/69722830#69722830

FS#4073 - make kernel_menuconfig fails at m4 1.4.18 in Ubuntu 21.10 because of SIGSTKSZ
https://github.com/openwrt/openwrt/issues/9055

autotools

| /home/runsisi/working/bmc/openbmc-2.8.0/build/romulus/workspace/sources/m4-native/build-aux/missing: line 81: aclocal-1.15: command not found

手工执行:

❯ /home/runsisi/working/bmc/openbmc-2.8.0/build/romulus/workspace/sources/m4-native/build-aux/missing aclocal-1.15
/home/runsisi/working/bmc/openbmc-2.8.0/build/romulus/workspace/sources/m4-native/build-aux/missing: line 81: aclocal-1.15: command not found
WARNING: 'aclocal-1.15' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.
         The 'aclocal' program is part of the GNU Automake package:
         <http://www.gnu.org/software/automake>
         It also requires GNU Autoconf, GNU m4 and Perl in order to run:
         <http://www.gnu.org/software/autoconf>
         <http://www.gnu.org/software/m4/>
         <http://www.perl.org/>

并不需要更新 autotools 的版本,只需要在源代码目录执行如下命令即可:

❯ autoreconf

由于构建环境变化太大,类似的错误只会更多,不建议再尝试了,直接使用 docker 进行构建。

使用容器

使用 docker 搭建 Ubuntu 20.04 构建环境:

❯ docker pull ubuntu:20.044
❯ docker run -it -e http_proxy -e https_proxy -v $PWD/openbmc-2.8.0:/home/runsisi/working/bmc/openbmc-2.8.0 ubuntu:20.04

由于 bitbake 的 bblayers.conf 用到了绝对路径,因此保持容器内外目录结构不变。

安装构建工具并配置相关的环境:

apt install build-essential automake autoconf
apt install python3 bc

apt install chrpath cpio diffstat gawk git wget
apt install locales
// for kernel menuconfig, 选择 tmux 或者 screen 都行
apt install tmux screen libncurses-dev

vi /etc/locale.gen
en_US.UTF-8 UTF-8

locale-gen

useradd -m runsisi

注意 bitbake 要求 UTF-8 环境:

su runsisi

export LANG=en_US.UTF-8
bitbake -k obmc-phosphor-image

最后修改于 2024-01-01