IRC channel logs

2021-01-31.log

back to list of logs

<pder>I guess I am still not clear how guix manages to get to gcc just using mes-libc?
<pder>is it due to gash and other utilities written in scheme?
<fossy>stikonas: I'll make a roadmap issue today I guess
<stikonas>pder: yes, and some shortcuts too...
<stikonas>I guess gash has some utils to help with configure scripts that we are struggling
<stikonas>basically guix goes directly to binutils and gcc from where we are...
<stikonas>pder: here https://guix.gnu.org/manual/en/html_node/Reduced-Binary-Seed-Bootstrap.html we have everything except for gash binutils and gcc
<stikonas>and we actually have more stuff...
<stikonas>coreutils actually has regex.c and regex.h which flex needs
<stikonas>maybe we can use that somehow
<stikonas>although, regex on its own is not enough...
<stikonas>guix even builds coreutils after gcc and glibc...
<stikonas>but at least we seem to be reproducible for now
<stikonas>bash hash matches between two runs
<pder>I havent tried it yet, but I am curious if our tcc version can build later versions of tcc.
<pder>It would be interesting to try using musl, but personally I think it would be better in the long run to add missing things to mes-libc and fix any bugs there, since its important to have that solid before building another toolchain
<rain1>it's a good question
<rain1>what about a meta bug tracker for bootstrapping in general to post and stay updated on questions like that?
<stikonas>pder: we have latest tcc
<stikonas>latest released...
<stikonas>but yeah, either we need to expand mes libc or get musl
<pder>True, but I think someone added musl support to a later version than 0.9.27
<pder>I might be mistaken
<pder>Actually the first commit related to musl I see is release_0_9_26-1030-g0ac29b53
<pder>Has uclibc been considered?
<stikonas>pder: I briefly looked at it
<stikonas>and dietlibc
<stikonas>not too much luck
<stikonas>musl seems the easiest
<stikonas>(or if that doesn't work, then maybe extending mes-libc)
<stikonas>in the very worse case, it might be possible to write makefile for gcc...
<stikonas>(and binutils and glibc)
<stikonas>but I would rather avoid that
<stikonas>musl probably got a bit easier now that we have bash and coreutils...
<stikonas>so we don't need to write our own build system
<stikonas>but there were still tcc problems when compiling musl
<xentrac>I may have missed messages intended for me :(
<fossy>i don't think you did
<xentrac>that's good!
<stikonas>oh, I also missed yes from coreutils
<stikonas>and it builds very easily
<fossy>i love yes
<stikonas>well, I think we need it for configure
<stikonas>anyway PR here https://github.com/fosslinux/live-bootstrap/pull/25
<stikonas>it's just literally adding it to COREUTILS in makefile
<fossy><3 makefiles :D
<stikonas>argh, I think yes was the missing piece for manu configure scripts
<fossy>really? like what?
<stikonas>so that's good now :)
<xentrac>makefiles are pretty nice
<fossy>ooh can we build musl now
<fossy>because configure handwritten, no?
<stikonas>fossy: we can try
<stikonas>yes, configure is handwritten
<stikonas>but there are some problems last I checked (with busybox)
<fossy>hooray the first piece of software that we can use a real buiild system for
<stikonas>tcc -ar is a bit broken
<fossy>or at least attempt
<fossy>yes
<stikonas>so we need to workaround that
<stikonas>and there are some problems with some assembly files
<fossy>the too many files issue?
<stikonas>yeah
<fossy>stikonas: oh, i know what that is
<stikonas>but do you have fix?
<stikonas>or workaround?
<fossy>the assembly thing is that tinycc (our one at least) dosen't have hex numbers
<fossy>all hex numbers have to be converted to decimal in assembly
<stikonas>well, maybe...
<stikonas>you can try to look at those problems I had...
<fossy>that's at least one issue, i ran into it with linux
<stikonas>maybe together we can wrestle it...
<fossy>yeah sure
<stikonas>also there was static keyword issue
<fossy>also, what do you think about removing sources/ directory and downloading directly to tmp/?
<deesix>"""xentrac did an amazing job with stone-knife FORTH but eventually opcodes still has to show up eventually.""" That was the msg with you nick.
<stikonas>we can either patch source or get tcc snapshot...
<fossy>it would mean that it would have to redownload each time tho
<stikonas>fossy: a bit cheating, but I finally managed to use configure...
<stikonas>on tar
<fossy>stikonas: i am still not a fan of mob
<stikonas>yeah, we'll see, it's not too hard to patch statics out of source
<stikonas>there is a dozen or so...
<fossy>i swear tcc supports static
<fossy>does it noT?
<stikonas>maybe not when it's used so strangely
<fossy>ohhh
<fossy>i remember now, the weird syntax
<stikonas>it's not complaining about everything
<stikonas>it was inside array index
<fossy>yeah
<stikonas>[static something]
<fossy>patch that out imo
<stikonas>do we want to rebuild tar with makefile and getdata that we patched out? Or not worth it?
<stikonas>it wouldn't really give us any benefits...
<stikonas>but yacc is able to deal with tar's getdata.y
<fossy>what kind of data?
<stikonas>sorry date
<stikonas>not data
<fossy>oh, getdata the file LOL
<stikonas>yeah, getdate.y -> getdate.{c,h}
<fossy>um, i don't really mind. i don't think it provides much of a benefit
<fossy>hm, it might be worth for configure scripts though
<fossy>i know autotools configure scripts are datesensitive
<stikonas>files have dates
<fossy>but i think it's just it has to be newer than a file in the tarball (and i think all our files are unix time 0)
<stikonas>so I'm not too sure what's not working
<stikonas>yeah...
<stikonas>so far we have no time
<stikonas>which is good for reproducibility
<fossy>yeah, everything is at Jan 1 1970
<stikonas>well, I check bash between 2 runs was identical
<fossy>well if we extract the time, that's still reproducible
<fossy>that's good
<stikonas>by the way, we used some proper build system for something
<stikonas>I think bzip2
<stikonas>but it's a simple package
<fossy>oh yeah it was bzip2
<fossy>bc it has just a file
<Hagfish> https://fsharpforfunandprofit.com/posts/cyclic-dependencies/ not about bootstrapping specifically, but makes some relevant points
<Hagfish>in the Hacker News comments, someone even talks about bootstrapping gcc
<Hagfish> https://news.ycombinator.com/item?id=25971245
<OriansJ>I love the create a C compiler in assembly line, like they don't even realize that we have already done that to bootstrap M2-Planet
<xentrac>the orange website is invariably full of highly-voted fools; you don't get highly-voted comments by waiting until after you've read through an entire article to post a comment about it
<siraben>upvoted that mes comment :D
***mephista is now known as spicy_icecream
<gforce_d11977>fossy: can you maybe use 'mkimage' from uboot to convert your vmlinux to bzimage?
<fossy>gforce_d11977: thanks for the pointer, i will def take a look
<fossy>i am seeing that kexec can take an elf. but the elf dosen't work
<fossy>in kexec
<fossy>so i might have better luck with bzimage
<gforce_d11977>fossy: at least it's worth a try for fast conversion and if it succeeds, the tool is maybe not too hard to compile
<fossy>gforce_d11977: for sure
<fossy>gforce_d11977: are you use it makes it into a bzimage https://linux.die.net/man/1/mkimage
<fossy>it dosen't seem to make it into a bzimage, rahter a "u-boot image"
<gforce_d11977>fossy: you are right. i just read: https://unix.stackexchange.com/questions/197225/is-vmlinuz-and-bzimage-really-the-same
<gforce_d11977>and https://github.com/torvalds/linux/blob/master/arch/x86/boot/compressed/Makefile
<gforce_d11977>and https://www.kernel.org/doc/Documentation/x86/boot.rst
<gforce_d11977>so you dont need any compression, but a bootable kernel (e.g. bootsect.o + setup.o + misc.o + piggy.o)
<gforce_d11977>but maybe tis is not true for kexec, I must further
<gforce_d11977>fossy: have you tried to build 'kexec' for userspace with the minimal toolset what live-bootstrap provides for now?
<bauen1>pder: i'm using a stripped down version of musl with tinycc, but i've choosen some commit from mob, iirc because some minor features where added that made my life easier
<bauen1>but i can't remember if it was just related to the kernel or also musl
<bauen1>in any case building musl with tinycc is doable, but requires some adjusting due to unknown assembly opcodes
<bauen1>and a few other things
<bauen1>actually i may have some patched musl code lying around for building most of the library for linux-x86_64, let me check
<bauen1>weird, something keeps setting +x on musls libc, breaking my ci
<bauen1>of course it doesn't happen locally, because that would be too boring
<gforce_d11977>bauen1: 8-)))
<bauen1>looking at what tinycc commit i'm using for myunix fb1fb8219ccf4813d63edf8c40fddc756e0c60cc, there is:
<bauen1>2f94390 musl: disable boundcheck tests
<bauen1>245f6a0 stdarg: always have the __builtin_va_* available
<bauen1>8c6143d Fix stdarg on x86-64
<bauen1>those three commits are probably important for building musl
<bauen1>iirc with older versions there are some problems with double defines, and redefinitions with different values
<fossy>gforce_d11977: not yet
<fossy>but its a pretty simple package
<fossy>gforce_d11977: i did extract the vmlinux from your very useful chroot mode and then try to kexec it on anther system
<fossy>however that failed
***mephista is now known as spicy_icecream
<fossy>due to word size alignment
<stikonas[m]>bauen1: I might try that
<stikonas>fossy: oh you now downloading directly into tmp?
<stikonas>if some upstream mirror is gone, we might not have any copy of tarballs
<stikonas>even locally in that case
<stikonas>maybe it's better to download into .gitignored files in sysa/*/src?
<stikonas>bauen1: which musl version were you using?
<bauen1>stikonas: my myunix fork is based of v1.2.1
<bauen1>so of commit 73cc775bee53300c7cf759f37580220b18ac13d3
<stikonas>ok, thanks, I'll try to build tcc first
<stikonas>although, I think that commit is too new for mes libc
<stikonas>maybe will have to backport
<stikonas>I think we can build up to something in 2019
<stikonas>pder: by the way, coreutils cut is also a bit broken, some memory allocation problems
<siraben> https://gist.github.com/zeux/3ce4fcc3a43072b4315abde95319ecb6
<siraben>"How does Clang 2.7 hold up in 2021? (gist.github.com)"
<xentrac>that was depressing, siraben
<siraben>xentrac: how come?
<xentrac>so much cost, so little gain
<bauen1>isn't that not actually too bad ?
<bauen1>you (ideally) only compile once and then run the resulting object a lot more often
<xentrac>bauen1: the situation is dramatically worse than Proebsting had said, with respect to C compilers at least
<stikonas>well, you can't expect exponential increase for that long...
<pder>stikonas: I looked at cut and its a strange bug. cut seems to work fine with reading from files, but when reading from stdin is when you get the memory exhausted error
<pder>in lib/getstr.c on line 54, there is a check for !lineptr || !n || !stream. But if stream is stdin which is 0, that function will always return an error
<pder>Not sure how that code ever would normally work
<fossy>stikonas: yeah
<fossy>I think source not existing is a seperate problem
<fossy>we should address that in a separate script or smth
<fossy>or maybe a completely separate project
<fossy>stikonas: try 1.1.x series, it is very more simple iirc
<stikonas>1.1.x series of coreutils?
<fossy>musl
<stikonas>oh...
<stikonas>I was trying the one from gio repo
<fossy>oh yeah
<fossy>ok
<stikonas>by the way, I briefly tried to check tcc -ar issue...
<stikonas>I think it's not tcc problem itself
<fossy>possible...
<stikonas>probably somewhere lower in the stack there is a 1024 byte buffer
<stikonas>so we can't fit in more stuff in argv
<stikonas>but I don't know where exactly
<fossy>hmmmm
<stikonas>there are quite a few places hardcoding 1024 byte buffers
<fossy>I think you could be right...n
<fossy>tcc probably has some kind of max length constant for argv
<stikonas>either tcc
<stikonas>or somewhere in make
<stikonas>or even in mes libc
<stikonas>or maybe in multiple place
<stikonas>places
<stikonas>but in any case I think we have to go for musl...
<stikonas>:(
<stikonas>basically everything else I tried needs more libs
<stikonas>including perl
<stikonas>fossy: so the first error that I get when building musl now is "./arch/i386/syscall_arch.h:40: error: incorrect prefix"
<stikonas>(ignoring those static errors that are either patchable or newer tcc works on them)
<stikonas>that disappears with -DSYSCALL_NO_TLS but I'm not sure if we are allowed to use it...
<fossy>:/
<fossy>the question is if that macro is correct.
<stikonas>but somehow it's not triggered on two earlier macros
<stikonas>and if I comment it out, then following macros again all trigger it
<fossy>Odd
<stikonas>yeah...
<stikonas>you found gio's source code?
<stikonas>(so that line numbers are the same)
<stikonas>this commit https://gitlab.com/giomasce/musl/-/tree/58f2f63aab655c47ff998201408b3c5aa4042ea0
<stikonas>and I configure musl with CC=tcc AR="tcc -ar" RANLIB=true ./configure --host=i386 --disable-shared
<fossy>yeah I found
<fossy>stikonas: is SYSCALL_INSNS defined
<stikonas>fossy: well, it's either one or the other
<stikonas>we define it at the top of the file
<stikonas>normally it would be #define SYSCALL_INSNS "call *%gs:16"
<stikonas>and this makes tcc unhappy
<stikonas>it does compile with #define SYSCALL_INSNS "int $128"
<stikonas>but I guess it would crash later if we use int instruction
<stikonas>so tcc prints incorrect prefix in i386-asm.c if (pop->type != OP_SEG || seg_prefix)
<stikonas>I guess seg_prefix is %gs in this case so 0x65
<stikonas>so seg_prefix on its own triggers that condition
<stikonas>ok, that's not what happens
<stikonas>seg_prefix is 0 and pop->type=524544
<stikonas>and OP_SEG is I guess 1 << 8 so not equal to pop->typo
<stikonas>fossy: I'll try some other musl version
<stikonas>early 1.1.x version don't work, due to other errors, but 1.1.20 might work
<stikonas>ok, now I got src/fcntl/fcntl.c:12: warning: implicit declaration of function '__builtin_va_start'
<stikonas>probably need patch from nsb...
<stikonas>yes, that worked
<stikonas>so 1.1.20 is more promising right now
<stikonas>fossy: now I get src/fenv/i386/fenv.s:20: error: unknown opcode 'stmxcsr'
<stikonas>I guess tcc does not what stmxsr is...
<stikonas>(and I also don't know) need to go read docs...
<bauen1>stikonas: there's a few others, try running make with `--keep-going` to find most of the issues
<bauen1>might be few enough to hand assemble it
<stikonas>I think it's almost done
<stikonas>I tried that on gio's version
<stikonas>with that SYSCALL_NO_TLS...
<stikonas>so there is this fenv.s file
<stikonas>and one more that I think I knew how to fix
<stikonas>that had jecxz 1f which I replaced with cmp %ecx, 0 and je 1f
<stikonas>bauen1: fossy, so I think only those two issues, stmxcsr in fenv.s and jecxz in signal/i386/sigsetjmp.s which I think I replaced (but would be good if somebody knowing more assembly confirm that my fix is valid)
<bauen1>stikonas: did you hand-assemble them or did you replace them with equivilent instruction sequences ?
<stikonas>oh, I tried replacing with equivalent instruction sequence
<stikonas>but I only did one for now ( and it needs reviewing)
<stikonas>jecxz 1f -> cmp %ecx,0 \n je 1f
<stikonas>can I have 0 as cmp operand or does it have to be register?
<bauen1>stikonas: https://www.felixcloutier.com/x86/cmp it can be an immediate value
<bauen1>so that should probably work
<bauen1>and looks good
<stikonas>all of this if floating point code, so hopefully not too critical
<stikonas>we don't use floats much
<stikonas>argh, now I got the same error I was getting with earlier musl: src/internal/i386/syscall.s:27: error: bad expression syntax [[]
<stikonas>add $[__sysinfo-2b],%eax
<stikonas>I deleted those offending fenv.s lines for now
<stikonas>hmm, after I removed those lines, I get the same crash that I had when I initially compiled with -DSYSCALL_NO_TLS...
<stikonas>so maybe that was fine and the problem is elsewhere...
<stikonas>not much info in this backtrace though https://paste.debian.net/1183492/
<bauen1>stikonas: a_crash is a musl helper that gets called (in code) when something is wrong, so it should be easy to find where
<stikonas>well,I'm trying to find init_tls
<stikonas>that's in src/env/__init_tls.c
<stikonas>hmm /* Failure to initialize thread pointer is always fatal. */ if (__init_tp(__copy_tls(mem)) < 0)
<stikonas>and this points to assembly again https://gitlab.com/giomasce/musl/-/blob/master/src/thread/i386/__set_thread_area.s
<stikonas>hmm
<stikonas>sigh :(
<stikonas>maybe I need this https://git.musl-libc.org/cgit/musl/commit/src/thread/i386/__set_thread_area.s?id=0b0640219338b80cf47026d1970b5503414ed7f3
<stikonas>fossy: wow, I think that worked
<stikonas>oh, sorry, too early
<stikonas>wrong tcc
<stikonas>:(
<stikonas>yeah, still crashes
<stikonas>oh, actually, that fix helped, it just crashes later
<stikonas>in vsyscall..
<stikonas>fossy: bauen1: that's a bit better! https://paste.debian.net/1183495/
<bauen1>nice
<stikonas>(this is back to gio form with that extra patch https://git.musl-libc.org/cgit/musl/commit/src/thread/i386/__set_thread_area.s?id=0b0640219338b80cf47026d1970b5503414ed7f3)
<stikonas>but I cheated a bit with ar for now
<stikonas>used gnu ar from outside system
<stikonas>but I think that's understood problem
<stikonas>and
<stikonas>/after/flex/src # ./flex --version
<stikonas>flex 2.6.4
<stikonas>so I think it works!
<stikonas>that's non-trivial example
<stikonas>still quite a bit of work to automate musl...
<stikonas>fossy: should we keep musl binaries in the same prefix /after?