IRC channel logs

2025-03-15.log

back to list of logs

<stikonas>janneke: hi. I've sent you a patch that synchs M1 defines for x86 and x86_64 from M2libc
<stikonas>there were some codegen changes in M2-Planet git repo
<stikonas>well, it also removes old style (capitalized long) defines too
<janneke>stikonas: thanks!
<stikonas>hopefully we had long enough transition period that nobody would be using very old M2-Planet anymore with mes
<janneke>stikonas: right -- except that the (guix shell description in the) mes repository itself is still at 1.11.0 :)
<janneke>i'll apply this to "wip" for now but it should probably go to master after bumping m2-planet
<stikonas>yeah, 1.11.0 should work with new defines I think
<stikonas>but yeah, we probably want this in some dot release soonish
<stikonas>I'll try to test bootstrap before releasing stage0-posix/M2-Planet
<janneke>"<stikonas> yeah, 1.11.0 should work with new defines I think"
<janneke>oh, that's amazing
<janneke>are you using the mes lib c work in "wip" yet?
<stikonas>no, haven't tried anything from wip yet
<stikonas>maybe ekaitz is ?\
<janneke>i was hoping it would enable skipping musl...buit yeah, it doesn't
<stikonas>last few weeks I was busy reviewing all those patches from gtker...
<ekaitz>i started trying things on top of master
<stikonas>M2-Planet changelog is huge this time...
<stikonas> https://github.com/oriansj/stage0-posix/blob/master/CHANGELOG.org
<ekaitz>we need a release there
<stikonas>yeah...
<stikonas>I have updated M2libc in all submodules
<stikonas>need to update stage0-posix now
<stikonas>and then still need to test bootstrap...
<stikonas>well, at least to make sure mes-m2 works
<stikonas>I'll try to make release soonish, perhaps today
<stikonas>and if more patches keep coming, we can always have the next release sooner rather than later
<stikonas>argh, I think current master is broken :(
<stikonas>need to bisect first...
<stikonas>looks like it might be switch / case rework
<stikonas>oh indeed, it has a complicated switch expression... switch(0xFF & global->readCur[7])
<stikonas>oh but that's switch, not case...
<stikonas>argh, this will be tricky...
<stikonas>this only happens with bootstrapped M2-Planet...
<stikonas>but not with M2-Planet compiled with GCC
<ekaitz>uhhh
<stikonas>yeah, so hard to debug... no good debug symbols...
<stikonas>well, it crashes somewhere in process_switch_iter
<ekaitz>i also was going to ask about if vs switch
<ekaitz>how much faster is switch? in M2?
<stikonas>so definitely something is wrong with that switch commit. And you wanted that release specifically for that release
<ekaitz>stikonas: it's also ok if we only support numbers
<ekaitz>feel free to revert
<stikonas>oriansj checked at some point, switch generates better assembly than if/else
<stikonas>well, it's still a nice feature to have
<stikonas>and it works with GCC compiled M2-Planet
<stikonas>well, we had plenty of those kind of bugs when we worked on bootstrapping tcc and gcc on riscv64...
<stikonas>I don't recall any in M2-Planet before...
<stikonas>oh I know what it might be
<stikonas>I had int value = constant_expression();
<stikonas>it's not inside loop
<stikonas>but effectively it is inside manual "goto" loop
<stikonas>ekaitz: yes, that was it...
<ekaitz>we got release then?
<stikonas>well, it is unblocked here
<ekaitz>janneke: should I rebase to wip and continue there?
<stikonas>still need to test mes boostrap
<stikonas> https://github.com/oriansj/M2-Planet/commit/b69810eaa8d39305a3d4bfb16181d142dd019e67
<janneke>ekaitz: probably...if it works for you
<ekaitz>janneke: if it's broken I won't, is it?
<ekaitz>:)
<janneke>ekaitz: i don't think so; it just won't build gcc4 without musl just yet
<ekaitz>oh ok
<stikonas>ok, so far no issues in testing (appart from the expected missing M1 defines in the released mes)
<stikonas>mes-m2 seems to be functional
<ekaitz>that's great
<ekaitz>stikonas: keep me posted if you make the release
<stikonas>yeah, starting with mescc-tools for now
<stikonas>need to do mescc-tools, mescc-tools-extra, M2-Planet, M2-Mesoplanet and combined stage0-posix
<ekaitz>good
<stikonas>well, mescc-tools is here https://github.com/oriansj/mescc-tools/releases/tag/Release_1.6.0
<stikonas>need to upload to savannah too I think...
<stikonas>don't remember how to do that yet...
<stikonas>ok, that is done: http://download.savannah.nongnu.org/releases/mescc-tools/
<stikonas>mescc-tools-extra 1.4.0 is now uploaded too: https://github.com/oriansj/mescc-tools-extra/releases/tag/Release_1.4.0
<stikonas>M2-Mesoplanet 1.12.0: https://github.com/oriansj/M2-Mesoplanet/releases/tag/Release_1.12.0
<stikonas>ekaitz: https://github.com/oriansj/M2-Planet/releases/tag/Release_1.12.0
<stikonas>just need to do combined stage0-posix release...
<ekaitz>great
<stikonas>and send emails
<stikonas>but you can start testing
<stikonas>there is tarball in that link
<stikonas>make sure to download non-autogenerated one but uploaded one
<stikonas>(autogenerated one does not include submodules)
<ekaitz>yep
<ekaitz>guix handles that
<ekaitz>the correct path is already written
<ekaitz>hmmm segfault
<ekaitz>i need to try this a little bit better
<ekaitz>oh it was me
<ekaitz>great
<ekaitz>but this might find some issues
<ekaitz>switches segfault
<ekaitz>hmmm
<matrix_bridge><gtker> Do you have a repro example?
<ekaitz>i'm sure i just screwed up in my code hehe
<ekaitz>but i don't know how
<matrix_bridge><gtker> It shouldn't segfault, even if you pass it invalid code
<ekaitz>it's mescc what segfaults
<matrix_bridge><gtker> Ah, then I can't help you 😄
<ekaitz>don't worry
<ekaitz>i'll figure out
<ekaitz> https://paste.debian.net/1363297/ this is making mescc segfault...i'm surely being very stupid but I don't see where
<stikonas>and it worked with M2-Planet?
<stikonas>ok, uploaded stage0-posix 1.8.0 release notes / tarball too: https://github.com/oriansj/stage0-posix/releases/tag/Release_1.8.0
<ekaitz>that's great!
<stikonas>still need to email to bootstrappable builds (and perhaps reproducible builds) mailing list
<ekaitz>idk what's going on in here
<ekaitz>i'm surely just doing some stupid shit
<ekaitz>it only happens when built with M2Planet
<ekaitz>with gcc works
<stikonas>so mes->mescc built with M2-Planet works?
<stikonas>sorry doesn't work
<stikonas>but gcc->mes->mescc does work?
<ekaitz>yes
<ekaitz>maybe its just my code
<stikonas>could be bug in M2-Planet...
<ekaitz>yeah but I have another swtich taht works
<ekaitz>my fingers don't though lol
<ekaitz>stikonas: i simplified the commit
<ekaitz> https://paste.debian.net/1363315/
<ekaitz>do you see anything that is not equivalent there?
<stikonas>and this works?
<ekaitz>nope
<ekaitz>`t` is a long
<stikonas>dest->cdr_value is pointer?
<stikonas>or integer?
<stikonas>though you simplified it later...
<stikonas>perhaps try gdb?
<ekaitz>i had it simpler before but I just wanted to make everything superobvious and not touch much of what it was already there
<ekaitz>oh if I try to build it by hand it works?
<ekaitz>wtf
<ekaitz>i have to check the actual command that is running here because there's too much tooling
<ekaitz>gdb says mes is not in executable format
<ekaitz>ugh
<stikonas>strange...
<ekaitz>so i cannot gdb into it
<ekaitz>but the code segfaults
<ekaitz>and the segfault was introduced here
<ekaitz>i'm pretty sure my change keeps the same behavior but, am i missing something?
<ekaitz>maybe is there some weird case I'm not handling properly?
<ekaitz>ugh
<stikonas>ok, I've send stage0-posix release mail to bootstrappable and rb-general mailing lists
<ekaitz>:)
<ekaitz>can I make M2-Planet only assemble files?
<ekaitz>well it does only assemble, doesn't it
<ekaitz>maybe I can take a look to the output before it is compiled to `mes` binary
<matrix_bridge><gtker> ekaitz: With "--dirty-mode" it won't delete intermediate files and you can inspect them. The M1 files are the closest to assembly
<ekaitz>good!
<ekaitz>thanks
<stikonas>--dirty mode I guess is for M2-Mesoplanet
<stikonas>well, M2-Planet indeed will just assemble, it won't do anythign more
<stikonas>and that assembly will have a few comments too, so will help you understand where you are
<ekaitz>yeah
<ekaitz>i just saw
<ekaitz>i have the same function compiled with the ifs and without them
<ekaitz>but ufff i don't know x86
<stikonas>well, instructions that we use are not that different from riscv
<stikonas>but you could use riscv build too for this :D
<ekaitz>yeah...
<ekaitz>what i did is to convert my switch back to an if but with the same structure
<ekaitz>and it fails
<ekaitz>so it's me that I didn't understand the code path properly
<ekaitz>stikonas: does this make sense for you? https://paste.debian.net/1363338/
<ekaitz>it doesn't make any sense to me
<ekaitz>i just repeated the code using switches instead of the if and the values are different
<ekaitz>and taking some example
<ekaitz>SWITCH___________________________________________
<ekaitz>1011666872 1014045680 475200264 536466608 538845416 1011666872 1014045680
<ekaitz>IFS______________________________________________
<ekaitz>1011666872 1014045680 475200264 536466608 538845416 536466608 538845416
<ekaitz>the cdr value, the last one
<ekaitz>1014045680 - 538845416 = 475200264
<ekaitz>so, it's using the d value without the - dist
<ekaitz>so it's falling in the default case when it shouldn't
<ekaitz>it's falling always in the default case
<ekaitz>:(
<ekaitz>stikonas: i'd say the switch is broken
<stikonas>ekaitz: perhaps...
<stikonas>it was just developed yesterday...
<ekaitz>the other switch works, because the default is empty
<ekaitz>well, no
<ekaitz>idk why the other one works, maybe it's because this one has numbers and the other has characters
<ekaitz>idk
<stikonas>strange though
<stikonas>default was also tested here https://github.com/oriansj/M2-Planet/blob/master/test/test0031/switch.c
<ekaitz>i bet it can be reproduced as is
<ekaitz>the t value is 0,1,2...
<ekaitz>what else can it be? the switch there is so obvious...
<ekaitz>oh wait
<ekaitz>hm
<ekaitz>the only case that doesn't fall in the default is the 0 case
<ekaitz>which should fall in the default
<stikonas>well, default is implemented here https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/cc_core.c#L2821
<ekaitz>stikonas: i found the problem
<ekaitz>i replaced the constants with the actual value
<ekaitz>and now it worked
<ekaitz>so the defines are not being expanded
<ekaitz>also the enums don't work (i tried)
<stikonas>oh, I see
<stikonas>still better than nothing I guess
<stikonas>hmm, let me check, there is https://github.com/oriansj/M2-Planet/blob/master/test/test0031/switch.c#L91 in the test
<ekaitz>stikonas: got it
<ekaitz> case :TMACRO·
<ekaitz>·
<ekaitz> case :7
<ekaitz>that's how it expands
<stikonas>is TMACRO not 7?
<ekaitz>shouldn't the columns be after the number?
<ekaitz>no no, those are two cases
<ekaitz>the 7 i wrote by hand
<ekaitz>the TMACRO y just left
<ekaitz>the preprocessing should replace those shouldn't it?
<ekaitz>oh maybe not because I see some STACK_SIZE out there too
<ekaitz>in any case, why is the colon before the number?
<ekaitz>i just run -E
<stikonas>those colons are processed by M2-Planet tokenizer
<ekaitz>so the preprocessor converts C to something else?
<stikonas>well, just this thing
<stikonas>it's artifact from label treatment
<stikonas>C labels are "label:"
<stikonas>but M1 labels are ":label"
<stikonas>hence I put https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/cc_core.c#L952 back as workaround
<ekaitz>but :7 is the same as :HELLO?
<ekaitz>because the first works and the second goes to default
<stikonas>where is this :HELLO?
<stikonas>in switch.c?
<ekaitz>it's just an example
<stikonas>or your code
<stikonas>oh yeah, I think so
<stikonas>unless we missed soemthing
<ekaitz>in my code the defines don't work but the number does
<stikonas>so that if statement only works on numbers
<stikonas>so maybe that's why
<stikonas>see https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/cc_core.c#L954C3-L954C40
<stikonas>so what happens to enums then...
<ekaitz>enums don't work either
<stikonas>ok, so clearly bug in M2-Planet
<stikonas>I migth not have time to fix it until end of March though
<stikonas>maybe gtker would though
<ekaitz>with the enums el output is the same
<ekaitz>:NAME_OF_THE_ENUM
<stikonas>ekaitz: yeah, so I think what is happening
<stikonas>is for :LABEL
<stikonas>we are hitting https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/cc_core.c#L950C10-L950C35
<stikonas>but typedefs and enums are processed in the next block
<stikonas> https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/cc_core.c#L962
<ekaitz>hm and what does that do?
<stikonas>if it notices :7 it returns 7
<stikonas>but see next block deals with variables and then block after that with numbers
<stikonas>so I think that if : conditional
<stikonas>should actually just strip : and pass to the next 2 blocks (variables and numbers)
<ekaitz>hm!
<stikonas>so I think I mostly understand why it happens
<stikonas>we can release M2-Planet 1.12.1 later once this is fixed...
<ekaitz>:)
<ekaitz>i may try to fix it but I have short time blocks and it's going to be hard
<matrix_bridge><gtker> stikonas: Are you working on a patch or do you want me to open a PR?
<stikonas>well, I tried a bit of experimenting, but didn't get anything working
<stikonas>feel free to try...
<stikonas>I don't have much time today anyway
<stikonas>but I think the problem is in constant_unary_expression in the handling of :
<matrix_bridge><gtker> Is there a repro example that fails?
<stikonas>ekaitz: also note that those constant expressions (in case and in other places such as array size) don't respect operator priority
<stikonas>but this is probably an edge case
<stikonas>gtker probably even switch.c in our testsuite
<stikonas>e.g. https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/test/test0031/switch.c#L91 that you added
<matrix_bridge><gtker> Is there a failing program I can test against? As far as I can see we're using an enum in the switch.c tests
<stikonas>gtker: but it's switch(10)
<stikonas>so it never gets processed
<stikonas>but anyway, I don't have any testcase either
<stikonas>ekaitz: can you help gtker with testcase?
<matrix_bridge><gtker> stikonas: I've got one it seems.
<matrix_bridge><gtker> int test_default() {
<matrix_bridge>int a = 6;
<matrix_bridge>switch (a) {
<matrix_bridge> case SIX:
<matrix_bridge> return 0;
<matrix_bridge> default: return 1;
<matrix_bridge>}
<matrix_bridge>return 1;
<matrix_bridge>}
<matrix_bridge><gtker> Fails on current
<stikonas>that inverse : behavious is somewhat annoying :(
<stikonas>gtker: maybe it is easier to undo that?
<stikonas>and fix https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/cc_core.c#L3365 ?
<ekaitz>oh sorry guys I was going to send you one but I was busy
<ekaitz>so yeah
<ekaitz>that's consistent with what I experienced
<matrix_bridge><gtker> stikonas: Yeah, it might be. At least for case values since they aren't labels. Might be annoying since we need to add state to the tokenizer for when the previous token was "case"
<stikonas>well, I was thinking about undoing it completely
<stikonas>tokenize : separately
<stikonas>and then for labels, check if next token is :
<stikonas>instead of first char is :
<matrix_bridge><gtker> Hmm, yeah, that would also work and might be cleaner. It would probably require relatively large changes though?
<stikonas>but where else : is used?
<stikonas>just labels and case
<matrix_bridge><gtker> Yeah, true
<stikonas>and part in tokenizer is https://github.com/oriansj/M2-Planet/blob/754004e1b7d89b0f311447f1515190fff51da357/cc_reader.c#L279
<matrix_bridge><gtker> I believe I have a slightly hacky workaround for now. But it's probably a good idea to fix labels
<matrix_bridge><gtker> I'll add a few more tests and create a PR. Probably within 20 minutes
<matrix_bridge><gtker> stikonas, ekaitz: PR is up https://github.com/oriansj/M2-Planet/pull/103
<stikonas>ok, seems good for initial version
<ekaitz>yup i was thinking on doing something similar but I don't know the codebase
<ekaitz>thanks gtker!
<stikonas>ekaitz: can you test?
<ekaitz>it's not obvious to, but I'll try
<stikonas>see if this M2-Planet commit helps with you bigger case
<ekaitz>i'm trying to get the patch and all and github doesn't provide it
<ekaitz>hehe
<stikonas>I think it should
<ekaitz>oh if I add .patch to the url it gives it to me
<ekaitz>good
<stikonas> https://github.com/oriansj/M2-Planet/commit/94e2dbdcac062e2abc6a41439556dd1255363433.patch
<stikonas>yeah
<ekaitz>it doesn't segfault
<ekaitz>but let me try properly just in case
<ekaitz>yep
<ekaitz>it works
<stikonas>ok, I'll make a release tomorrow
<ekaitz>thank you!