IRC channel logs

2022-01-20.log

back to list of logs

<oriansj>I really need to find time to fix M2-Mesoplanet's nested macro support
***janneke_ is now known as janneke
***gio_ is now known as gio
<oriansj>stikonas: good news. I've fixed nest #if blocks in M2-Mesoplanet
<oriansj>it now correctly compiles on all architectures
<stikonas>oriansj: oh nice. Maybe worth backporting to M2-Planet?
<oriansj>possibly, it is a small change
<oriansj>now just to start testing bigger programs to flush out additional bugs
<oriansj>probably should add a little logic to keep the tempfile around if we need to dig in
<stikonas>oriansj: also there is segfault if its build with M2-Planet
<stikonas>s/build/built/
<stikonas>might be something to do with tempfiles too...
<oriansj>oh joy
<oriansj>ok, I'll add that to my todo list
<stikonas>hmm, blood_elf.c fails with "non-line number: / provided to #FILENAME"
<stikonas>(that's if I build with gcc)
<oriansj>./bin/M2-Mesoplanet -f ../mescc-tools/blood-elf.c -f ../mescc-tools/stringify.c -o foo
<oriansj>hmm
<oriansj>no segfault here
<stikonas>oriansj: and you are using Mesoplanet built with M2-Planet?
<stikonas>not gcc
<stikonas>because I do get segfault with your command line
<stikonas>something crashes in DO_match_3
<stikonas>but I can't see any backtrace with those binaries
***ChanServ sets mode: +o janneke
<alMalsamo>So I checked this site: https://www.bootstrappable.org/projects/mes.html which mentions stage0 okay, but there is no mention of M2-Planet or M2-Mesoplanet, what are those projects for?
<alMalsamo>ALso why does it go MesCC --> TinyCC --> GCC 2.95.0 --> GCC 4.7.4
<alMalsamo>I understand TinyC to GCC but what is the purpose of compiling 2.95.0? Why not go straight from TinyCC to GCC 4.7.4?
<alMalsamo>Hmm I just checked out source for stage0 to understand what that is, and I see a file git clone https://git.savannah.nongnu.org/git/stage0.git
<alMalsamo>oops I meant to paste: stage0/stage3/M2-Planet_x86.c
<alMalsamo>Does this mean M2-Planet is a part of stage0?
<janneke>alMalsamo: because this was easier, we will want to get rid of gcc-2.95.3 some time soon
<stikonas>alMalsamo: first of all you can't go to GCC 4.7.4 with stable TCC
<stikonas>alMalsamo: you could go to GCC 4.0.4
<stikonas>and that is what was done in live-bootstrap
<stikonas>and to understand M2-Mesoplanet, I should first note that stage0 is for bootstrapping on baremetal
<stikonas>but we have another similar project stage0-posix that assumes posix environent (i.e. some simple kernel) with basic syscalls
<stikonas>in principle both stage0 and stage0-posix follow similar early steps, hex0->hex1 (simple linker)->hex2 (more advanced linker)->M0 (macro assembler) -> cc_* (C compiler written in assembly) -> M2-Planet
<stikonas>and all those steps are designed to run on both POSIX and baremetal
<stikonas>though obviously that would require much more manual work on baremetal unlike POSIX version which can be scripted
<stikonas>because M2-Planet is designed to run on baremetal, there are some things it can't suppport, e.g. #include statements
<stikonas>on baremetal, you would have to do #includes manually, i.e. combine sources
<stikonas>so we are now working on M2-Mesoplanet which is specific to posix bootstrap
<stikonas>and is basically a C preprocessor plus some wrapper around M2-Planet (it's similar to gcc vs cc1)
<stikonas>gcc executable is not a C compiler
<stikonas>it just invokes a few other binaries
<stikonas>(e.g. cc1 is a C compiler, then as is assembler, ld is linker)
<stikonas>similarly, M2-Mesoplanet invokes M2-Planet, M1 and hex2
<stikonas>and to avoid confusion M1 is a cross-platform (written in C) equivalent of M0 (written in hex2)
<stikonas>alMalsamo: hopefully that clarifies things a little bit
<stikonas>alMalsamo: to go to GCC 4.7.4 you can follow these steps https://github.com/fosslinux/live-bootstrap/blob/master/parts.rst
<stikonas>these are fairly strict in not using any pre-generated files (not just pre-compiled binaries)
<stikonas>can skip about half of them if you are not bothered by those
<ekaitz>janneke: should I announce my future work now?
<ekaitz>looks like a good moment for it
<ekaitz>so the thing is that I'm going to work on backporting gcc for riscv
<ekaitz>in order to have a bootstrappable compiler for riscv
<ekaitz>I have a whole year for that since I got some funds
<muurkha>oh, that's wonderful!
<muurkha>I wonder if an emulator for an old processor that could run old versions of GCC would be less work
<stikonas>oh nice!
<muurkha>we tend to default to i386, but MIPS might be easier to write an emulator for
<stikonas>ekaitz: which versions are you going to target?
<ekaitz>i talked with janneke and he suggests 4.6
<stikonas>hmm
<stikonas>well, if that works, we can always switch from 4.7.4 to 4.6 in bootstrap
<ekaitz>I was looking into 4.7
<ekaitz>but I was suggested to check 4.6 because of its code modularity if i'm not mistaken
<ekaitz>i was going to ask janneke for more clarifications on that
<ekaitz>i'm still preparing the project plan
<janneke>ekaitz: sure, why not?
<ekaitz>:)
***ChanServ sets mode: -o janneke
<janneke>ekaitz: the wip-full-source-bootstrap branch already uses gcc-4.6 but still has the gcc-2.95.3 intermediate step
<ekaitz>janneke: but is there any issue with moving to 4.7?
<ekaitz>just asking
<ekaitz>why did you choose 4.6
<janneke>gcc-4.7.4.tar.gz 102M
<janneke>gcc-core-4.6.4.tar.gz 37M
<janneke>gcc-4.7 has no modular distribution
<janneke>for every iteration trying to build the first gcc-core, which can take many tries, you'll be unpacking a lot of unnecessary cruft
<janneke>not funny
<ekaitz>ooooh
<stikonas>unpacking 100MB isn't that long though...
<stikonas>or maybe it's quicker because I have SSD...
<stikonas>anyway, there is probably not significant difference in terms of bootstrap (4.6 vs 4.7.4)
<alMalsamo>stikonas: Thanks for that link to the fosslinux github, this is a lot more complicated than I imagined! But to bootstrap following this process, won't I need to rely on something like the GNU Guix live image to have some sort of environment within which to run stage0-posix utilities and M2-Planet to finally get GNU Mes compiled?
<stikonas>alMalsamo: no, it's completely self-contained
<stikonas>you only need to start with hex0 and kaem-optional-seed (trivial shell)
<stikonas>kaem-optional-seed is 757 byte long and can only read commands and their arguments from file and run it
<stikonas>(well, and strip comments from that file)
<stikonas>but you do need some kernel
<stikonas>just doesn't have to be Guix live image
<stikonas>alMalsamo: but you need some kind of kernel anyway for GNU Mes
<stikonas>GNU Mes does not run on baremetal systems
<stikonas>it really needs POSIX
<stikonas>and we don't have any simple kernel for bootstrapping right now
<alMalsamo>stikonas: So what kernel should I be using if I want to try starting with hex0 and kaem-optional-seed?
<alMalsamo>And is kaem in stage0-posix or where is the code for this, I haven't heard of this shell before...
<muurkha>linux
<stikonas>alMalsamo: any Linxu kernel
<stikonas>well, live-bootstrap needs 32-bit kernel (not 64) but early stages work fine with 64-bit kernels too
<stikonas>alMalsamo: so you can do bootstrap in chroot, qemu or real system
<stikonas>real system is the most involved though since you need to get some bootloader for linux kernel, etc...
<stikonas>you'll also need some empty disk
<stikonas>running it in qemu or chroot is of course much simpler
<stikonas>and if you just run stage0-posix, you can run it without any isolation inside your distro
<alMalsamo>Hmm well I want to end up with GNU Guix amd64 binaries, is this possible even if I start iwth an i686 kernel?
<alMalsamo>I have two empty SSDs in my laptop without even a partition table on them, so I must install GNU Grub first somehow then boot an i686 Linux kernel?
<stikonas>alMalsamo: kernel bits do not affect binaries
<stikonas>but what you have to keep in mind that bootsrap process works ONLY on x86
<stikonas>nothing else works
<stikonas>we do have some steps for other arches
<alMalsamo>Hmm okay that's a bummer I would like to do this on other microarchitectures eventually, but for now I only have x86_64 machines available so this doesn't bother me much FOR NOW
<stikonas>stage0-posix supports x86 x86_64, aarch64, riscv32, riscv64 but further steps work only on x86
<stikonas>alMalsamo: well, contributions are welcome
<alMalsamo>Oh cool even RISC-V support, I thought GNU Guix didn't even work on RISC-V yet
<stikonas>no, Guix doesn't
<stikonas>stage0-posix does work on risc-v
<stikonas>and it builds M2-Planet and some utilities
<alMalsamo>OKay I want some RISC-V hardware but i don't want SiFive chips because they are proprietary so I am looking for chips with libre HDL code
<stikonas>so you are in C land for furthter bootstrap
<stikonas>no more assembly / hex programming
<alMalsamo>So I cloned this repo: https://git.savannah.nongnu.org/git/stage0.git Is this completely unnecessary as I should just look for stage0-posix repo instead?
<stikonas>well, stage0 is baremetal bootstrap...
<stikonas>but yes, you don't need that if you have POSIX
<stikonas>most people look at stage0-posix but there is some work on stage0
<muurkha>alMalsamo: there are a lot of libre RISC-V designs, like VexRiscV and PicoRV32. not sure if there's a fully libre toolchain to get them running on an FPGA but I think VexRiscV can
<stikonas>e.g. bauen1 is trying to run bootstrap on baremetal ARM
<alMalsamo>Yeah there is also Boomv2 from Berkely and Alibaba XuanTie E902, E906, C906 and C910 which are RISC-V 64-bit
<alMalsamo>not copylefted though :(
<alMalsamo>But I kind of want a SoC board with a GPU because I am a newb
<alMalsamo>So I am still waiting...
<muurkha>you can make your own copylefted derivative work if you want
<muurkha>but the big problem for copylefted silicon is how do you tell if the silicon really implements the purported design and how do you run your changes if you make a changed versio
<stikonas>well, toolchain to build it on FPGA will definitely be non-bootstrappable
<stikonas>but CPU bootstrap vs bootstrap on FPGA is somewhat similar to stage0 vs stage0-posix
<stikonas>except that it's probably easier to build simple kernel than your own hardware
<muurkha>not forever. yosys/nextpnr is potentially bootstrappable