Giter Club home page Giter Club logo

gerbil's Introduction

Gerbil Scheme

Gerbil is an opinionated, some might even say tendentious, dialect of Scheme designed for systems programming. It provides a state of the art macro and module system on top of the Gambit runtime and compiler and an extensive standard library. One way to think of Gerbil is as the C++ to Marc Feeley's C.

The macro system is based on quote-syntax, and provides the full meta-syntactic tower with a native implementation of syntax-case. It also provides a full-blown module system, similar to PLT Scheme's (sorry, Racket's) modules. The main difference from Racket is that Gerbil modules are single instantiation, supporting high performance ahead of time compilation and compiled macros.

Installation

The source code for Gerbil is hosted on GitHub, with the latest release available in releases.

If you are on Linux installation from source is straightforward:

$ git clone [email protected]:mighty-gerbils/gerbil.git
$ cd gerbil
$ ./configure
$ make -j4
$ sudo make install

This will install Gerbil in /opt/gerbil; all you have to do then is add /opt/gerbil/bin to your path. Obviously, you can customize the install prefix by using the --prefix=/path/to/gerbil/installation configure option.

Note the default configuration has some dependencies you may need to install: sqlite, zlib, and libcrypto/openssl. You can install them in ubuntu with:

$ sudo apt install libssl-dev zlib1g-dev libsqlite3-dev

Note If you want to install the latest release (v0.18), you can also use the precompiled binary packages for Ubuntu, Debian, Fedora, and CentOS. They are available in the v0.18 release page.

If you are on MacOS you can install Gerbil using our brew formula:

$ brew install mighty-gerbils/gerbil/gerbil-scheme

For more detailed installation instructions see the Guide.

Using Gerbil

The Gerbil interpreter is gxi, and the compiler is gxc.

If you want an interactive Gerbil shell just execute the interpreter directly by running gxi.

For "hello, world" see the Guide.

Documentation

The documentation is a work in progress, but there are some resources that should get you started:

The documentation is automatically rendered online at cons.io. You can render it locally by running doc/build.sh, which will leave the html output in doc/.vuepress/dist; the script uses vuepress and requires npm to be installed.

Deep Dive

Probably the best way to dive into Gerbil is by reading the sources, as all the main language features are exercised in one way or another within the implementation.

Depending on your inclinations, there are several starting points:

  • If you are interested in general purpose programming, then you should look at the stdlib sources.
  • If you are interested in Gerbil macrology, then the place to start is the core prelude. This is the language that you get in the interpreter and what is available when writing a new module without explicitly specifying a prelude.
  • If you are interested in the Gerbil expander internals, then you should look at the expander sources.
  • If you are interested in the Gerbil compiler internals, then you should look at the compiler sources.

For questions and support, you can find us on gitter in #gerbil-scheme.

License and Copyright

Source Code

The source code is distributed with the Gambit license; that means that Gerbil on Gambit is dual licensed under LGPLv2.1 and Apache 2.0.

Gerbil's original author and primary maintainer is vyzo, aka in the Net as Dimitris Vyzovitis. The obligatory copyright notice, had I bothered and polluted everything with more than a (C) vyzo, would read like this:

© 2007-2023 Dimitris Vyzovitis and contributors
Gerbil is Free Software, distributed under the GNU LGPLv2.1 or later
and the Apache 2.0 license.

The implementations of srfi 115 and srfi 159 come from Chibi, as these are the only available reference implementations. As such, they are © Alex Shinn and distributed under a BSD-style license.

Logo

The Gerbil Scheme logo is © 2019 Brad Christensen. The logo, its variations, and derivatives found within the official Gerbil Scheme code repository are provided under a royalty-free non-exclusive license for use by any person or entity wanting to use them solely in the context of the Gerbil Scheme programming language, including for commercial use, and grants them the rights to copy, distribute, display, and create derivative works so long as those derivatives are made available under this same license.

Creators of derivatives are encouraged to offer them for inclusion to the official code or associated Gerbil Scheme repository, where upon acceptance they will be easier to find and use (for example in documentation and acticles) by the community at large. Furthermore, a derivative's terms of use will be made available by the statements here.

This license in no way guarantees the availability of the logo, or any of its variations or derivitives in the future.

Epilogue

Gerbil had been vyzo's private Scheme for many years, evolved out of a set of common macros that were used across different implementations and eventually a full-blown PLT macro language for actor oriented distributed programming. As such, there have been multiple backends that supported the evolution of the Gerbil dialect, but vyzo elected to base the canonical version of Gerbil on Gambit because it is the most portable, performant and low-level Scheme kernel available.

At the prompting of some friends (they know who they are), who had seen private versions of Gerbil, vyzo decided to release it in public with a clean source-based bootstrap version that bootstraps on gambit with a precompiled version of the macro system and compiler. That means that the system could be (and now is) entirely self-hosted.

Gerbil is under continuous use and development. The core language has been stable for a while, but we are busy porting batteries, adding features, fixing bugs, and expanding the scope of syntactic abstraction.

Patches (even for typos in the comments) are always welcome. No copyright assignment ever, you keep what you contribute.

gerbil's People

Contributors

00vareladavid avatar alex-segura avatar alexknauth avatar belmarca avatar caribpa avatar chiefnoah avatar cynicalasshole avatar dependabot[bot] avatar dlozeve avatar drewc avatar edita-timo avatar edw avatar eraserhd avatar fare avatar jsulmont avatar jxy avatar khepin avatar lassik avatar leahneukirchen avatar michalmaruska avatar ober avatar paradiesstaub avatar patternspandemic avatar proksi21 avatar shakdwipeea avatar vyzo avatar wime12 avatar woxtu avatar wsxiaoys avatar zmyrgel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gerbil's Issues

libcrypto ffi compilation issues with openssl-1.1.x

Hello!
This happened with openssl-1.1.0e.
Changing ffi_DH_pub_key to:

static BIGNUM *ffi_DH_pub_key (DH *dh)
{
BIGNUM const *pub;
DH_get0_key( dh, &pub, NULL );
return pub;
}

seems to work for me, though. Sorry, no PR.

GambitC executable path

Is it possible to use a different name for the GambitC executable? Under Arch Linux, gsc is GhostScript, what is normally gsc is /usr/bin/gambitc or /usr/bin/gsc-script.

gxprof fails linking due to missing libieee

Building the arch linux package gerbil-scheme-git fails with the following error:

