IRC channel logs

2025-03-13.log

back to list of logs

<matrix_bridge><gtker> oriansj: If raw bytes wrapped in '' should be used for u8s, and % for u32s what would be the correct way of outputting an array of u16s?
<matrix_bridge><Andrius Štikonas> Hmm, I guess we don't have a way that works for both normal arches and word based...
<matrix_bridge><gtker> stikonas: It's not required for the current bootstrap target (tcc_1_7) but it might become relevant at some point
<ekaitz>stikonas: m2-planet release with switch/case support?
<stikonas>ekaitz: let me check changelog
<stikonas>yeah, last release should support switch/case
<ekaitz>last is 1.11.0?
<ekaitz>that's from 2023
<matrix_bridge><Andrius Štikonas> hmm
<ekaitz>i'm looking at github
<matrix_bridge><Andrius Štikonas> I think so
<ekaitz> https://github.com/oriansj/M2-Planet
<stikonas> https://github.com/oriansj/M2-Planet/blob/0236ee4f8533258de7442246e0fba2d7b5c42fcf/cc.c#L53
<stikonas>we'll need to bump it soon
<stikonas>well, there are lots of new things in git master
<ekaitz>i'm using it, so if you bump it, please let me know!
<ekaitz>hmm looks like 1.11.0 doesn't support it because it's failing
<ekaitz>ACTION is sad
<matrix_bridge><gtker> stikonas, ekaitz: I believe https://github.com/oriansj/M2-Planet/commit/5566930976d23f0c6efeb03cf6cc19cf04cb61c1 added switch statements on Nov 10, while 1.11.0 was released on Nov 01. It seems we forgot to add switch statements to the "Current" changelog header
<ekaitz>oh ok so i need a newer version
<matrix_bridge><Andrius Štikonas> hmm, we should do a new release then...
<matrix_bridge><gtker> We don't have a release with switches, but the current master does
<stikonas>hmm, should we make one after I merge current PR?
<matrix_bridge><gtker> stikonas: I don't have anything urgent to get in before the release, so we could do one now
<stikonas>gtker: do you think it's reasonably stable now?
<matrix_bridge><gtker> Maybe update the changelog with switches?
<stikonas>yeah...
<stikonas>well, need to merge your PR too
<stikonas>and do a bit more testing...
<matrix_bridge><gtker> I can do it in my PR
<stikonas>see if live-bootstrap works at least on x86
<stikonas>ok, thanks. Please do so
<matrix_bridge><gtker> stikonas: PR updated
<stikonas>thanks
<stikonas>hmm, interesting, we did have stage0-posix release in Sep 2024
<stikonas>so that one includes new M2-Planet
<stikonas>but I guess there was no standalone release
<stikonas>gtker: do we not support size == 2?
<stikonas>oh yes, there is a comment
<ekaitz>hm! i'm trying it and it's not working
<ekaitz>is there any obvious limitation in the switch statement i'm missing?
<matrix_bridge><Andrius Štikonas> Hmm, what is your code?
<ekaitz> https://paste.debian.net/1362916/
<matrix_bridge><Andrius Štikonas> This is testcase that we have https://github.com/oriansj/M2-Planet/blob/master/test/test0031/switch.c
<ekaitz>my code is simpler than that testcase
<matrix_bridge><Andrius Štikonas> Yeah...
<matrix_bridge><Andrius Štikonas> So what is going wrong?
<matrix_bridge><Andrius Štikonas> Goes to the wrong branch?
<ekaitz>no, it fails
<ekaitz>the build
<matrix_bridge><Andrius Štikonas> Hmm
<ekaitz>but maybe it's just me fighting against the buildsystem
<matrix_bridge><Andrius Štikonas> Any useful error?
<ekaitz>not really
<ekaitz>maybe it's the mes scaffolding
<ekaitz>it's failing in kaem --strict -f kaem.run
<ekaitz>src/reader.c:460:switch is not a defined symbol
<ekaitz>hmmm
<matrix_bridge><Andrius Štikonas> Hmm
<matrix_bridge><Andrius Štikonas> And are you sure it is new m2 planet?
<ekaitz>i'm not sure if this is giving me the proper m2
<ekaitz>heh
<matrix_bridge><gtker> Isn't it because of `switch (c)
<matrix_bridge>{
<matrix_bridge>- n = reader_read_hex ();
<matrix_bridge>- c = n->value;
<matrix_bridge>- case '\\':`?
<matrix_bridge><gtker> Assignments inside the switch?
<ekaitz>isn't it legal to make assignments inside a switch?
<ekaitz>ah! haha! it's a commit body, those - lines mean the line is removed
<ekaitz>in gcc it works
<matrix_bridge><gtker> Ah yeah, nvm lol
<matrix_bridge><gtker> Can we switch on char literals?
<ekaitz>hmmm
<ekaitz>it's not working yet... and I refreshed the commit with the last one you did
<ekaitz>latest*
<ekaitz>hmmm
<ekaitz>i'm surely doing something wrong
<matrix_bridge><Andrius Štikonas> Hmm, we should sort this out before release...
<ekaitz>it's probably the guix packaging here that is wrong
<matrix_bridge><Andrius Štikonas> Your error suggests that it is switch statement itself that is unrecognised
<ekaitz>yes
<ekaitz>and i think guix is using the M2 of a previous environment and not this
<ekaitz>and i'm very upset
<ekaitz>:)
<stikonas>anyway, let us know if you figure this out
<stikonas>if we make a new release, bettter fix this
<stikonas>(if that's not a guix issue)
<ekaitz>i'm pretty sure it's guix but i don't know why
<ekaitz>do i need other mescc-tools if I change m2-planet?
<stikonas>ekaitz: probably not
<stikonas>though we had some breaking change, but it might be fine
<stikonas>well, the pointer arithmetic now works for += and -= operators
<stikonas>(but not for + or -)
<ekaitz>stikonas: scaffold/main.M1:7 :Received invalid other; xor_eax,eax
<ekaitz>but I don't have the switch issue anymore
<stikonas>oh, that's M2libc
<stikonas>I think you need newer defines
<stikonas>hmm, now how do they get added to mes
<stikonas>I guess mes keeps its own copy
<stikonas>it's these two commits: https://github.com/oriansj/M2libc/commit/52965694d58d846f94eaac3a897647c94e4959f4 https://github.com/oriansj/M2libc/commit/cbf165034fbd90b2f760185774cbcb17b8a27435
<ekaitz>oh shit
<stikonas>it's in ./lib/m2/x86/x86_defs.M1
<stikonas>should be easy to sync...
<stikonas>but yeah, that's something I forgot about
<ekaitz>just clone and overwrite
<stikonas>it's a bit annoying
<stikonas>cause any codegen changes in M2-Planet that need new defines
<stikonas>are certain to break mes bootstrap
<stikonas>well, "fix" is easy, just need to add those to mes
<stikonas>but then need to wait for a new release of mes...
<ekaitz>heh
<ekaitz>i don't know why mes doesn't get them from M2lib
<stikonas>hmm, maybe janneke can answer that...
<stikonas>well, it's fine for risc-v
<stikonas>since that list of defines is now basically complete
<ekaitz>and what are all these: DEFINE RETURN C3
<ekaitz>those are removed in M2lib
<stikonas>return opcode
<stikonas>maybe it still has ret?
<stikonas>oh, those are old style defines
<stikonas>before M2-Planet switched to newer style (more similar to GAS) defines
<stikonas>I guess those can go away soon from mes
<stikonas>especially once mes depends on newer features of M2-Planet
<ekaitz>oh
<ekaitz>i just used the new files
<ekaitz>and it didn't complain because of it
<ekaitz>src/reader.c:462:src/reader.c:462:ERROR in process_switch
<ekaitz>MISSING }
<ekaitz>Subprocess error 1
<ekaitz>ABORTING HARD
<ekaitz>but it complained about that instead
<stikonas>ok, that's the error from new M2-Planet
<stikonas>hmm, I guess MISSING } means it saw something unexpected?
<stikonas>ekaitz: that's with the same switch statement from your pastebin?
<ekaitz>yes
<ekaitz>maybe the \\?
<ekaitz> https://paste.debian.net/1362935/
<ekaitz>that's the switch
<stikonas>ekaitz: yeah, that's chars...
<stikonas>this also fails https://paste.debian.net/1362936/
<stikonas>with the same error
<stikonas>or maybe something else there
<stikonas>still checking
<stikonas>but we have a simpler reproducer
<ekaitz>hehe
<ekaitz>i have a magnet for these things
<stikonas>ekaitz: I think switch can accept char but not case
<stikonas>case seems to need int
<ekaitz>okay so if I write a number instead it should work?
<stikonas>I think so
<stikonas>you might also need to add default
<ekaitz>can we improve M2planet to support chars?
<ekaitz>does it support enums?
<stikonas>well I'm looking now
<stikonas>it seems to me that it expects only 1 token there https://github.com/oriansj/M2-Planet/blob/6341097a328b7a2cc2a0325b54fb335072fc9772/cc_core.c#L2783
<stikonas>'a' I guess are 3 tokens
<stikonas>gtker: can we used constant_expression here?
<stikonas>ekaitz: as for enums, yes, new one has support for enums
<stikonas>should be fairly good
<ekaitz>that's great
<stikonas>oh, buti not sure
<stikonas>if they work together with switch/case
<stikonas>so that might not help you...
<stikonas>we should try to fix it...
<ekaitz>yeah...that would make my work in mes way easier
<stikonas>let me open a bug...
<ekaitz>oh thanks
<stikonas> https://github.com/oriansj/M2-Planet/issues/99
<ekaitz>how hard do you think it is to add chars there?
<stikonas>should be doable I think
<stikonas>gtker might do if faster than me though
<ekaitz>hehe
<ekaitz>i tried to read the code and it doesn't look impossible
<ekaitz>but i need some concentration
<stikonas>but in the meantime I guess you could do something like case 0x61: // 'a'
<ekaitz>yep
<ekaitz>it's working with the numbers
<ekaitz>so... not bad
<stikonas>well, I have a hacky commit that goes most of the way
<stikonas>and it also breaks some stuff :(
<stikonas>needs a space between case expression and :
<stikonas> https://paste.debian.net/1362945/
<ekaitz>hm!
<ekaitz>it makes sense
<stikonas>oh, that's because of some label hacks in M2-Planet tokenizer...
<stikonas>it thinks 1: is a label
<stikonas>and converts it to :1
<ekaitz>oh no
<stikonas>oh I guess that was previously dealt with if(':' == global_token->s[0])
<stikonas>so needs more thought on how to cleanly do it...
<stikonas>well, I might not have more time today
<stikonas>but maybe gtker can take over this patch :)
<ekaitz>thanks for the time :)
<oriansj>stikonas: just a thought but $ isn't used by word based architectures yet; what if we do a little shift to give word based architectures a standard 16bit symbol (as the byte based architectures are using @0x1234)
<stikonas>$ is used
<stikonas>I think all chars are used
<stikonas>$ is used for jumps
<oriansj>yes but not in M1
<stikonas>oh, maybe not
<oriansj>all of the chars can be dual use
<oriansj>one meaning in M1 (for immediates) and one meaning in hex2 (for jumps and calls)
<stikonas>indeed, $ does not seem to be used
<stikonas>but we don't want to implement that in M0...
<oriansj>you don't have to implement it in M0
<stikonas>yeah, just need to guard this feature
<stikonas>behind maybe_bootstrap_error
<oriansj>or we just take a day or two to backport it