IRC channel logs
2024-10-27.log
back to list of logs
<fossy>urgh, not openssl problems again <fossy>i'm working on getting bearssl in a state suitable for bootstrapping <matrix_bridge><Andrius Štikonas> But before that, it would be nice to have something small <fossy>openssl is also just much more complicated lol <matrix_bridge><Andrius Štikonas> I wonder if bearssl is buildable with tcc... <matrix_bridge><Andrius Štikonas> Though we have no network before Linux anyway <lanodan>bearssl at least with upstream tcc builds fine, including tests <notgull>I'm trying to get the AMD64 part of the stage0-posix project on my system, but I keep running into errors. When I try to investigate the executable, I get the file type: "/tmp/M0: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), can't read elf program headers at 1073741824, no section header" <notgull>I used hex2 to compile it from the `AMD64` submodule, any ideas? <notgull>cat ../AMD64/ELF-amd64.hex2 ../AMD64/M0_AMD64.hex2 > /tmp/M0.hex2 <notgull>./bin/hex2 -f /tmp/M0.hex2 -o /tmp/M0 <notgull>Is there supposed to be another options on hex2? <stikonas>yeah, we need to specify --little-endian --architecture amd64 <stikonas>(or if you run make test-amd64 from stage0-posix directory) <notgull>It looks like specifying the first two options made it compile <stikonas>(which just kicks of ./bootstrap-seeds/POSIX/AMD64/kaem-optional-seed <stikonas>most other reasonable numbers would work <stikonas>I guess as long as it's outside reserved ranges, something over 1MiB would probably work <notgull>Ok now I have the executable I wanted, thanks! <notgull>Mmm, I imagine it's largely irrelevant? <stikonas>nothing should change as long as Linux accepts that base address in elf header <stikonas>in fact almost all stage-posix-amd64 binaries are position independent <stikonas>(I think kaem-optional-seed is the only exception for now_ <notgull>Anyhow what I'm trying to do is get cc_amd64 working <stikonas>but even for PIE binaries, Linux elf loader doesn't like if base address is 0 <notgull>So I know what I can and can't add to M2-Planet <stikonas>yeah, basically looking at M2-Planet would give you a good idea what is supported <stikonas>for structs, I think you are limited to struct pointers <stikonas>well, for loops can't do for (int i = 0; ...) <notgull>My assumption is that "unsigned char" and any other "unsigned [X]" types aren't supported either, right? <stikonas>you need to declare int i = 0 before for loop <stikonas>probably better support in M2-Planet than in cc_x86 <stikonas>if you see, M2-Planet assembly outputs, i.e. emit_out functions <notgull>I'm trying to compile QBE with M2-Planet, and the error I'm getting is this <stikonas>then you can see lots of signed vs unsiged cases <notgull>"/home/jtnunley/Projects/c9x/qbe/all.h:11:ERROR in typedef statement" <notgull>That statement is: typedef unsigned char uchar; <stikonas>arithmetic_recursion(additive_expr_a, "ADD R0 R1 R0\n", "ADDU R0 R1 R0\n", "+", additive_expr_stub_b); <stikonas>oh, typedef might not be smart enough here <stikonas>(for M2-Planet at least, cc_x86 supports less) <notgull>I looked there, I see "unsigned" but not "unsigned char" <stikonas>anyway, I wouldn't use cc_x86 for anything other than M2-Planet <notgull>So I wanted to take a crack at rewriting that file a bit, but I needed to know what cc_x86 supporte <stikonas>oh, maybe the problem is that only 1 word types are supported <stikonas>anyway, looks like indeed there is no "unsingned char" <notgull>I was investigating if it's feasible to add that in the current compiler <notgull>Make it so `type_name()` can handle it <stikonas>well, you can always at least look ahead for the further tokens <stikonas>global_token->next and global_token->next->next, etc... <stikonas>and as for cc_x86, it basically has no support for pre-processor <stikonas>we could probably do without unions in cc_x86 even though we have them <notgull>My overarching goal here is making it so dozer can be compiled early on in the bootstrap chain <notgull>Right now it can be compiled by TinyCC, sort of <notgull>But I'd like to introduce it as early as I can <stikonas>well, the earliest possible stage is M2-Planet I think <notgull>I originally wanted to do mescc but I don't know enough Scheme to effectively modify it to compile QBE <stikonas>and anything earlier would required rust_x86 written in assembly :D <stikonas>yeah, scheme tends to be hard for most people <notgull>You can probably get some kind of "proto-Rust" written in Assembly, that supports structs and impls and stuff but not traits and generics <stikonas>though some people like scheme a lot and find it easier <notgull>But at that point you basically have C written with a different syntax, and at that point you may as well just use C <notgull>Frankly it's less of Scheme itself and more of mes's codebase <notgull>It's quite dense for a Scheme program <notgull>I wonder if it would be possible to make it so M2-Planet could compile TinyCC? <notgull>Let me see what happens if I run M2-Planet on one of tcc's headers <stikonas>though probably quite a bit of work requried <stikonas>perhaps not in terms of missing features <stikonas>but there is a lot of fiddling at the end when you are really close to bootstrapping tcc <stikonas>i.e. tcc depends on int being 4 bytes, etc... <stikonas>hmm, probably limitation of pre-processor <notgull>Is there a way to set include path in mesoplanet? <notgull>`./M2-Mesoplanet -f ~/Projects/TinyCC/tinycc/tcc.h -I ~/Projects/TinyCC/tinycc` fails with the same error <notgull>I see that line, it sets "M2LIBC_PATH" <stikonas>maybe it doesn't accept any other include dirs <notgull>I ran with the PWD set to tinycc's dir, and it looks like it fails when it tries to read in stdarg.h <notgull>So it looks like stdarg.h would need to be added to M2libc <notgull>...which means vararg support would need to be added to M2-Planet <stikonas>anyway, even mescc only builds patched tcc <stikonas>ekaitz and I had some issues with varargs when bootstrapping tcc from mescc on riscv64... <notgull>I'm assuming this would be an issue in building QBE as well, since QBE has vararg functions <stikonas>yeah, so that's one of the missing features... <stikonas>M2-Planet doesn't seem to have any varargs <stikonas>probably another missing feature would be support for "i++ or ++i" <stikonas>M2-Planet doesn't support pre or post inc/de-crement operators <stikonas>type sizes might be an issue too as I've mentioned <stikonas>even though M2-Planet is not that far behind mescc <notgull>Yeah I think my plan is probably just going to be to use TinyCC as my bootstrap base for now <notgull>Then once dozer is in a more manageable state and I can bootstrap rustc v1 from there, I'll go back and see if I can make any progress from the other end <notgull>Mmm yeah, and even then it takes a bit of work to get it working with QBE <stikonas>yeah, QBE was mentioned in this channel before <notgull>Yeah tinycc can compile qbe relatively easily, but it can't handle QBE's assembly syntax <stikonas>yeah, tcc assembly support is not too good <notgull>I think one of the Hare guys actually proposed a patch to tcc to fix that <stikonas>which I think is because tcc is not a C to assembly compiler... <stikonas>it is directly converting C to binary code <stikonas>well, they should just push that patch to tcc <notgull>Yeah it's been a month or so, I'll just push it... <stikonas>though don't hold your breath about it ending up in release <notgull>Who's even in charge of that these days? <Googulator>notgull: I'd suggest not using molassescc, I mean, mescc, for anything more than necessary <Googulator>compiling tcc with mescc is the single slowest step of the early bootstrap, before we have a real Linux kernel - by comparison, the next set of recompiling tcc with itself is virtually instantaneous <Googulator>compiling Dozer with mescc would probably take weeks even on a Zen 5 CPU