.
.
.
[*] Building gerbil tools
... compile gxprof
... compile exe gxprof -> gxprof
/usr/bin/ld: cannot find -lieee
collect2: error: ld returned 1 exit status
*** ERROR IN ##main -- target link failed while linking "/tmp/gerbil-scheme-git/src/gerbil-build/bin/gxprof_.o" "/tmp/gerbil-scheme-git/src/gerbil-build/bin/gxprof.o"
*** ERROR IN gxc#compile-exe-stub-module -- Syntax Error
*** ERROR IN ?
--- Syntax Error at compile: Compilation error; gsc exit with nonzero status
... form:   "/tmp/gerbil-scheme-git/src/gerbil-build/bin/gxprof.scm"
... detail: "/tmp/gerbil-scheme-git/src/gerbil-build/bin/gxprof"
... detail: 17920
*** ERROR; build failed

I don't have any libieee, and a bit of searching tells me I shouldn't have one, it is supposed to be a part of glibc. I cannot find any reference to it, so maybe autotools automatically adds it?
Does anyone know of a way to fix this?

HTTPS requests ERROR on OpenBSD

I'm not sure if this is bug or not but making HTTPS requests fail on OpenBSD.

 $ ./gxi
Gerbil v0.14-DEV-9-gace2d884 on Gambit v4.9.0
> (import :std/net/request)
> (http-get "http://www.google.fi")
#<request #7>
> (http-get "https://www.google.fi")
*** ERROR IN ##force-undetermined -- Unimplemented operation
(make-tls-context)
1>

As shown above, plain HTTP request works but errors out if URL is using https.
Did I do something wrong or is it another LibreSSL vs. OpenSSL issue?

split-request-url fails with non-urlencoded urls in path

https://github.com/vyzo/gerbil/blob/95b65c1e89ca87a67b37b9483de5653e87c42c10/src/std/net/httpd/handler.ss#L329

> (split-request-url "https://my-site.com/https://github.com/author/package-name")
*** ERROR IN (console)@23.1 -- http-read-request: [io-error] invalid url
--- irritants: /https://github.com/author/package-name
> (split-request-url "https://my-site.com/?url=https://github.com/author/package-name")
*** ERROR IN (console)@25.1 -- http-read-request: [io-error] invalid url
--- irritants: /?url=https://github.com/author/package-name

Urlencoded works fine.

gsc is Ghostscript, not Gambit, in Archlinux

In Archlinux, the Gambit package has the "gambitc" binary instead of the "gsc" binary.
This is done to prevent a name clash with ghostscript.
build.sh fails as a result of this.

stdlib fails to build on OpenBSD

Just tried to build the gerbil from github checkout but build fails when going through the stdlib build:

tmy@phobos src $ ./build.sh stdlib                      
[*] Building gerbil stdlib
... generate stdlib depgraph
... compile foreign os/_socket
../../../src/std/os/_socket.c:2703:12: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
 if (salen < 0)
     ~~~~~ ^ ~
../../../src/std/os/_socket.c:2845:24: error: variable has incomplete type 'struct ip_mreq_source'
 struct ip_mreq_source mreq;
                       ^
../../../src/std/os/_socket.c:2845:9: note: forward declaration of 'struct ip_mreq_source'
 struct ip_mreq_source mreq;
        ^
../../../src/std/os/_socket.c:2846:19: error: invalid application of 'sizeof' to an incomplete type 'struct ip_mreq_source'
 socklen_t olen = sizeof (struct ip_mreq_source);
                  ^      ~~~~~~~~~~~~~~~~~~~~~~~
../../../src/std/os/_socket.c:2845:9: note: forward declaration of 'struct ip_mreq_source'
 struct ip_mreq_source mreq;
        ^
1 warning and 2 errors generated.
*** ERROR IN ##main -- target compilation or link failed while compiling "/home/tmy/git/gerbil/src/std/os/_socket.scm"
*** ERROR IN std/make#gsc-compile, "make.ss"@386.7 -- Compilation error; gsc exited with nonzero status 17920
*** ERROR; build failed

Documentation: Gerbil / Gambit interop

As I am reporting issues: Gerbil is built on top of Gambit but there seems to be no prominent info about the interoperation. In particular: is it possible, and if so how, to use Gambit packages with Gerbil? Are Gambit packages (Snow, Black Hole, Spheres) provided/accessible as Gerbil modules?
Thank you,
Ulf

OpenBSD 6.3-CURRENT (amd64) fails building on sqlite.

../../../src/std/db/_sqlite.c:626:10: fatal error: 'sqlite3.h' file not found
#include <sqlite3.h>
         ^~~~~~~~~~~
1 error generated.
*** ERROR IN ##main -- target compilation or link failed while compiling "/home/jamppa/git/gerbil/src/std/db/_sqlite.scm"
*** ERROR IN std/make#gsc-compile, "make.ss"@416.7 -- Compilation error; gsc exited with nonzero status 17920
*** ERROR; build failed

Currently running on OpenBSD kaganovich.my.domain 6.3 GENERIC.MP#25 amd64 and both sqlite's are found on the system.

sqlite-2.8.17p4 (installed)
sqlite3-3.23.0 (installed)

sqlite3.h is located in /usr/local/include/sqlite3.h. I think it could be as easy as allowing a compiler/linker-flag to include that directory in its' search path, but can't seem to figure out how.

If I personally write out the whole db-part out of files/features to build, gerbil builds without a hitch.

Bug in compiler?

While trying to write a simple cell automaton for http://AdventOfCode.com/2018/day/12 I hit a bug in
Gerbil v0.15-DEV-2-g7d09a4ce on Gambit v4.9.1. Try loading this file:

(import
  :gerbil/gambit/bits
  :std/misc/repr)

