IRC channel logs

2022-01-28.log

back to list of logs

<system>hi! i think this channel is more appropriate for talking about my effort to bootstrap the nim compiler for guix, but please correct me if i'm wrong
<system>why am i called system???
***system is now known as unmatched-paren
<unmatched-paren>that's better ;)
<unmatched-paren>so i found that the earliest nims were written in pascal, which isn't bootstrapped either :(
<unmatched-paren>but it doesn't seem impossible; i'm wondering if it would be possible to compile fpc with either gnu pascal (unmaintained) or one of the three pascal->c converters i've found...?
<unmatched-paren>sadly p2c segfaults when i try to compile anything with it...
<AwesomeAdam54321>unmatched-paren: Even though GNU Pascal isn't currently maintained, it doesn't mean it can't be used to bootstrap right?
<AwesomeAdam54321>s/bootstrap/bootstrap nim
<pabs3>AwesomeAdam54321: unmatched-paren quit before your message
***ChanServ sets mode: +o rekado_
<rekado_>I just built GHC 4.08.2
<unmatched-paren>AwesomeAdam54321: yeah, it should still be possible to use gpc
<rekado_>I never got GPC to build
<unmatched-paren>rekado_: you managed to build it entirely from source?
<rekado_>might be easier with an older GCC
<unmatched-paren>hm, p2c
<unmatched-paren>s/build it/build ghc/
<unmatched-paren>a pascal to c converter would probably be our best bet then
<rekado_>yes, I built GHC from source. I configured with “--enable-hc-boot” — the configure script says “Boot the Glasgow Haskell Compiler from intermediate .hc files.”
<rekado_>I looked at the .hc files and they like like proper source code to me.
<rekado_>doesn’t smell like autogenerated stuff
<unmatched-paren>congratulations! \o/
<rekado_>lots of comments there too
<rekado_>I don’t know … I don’t feel like celebrating yet. This was too easy.
<rekado_>Something’s gotta be wrong.
<AwesomeAdam54321>unmatched-paren: The generated C code from the converter needs to be human-readable though, or else it can't really be considered source code
<rekado_>if you run the converter as part of the build it’s fine
<rekado_>use it as a pre-processor
<unmatched-paren>p2c segfaults on this alpine proot running in termux on android, but i'll test it on my laptop when i'm able
<AwesomeAdam54321>rekado_: that makes sense, plus the converter can be audited anyways
<unmatched-paren>the one thing i'm worried about is that freepascal might be written with fp-exclusive extensions that aren't supported by p2c
<unmatched-paren>if that happens, i'll resort to just compiling nim with p2c
<unmatched-paren>but obviously taking this opportunity to bootstrap fp is preferable
<rekado_>usually it helps to build an older version first; newer versions might rely on extensions previous versions introduced.
<rekado_>I’ll try building GHC 6.0 with GHC 4 next.
<stikonas>well, building newer GHC with older should be no big deal, it's just a matter of number of intermediate steps
<civodul>rekado_: woohoo! this all sounds like exciting prospects!
<rekado_>stikonas: yes, my old notes say that I should do: 4.08.2 -> 6.0 -> 6.6 -> 6.12(?) -> 7.4 -> 7.6
<rekado_>but I’m a little … offended that I didn’t have to do anything special with hugs and interpreting parts of GHC with the compiled RTS from GHC 4 …
<rekado_>this was too easy
<stikonas>yes, sounds somehow very easy. But maybe it is
<rekado_>if it really was so easy then I wonder why nobody has done it before
<stikonas>yeah, I'm having the same thoughts
<rekado_>the only difference is that back then I didn’t have GCC 2.95
<stikonas>would be good to figure out where those .hc files are comming from
<rekado_>they are code
<stikonas>so you need old GCC?
<rekado_>a total of 4k lines with plenty of comments
<stikonas>to build this?
<rekado_>yes
<rekado_>the C code is just too pre-standard to be built with any more recent GCC
<stikonas>oh, even GCC 4 fails?
<rekado_>we had a discussion about some of the quirks here a few years back
<stikonas>still, even if GCC 2.95 has to be used, that's better than non-bootstrappable haskell
<rekado_>I haven’t tried GCC 4 — recently anyway
<rekado_>my notes don’t say if I tried it back then
<rekado_>(I also used Perl 5.14, because of $*)
***attila_lendvai_ is now known as attila_lendvai
<oriansj>rekado: now that is *HUGE* news if true.
<oriansj>when you get a chance do a write up so some more people can confirm and start looking for potential blobby bits we need to address
<oriansj>unmatched-paren: all bootstrapping discussion is welcome here. and there may be notes on bootstrapping pascal in the channel logs that might interest you
<stikonas>oriansj, rekado_: GCC 4.0.4 works just fine
<stikonas>it does build in live-bootstrap
<stikonas>which also has perl 5.32
<stikonas>oh, actually maybe not everything has built
<stikonas>but I do get
<stikonas>bash-5.1# ./ghc/driver/ghc --version
<stikonas>The Glorious Glasgow Haskell Compilation System, version 4.08.2
<rekado_>perl > 5.30 should misbehave silently
<rekado_>$* was stripped of its magic and only later was turned into an error.
<rekado_>versions since its effect has been removed and prior to turning it into an error will misbehave when multi-line regexp matches are wanted
<unmatched-paren>oriansj: actually, bootstrapping fpc is not my main goal
<unmatched-paren>oriansj: i wanted to add first-class https://nim-lang.org support to guix, but in the process i learned that their csources repo that's used for bootstrapping was actually produced by the nim compiler and thus is not source
<unmatched-paren>`git log --reverse` revealed that the first nim was written in pascal
<unmatched-paren>so here i am :)
<Hagfish>it's great to have you here!
<Hagfish>i wouldn't have guessed pascal (i don't know what i would have guessed), but having that known and documented and bootstrap would be amazing
<unmatched-paren>Hagfish: thanks! there are several pascal to c transpilers around. i'm betting on them rn...
<rekado_>stikonas: I built it again with GCC 4.9 (4.8 is broken right now, and we have no earlier minor version in Guix), and while the build seemingly succeeds there are a lot of errors.
<rekado_>oddly enough the build system does not consider these fatal
<rekado_>I’ll stick with 2.95
<rekado_>with 2.95 I get two messages about missing targets: make[3]: *** No rule to make target 'Array.o', needed by 'libHSstd.a'. Stop.
<rekado_>and: make[2]: *** No rule to make target 'utils/Argv.o', needed by 'hsc'. Stop.
<rekado_>but no hard build errors like with GCC 4.9
<stikonas>well, maybe later I can try to see if it's easily patchable, shouldn't be too hard
<stikonas>gcc 2.95 is fine in principle, but even in Guix janneke wants to move away from it
<ekaitz>btw did you guys ever found "configure: error: cannot run C compiled programs." when compiling gcc?
<ekaitz>I'm using janneke 's guix package for 4.6.4 but I'm not using TCC and I get that weird error
<ekaitz>at least it finds the libraries like it should and looks like everything compiles correctly...
<janneke>ekaitz: it could be that i never got this far, dunno
<janneke>this is a pretty old branch
<unmatched-paren>note to self: 46c41e436 is the latest nim commit that contains the pascal version
<ekaitz>janneke: might be but it looks your thing is pretty mature
<ekaitz>anyway the error code is somewhat disturbing
<ekaitz>i've been searching about it but the results were pretty wild: from missing glibc (which is not missing) to trying to compile for the wrong architecture (which I'm not doing YET)
<unmatche`>so, i can't actually get p2c to work...
***unmatche` is now known as unmatched-paren`
<unmatched-paren`>`export P2CC_CC=gcc; p2cc fpmake.pp` exits with
<unmatched-paren`>/gnu/store/2xpvvdh9ks4m4l50jb8p8rjkpq63fnpd-profile/bin/ld:fpmake.pp: file format not recognized; treating as linker script
<unmatched-paren`>it's apparently trying to pass the file to the linker??
<unmatched-paren`>raw `p2c` complains about `p2crc`, which i think is fixable by creating it, but it seems to try to use /tmp/<guix build directory for p2c>/p2c-2.01/src/p2crc, which of course doesn't exist
<unmatched-paren`>wait, doesn't that make `p2c` non-deterministic if it records the directory it was built in?
<unmatched-paren`>this program from the 90s is clearly not particularly up-to-date :)
<unmatched-paren`>i've also found `ptoc` which converts pascal to c++, but its license is unclear
<unmatched-paren`> https://www.huge-man-linux.net/man1/p2c.html describes the options, but no combination seems to work yet
<stikonas>rekado_: have you managed to solve make[3]: *** No rule to make target 'Array.o', needed by 'libHSstd.a' ?
<stikonas>those files in lib/std seem to be built from haskell sources...
<unmatched-paren`>okay, p2c will definitely not be adequate to build either nim or fpc. and by the time fpc was imported into version control it was already self-hosting...
<unmatched-paren`>this is looking kind of bad :(
<stikonas>unmatched-paren`: it's not the first time this happens...
<unmatched-paren`> https://github.com/knizhnik/ptoc but i can't find a license anywhere
<unmatched-paren`>(worth noting that this is not the official repo, just someone uploaded it to github)
<unmatched-paren`>does: PtoC is shareware and is distributed in the hope to be useful.
<unmatched-paren`>Your are free to use this converter, modify the sources
<unmatched-paren`>and do with this converter everything else you want.
<unmatched-paren`>count as `free` in the gnu sense?
<unmatched-paren`>hm, actually, p2c might work with nim at least.. probably not with fpc though
<unmatched-paren`>although the pascal nim doesn't seem to support some architectures that guix supports, it looks easy enough to patch
<unmatched-paren`>does anyone here know pascal? p2c is failing on *one* file, and i can't tell why because it has absolutely no error handling
<unmatched-paren`>aaaa nim mostly turns into c correctly but it doesn't compile >:(
<Hagfish>unmatched-paren`: i think the free software community has been caught out by that sort of licence before
<Hagfish>i think elm vs pine is the example i'm thinking of
<Hagfish>the author of elm(?) said that although the licence allowed "changing and redistributing" the source code, it didn't allow you to do both
<unmatched-paren`>and i thought this would be reasonably easy :(
<unmatched-paren`>ah
<Hagfish>which was not what people had assumed (and maybe not what a court would decide), but the free software community ended up writing their own replacement from scratch, with a saner licenec
<unmatched-paren`>but 'and' means 'both'??
<Hagfish>exactly :)
<unmatched-paren`>they should have said `xor` :)
<Hagfish>the author claimed that the *intent* was that you could only distribute unmodified changes
<Hagfish>and that if the licence didn't explicitly allow distribution of derivative works, then that right was specifically withheld
<Hagfish>or, withheld by default, under copyright law
<rekado_>stikonas_: my notes from the past: https://elephly.net/paste/1643316428.html
<rekado_>note also the IRC discussion about the weird C code in the RTS of GHC 4
<stikonas_>oh so Hugs is used?
***stikonas_ is now known as stikonas
<stikonas>anyway, even if I try, I should probably get gcc 2.95.3...
<rekado_>no, hugs is not used
<rekado_>that was the original plan
<rekado_>looks like it might not be needed after all
<rekado_>the failure to build two .o files may require revisiting this
<stikonas>yeah, that was my impression too
<stikonas>but it's very annoying to build anything in ghc 4 because make just ignores any errors...
<stikonas>so one have to scroll back to see what failed