How to build Pure-Capability CheriBSD for the Morello Platform to compile, debug and execute software

Hi all,

I apologise in advance, this might be long-winded as I am fairly new to CheriBSD and Morello. I have an AWS machine running Ubuntu 18 on an Intel x64 system.

My aim is to have a CheriBSD instance running the Arm Morello FVP, and to then compile, debug and run various pieces of software. Obviously, some of the source code will have to be amended to account for the CHERI changes to pointers and accepted data types.

A quick read of the CheriBSD GitHub tells me that ./cheribuild.py is my go-to for building all things CheriBSD. I've cloned the cheribuild GitHub repo so that I can use the script to install what I need.

At the moment, I'm running:

./cheribuild.py run-morello-purecap -d

...but my questions are:

What is that coming with? Do I already have everything I need as part of the development toolchain to compile (Clang/LLVM), debug (gdb)? Does that create a disk image? How do I find everything that is being included when running that command?

How do I find the dependencies that are being included and built when using -d?

When running ./cheribuild.py --list-targets, it displays multiple of what look like closely similar options. How do I know which one I need to specify? What is the difference between llvm-native, llvm-morello-purecap, morello-llvm-morello-purecap and llvm, for example? Are some of these simply aliases and mean the same thing? Are some being added to the host machine, and some being added to the CheriBSD instance?

How do the disk-images work with ./cheribuild disk-image-<architecture>? Can I boot from this to save the machine state? How can I save the state of the machine so that I can reboot, and pick back up from where I left off? This would be nice to know so I don't have to build every time I exit or have to use a command like screen, or is this simply not possible.

What is the difference between ./cheribuild.py run-morello-purecap -d  and ./cheribuild.py cheribsd-morello-purecap -d?

If I build using ./cheribuild run-morello-purecap -d and then realise I would like to build another target such as Nginx for example and add it to the instance already built, do I simply run: ./cheribuild nginx-morello-purecap, and it will "amend" the CheriBSD instance, or is there another method I should be using instead?

Does all compilation, debugging etc. take place on the host machine, rather than CheriBSD itself?

--------------------------

I appreciate there are a lot of questions here and a lot to go through, so I appreciate anyone offering help to somebody new to the area! 

If there is any documentation, guides or tutorials that answers my questions, please post the link as I am trying to be a self-learner as much as possible :)

Thanks!

Parents
  • I have a hello-world.c program I'd like to cross-compile across to the CheriBSD OS. What does this process look like? Is there a guide I can follow?

    If you want to compile a simple C/C++ file, cheribuild installs some helper scripts in output/morello-sdk/utils/cheribsd-morello-purecap-clang(++) that will add the necessary compiler flags to select right ABI and CheriBSD sysroot (the flags are defined in output/morello-sdk/bin/cheribsd-morello-purecap.cfg). If you want to compile something more complicated, I would recommend adding a new target to cheribuild. I've added a short wiki page that shows how to add new targets, I hope it is helpful: https://github.com/CTSRD-CHERI/cheribuild/wiki/Adding-a-new-cheribuild-target.

    We also have a few CHERI exercises here: https://ctsrd-cheri.github.io/cheri-exercises/introduction/index.html . The guide mostly talks about CHERI-RISC-V but applies equally to Morello.

    Also, how does the cheribsd-sdk-<architecture> come into play during this whole process?

    This target is effectively and alias to build a compiler and a sysroot. If you already booted CheriBSD, you will have both of these so you won't need to run cheribsd-sdk-<foo>.

Reply
  • I have a hello-world.c program I'd like to cross-compile across to the CheriBSD OS. What does this process look like? Is there a guide I can follow?

    If you want to compile a simple C/C++ file, cheribuild installs some helper scripts in output/morello-sdk/utils/cheribsd-morello-purecap-clang(++) that will add the necessary compiler flags to select right ABI and CheriBSD sysroot (the flags are defined in output/morello-sdk/bin/cheribsd-morello-purecap.cfg). If you want to compile something more complicated, I would recommend adding a new target to cheribuild. I've added a short wiki page that shows how to add new targets, I hope it is helpful: https://github.com/CTSRD-CHERI/cheribuild/wiki/Adding-a-new-cheribuild-target.

    We also have a few CHERI exercises here: https://ctsrd-cheri.github.io/cheri-exercises/introduction/index.html . The guide mostly talks about CHERI-RISC-V but applies equally to Morello.

    Also, how does the cheribsd-sdk-<architecture> come into play during this whole process?

    This target is effectively and alias to build a compiler and a sysroot. If you already booted CheriBSD, you will have both of these so you won't need to run cheribsd-sdk-<foo>.

Children
No data