IRC channel logs

2023-12-05.log

back to list of logs

<oriansj>janneke: or it is so fun people don't even think to ask anyone for help
<janneke>oriansj: yeah, who knows ;)
<Googulator1>...who knew bootstrapping inside a VM can somehow crash the host OS...
<Googulator1>fossy: a little snippet useful for debugging live-bootstrap: trap 'bash -c '"'"'while true; do printf "# ";  $(cat); done'"'"'' ERR
<Googulator1>works in the very first bash build to get an interactive shell if something goes wrong
<Googulator1>replace "set -e" with this in the script you want to debug
<janneke>on #gnu, someone just asked "can gcc be compiled without gcc"
<Googulator>the only downside to this Bash snippet is that it requires an Enter followed by a Ctrl+D before it accepts a command
<Googulator>added to script-generator: https://gist.github.com/Googulator/3984097de4e618ac7bc4ef13ca261568
<Googulator>fossy: caught a bug in script-generator: in interpreter(), last may be used uninitialized
<Googulator>causing weird behavior if the first directive is a define
<matrix_bridge><cosinusoidally> I've managed to get my alternative bootstrap path up to tcc 0.9.27. I can generate a copy of tcc.o that is bit identical to that of my in tree tcc 0.9.27 rebuilding itself.
<matrix_bridge><cosinusoidally> Only thing that is not quite right atm is libtcc1.o . I think there's a bug in my polyfill libc that is causing the assembler to select slightly differrent instructions: 2b 8d dc ff ff ff (sub -0x24(%ebp),%ecx) vs 2b 4d dc (sub -0x24(%ebp),%ecx) . If I link the same tcc.o against glibc then the bug goes away.
<matrix_bridge><cosinusoidally> https://github.com/cosinusoidally/tcc_bootstrap_alt/blob/master/sum are the expected hashes
<janus>cosinusoidally: you wrote sub (-0x24(%ebp),%ecx) twice?
<matrix_bridge><cosinusoidally> In the "incorrect" libtcc1.o sub -0x24(%ebp),%ecx is encoded as 2b 8d dc ff ff ff , in the correct one it is 2b 4d dc
<matrix_bridge><cosinusoidally> It is encoding a 32 bit immediate rather than a 8 bit one
<Googulator>Is linking a fully native binary on the agenda?
<matrix_bridge><cosinusoidally> There's probably some bug in my libc. For example I got a long way with a broken strcmp (until I replaced my buggy version with a good one from meslibc)
<matrix_bridge><cosinusoidally> Googulator: at the moment I'm loading/running the elf files with a custom loader (from tcc_27 I run ./x86/bin/elf_loader_cc_x86.exe -l libtcc1.o -l ../tcc_26/libc_boot3.o -l tcc.o ...) but in theory if I figure out the correct tcc comand I could get it to generate a linked binary version of itself. tcc.o will currently be looking in the wrong place for crt files etc.
<Googulator>If you managed to do that, we could remove mes/mescc from the bootstrap path in live-bootstrap, at least on x86
<Googulator>building mes, and then building tcc with mescc is currently the slowest step on the way to getting a Linux kernel
<Googulator>& it gets exponentially slower on older hardware
<Googulator>on a Core 2 Duo, just compiling tcc to assembly with mes takes longer than the entire Linux kernel build
<Googulator>on modern hardware, Linux is slower to build than mes-tcc, but mes-tcc is still a really slow step, especially compared to how fast tcc then rebuilds itself
<Googulator>I actually tested some commands to have tcc_27 loaded by elf_loader generate a fully linked version of itself, but it breaks due to lseek not being implemented
<matrix_bridge><cosinusoidally> In theory if I could create a drop in replacement to tcc-mes here https://github.com/fosslinux/live-bootstrap/blob/f98161581c6423f53169cfcd4356af6ed9757b3d/sysa/tcc-0.9.26/tcc-0.9.26.kaem#L113 then I could bypass mescc
<matrix_bridge><cosinusoidally> yep lseek is currently missing. I was adding libc functions one at a time as required https://github.com/cosinusoidally/tcc_bootstrap_alt/blob/master/tcc_10/libc_boot3.c#L357
<Googulator>yeah, that tcc-mes is a pain in the ass to get built
<Googulator>also, building meslibc with tcc would be the dream too
<Googulator>not sure if it's feasible
<Googulator>btw, has anyone figured out a way to run mescc using guile instead of mes, just to compare the speed?
<Googulator>I get "no code for module (mescc)"
<Googulator>(of course guile is not gonna be available in early bootstrap where mescc is needed, but I'm trying to figure out if the slowness comes from mes or mescc)
<matrix_bridge><cosinusoidally> meslibc does get built by tcc in https://github.com/fosslinux/live-bootstrap/blob/master/sysa/tcc-0.9.26/tcc-0.9.26.kaem .iirc a stock tcc 0.9.27 can't build it though.
<Googulator>hmm, "if match ${ARCH} riscv64; then tcc-mes -c [...] ../${TCC_PKG}/lib/lib-arm64.c"
<Googulator>is that actually correct?
<Googulator>lib-arm64.c for riscv64, and only for riscv64, not even for arm64?
<stikonas>Googulator: yes, you can run mes with guile
<stikonas>it's quite a bit faster
<stikonas>at leasta few times if I remember correctly
<Googulator>if it's "a few times", that's not a big enough improvement, given how slow it is right now
<stikonas>probably one can get some speed from mes back if we replace if's with switch statements throught mes
<stikonas>well, on riscv64 getting to tcc takes a week
<Googulator>ouch
<Googulator>what core?
<stikonas>but it works, I've ran it...
<stikonas>visionfive2 machine, let me checck the core
<stikonas>JH7110
<stikonas>but that machine doesn't feel that slow with GCC
<stikonas>so must be something mes is doing
<stikonas>possibly memory?
<Googulator>I'm quite sure it's memory bandwidth related
<stikonas>mes and M2-Planet and kind of based on x86
<stikonas>so codegen does a lot of stack pushes/pops
<stikonas>rather than using registers
<stikonas>but I'm not sure if that's the cause of slowness
<stikonas>probably not having huge cache also slows it down
<Googulator>I'm testing on Core 2 Duo/Quad and Ryzen 7840HS - the Ryzen is about 2x faster building the Linux kernel (on 1 core, since no SMP in Fiwix), but over 10x faster for building tcc with mes
<Googulator>Clock & IPC difference explains the difference in Linux
<Googulator>tcc-mes, not so much
<stikonas>Ryzen's have far bigger Cache or am I misremembering?
<Googulator>8MB L2, 16MB L3
<Googulator>Core has 4MB L2 and no L3
<Googulator>but the biggest difference is RAM
<Googulator>DDR2 vs DDR5
<Googulator>10 vs 90 GB/s
<stikonas>hmm, I wonder what is RAM speed in visionfive2
<Googulator>it's claimed to be "LPDDR4"
<Googulator>not clear if that's plain 4 or 4X
<stikonas> https://forum.rvspace.org/uploads/default/original/2X/5/593b9475b31724bab32e53059e185931e5225cf4.gif
<stikonas>that might be useful
<stikonas>random 64-bit reads are under 1 GiB/s
<Googulator>That's _not healthy_
<stikonas>hmm, what is x axis here?
<Googulator>there's no reason for LPDDR4(X) to be that slow
<stikonas>but that might explain why visionfive2 is so slow...
<stikonas>(when using mes)
<GoogulatorMobile>qemu has crashed the host system again... wtf
<stikonas> https://doc-en.rvspace.org/JH7110/Datasheet/JH7110_DS/c_ddr.html also says DDR4/3 and LPDDR4/3 modes and signaling, rates up to the speed of 2,800 Mbps
<stikonas>so it's really slow...
<GoogulatorMobile>That's misleading
<GoogulatorMobile>It's per-pin
<stikonas>oh ok
<GoogulatorMobile>The Micron chip is 1866MHz DDR
<GoogulatorMobile>So 3733 "Mbps" (more correctly MT/s)
<stikonas>ok, there is also this https://openbenchmarking.org/result/2301270-MISK-VISIONF75
<stikonas>so 3 GB/s
<GoogulatorMobile>It has 2 channels of 16 bits each, so a 32-bit wide interface
<GoogulatorMobile>In theory, it should hit just under 15GB/s
<GoogulatorMobile>The Rock 5B (very similar board, but ARM64) gets 34GB/s
<GoogulatorMobile>Both boards are made by Radxa, but different cobranding