Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:39
    CI run 3593958467 passed
  • 15:19

    feeley on master

    Add cpu cycle count to |time| s… (compare)

  • 11:57
    feeley commented on 53f03e4
  • 07:16
    CI run 3589906839 passed
  • 05:53

    gambiteer on master

    Add new macro giving minimum bi… (compare)

  • 05:35
    gambiteer commented on 53f03e4
  • 05:01
    feeley commented on 53f03e4
  • 04:06
    CI run 3588958459 passed
  • 03:34
    gambiteer commented on 6071372
  • 02:42

    gambiteer on master

    Fix exact-integer division (compare)

  • 00:47
    CI run 3587930130 passed
  • Nov 30 23:25
    gambiteer commented on 6071372
  • Nov 30 23:24

    gambiteer on master

    Fix for division on universal b… (compare)

  • Nov 30 02:38
    CI run 3579423372 passed
  • Nov 30 01:15

    feeley on master

    Add ##cpu-cycle-count primitive (compare)

  • Nov 29 11:07
    feeley commented #800
  • Nov 28 20:09
    amirouche commented #800
  • Nov 28 20:08
    amirouche commented #800
  • Nov 28 13:10
    feeley commented #800
  • Nov 28 12:01
    feeley edited #800
Ben Cornett
@cornett

If I compile the following:

(let loop ((i 0))
  (when (< i 100000000)
    (display i)
    (newline)
    (loop (+ i 1))))

and then pipe the output to head like this

 ./x | head

the pipeline appears to hang. I'm not sure what ./xis doing, since it has no place to write to, but it nevertheless consumes a lot of cpu time.

Jaime Fournier
@ober
does display add a \n?
Bradley Lucier
@gambiteer
No.
Marc-André Bélanger
@belmarca
An equivalent Python program has a different behavior
➜  flub cat foo.py
i = 0
while i < 10000:
    print(i)
    i+=1
➜  flub python3.10 foo.py | head  
0
1
2
3
4
5
6
7
8
9
Traceback (most recent call last):
  File "/tmp/flub/foo.py", line 3, in <module>
    print(i)
BrokenPipeError: [Errno 32] Broken pipe
Marc Feeley
@feeley

@cornett By default the interpreter uses stdin and stdout as the “REPL channel” to interact with the user. This can be changed with the -:dc runtime option so that the REPL channel is connected to the controlling terminal. This allows observing the error:

$ cat head.scm
(let loop ((i 0))
  (when (< i 100000000)
    (display i)
    (newline)
    (loop (+ i 1))))
