IRC channel logs

2021-11-23.log

back to list of logs

<oriansj>stikonas: absolutely
<oriansj>now why the heck is gcc's build of M2-Planet segfaulting on this: https://paste.debian.net/1220475/
<oriansj>Program received signal SIGSEGV, Segmentation fault
<stikonas>hmm, strace or gdb?
<oriansj>gdb just shows Program received signal SIGSEGV, Segmentation fault when I try to step into it
<oriansj>as this is the last bit before I can fully flush out the spawn functionality: https://github.com/oriansj/M2-Mesoplanet/tree/sanitycheck
<oriansj>I made a seperate branch for anyone else to look at
<oriansj>as with -E it is passing the tests
<oriansj>So it has to be in this new block
<stikonas>hmm, how do you segfault it?
<stikonas>I do get it passing on simple C files
<oriansj>I have a return 42 example program that I named foo.c with I hit the bug just doing ./bin/M2-Mesoplanet -f foo.c
<stikonas>it creates /tmp/M2-Mesoplanet-... file and exits
<stikonas>hmm, so I don't think I can reproduce it
<oriansj>it crashes before making the file for me
<oriansj>ok, so something borked on my end?
<stikonas>probably
<stikonas>glibc?
<stikonas>I am on glibc 2.33, although it's probably something simpler
<oriansj>yep fresh out of the box debian
<gbrlwck>i'm having trouble compiling lib/linux/<arch>-mes-mescc/crt1.c (strictly following live-bootstrap). is one of you able to compile that with mescc?
<gbrlwck>i get expr->register: not supported: #f (for both: riscv64 and x86)
<stikonas>gbrlwck: are you sure you set all variables?
<stikonas>including MES_PREFIX and GUILE_LOAD_PATH
<stikonas>missing/incorrectly set up env variables were the most common cause of problems with mescc for me
<gbrlwck>i add the lib paths via -L option, mescc compiles fine. i am able to run it on a simple "return 42" c program (which obviously won't work)
<gbrlwck>if you have a working mes/mescc setup it would be great if you could check whether you are able to compile crt1.c (x86)
<stikonas>which commit?
<stikonas>(I might not have time today, but I can try tomorrow)
<gbrlwck>doesn't have to be today
<gbrlwck>can be your last: c07111ff876882591bc0077b32b7303d3bf2b99e
<gbrlwck>i started building on top of that (but that's just RISC-V emission, i did not change anything within mes)
<gbrlwck>if you could paste the results in here, that'd be great :) i'll read the logs for the time i'm not online
<oriansj>hmm well the syscalls logged strace seem to indicate much earlier as the cause https://paste.debian.net/1220477/
<stikonas>so after uname call I have openat(AT_FDCWD, "/tmp/M2-Mesoplanet-FU8dtE", O_RDWR|O_CREAT|O_EXCL, 0600) = 5
<oriansj>ok, it appears to be something with my debian gcc install
<oriansj>ok, its making the tempfile and "writing to it"; however nothing is showing up in the file
<oriansj>wait rw isn't a valid mode? huh
<oriansj>I guess I'm going to have to do w+ and r+ modes in M2libc for fopen
<oriansj>so --debug flag or --no-debug flag for M2-Mesoplanet?
<oriansj>its spawning correctly (ish)
<oriansj>now to add in the logic for using the M2libc definition files and elf-headers
<oriansj>and spawing is entirely isolated into cc_spawn.c so it can be easily removed from cc-minimal.c's dependency chain
<stikonas[m]>maybe --no-debug
<stikonas[m]>by default stage0-posix builds everything with debug info
<stikonas[m]>and those binaries are small enough anyway, so debug info is not a big problem
<stikonas[m]>and it's much easier to inspect
<oriansj>I have spawn working correctly
<oriansj>commit will be up shortly
<oriansj>and up
<oriansj>as of right now ./bin/M2-Mesoplanet -f foo.c -o foo will preprocess, compile, assemble and link without issue basics correctly
<oriansj>however it just needs a little logic when dealing with #include to set a flag if stdio is used
<oriansj>here is the logic needed: https://paste.debian.net/1220512/
<oriansj>the big next step is the actual importing of code with #include with <file> using the M2LIBC_PATH
<stikonas>yes, that will make building more similar to usual compiler...
<stikonas>oriansj: maybe with spawning and no -E it shouldn't output to stdout?
<stikonas>as it will print lots of binary garbage to terminal
<oriansj>stikonas: well it was a rough solution
<stikonas>but it does work much nicer now than before
<oriansj>a.out is the standard
<gbrlwck>M2-Mesoplanet sounds exciting!
<gbrlwck>did you compile by `make`? any other prerequesites necessary?
<stikonas>gbrlwck: right now by make, but I guess once oriansj gets #include working, we can pull it into stage0-posix
<stikonas>in principle you can compile it with M2-Planet
<stikonas>it should be mostly the same procedure
<stikonas>just slightly different set of files (e.g. no cc_core.c but there is now cc_env.c and cc_spawn.c)
<gbrlwck>i tried: `/root/M2-Planet/bin/M2-Planet --architecture riscv64 -f M2libc/bootstrappable.c -f cc_reader.c -f cc_core.c -f cc_macro.c -f cc_env.c -f cc_spawn.c -f cc.c -f cc.h -f cc_globals.c -f gcc_req.h --debug -o bin/M2-Mesoplanet` but this gives "Unterminated string"
<gbrlwck>weird. `make` did not work before (not sure why) but typing make now did the trick
<gbrlwck>ok, cool
<gbrlwck>this is nice!
<stikonas[m]>gbrlwck: try to see which file
<stikonas[m]>It might be some comment that trips tokenizer
<stikonas[m]>Remove some files from -f
<stikonas[m]>And see if error message changes
<gbrlwck>not sure what happened, but it seems to work now :)
<stikonas[m]>Building with M2-Planet?
<stikonas[m]>OK, if that works then it's good
<gbrlwck>ah, no, building with gcc
<gbrlwck>oriansj: https://github.com/oriansj/M2-Mesoplanet/pull/1
<gbrlwck>i did a small PR for updating the README and --help (listing all possible options)
<gbrlwck>ok, i found the error
<gbrlwck>"doesn't" in the // comment in gcc_req.h on line 18 triggers the unterminated string..
<gbrlwck>now i get "unknown type FILE".. is it possible this is not defined in M2libc/bootstrappable.c but only M2libc/stdio.c ?
<stikonas>gbrlwck: replace it with /* doesn't */
<stikonas>oh actually no
<stikonas>remove gcc_req.h from your M2-Planet command line
<stikonas>it's for gcc
<gbrlwck>s/doesn't/does not/
<gbrlwck>works ;)
<gbrlwck>should i open a github issue?
<stikonas>well, that too but in any case your shouldn't include that file
<stikonas>well, I know about that issue
<stikonas>it's because // comments are stripped later (after tokenizer runs)
<stikonas>so not completely trivial
<stikonas>and the reason for removing // comments later is that in bootstrap mode they are not comments
<stikonas>cc_* compilers use // CONSTANT instead of #define
<stikonas>and # is a comment
<gbrlwck>i see
<stikonas>gbrlwck: but yes, you'll need stdio.c
<stikonas>and other headers like ../M2libc/amd64/Linux/unistd.h
<stikonas>see stage0-posix for how to build
<stikonas> https://github.com/oriansj/stage0-posix/blob/master/AMD64/mescc-tools-full-kaem.kaem#L95
<stikonas>it's possible to build it in M2-Planet --bootstrap-mode too (test1000 does that to check some of the cc_* compatibility) but we can just do proper build
<gbrlwck>i get "unknown type const" ?
<stikonas>gbrlwck: what command line are you running?
<stikonas>I can try
<stikonas>but M2-Planet should know const...
<gbrlwck> https://termbin.com/35ol
<stikonas>I think it doesn't enforce it but should compile
<gbrlwck>maybe i should update my M2-Planet
<gbrlwck>updated, but didn't help :)
<stikonas>yes, you should update
<stikonas>I get ./M2libc/stddef.h:18:newline expected at end of macro directive
<stikonas>Mesoplanet does not assume cc_* compatibility
<stikonas>and we started using some of the new features like i += 1;
<stikonas>const looks like new addition by oriansj
<stikonas>we have to add it to unlink because that's what POSIX requires
<stikonas>but M2-Planet chokes up on it
<stikonas>Usually we have char* const
<stikonas>so perhaps that's what we need to do with unlink too
<gbrlwck>"Unkown type filename"
<stikonas>that's because you need char const* filename
<stikonas>M2-Planet --architecture $ARCH -f ./M2libc/sys/types.h -f ./M2libc/stddef.h -f ./M2libc/$ARCH/Linux/unistd.h -f ./M2libc/$ARCH/Linux/fcntl.h -f M2libc/stdlib.c -f ./M2libc/stdio.c -f ./M2libc/bootstrappable.c -f M2libc/bootstrappable.c -f M2libc/string.c -f cc.h -f cc_globals.c -f cc_reader.c -f cc_core.c -f cc_macro.c -f cc_env.c -f cc_spawn.c -f cc.c --debug -o M2-Mesoplanet.M1
<stikonas>but that needs fdopen
<stikonas>you also had order of some files in -f wrong
<stikonas>header files with declarations should come first
<stikonas>so we need to add fdopen to M2libc before we can compile it
<gbrlwck>does this do more than converting the file descriptor to a FILE * (and check the mode)?