This is very much a draft still as I go along. Everything in here is subhect to change heavily, could be wrong and your mileage may vary greatly.
Everything here assumes native build on Arch POWER riscv64.
This is probably broken in some way but works for me.
#!/bin/bash