$ gsi -:dc head.scm | head
0
1
2
3
4
5
6
7
8
9
*** ERROR IN ##wr-substr -- Broken pipe
(write-substring "923" 0 3 '#<output-port #2 (stdout)>)

So when the -:dc option is not used the runtime system will attempt to output this error message on the REPL channel which is stdout, but this generates a similar error that the runtime system tries to output to stdout, and an infinite error loop results.
In the past Gambit used the controlling terminal for the REPL channel, but this was changed because users found this to give surprizing behavior, in particular they expect echo "(+ 1 2) (exit)" | gsi to feed the REPL with commands, which did not work when the controlling terminal is used as the REPL channel.
If you prefer the old behavior, you could set the GAMBOPT environment variable with export GAMBOPT=dc

Note also that you can get more context for the error by adding 2 or 3 to the -:d runtime option:
$ gsi -:d2c head.scm | head
0
1
2
3
4
5
6
7
8
9
*** ERROR IN ##wr-substr -- Broken pipe
(write-substring "923" 0 3 '#<output-port #2 (stdout)>)
0  ##wr-substr             
1  ##write-generic-to-character-port 
2  ##display               
3  loop                    "head.scm"@3:5          (display i)
4  (interaction)           "head.scm"@1:1          ((letrec ((loop (lambda (...
5  ##load                  
6  ##load                  
7  ##main                  
$ gsi -:d3c head.scm | head
0
1
2
3
4
5
6
7
8
9
*** ERROR IN ##wr-substr -- Broken pipe
(write-substring "923" 0 3 '#<output-port #2 (stdout)>)
0  ##wr-substr             
1  ##write-generic-to-character-port 
2  ##display               
3  loop                    "head.scm"@3:5          (display i)
        i = 923
        loop = (lambda (i) (if (< i 100000000) (begin (display i) (newlin... #3
4  (interaction)           "head.scm"@1:1          ((letrec ((loop (lambda (...
5  ##load                  
6  ##load                  
7  ##main
Marc Feeley
@feeley
Yet another option is the -:d0 runtime option that does not output error messages, so the infinite error loop is not even entered:
$ gsi -:d0 head.scm | head
0
1
2
3
4
5
6
7
8
9
$
Ben Cornett
@cornett
@feeley Thanks Marc! That makes sense now. I also appreciate the effort you have put into the debugging facilities. Some other scheme implementations I've used leave a lot to be desired in that regard.
cs7
@cs7:matrix.org
[m]

(Repeat,) there will be a video call a bit later this year with Marc to learn more about compiler internals.

Datetime TBD. Feel free to signal interest to me and i’ll remind when it approaches.

Bob Coleman
@skilldown
@cs7:matrix.org I'm definitely interested in the call. Gambit@30 was a blast and I'd love to learn more about the compiler.
Bheesham Persaud
@bheesham

hey all. i seem to be having trouble compiling gambit (just cloned from github) on fedora 36 (GCC 12.1.1)

the output is

gcc -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -march=native -fPIC -fno-common -mpc64
    -Wno-unused -Wno-write-strings -Wdisabled-optimization -fwrapv -fno-strict-aliasing -fno-trapping-math -fno-math-errno -fschedule-insns2 -foptimize-sibling-calls -fomit-frame-pointer -march=native -fPIC -fno-common -mpc64
   -rdynamic  -I"../include"  -o gsi    _gsi.o _gsi_.o "../lib/libgambit.a"  libgambitgsi.a                                                                                                                                      
/usr/bin/ld: ../lib/libgambit.a(_num.o): in function `___H___num':                         
_num.c:(.text+0x25b73): undefined reference to `log1p'                                                          
/usr/bin/ld: _num.c:(.text+0x25c9f): undefined reference to `atan'                                              
/usr/bin/ld: _num.c:(.text+0x2652e): undefined reference to `log' 
/usr/bin/ld: _num.c:(.text+0x26df6): undefined reference to `exp'  
/usr/bin/ld: _num.c:(.text+0x26f12): undefined reference to `exp'

the configure command was:

./configure --enable-single-host --enable-march=native --enable-dynamic-clib

I can get further if I add CFLAGS="-lm" to my environment, but it just fails past that. did anyone run into this before? is there something i'm missing?

Bheesham Persaud
@bheesham

though, interestingly the docker build passes. I tried with:
./configure --enable-single-host --enable-march=native --enable-dynamic-clib && docker build -t gambit .
(again in a fresh repo)

hhmmm... I'm not too sure what's going on here

Bheesham Persaud
@bheesham
ah! so i think there's something wrong with my machine (or potentially some flags?) -- i was able to build gambit using fedora:latest (see this Dockerfile: https://gist.github.com/bheesham/13b690846017b01ad7aec1b49ef498a4)
Bheesham Persaud
@bheesham
uh, nvm, seems like asking for help fixed my problem. I ended up calling a bunch of variations of ./configure and now the original command works. :tada:
Marc Feeley
@feeley
@bheesham could you explain what worked? some other people have encountered a similar experience so it would be good to point them to a solution.
4 replies
cs7
@cs7:matrix.org
[m]
feeley (Marc Feeley): Is the Gambit wiki obsoleted?
Marc Feeley
@feeley
@cs7:matrix.org The Gambit wiki is no longer being updated and is in read-only mode (because there was too much spam). I don’t have time to police it or maintain it but if someone wants to do it then that would be OK. So the current plan is to keep it as-is for people who want to find some documentation there (and for hyperlinks to the wiki to remain valid)
cs7
@cs7:matrix.org
[m]
Aha. Uu. Wait, only email signuped users had write access wasn’t it
What about just saying after email signup also needs moderator approval?
Marc Feeley
@feeley
there was a captcha but that wasn’t foolproof…
The wiki was never very active and there were only a few contributors… if someone wants to maintain it I can give them access.
cs7
@cs7:matrix.org
[m]
Invite only wiki makes sense
Bheesham Persaud
@bheesham

may I have an invite to the wiki please? there's a quick link I want to update.

the link to the mailing list on https://gambitscheme.org/wiki/index.php?title=How_to_contribute is broken, as reported in gambit/gambit#750, similar to gambit/gambit#495 (now closed)

Marc Feeley
@feeley
I have changed the settings on the wiki so that all current users can edit pages. I’ll add new users manually so I can filter out spammers. So if you want an account please DM or email me. If there is enough interest we can un-phase-out the wiki...
Bheesham Persaud
@bheesham
thank you! :)

re: the flags used to configure gambit

I'm not entirely sure what to think about that. it seems strange that I'd need to build with --enable-dynamic-clib (or any of the variations I found to work) and then pass in all the flags I want afterwards

Steve Bigham
@vesten
Can I make a c-lambda procedure from a variadic C function?
Marc-André Bélanger
@belmarca
says no in the doc, maybe write surrogates up to N args?
Steve Bigham
@vesten
Thanks @belmarca . It's absolutely clear in the docs. I can't believe I missed that.
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
hello gambit people!
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
I am interested in bootstrapping gambit without using any prebuilt artefacts. From what I am reading gambit has pregenerated C files that can be compiled with a regular C compiler which then builds gambit and starts the bootstrap chain. Is it possible to create those C files from scratch, with an older version of gambit or something?
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
by bootstrapping I mean this: https://bootstrappable.org/
Marc-André Bélanger
@belmarca
It's turtles all the way down!
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
hey its me again ha!
Bradley Lucier
@gambiteer
Do you have a Scheme interpreter already in your system?
Marc-André Bélanger
@belmarca
they seem to make the distinction between "self hosted" and "bootstrapped", but the "bootstrapping" process is precisely that which allows the compiler to compile itself
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
I can have, such as guile
Marc-André Bélanger
@belmarca
So in essence, it's turtles all the way down - who compiles the compiler?
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
a lot of times its required to have an alternative compiler to compile the compiler
or go backwards to an earlier version of the compiler, before it was self hosted
(and then start working from version to version, very painfully :p)
Marc-André Bélanger
@belmarca
which begs the question, who compiles the alternative compiler?
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
hopefully the alternative compiler is implemented in c or c++, then you "just" need to bootstrap gcc
Marc-André Bélanger
@belmarca
That website seems to be concerned with chain of trust more than "bootstrapping" in the usual meaning of the word
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
yeah for sure. oftentimes its required to start from a binary at some point in order to be practical
but minimizing those is still useful i think!
Marc-André Bélanger
@belmarca
Spawns_Carpet
@inceptor-untraversed:matrix.org
[m]
guile also seems to bootstrap itself from a minimal C interpreter
Marc Feeley
@feeley
@inceptor-untraversed:matrix.org Gambit is a bootstraped implementation of Scheme. The system’s sources are a bunch of C files, some are written by hand (about 50,000 LOC for the garbage collector, operating system interface, etc) and most are generated by the Gambit Scheme compiler, gsc (about 1,500,000 LOC, for the implementation of the higher-level parts: thread scheduler, I/O subsystem, bignums, eval, REPL, R7RS standard procedures, and gsc itself). These 1,500,000 LOC are generated from about 120,000 lines of Scheme code. This diagram illustrates the bootstrapping process:
image.png