Skip to content

Using sub‐object c18n

John Baldwin edited this page Feb 21, 2025 · 3 revisions

This is a temporary document detailing how to use sub-object c18n. Eventually support for this will be merged into the main toolchain packages at which point these special steps will no longer be required.

On a Morello Box

Update to a recent dev

The first step on an existing Morello box is to ensure you are running a recent dev (at least 6059700d7fb0774019e0ac05a0890527e02072cb) with a matching kernel and world.

Install a c18n toolchain

pkg64 install llvm-morello-c18n

Building libc

Assuming you have built world before from a checkout of dev, this builds a compartmentalized libc:

cd cheri/git/cheribsd/lib/c18n/libc
make buildenv CROSS_TOOLCHAIN=llvm-morello-c18n WITH_COMPARTMENT_POLICY=yes
make clean
make

If you are brave, you can make install after exiting the build environment. Alternatively, you can copy the libc.so.7 from the object directory to a temporary directory and then point LD_LIBRARY_PATH at the temporary directory when executing individual programs.

Cross-Building

To cross-build an image using sub-object c18n, ensure you are using the right branch / tag of LLVM or Morello LLVM and then build a disk image using the normal cheribuild target.

CHERI LLVM

cd cheri/git/llvm
git remote add jhb [email protected]:bsdjhb/cheri-llvm-project.git
git fetch jhb
git checkout libc_first_boot
cheribuild llvm --skip-update

You can then build a RISC-V image using the normal cheribuild cheribsd-riscv64-purecap disk-image-riscv64-purecap --cheribsd/build-options="WITH_COMPARTMENT_POLICY=yes".

Morello LLVM

cd cheri/git/morello-llvm
git remote add jhb [email protected]:jhb/llvm-project.git
git fetch jhb
git checkout libc_first_boot
cheribuild morello-llvm --skip-update

You can then build a RISC-V image using the normal cheribuild cheribsd-morello-purecap disk-image-morello-purecap --cheribsd/build-options="WITH_COMPARTMENT_POLICY=yes".