fosslinux / live-bootstrap

Use of a Linux initramfs to fully automate the bootstrapping process
291 stars 26 forks source link

add alternative tcc bootstrap path #407

Open cosinusoidally opened 6 months ago

cosinusoidally commented 6 months ago

This is a draft PR that adds my alternative bootstrap path for tcc https://github.com/fosslinux/live-bootstrap/issues/355 . I've marked this as a draft as it is probably not yet in a state suitable for merging (eg I updated the ci to unconditionally enable the flag --tcc_bootstrap_alt but probably both the mes and tcc_bootstrap_alt path need testing automatically via ci). I also had some issues with nested conditionals in kaem that meant I needed to add some awkward combined conditionals (which also currently have bug that will break architectures other than x86/riscv). There may be a better way of doing that.

cosinusoidally commented 6 months ago

I think the ci job on the pr is testing the --tcc_bootstrap_alt route. I've kicked off a run of the mes route on my fork just to check I've not broken the standard path https://github.com/cosinusoidally/live-bootstrap/actions/runs/7489674266 (I have already tested a partial run of the standard path, but only up to tcc-0.9.27).

cosinusoidally commented 6 months ago

Just pushed an updated version that computes sha sums as per our discussion on matrix. I had to split the tcc-0.9.26 hashes as some of them are only relevant to tcc-mes. I rebuilt the final version of tcc-0.9.26 a second time which caused the sha256sum to converge to the same value as the standard mes based bootstrap path. I couldn't get the same rebuild trick to work for tcc-boot0 and tcc-boot1 so I just ignore these hashes when the alt bootstrap path is enabled.

I've also added a separate ci step that tests my alt bootstrap path.

I've just noticed that my branch seems to break in qemu. It gets as far as the first call to cdrun here https://github.com/cosinusoidally/tcc_bootstrap_alt/blob/0.1/after.kaem#L20 and then crashes. I think it's failing around here https://github.com/cosinusoidally/tcc_bootstrap_alt/blob/0.1/tcc_js/cdrun.c#L48-L54 (based on the last thing printed to the terminal) . I'm guessing I may be hitting some issue in the chdir or execve syscall in builder-hex0

The command I used to generate my qemu image was something along the lines of:

./rootfs.py --bare-metal --target /tmp/build --tcc_bootstrap_alt

I used bare-metal as I was running the rootfs.py command inside a vm. I then grabbed the init.img file from /tmp/build and ran it inside a qemu vm on the host.