(def cell-transition #(0 0 1 0 0 0 1 0 1 0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 0 1 1 0 0 0 1 0))

(def (normalize-state offset state)
  (prn ['ns offset state])
  (def fbs (first-bit-set state))
  (values (+ offset fbs) (arithmetic-shift state (- fbs))))

(def (next-generation offset state)
  (prn ['ng offset state])
  (defvalues (offset state) (normalize-state offset state))
  (def n 0)
  (def p 1)
  (for (i (in-range 0 (+ 4 (integer-length state))))
    (let ((surroundings (bitwise-and 31 (arithmetic-shift state (- 4 i)))))
      (unless (zero? (vector-ref cell-transition surroundings))
        (increment! n p))
      (increment! p p)))
  (values (+ offset 2) n))

(prn (values->list (next-generation 0 84799340321545375494787646787)))

I get the following error:

['ng 0 84799340321545375494787646787]
['ns #!void #!void]
*** ERROR IN normalize-state, (console)@200.14 -- (Argument 1) Exact INTEGER expected
(first-bit-set #!void)

I expected the 'ns arguments to be the same as the 'ng arguments.

Error building gerbil

Fresh install of gambit (v4.8.9); all 14 checks completed successfully.
When building gerbil on Fedora Linux 27:
... compile debug/heap
In file included from heap__0.c:352:0:
heap__0.c: In function ‘___H_heap____0’:
heap__0.c:11295:54: error: ‘___BODY_OFS’ undeclared (first use in this function); did you mean ‘___BODY_AS’?
___SCMOBJ next = ___TAG((base + ___STILL_HAND_OFS - ___BODY_OFS),
^
/usr/local/Gambit/include/gambit.h:1683:34: note: in definition of macro ‘___CAST’
#define ___CAST(type,val)((type)(val))
^~~
heap__0.c:11295:19: note: in expansion of macro ‘___TAG’
___SCMOBJ next = ___TAG((base + ___STILL_HAND_OFS - ___BODY_OFS),
^~~~~~
heap__0.c:11295:54: note: each undeclared identifier is reported only once for each function it appears in
___SCMOBJ next = ___TAG((base + ___STILL_HAND_OFS - ___BODY_OFS),
^
/usr/local/Gambit/include/gambit.h:1683:34: note: in definition of macro ‘___CAST’
#define ___CAST(type,val)((type)(val))
^~~
heap__0.c:11295:19: note: in expansion of macro ‘___TAG’
___SCMOBJ next = ___TAG((base + ___STILL_HAND_OFS - _BODY_OFS),
^~~~~~
*** ERROR IN ##main -- target compilation or link failed while compiling "/home/k/src/gerbil/lib/std/debug/heap__0.scm"
*** ERROR IN gxc#compile-scm-file
% -- Syntax Error
*** ERROR IN ?
--- Syntax Error at compile: Compilation error; gsc exit with nonzero status
... form: "/home/k/src/gerbil/lib/std/debug/heap__0.scm"
... detail: 17920
*** ERROR; build failed
[k@grisea src]$ ls

defmethod fails on classes

Trying to use generics on classes.

> (import :std/generic)
> (defgeneric foo (lambda (self) self))
> (defclass bar ())
> (defmethod (foo (bar bar)) #t)
*** ERROR -- Unbound variable: class::t

My guess is that the (type::t (runtime-type-identifier klass)) syntax is missing an unquote somewhere, and my lack of clue on scheme macros leaves me here.

Thanks!

strange :std/net/request failures

Unfortunately requesting pages seems to be hit and miss:

[georgiy@PANTHER ~]$ gxi
Gerbil v0.12-DEV on Gambit v4.8.8

(import :std/net/request)
(http-get "http://hitchtheworld.com")
#<request #7>
(http-get "http://debian.org")
*** ERROR IN (console)@3.1 -- URL redirection loop "http://www.debian.org/"
1>

For some reason it's not able to get the Debian home page among others the way any of my browsers can and the way I can get with Python's Requests library.

Emoji encoding

When encode emoji symbol to JSON, only 4 last characters remains instead of 5
(\u0001F600 becomes \uf600)

expanding define-syntax

Is there a way in Gerbil to expand a source file to another file so that all macro uses (define-syntax would be enough for the moment) are expanded? (Like alexpander does, but without the artifacts that alexpander introduces.)

ptrace bindings?

I started writing an FFI to ptrace, starting out with an api based on what OpenBSD provides:

(export ptrace-attach
        ptrace-detach
        ptrace-continue
        ptrace-kill
        ptrace-read-data
        ptrace-read-text
        ptrace-write-data
        ptrace-write-text
        ptrace-step
        ptrace-process-threads
        ptrace-process-registers
        ptrace-set-process-registers!)

Is this something that we might want in std/os? I'm not quite ready to PR, as I want to make sure the work is portable: the ptrace operations and options vary across OSes and there are some machine-specific aspects to deal with in the register sets.

generic defmethod does not redefine a method

When running defmethod on an already existing method, it uses the old one always, not the redefinition.

Gerbil v0.12-DEV-1038-g4323fa2 on Gambit v4.8.8

(import :std/generic)
(defgeneric foo)
(defclass A ())
(defmethod (foo (a A)) "A, eh?")
(foo (make-A))
"A, eh?"
(defclass (B A) ())
(foo (make-B))
"A, eh?"
(defmethod (foo (b B)) "B, eh?")
(foo (make-B))
"B, eh?"
(defmethod (foo (b B)) "Redefine foo for B, eh?")
(foo (make-B))
"B, eh?"

RFI: search and info commands in gxpkg

Short of Gambit's own native module/package system I am using gerbil's, which is quite nice to work with.

In order to facilitate adoption, we could have a searchable package metadata repository. This could enable gxpkg usage such as:

gxpkg search BLAS

package | version | runtime | author | release date
---
scmblas | v x.y.z | gambit | feeley | YYYY-MM-DD
blas | v x.y.z | gerbil | vyzo | YYYY-MM-DD
gblas | v x.y.z | gambit, gerbil | belmarca | YYYY-MM-DD

gxpkg info gblas

Description: Gambit FFI bindings to BLAS.
Author: Marc-André Bélanger
Runtime: Gambit, Gerbil
Repo: github.com/X/YZ
Version: x.y.z
Release date: YYYY-MM-DD
Commit: hash123

The search and info commands would simply query an HTTP package metadata repository. A list of all packages could be kept locally and updated at will. A call to gxpkg install my-package would then clone the proper repository to ~/.gerbil/pkg/my-package and run the Makefile.

We could require the Makefile to contain at minimum the gerbil rule, used to compile the library with gxc. gxpkg would then simply call this rule and the rest would fall into place. Thus the trouble of actually building the required object files (or whatever else needs to be done) is left to the library/package author and requires only one assumption from us, the existence of the gerbil rule. So if an author wants to write tests, they can, but we don't disallow untested code. Etc.

The metadata repository's state could be mutated by git (or another VCS) hooks. As an author I can thus write my library locally and push it to GitHub (or BitBucket or whichever provider). Ideally, our metadata server is notified of the latest metadata with a simple POST. However git doesn't have post-push hooks, so that could be a little bit annoying.

Package versioning could be handled relatively simply. Instead of having a master package whose HEAD tracks whatever commit is in the metadata repository, we could use a directory structure such as:

~/.gerbil/pkg/my-package
~/.gerbil/pkg/my-package/current
~/.gerbil/pkg/my-package/hash123
~/.gerbil/pkg/my-package/hash456
~/.gerbil/pkg/my-package/tagXYZ

With current being used whenever (import :user/my-package) is called. A call such as (import :user/my-package#hash123) or (import :user/my-package 'tagXYZ) could then use the library at any particular commit. This allows the use of different versions of a package in different REPLs. If, on the contrary, a call such as (import :user/my-package 'tagXYZ) simply checked out the particular commit (a functionality that is not undesirable), there would be a single package version available at all times (unless one wants to mess with starting different processes at long enough intervals to let the checkout from one process to complete, etc).

This is obviously an incomplete proposal. I haven't discussed important details such as authentication/authorization (who gets to write to the metadata repository?) and signing of packages as well as how much trust to put into said packages (gxc is involved after all).

Hope this gets the ball rolling :)

gxpkg doesn't check if 'build.ss' is executable

When trying to install package from github using 'gxpkg install ...', it fails with error "Permission denied".
This happens because gxpkg script doesn't check if 'build.ss' file has executable rights.

Installation: compiler build failure.

Hi,
I am experiencing a build failure when trying to install Gerbil. Relevant passage from build output:

... compile gerbil/compiler.ss

finalizing build [final]
gerbil/boot/gx-init-exe.scm -> /Users/uma/Applications/gerbil/lib/gx-init-exe.scm
gerbil/boot/gx-init-static-exe.scm -> /Users/uma/Applications/gerbil/lib/gx-init-static-exe.scm
gerbil/boot/gx-init.scm -> /Users/uma/Applications/gerbil/lib/gx-init.scm
gerbil/boot/gxi-init.scm -> /Users/uma/Applications/gerbil/lib/gxi-init.scm
gerbil/boot/gxi-interactive.scm -> /Users/uma/Applications/gerbil/lib/gxi-interactive.scm
gerbil/interactive/init.ss -> /Users/uma/Applications/gerbil/lib/init.ss
gerbil/interactive/r7rs-init.ss -> /Users/uma/Applications/gerbil/lib/r7rs-init.ss
gerbil/gxi -> /Users/uma/Applications/gerbil/bin/gxi
gerbil/gxc -> /Users/uma/Applications/gerbil/bin/gxc
gerbil/gxi-build-script -> /Users/uma/Applications/gerbil/bin/gxi-build-script
[] Cleaning up bootstrap
[
] Building gerbil stdlib
*** ERROR IN gx#core-apply-expander__% -- Syntax Error
*** ERROR IN "build-spec.ss"@94.28
--- Syntax Error: Bad syntax
... form: ,@(include-gambit-sharp)
*** ERROR; build failed

This is on MacOS Sierra, Gambit 4.8.9 (as DMG), with build command:

./build.sh

in src directory as explained in "Install", i.e. no flags.

gxi seems to work (REPL starts). But gxc yields:

env: gxi-script: No such file or directory

Other notes: Compilation of many ".ss" files gives a warning. Example:

... compile gerbil/compiler/base.ss
clang: warning: argument unused during compilation: '--param max-gcse-memory=300000000' [-Wunused-command-line-argument]

I can provide the full output if necessary.

Cheers & all the Best
Ulf

test suite for socket servers

With the addition of kqueue support in #88 we have both major polling server implementations, but we lack a test suite.
Make one and add it to run-tests with a cond-expand depending on the system.

Webassembly?

Hi, I've been trying to get Gerbil to compile to Webassembly, but I can't quite figure it out. I've successfully gotten it to work for Gambit by looking at the process used in this old script: https://github.com/gambit/gambit/blob/master/misc/build-gambit-emscripten. Here's the basic idea:

  1. Compile Gambit using the Emscripten toolchain
  2. Compile an .scm file to .c using the -link option in gsc: gsc -link test.scm. This produces two .c files, test_.c and test.c.
  3. Feed the .c files into emcc along with all the .o files in gambit/lib from step 1.

I'd like to have gxc produce the .c files from step 2, but I can't get it to work. I see there's no explicit -link flag, so I tried various combinations of -gsc-flag, -gsc-option, and -s with no luck (but maybe I just used them wrong?).

And, once that's working, will I need to link in anything from gerbil/lib? I see a lot of object files in there, but I'm not sure how they get used in the build process.

Thanks in advance!

gerbil compiler apparently sends text output straight to /dev/tty, not allowing re-directs

It is impossible to make the gerbil compiler silent. For instance, if I run the command

$ gxc -d . -exe -static -O -o hello ./hello.scm

I get about 10 lines of informational output. However I cannot re-direct that output; it is sent directly to /dev/tty. So,

$ gxc -d . -exe -static -O -o hello ./hello.scm 2> /dev/null > /dev/null

also generates 10 lines of informational output on the console.

no (easy/sane) way to know what version of Gerbil I am using

The output of "gxc -h" indicates that there is no way to get version information. The gxi command doesn't even have a help option I can use to discover whether or not there is a command I can pass to get the version. Going into the gxi REPL a version string is visible but upon inspection of the source it turns out to be hardcoded and not at all indicative of what sort of tagged release or git commit I'm running from.

All programs should take some inspiration from Vim on this front:

[georgiy@PANTHER ]$ vim --version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Sep 1 2017 13:16:51)
Included patches: 1-1030
Modified by [email protected]
Compiled by [email protected]
Huge version without GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_sgr +tag_old_static
+arabic +find_in_path -mouse_sysmouse -tag_any_white
+autocmd +float +mouse_urxvt -tcl
-balloon_eval +folding +mouse_xterm +termguicolors
-browse -footer +multi_byte -terminal
++builtin_terms +fork() +multi_lang +terminfo
+byte_offset +gettext -mzscheme +termresponse
+channel -hangul_input +netbeans_intg +textobjects
+cindent +iconv +num64 +timers
-clientserver +insert_expand +packages +title
-clipboard +job +path_extra -toolbar
+cmdline_compl +jumplist +perl/dyn +user_commands
+cmdline_hist +keymap +persistent_undo +vertsplit
+cmdline_info +lambda +postscript +virtualedit
+comments +langmap +printer +visual
+conceal +libcall +profile +visualextra
+cryptv +linebreak +python/dyn +viminfo
+cscope +lispindent +python3/dyn +vreplace
+cursorbind +listcmds +quickfix +wildignore
+cursorshape +localmap +reltime +wildmenu
+dialog_con +lua/dyn +rightleft +windows
+diff +menu +ruby/dyn +writebackup
+digraphs +mksession +scrollbind -X11
-dnd +modify_fname +signs -xfontset
-ebcdic +mouse +smartindent -xim
+emacs_tags -mouseshape +startuptime -xpm
+eval +mouse_dec +statusline -xsmp
+ex_extra +mouse_gpm -sun_workshop -xterm_clipboard
+extra_search -mouse_jsbterm +syntax -xterm_save
+farsi +mouse_netterm +tag_binary
system vimrc file: "/etc/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "
/.vim/vimrc"
user exrc file: "$HOME/.exrc"
defaults file: "$VIMRUNTIME/defaults.vim"
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim80"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -Werror=format-security -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/python3.6m -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: gcc -L. -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim -lm -lnsl -lselinux -lncurses -lacl -lattr -lgpm -ldl -Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,relro -fstack-protector-strong -L/usr/local/lib -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -lnsl -ldl -lm -lcrypt -lutil -lc
[georgiy@PANTHER ~]$

ncurses/TUI in Gerbil?

Is there a recommended way to use Gerbil to write a TUI (e.g. using ncurses)? I've seen some use of the FFI in the standard library - is the recommended approach to create an FFI wrapper around ncurses or a comparable library, or is there a better way?

Build failure with glibc >= 2.26 due to SIGUNUSED

As of glibc 2.26, the SIGUNUSED signal was removed, leading to a build failure in std/os/signal.ss. I'm not sure if this is required for compatibility, or whether it could be removed from gerbil as well? FWIW, removing it led to successful compilation for me.

multicore?

Hi, reading through the docs I don't see if the concurrency primitives map to single core userspace threads or if there's support for multicore, or even m:n threading? Gambit docs mentioned the threads are single-core so I guess the same is true here? Either way making it clear in the docs would be nice :)

security problem with :std/net/request and likely Gerbil's TLS stack itself

Basically what we seem to be dealing with here is a complete inability to detect man in the middle attacks and TLS errors.

To reproduce an example of what I mean here use Firefox, Chromium, or whatever browser of your choice to pay a visit to https://ranprieur.com and you will be warned by the browser that the TLS certificate doesn't match the domain without being shown the page.

Because the site doesn't use HSTS this can potentially be worked around and at least in Firefox a (temporary) exception could be issued if the user deems the problem to be the result of incompetence and not malice like say the site operator forgetting to renew their certificate in a timely matter. Even in cases where it's impossible to be sure whether the TLS error is due to incompetence or the user being attacked like when dealing with self signed certificates for example the user is still aware that there is a problem and potential security risk. With that awareness they can then potentially think and make an informed decision like say making an exception for say a blog they read which they don't care if eavesdroppers know they read but not for when using their email provider's web client as they don't want to risk their password being stolen.

Likewise Python's Requests library also warns of TLS errors as shown here:

[georgiy@PANTHER ~]$ python3
Python 3.6.2 (default, Aug 11 2017, 11:59:59)
[GCC 7.1.1 20170622 (Red Hat 7.1.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import requests
requests.get('https://ranprieur.com')
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
conn.connect()
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 342, in connect
_match_hostname(cert, self.assert_hostname or hostname)
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 352, in _match_hostname
match_hostname(cert, asserted_hostname)
File "/usr/lib64/python3.6/ssl.py", line 321, in match_hostname
% (hostname, ', '.join(map(repr, dnsnames))))
ssl.CertificateError: hostname 'ranprieur.com' doesn't match either of 'server311.com', 'www.server311.com'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 423, in send
timeout=timeout
File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 630, in urlopen
raise SSLError(e)
requests.packages.urllib3.exceptions.SSLError: hostname 'ranprieur.com' doesn't match either of 'server311.com', 'www.server311.com'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3.6/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 488, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 609, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 497, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: hostname 'ranprieur.com' doesn't match either of 'server311.com', 'www.server311.com'

As can be clearly seen again users are warned by Requests that something is amiss. Maybe they decide it's too risky for them to proceed and stop whatever they're doing. Maybe they decide to do the analogue of enabling an exception to the normal TLS handling policy in Firefox and issue subsequent requests with verify=False instead of the implicit secure default True which is exactly as things should be. Either way they are well aware that there is a TLS problem and can abort their activities or continue while being aware of the risks as they see fit. They are aware of the problem and can decide if/how to deal with it.

Unfortunately things don't work this way with Gerbil:

[georgiy@PANTHER ~]$ gxi
Gerbil v0.12-DEV on Gambit v4.8.8

(import :std/net/request)
(http-get "https://ranprieur.com")
#<request #7>

Here to user gets no warning whatsoever that anything is wrong with the TLS connection and is given the illusion of security. They could easily be the victims of a man in the middle attack stealing their passwords, API keys, security tokens, etc while being none the wiser.

Please make it possible for users to know when something is amiss with their TLS connections and decide if/how to respond to it.

fatal error: openssl/evp.h: No such file or directory

This is on Ubuntu Linux 15.10, with

heine:~/programs/gerbil/src> gsc -v
v4.8.4 20160131033049 x86_64-unknown-linux-gnu "./configure 'CC=gcc -march=native' '--enable-single-host' '--enable-multiple-versions' '--enable-shared'"

heine:/programs> git clone https://github.com/vyzo/gerbil.git
Cloning into 'gerbil'...
remote: Counting objects: 964, done.
remote: Compressing objects: 100% (119/119), done.
remote: Total 964 (delta 64), reused 0 (delta 0), pack-reused 845
Receiving objects: 100% (964/964), 708.98 KiB | 0 bytes/s, done.
Resolving deltas: 100% (540/540), done.
Checking connectivity... done.
heine:
/programs> cd gerbil/
heine:/programs/gerbil> ls
README.md bin/ bootstrap/ doc/ etc/ lib/ src/
heine:
/programs/gerbil> cd src/
heine:~/programs/gerbil/src> ./build.sh
[*] Building gerbil stage0

preparing /home/lucier/programs/gerbil/bootstrap/stage0
compiling runtime
building gerbil/runtime in /home/lucier/programs/gerbil/bootstrap/stage0/lib
... compile gx-gambc
... compile gx-gambc0
... compile gx-gambc1
... compile gx-gambc2
preparing bootstrap
sending incremental file list
gerbil/
gerbil/compiler.ssi
gerbil/compiler__0.scm
gerbil/compiler__1.scm
gerbil/compiler__rt.scm
gerbil/core.ssi
gerbil/core::::MOP:1__rt.scm
gerbil/core::::MOP:2__rt.scm
gerbil/core::::MOP:3__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::::sugar:1__rt.scm
gerbil/core::::sugar:2__rt.scm
gerbil/core::::sugar:3__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core::__rt.scm
gerbil/core__1.scm
gerbil/core__10.scm
gerbil/core__11.scm
gerbil/core__12.scm
gerbil/core__13.scm
gerbil/core__14.scm
gerbil/core__15.scm
gerbil/core__2.scm
gerbil/core__3.scm
gerbil/core__4.scm
gerbil/core__5.scm
gerbil/core__6.scm
gerbil/core__7.scm
gerbil/core__8.scm
gerbil/core__9.scm
gerbil/core__rt.scm
gerbil/expander.ssi
gerbil/expander__rt.scm
gerbil/gambit.ssi
gerbil/gambit__rt.scm
gerbil/expander/
gerbil/expander/common.ssi
gerbil/expander/common__1.scm
gerbil/expander/common__rt.scm
gerbil/expander/compile.ssi
gerbil/expander/compile__0.scm
gerbil/expander/compile__rt.scm
gerbil/expander/core.ssi
gerbil/expander/core__0.scm
gerbil/expander/core__1.scm
gerbil/expander/core__rt.scm
gerbil/expander/module.ssi
gerbil/expander/module__0.scm
gerbil/expander/module__1.scm
gerbil/expander/module__rt.scm
gerbil/expander/root.ssi
gerbil/expander/root__0.scm
gerbil/expander/root__rt.scm
gerbil/expander/stx.ssi
gerbil/expander/stx__0.scm
gerbil/expander/stx__1.scm
gerbil/expander/stx__rt.scm
gerbil/expander/stxcase.ssi
gerbil/expander/stxcase__0.scm
gerbil/expander/stxcase__1.scm
gerbil/expander/stxcase__rt.scm
gerbil/expander/top.ssi
gerbil/expander/top__0.scm
gerbil/expander/top__rt.scm
gerbil/gambit/
gerbil/gambit/bits.ssi
gerbil/gambit/bits__rt.scm
gerbil/gambit/continuations.ssi
gerbil/gambit/continuations__rt.scm
gerbil/gambit/exceptions.ssi
gerbil/gambit/exceptions__rt.scm
gerbil/gambit/fixnum.ssi
gerbil/gambit/fixnum__rt.scm
gerbil/gambit/flonum.ssi
gerbil/gambit/flonum__rt.scm
gerbil/gambit/foreign.ssi
gerbil/gambit/foreign__rt.scm
gerbil/gambit/hash.ssi
gerbil/gambit/hash__rt.scm
gerbil/gambit/hvectors.ssi
gerbil/gambit/hvectors__1.scm
gerbil/gambit/hvectors__rt.scm
gerbil/gambit/misc.ssi
gerbil/gambit/misc__rt.scm
gerbil/gambit/os.ssi
gerbil/gambit/os__rt.scm
gerbil/gambit/ports.ssi
gerbil/gambit/ports__0.scm
gerbil/gambit/ports__rt.scm
gerbil/gambit/random.ssi
gerbil/gambit/random__0.scm
gerbil/gambit/random__rt.scm
gerbil/gambit/readtables.ssi
gerbil/gambit/readtables__rt.scm
gerbil/gambit/system.ssi
gerbil/gambit/system__rt.scm
gerbil/gambit/threads.ssi
gerbil/gambit/threads__0.scm
gerbil/gambit/threads__rt.scm

sent 2,517,394 bytes received 2,035 bytes 5,038,858.00 bytes/sec
total size is 2,509,565 speedup is 1.00

compiling gerbil core
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__10.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/compiler__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/root__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/module__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/common__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/core__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/stxcase__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/stx__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/stxcase__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/compile__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/root__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/stxcase__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/core__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/common__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/core__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/stx__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/top__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/stx__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/compile__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/module__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/top__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander/module__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__3.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::::sugar:1__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__2.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__11.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/compiler__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__6.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/compiler__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__13.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/expander__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::::MOP:1__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::::MOP:2__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/os__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/misc__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/random__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/foreign__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/hvectors__1.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/bits__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/ports__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/fixnum__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/exceptions__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/system__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/readtables__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/flonum__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/ports__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/threads__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/hvectors__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/hash__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/random__0.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/threads__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit/continuations__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__4.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__7.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::::sugar:3__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__12.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::::sugar:2__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__14.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::::MOP:3__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__8.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__15.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__9.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core__5.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/gambit__rt.scm
... compile /home/lucier/programs/gerbil/bootstrap/stage0/lib/gerbil/core::__rt.scm
finalizing build
'boot/gx-init.scm' -> '/home/lucier/programs/gerbil/bootstrap/stage0/lib/gx-init.scm'
'boot/gxi-init.scm' -> '/home/lucier/programs/gerbil/bootstrap/stage0/lib/gxi-init.scm'
'gerbil/gxi' -> '/home/lucier/programs/gerbil/bootstrap/stage0/bin/gxi'
'gerbil/gxc' -> '/home/lucier/programs/gerbil/bootstrap/stage0/bin/gxc'
[] Building gerbil stage1
preparing /home/lucier/programs/gerbil/bootstrap/stage1
compiling runtime
building gerbil/runtime in /home/lucier/programs/gerbil/bootstrap/stage1/lib
... compile gx-gambc
... compile gx-gambc0
... compile gx-gambc1
... compile gx-gambc2
compiling gerbil core
building gerbil in /home/lucier/programs/gerbil/bootstrap/stage1/lib
... compile gerbil/expander.ss
... compile gerbil/expander/stxcase.ss
... compile gerbil/expander/module.ss
... compile gerbil/expander/common.ss
... compile gerbil/expander/top.ss
... compile gerbil/expander/stx.ss
... compile gerbil/expander/core.ss
... compile gerbil/expander/compile.ss
... compile gerbil/expander/root.ss
... compile gerbil/prelude/core.ss
... compile gerbil/prelude/gambit.ss
... compile gerbil/prelude/gambit/ports.ss
... compile gerbil/prelude/gambit/misc.ss
... compile gerbil/prelude/gambit/random.ss
... compile gerbil/prelude/gambit/continuations.ss
... compile gerbil/prelude/gambit/os.ss
... compile gerbil/prelude/gambit/exceptions.ss
... compile gerbil/prelude/gambit/threads.ss
... compile gerbil/prelude/gambit/bits.ss
... compile gerbil/prelude/gambit/hvectors.ss
... compile gerbil/prelude/gambit/system.ss
... compile gerbil/prelude/gambit/foreign.ss
... compile gerbil/prelude/gambit/hash.ss
... compile gerbil/prelude/gambit/readtables.ss
... compile gerbil/prelude/gambit/fixnum.ss
... compile gerbil/prelude/gambit/flonum.ss
... compile gerbil/compiler.ss
finalizing build
'boot/gx-init.scm' -> '/home/lucier/programs/gerbil/bootstrap/stage1/lib/gx-init.scm'
'boot/gxi-init.scm' -> '/home/lucier/programs/gerbil/bootstrap/stage1/lib/gxi-init.scm'
'gerbil/gxi' -> '/home/lucier/programs/gerbil/bootstrap/stage1/bin/gxi'
'gerbil/gxc' -> '/home/lucier/programs/gerbil/bootstrap/stage1/bin/gxc'
[
] Building gerbil stage2
preparing /home/lucier/programs/gerbil
compiling runtime
building gerbil/runtime in /home/lucier/programs/gerbil/lib
... compile gx-gambc
... compile gx-gambc0
... compile gx-gambc1
... compile gx-gambc2
compiling gerbil core
building gerbil in /home/lucier/programs/gerbil/lib
... compile gerbil/expander.ss
... compile gerbil/expander/stxcase.ss
... compile gerbil/expander/module.ss
... compile gerbil/expander/common.ss
... compile gerbil/expander/top.ss
... compile gerbil/expander/stx.ss
... compile gerbil/expander/core.ss
... compile gerbil/expander/compile.ss
... compile gerbil/expander/root.ss
... compile gerbil/prelude/core.ss
... compile gerbil/prelude/gambit.ss
... compile gerbil/prelude/gambit/ports.ss
... compile gerbil/prelude/gambit/misc.ss
... compile gerbil/prelude/gambit/random.ss
... compile gerbil/prelude/gambit/continuations.ss
... compile gerbil/prelude/gambit/os.ss
... compile gerbil/prelude/gambit/exceptions.ss
... compile gerbil/prelude/gambit/threads.ss
... compile gerbil/prelude/gambit/bits.ss
... compile gerbil/prelude/gambit/hvectors.ss
... compile gerbil/prelude/gambit/system.ss
... compile gerbil/prelude/gambit/foreign.ss
... compile gerbil/prelude/gambit/hash.ss
... compile gerbil/prelude/gambit/readtables.ss
... compile gerbil/prelude/gambit/fixnum.ss
... compile gerbil/prelude/gambit/flonum.ss
... compile gerbil/compiler.ss
finalizing build
'boot/gx-init.scm' -> '/home/lucier/programs/gerbil/lib/gx-init.scm'
'boot/gxi-init.scm' -> '/home/lucier/programs/gerbil/lib/gxi-init.scm'
'gerbil/gxi' -> '/home/lucier/programs/gerbil/bin/gxi'
'gerbil/gxc' -> '/home/lucier/programs/gerbil/bin/gxc'
[] Cleaning up bootstrap
[
] Building gerbil stdlib
... compile format
... compile pregexp
... compile sort
... compile sugar
... compile make
... compile event
... compile coroutine
... compile srfi/srfi-support
... compile srfi/8
... compile srfi/9
... compile srfi/1
... compile srfi/14
... compile srfi/13
... compile srfi/19
... compile srfi/41
... compile srfi/42
... compile srfi/43
... compile srfi/78
... compile srfi/95
... compile text/hex
... compile foreign text/base64
... copy ssi text/base64
... compile loader text/base64
... compile text/json
... compile net/address
... compile net/uri
... compile net/socks
... compile net/request
... compile foreign xml/_libxml
... copy ssi xml/_libxml
... compile loader xml/_libxml
... compile xml/libxml
... compile xml/sxml
... compile foreign xml/sxml-to-xml
... copy ssi xml/sxml-to-xml
... compile loader xml/sxml-to-xml
... compile xml/print
... compile xml
... compile foreign crypto/libcrypto
../../../src/std/crypto/libcrypto.c:1031:25: fatal error: openssl/evp.h: No such file or directory
compilation terminated.
*** ERROR IN ##main -- C compilation or link failed while compiling "/home/lucier/programs/gerbil/src/std/crypto/libcrypto.scm"
*** ERROR IN for-each -- Compilation error; gsc exited with nonzero status 17920
*** ERROR; build failed
heine:~/programs/gerbil/src>

Bug in def macroexpander

Here is my reduced test case.

(defrules foo () ((_ . _) #f))

(def (bar)
  (defvalues (_ _) (values #f #f))
  (foo)
  (def baz #f)
  baz)

Copying that into gxi causes a syntax error. Meanwhile, gxc seems happy about it.

Documentation on compiler's behavior on phi > 1

Currently gerbil generate following files for an lib1.ss

  • lib1.ssi
  • lib1__0.scm & .o1
  • lib1__{n}.scm & .o1
  • lib1__rt.scm & .o1

where __0 is actually compiled in generated executable, .ssi/__rt / __{n} seems only used by compiler itself.

it'll be great if the behavior is clear documented.

Building stdlib doesn't find external libraries on OpenBSD

When building stdlib with modules which require external libraries I get following error:

tmy@phobos src $ ./build.sh stdlib                                                                                                                                                                    
[*] Building gerbil stdlib
... generate stdlib depgraph
... compile foreign text/libyaml
../../../src/std/text/libyaml.c:555:10: fatal error: 'yaml.h' file not found
#include <yaml.h>
         ^~~~~~~~
1 error generated.
*** ERROR IN ##main -- target compilation or link failed while compiling "/home/tmy/git/gerbil/src/std/text/libyaml.scm"
*** ERROR IN std/make#gsc-compile, "make.ss"@386.7 -- Compilation error; gsc exited with nonzero status 17920
*** ERROR; build failed

Is there a way to add directories where the compiler should look for these when building gerbil std lib? I have yaml package installed and /usr/local/lib/libyaml.so.0.0 and /usr/local/include/yaml.h exists on my system.
The problem happens because OpenBSD compiler won't search libraries or headers under /usr/local by default.

List-set! at compile time

Hello,

I'm trying to implement a read/write generic accessor macro inspired by the definition of @ and @-set! in core.ss.

(defrules ref ()
  ((_ obj id)
   (match obj       
     ((? list?) (list-ref obj id))
     ((? vector?) (vector-ref obj id))
     ((? u8vector?) (u8vector-ref obj id))
     ((? string?) (string-ref obj id))
     ((? hash-table?) (hash-ref obj id))
     ((? object?) (slot-ref obj id))))
  ((recur obj id rest ...) (recur (recur obj id) rest ...)))

(defrules ref-set! ()
  ((_ obj id val)
   (match obj
     ((? list?) (list-set! obj id val))
     ((? vector?) (vector-set! obj id val))
     ((? u8vector?) (u8vector-set! obj id val))
     ((? string?) (string-set! obj id val))
     ((? hash-table?) (hash-put! obj id val))
     ((? object?) (slot-set! obj id val))))
  ((recur obj id path ... last val) (recur (ref obj id path ...) last val)))

It seems to work fine when loaded into the REPL but I'm having trouble when compiling it. list-set! does not seem to be available (which is the first thing I don't understand):

» gxc ref.ss
*** ERROR IN gx#core-expand-ref% -- Syntax Error
*** ERROR IN ?
--- Syntax Error: Reference to unbound identifier
... form:   (%#ref list-set!)
... detail: list-set!

The second thing is that if I add list-set! as defined in base-etc.ss ((def (list-set! lst k obj) (set! (car (list-tail lst k)) obj))), it does compile but takes about 10s with a toy example like the following whilst it is almost instantaneous when commenting out lines using ref and ref-set!:

(defclass A (a))
(defclass B (b))
(def o (make-A))

;; Using @
(set! (@ o a) (for/collect (_ (in-range 10)) (make-B b: 0)))

;; Using ref/ref-set!
(set! (ref o 'a) (for/collect (_ (in-range 10)) (make-B b: 0)))

;; Using @
(for (i (in-range 10))
  (when (= (@ (list-ref (@ o a) i) b) 0)
    (set! (@ (list-ref (@ o a) i) b) 1)))

;; Using ref/ref-set!
(for (i (in-range 10))
  (when (= (ref o 'a i 'b) 0)
    (set! (ref o 'a i 'b) 1)))

The problem is that it takes more than a minute on a 100 lines module using it regularly and fails with the following:

» gxc minesweeper.ss
minesweeper__0.c: In function ‘___H_minesweeper_____0’:
minesweeper__0.c:111234:1: warning: const/copy propagation disabled: 39687 basic blocks and 148490 registers; increase --param max-gcse-memory above 736908216 [-Wdisabled-optimization]
 ___END_M_COD
 ^~~~~~~~~~~~
minesweeper__0.c:111234:1: warning: PRE disabled: 39687 basic blocks and 148490 registers; increase --param max-gcse-memory above 736908216 [-Wdisabled-optimization]
minesweeper__0.c:111234:1: warning: const/copy propagation disabled: 39687 basic blocks and 148490 registers; increase --param max-gcse-memory above 736908216 [-Wdisabled-optimization]
minesweeper__0.c:111234:1: warning: const/copy propagation disabled: 39626 basic blocks and 148504 registers; increase --param max-gcse-memory above 735775568 [-Wdisabled-optimization]
gcc: fatal error: Killed signal terminated program cc1
compilation terminated.
*** ERROR IN ##main -- target compilation or link failed while compiling "~/.gerbil/lib/minesweeper__0.scm"
*** ERROR IN gxc#compile-scm-file__% -- Syntax Error
*** ERROR IN ?
--- Syntax Error at compile: Compilation error; gsc exit with nonzero status
... form:   "~/.gerbil/lib/minesweeper__0.scm"
... detail: 17920

I'm using Gerbil 0.14 on Gambit 4.9.1

libcrypto undefined symbol error on Debian 9

Hi,

Using a freshly compiled gerbil on Debian 9 I get the following error:

[*] Done
➜  src git:(master) ✗ cd ../bin 
➜  bin git:(master) ✗ ./gxi
Gerbil v0.13-DEV-441-gf4bf7d2e on Gambit v4.8.9
> (import :std/crypto)      
*** WARNING -- Could not find C function: "____20_libcrypto_2e_o1"
*** ERROR IN load-module -- ~/gerbil/lib/std/crypto/libcrypto.o1: undefined symbol: HMAC_CTX_init
(load "~/gerbil/lib/std/crypto/libcrypto.o1")
1> 

Features are (x86_64 linux gerbil-gambit linux-gnu gerbil-core gerbil).

Libssl version:

libssl-dev:
  Installed: 1.1.0f-3+deb9u2

On system Linux 4.9.0-6-amd64 #1 SMP Debian 4.9.88-1+deb9u1 (2018-05-07) x86_64 GNU/Linux

Related issue: #60

This might be due to libssl-dev 1.1? I cannot compile gambit-c with ssl support with libssl-dev 1.1.

Segmentation fault in emacs

Hi,

I'm eager to start playing around with Gerbil.
I've followed the instructions to set it up within Emacs, but I get a Segmenation fault when running M-x run-scheme

Process scheme segmentation fault (core dumped)

Gerbil runs fine in a shell

Gerbil v0.12-DEV-1448-gf323d8b on Gambit v4.8.8

It also runs fine in a terminal launched under Emacs.

My Emacs configuration, above and beyond (require 'gambit) is the following:

  (add-to-list 'load-path (substitute-in-file-name "$HOME/scheme/gerbil/etc/gerbil.el"))
  (autoload 'gerbil-mode "gerbil" "Gerbil editing mode." t)
  (defvar gsi-options " -:tE8,f8,-8,h2097152")
  (defvar gerbil-program-name (concat (substitute-in-file-name "$HOME/scheme/gerbil/bin/gxi") gsi-options))
  (setq scheme-program-name gerbil-program-name))

I get the segmentation fault every time. I tried and commented out all options except the last three, but with no luck. If I run M-x run-scheme with just (require 'gambit), I get a gambit REPL, so that works.

GNU Emacs 25.3.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.26) of 2018-02-09

Thanks you in advance.

Cast error building with g++

Hi, I am getting these errors when compiling with g++. Gambit tests are ok so assuming it is a gerbil issue? Dont really understand how to locate the error as it is in the .c file.

... compile os/signal
... compile os/signal-handler
In file included from signal-handler__0.c:271:
signal-handler__0.c: In function 'long int ___H_signal_2d_handler____0(___processor_state)':
/usr/local/gambit/v4.9.0/include/gambit.h:1707:27: error: invalid conversion from 'void*' to 'void (*)(int)' [-fpermissive]
 #define ___CAST(type,val)((type)(val))
                          ~^~~~~~~~~~~~
/usr/local/gambit/v4.9.0/include/gambit.h:7465:42: note: in definition of macro '___CFUN_ASSIGN_POINTER'
 #define ___CFUN_ASSIGN_POINTER(r,val)r = val;
                                          ^~~
/usr/local/gambit/v4.9.0/include/gambit.h:7448:31: note: in expansion of macro '___CAST'
 #define ___CFUN_CAST(type,arg)___CAST(type,arg)
                               RROR IN ##main -- target compilation or link failed while compiling "/Users/izzy/local/gerbil/lib/std/os/signal-handler__0.scm"
*** ERROR IN gxc#compile-scm-file__% -- Syntax Error
*** ERROR IN ?
--- Syntax Error at compile: Compilation error; gsc exit with nonzero status
... form:   "/Users/izzy/local/gerbil/lib/std/os/signal-handler__0.scm"
... detail: 17920
*** ERROR; build failed

Error while compiling statically linked executable

I'm following the tutorial/wiki "Getting Started with Gerbil development" after a fresh install.
Everything works according to plan, except the very last step, while attempting to produce a static artifact.

*** ERROR IN gxc#compile-exe-static-module -- Syntax Error
*** ERROR IN ?
--- Syntax Error at compile: cannot find static module
... form:   myuser/mylib
... detail: "myuser__mylib.scm"

Error when compiling with g++

#My installation of gambit is using the g++ as compiler.

When building the gerbil, it gives me the following error

../../../src/std/text/_zlib.c: In function 'z_stream* ffi_make_z_stream()':
../../../src/std/text/_zlib.c:351:42: error: invalid conversion from 'void*' to 'z_stream* {aka z_stream_s*}' [-fpermissive]
  z_stream *zs = malloc (sizeof (z_stream));
                                          ^

This first one I correct just by inserting the explicit cast. Then it gives me another errors:


../../../src/std/os/_socket.c:2845:24: error: aggregate 'ffi_setsockopt_mreq_src(int, int, int, long int, long int, long int)::ip_mreq_source mreq' has incomplete type and cannot be defined
  struct ip_mreq_source mreq;
                        ^
../../../src/std/os/_socket.c:2846:48: error: invalid application of 'sizeof' to incomplete type 'ffi_setsockopt_mreq_src(int, int, int, long int, long int, long int)::ip_mreq_source'
  socklen_t olen = sizeof (struct ip_mreq_source);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.