tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Building NetBSD on OpenBSD



Hi

I’ve been playing with build.sh on various platforms to get to know the toolchain better and recently I’ve built NetBSD on OpenBSD. 

TLDR: with some modifications to the limits in login.conf for the user building (or building as root), ./build.sh will build all platforms on a OpenBSD host as of current 29/6/2021.

Host details:
% uname -a
OpenBSD blowfish 6.9 GENERIC.MP#3 amd64

% cc --version
OpenBSD clang version 10.0.1 
Target: amd64-unknown-openbsd6.9
Thread model: posix
InstalledDir: /usr/bin

There were four problems to solve:

1. The texinfo/makeinfo tool would segfault when building the GCC info pages.

… but OpenBSD’s native makeinfo would build the page. Running the debugger on the core dump, led to a function that had been changed both in OpenBSD and in mainline texinfo. The patch addresses an off-by-one bug and an out of bounds access issue, which only seems to occur on OpenBSD.

http://mail-index.netbsd.org/source-changes/2021/06/07/msg130058.html

2. GCC could not find the LTO plugin at runtime

OpenBSD names shared libraries thus: libname.so.X.Z and there is no link installed for libname.so.X and libname.so.

The LTO plugin was being installed as liblto_plugin.so.0.0 and when GCC needed it, it could not find it. Of course, one could simply add a link the library and carry on, but we want the build script to be hands-free. There were various places were one could fix this and this one seemed to be the best fit in the hosts build configuration (one commit for each GCC version we have in tree):

http://mail-index.netbsd.org/source-changes/2021/06/28/msg130490.html
http://mail-index.netbsd.org/source-changes/2021/06/29/msg130508.html

3. Sysinst would not build due to the sanity checking of formatting symbols in installation strings.

The script msg_xlat.sh counts the %s in a string to make sure that there are the same number of formatting symbols across all of the matching language installation strings. The script uses IFS=% together with the set builtin to count the characters. OpenBSD’s shell behaves slightly differently to other shells when there is a % at the beginning of a string. Kre@ rewrote the script to be more portable.

http://mail-index.netbsd.org/source-changes/2021/06/29/msg130506.html

(An alternative here usually would be to use /bin/ksh to workaround shell problems but OpenBSD’s ksh == sh.)

4. Apparent memory exhaustion when building MIPS targets and targets needing LLVM RT (e.g. building amd64, i386 and evbarm64-el targets with X)

login.conf on a stock OpenBSD installation is setup with limits for groups, users and daemons. When building these targets, the compiler uses more memory than the limits allow. Of course, these days users tend to have personal machines with root access, but if one is at the mercy of a system administrator, login.conf can be adjusted. These values work but there are probably more optimal ones.

staff:\
	:datasize=infinity:\
	:datasize-cur=8192M:\
	:maxproc-max=512:\
	:maxproc-cur=256:\
	:ignorenologin:\
	:requirehome@:\
	:tc=default:

All the best
Chris


Chris Pinnock PhD FBCS CITP FIMA
PGP: F384 91B6 ACED 4131 7925 1BD8 74A8 0935 96A9 8C52



Home | Main Index | Thread Index | Old Index