When I recently tried building an embedded Linux system using Yocto Zeus on Arch, I ran into a couple of issues. Here’s a summary of the problem and and a workaround.

Problem 1: GCC 10

From version 10, GCC defaults to -fno-common instead of the previous default -fcommon. This can lead to linker errors due to multiple symbol definitions. The natural solution would be to override this new default with the old one using something like BUILD_CFLAGS. Unfortunately, this doesn’t work for all -native recipes as not all allow to override the CFLAGS, e.g. dtc-native. The only solution I have found for this problem is downgrading GCC.

Problem 2: file with libseccomp

Some recipe steps fail with errors like

Command '['file', '-b', '/…/base-files/3.0.14-r89/package/etc/skel/.profile']' died with <Signals.SIGSYS: 31>.

This is caused by the fact that the file utility in Arch is compiled with libseccomp support. This wouldn’t be a problem in itself, but the Yocto build system uses libpseudo which seems to cause the issue. The functionality provided by libseccomp can be disabled with file’s --no-sandbox switch.

Workaround

I have added a .bin directory to my Yocto project’s root directory which gets added to PATH with the highest priority (left-most). It symlinks gcc and g++ to gcc-8 and g++-8 (gcc8 package from the community repo), respectively. I furthermore included a wrapper script for file.

mkdir .bin
ln -s /usr/bin/gcc-8 .bin/gcc
ln -s /usr/bin/g++-8 .bin/g++
cat <<EOF > .bin/file
#!/bin/sh
/usr/bin/file --no-sandbox "\$@"
EOF
chmod +x .bin/file

In order to make working with this a little more convenient, I added a small script that can be sourced when starting to work on the project:

cat <<EOF > source-me
export PATH="\$PWD/.bin:\$PATH"
. ./poky/oe-init-build-env
EOF