Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Jan 19 17:59
    fare opened #659
  • Jan 14 23:42
    gambiteer commented on ca8b488
  • Jan 14 22:02
    Windows-mingw build of CI run 486454730 failed
  • Jan 14 21:37

    gambiteer on master

    Speed up implementation of SRFI… (compare)

  • Jan 12 16:17
    feeley commented #658
  • Jan 12 16:11
    jcubic commented #658
  • Jan 12 15:48
    feeley commented #658
  • Jan 12 15:30
    feeley closed #658
  • Jan 12 15:30
    feeley commented #658
  • Jan 12 14:10
    jcubic opened #658
  • Jan 09 18:35
    feeley closed #657
  • Jan 09 18:35
    feeley commented #657
  • Jan 09 15:28
    jcubic opened #657
  • Jan 09 14:42
    Windows-mingw build of CI run 474136150 failed
  • Jan 09 14:15

    feeley on master

    Universal backend: add URL whit… (compare)

  • Jan 08 21:28
    feeley commented #655
  • Jan 08 20:48
    lassik commented #655
  • Jan 08 08:00
    jcubic commented #655
  • Jan 08 07:59
    jcubic commented #655
  • Jan 08 02:00
    Windows-mingw build of CI run 470488801 failed
Riley Levy
To build a gambit program with emscripten, how do I get an emscripten version of libgambit.a?
Marc Feeley
@junkerjoe you can also use the following trick... if your source program contains a shebang line gsc will read the runtime options on the shebang line and embed them in the executable. This is convenient if you program starts off as an interpreted script that is compiled when ready for production. For example :
% cat limited.scm
#! /usr/bin/env gsi -:max-heap=100M
(##gc-report-set! #t)
(define (go)
  (let loop ((size 1000000) (last #f))
    (println size)
    (loop (* size 2) (make-vector size))))
(with-exception-catcher pp go)
% chmod +x limited.scm
% ./limited.scm
*** GC: 135us, 130K alloc, 12M heap, 84K live (1% 84288+1488)
*** GC: 2.4ms, 135K alloc, 52M heap, 23M live (44% 85168+24001584)
*** GC: 5.1ms, 139K alloc, 101M heap, 46M live (46% 85168+48001584)
*** GC: 9.3ms, 143K alloc, 105M heap, 92M live (88% 85168+96001584)
*** GC: 17ms, 147K alloc, 108M heap, 61M live (57% 85168+64001536)
#<heap-overflow-exception #2>
% gsc -exe limited.scm
% ./limited
*** GC: 109us, 71K alloc, 12M heap, 64K live (1% 64464+1488)
*** GC: 525us, 75K alloc, 36M heap, 15M live (42% 64928+16001536)
*** GC: 260us, 79K alloc, 69M heap, 31M live (45% 64928+32001536)
*** GC: 1.9ms, 82K alloc, 108M heap, 61M live (57% 64928+64001536)
*** GC: 3.4ms, 86K alloc, 12M heap, 65K live (1% 64928+1488)
#<heap-overflow-exception #2>
@rileylevy95_gitlab Please check the file misc/build-gambit-emscripten.tgz... it is quite likely that it has suffered from bitrot, but it shouldn't be too hard to get it working again. This biggest problem is probably the evolution of emscripten, so doing a checkout of an old version of emscripten may be needed if you just want to quickly experiment with this.
Riley Levy
Thank you
Ideally, would i run that script instead of ./configure?
That is really useful. Thanks @feeley
luca regini
Hi @feeley , how do you debug the gambit compiler? Do you run it completely in the interpreter? Do you start with the binary and then load in the interpreter what you'd like to debug?
luca regini
By "debugging" I really intended single-stepping in the source of the compiler. What's the most convenient way to do that?
Bradley Lucier
Try gsc/igsc.scm.
9 replies
François-René Rideau
In a clean git checkout of master, if I try to git checkout v4.9.3, I get an error about "local changes" to some files. My workaround was to use git worktree add v4.9.3 v4.9.3.
is it OK if the makefile tries to build some modules that fail with errors on some targets?
François-René Rideau
looks like gambit has been trying to compile _digest for riscv-64 at 100% cpu for 40 minutes.
Jaime Fournier
local changes happens I found when you are using a modified tree. git clean -xfd always fixed it for me. as per @belmarca advice
luca regini
How to specify additional include directories in gsi?
luca regini
(load "/home/lucar/gambit/gsc/igsc.scm")
  • ERROR -- Can't open file "/home/lucar/gambit-stage/usr/local/Gambit/lib/header.scm"
luca regini
@drewc I saw that section, which is the right option? I see only The ‘=DIRECTORY’ option overrides the setting of the central installation directory.
The ‘~~DIR=DIRECTORY’ option overrides the setting of the DIR installation directory.
These options are not what I am looking for
I need to add paths, not to ovveride the installation directory
Drew Crampsie
If you (or the code) is using "~~" as a prefix to the libs, is that not by its very nature an installed gambit library?
(eval '(begin
        (##namespace ("c#"))
        (##include "~~/lib/header.scm")))
Bradley Lucier

This seems to work

heine:~/programs/gambit/gambit> gsi -:=. gsc/igsc.scm 
loading "~~/gsc/_host.scm"
loading "~~/gsc/_utils.scm"
loading "~~/gsc/_source.scm"
loading "~~/gsc/_parms.scm"
loading "~~/gsc/_env.scm"
loading "~~/gsc/_ptree1.scm"
loading "~~/gsc/_ptree2.scm"
loading "~~/gsc/_gvm.scm"
loading "~~/gsc/_back.scm"
loading "~~/gsc/_front.scm"
loading "~~/gsc/_prims.scm"
loading "~~/gsc/_assert.scm"
loading "~~/gsc/_asm.scm"
loading "~~/gsc/_x86.scm"
loading "~~/gsc/_arm.scm"
loading "~~/gsc/_riscv.scm"
loading "~~/gsc/_codegen.scm"
loading "~~/gsc/_t-univ-1.scm"
loading "~~/gsc/_t-univ-2.scm"
loading "~~/gsc/_t-univ-3.scm"
loading "~~/gsc/_t-univ-4.scm"
loading "~~/gsc/_t-cpu-abstract-machine.scm"
loading "~~/gsc/_t-cpu-primitives.scm"
loading "~~/gsc/_t-cpu-object-desc.scm"
loading "~~/gsc/_t-cpu-utils.scm"
loading "~~/gsc/_t-cpu-backend-x86.scm"
loading "~~/gsc/_t-cpu-backend-arm.scm"
loading "~~/gsc/_t-cpu-backend-riscv.scm"
loading "~~/gsc/_t-cpu.scm"
loading "~~/gsc/_t-c-1.scm"
loading "~~/gsc/_t-c-3.scm"
loading "~~/gsc/_t-c-2.scm"
loading "~~/gsc/_gsclib.scm"
loading "~~/gsc/_gsc.scm"
loading "~~/gsc/_gscdebug.scm"
Gambit v4.9.3-1234-g6acd87df

>  (compile-file "c.scm")

This is in the Gambit source directory after a build.

luca regini
thanks @gambiteer this works also for me.
Bradley Lucier
I'm curious: What will you do with the interpreted compiler?
luca regini
I want to study the compiler internals and document them as far as I can. This is something that I wanted to do for quite some time. Being able to step into the code helps considerably.
Bradley Lucier
Guillaume Cartier
I have built Gambit on Windows 10 using mingw-w64 using the Mingw-builds installer and choosing architecture: x86_64, threads: posix, exception: seh (mimicking the configuration used by Marc in Gambit’s appveyor.yml) and all seems to work but I get quite frequent access violation crashes that all point to longjmp. Any idea anyone? Any trail would be helpful I have no idea where to go
Guillaume Cartier
Addendum: I just saw the commit: "Use gcc __builtin_setjmp when available” on Jun 13 2020 that seems to be exactly the fix for the crashes I encounter. I will try and build using the latest Gambit and see if it fixes my crashes. Will report the results :)
François-René Rideau
:hamster: Gerbil Scheme
♞ Gambit Scheme
Guillaume Cartier
With the commit "Use gcc __builtin_setjmp when available” I now have both the Mac and Windows crashing. I ended up fixing the crashes by building Gambit with —enable-cpluscplus
Erkin B Altunbaş
Can you update the README file in the repo with the latest supported SRFIs?
Right now Gambit column on the SRFI support table is incomplete because it relies on files in libs/srfi instead, which aren't present in the last tagged version.
It would be much easier to parse README for both head and tagged versions.
Erkin B Altunbaş
I manually added details for Gambit for the time being.
Marc Feeley

@erkin The SRFIs that are builtin are in the list returned by the R7RS procedurefeatures:


Gambit has some additional SRFIs implemented as modules that can be imported with import:

(import (srfi 28))  ;; Basic Format Strings
(import (srfi 41))  ;; Streams.
(import (srfi 64))  ;; A Scheme API for test suites
(import (srfi 69))  ;; Basic hash tables
(import (srfi 132)) ;; Sort Libraries
(import (srfi 158)) ;; Generators and Accumulators

I’ll look into how best to add that information to Gambit’s README.

Erkin B Altunbaş
Currently, the scraper misses 16, 30 and 88.
James Baker
Did anyone decipher why Gambit is producing erratic segfaults while doing a make modules? Seems to compile without issue using clang 10.0.1 albeit painfully slow but failing via gcc 8.3.0
Bradley Lucier
Is it true in all Gambit back-ends that a valid vector index is a fixnum?
Marc Feeley
@gambiteer yes
Vincent Toups
Gambit on Arch comes with a bunch of gambcomp-* scripts. Are they documented anywhere? Are these official ways to use the compiler?
I'm pretty interested in trying out the javascript compiler but I have had trouble finding docs
Drew Crampsie
But, as for "docs", -target js is all that's really needed
@VincentToups look into https://github.com/pre-srfi/webui/
The documentation is not up-to-date
Bradley Lucier

I have a question about style: I'm trying to use case-lambda and error checking in a reasonable way, and I came up with

(define vector->array
  (let ()
    (define (five-args vec interval storage-class mutable? safe?)
      (if (not (boolean? safe?))
          (error "raw-vector->array: The fifth argument is not a boolean: "
                 vec interval storage-class mutable? safe?)
          (four-args vec interval storage-class mutable? safe?)))
    (define (four-args vec interval storage-class mutable? safe?)
      (if (not (boolean? mutable?))
          (error "raw-vector->array: The fourth argument is not a boolean: "
                 vec interval storage-class mutable?)
          (three-args vec interval storage-class mutable? safe?)))
    (define (three-args vec interval storage-class mutable? safe?)
      (if (not (storage-class? storage-class))
          (error "raw-vector->array: The third argument is not a storage-class: "
                 vec interval storage-class)
          (two-args vec interval storage-class mutable? safe?)))
    (define (two-args vec interval storage-class mutable? safe?)
      (if (not (interval? interval))
          (error "raw-vector->array: The second argument is not an interval: "
                 vec interval)
          (let ((indexer (%%interval->basic-indexer interval))
                (body-length (storage-class-length storage-class))
                (body? (storage-class-body? storage-class)))
            (cond ((not (body? vec))
                   (error "raw-vector->array: The first argument is not suitable for a body of the given storage-class: "
                          vec interval storage-class))
                  ((not (= (body-length vec) (interval-volume interval)))
                   (error "vector->array: The length of the first argument is not equal to the volume of the second: "
                          vec interval))
                   (%%finish-specialized-array interval
     ((vec interval)
      (two-args vec interval generic-storage-class (specialized-array-default-mutable?) (specialized-array-default-safe?)))
     ((vec interval storage-class)
      (three-args vec interval storage-class (specialized-array-default-mutable?) (specialized-array-default-safe?)))
     ((vec interval storage-class mutable?)
      (four-args vec interval storage-class mutable? (specialized-array-default-safe?)))
     ((vec interval storage-class mutable? safe?)
      (five-args vec interval storage-class mutable? safe?)))))

Is this reasonable? What do others do?