mighty-gerbils / gerbil

Gerbil Scheme
https://cons.io
GNU Lesser General Public License v2.1
1.16k stars 112 forks source link

use current-compile-output-dir for intermediate compilation objects #1255

Open corpix opened 4 months ago

corpix commented 4 months ago

This patch force Gerbil (and Gambit) to write intermediate compilation objects into (current-compile-output-dir). Motivated by this error:

Some more context could be found on Gerbil support channel here.

$ gxc -static -exe -o app app.ss                                                                   
/nix/store/i2fr4hsl5bs704bp8kihxdxbnvcsm3h3-gerbil-cli/gerbil/lib/static/cli__cli.scm:
*** ERROR IN c#targ-start-dump -- Read-only file system
(open-output-file "/nix/store/i2fr4hsl5bs704bp8kihxdxbnvcsm3h3-gerbil-cli/gerbil/lib/static/cli__cli.c")
#f*** ERROR IN gxc#compile-executable-module/separate -- 
*** ERROR IN ?
--- Syntax Error at (compile-exe app.ss): Compilation error; process exit with nonzero status
... form:   ("/nix/store/58g7klswv88zp6d3kmdzyk67rf3x5035-gerbil-gerbil-unstable-2024-05-11/gerbil/v0.18.1/bin/gsc"
             "-link"
             "/nix/store/58g7klswv88zp6d3kmdzyk67rf3x5035-gerbil-gerbil-unstable-2024-05-11/gerbil/v0.18.1/lib/static/gerbil__runtime__gambit.c"
             ...
$ echo $GERBIL_LOADPATH
/nix/store/i2fr4hsl5bs704bp8kihxdxbnvcsm3h3-gerbil-cli/gerbil/lib

Quick demonstration of the effect this patch has on gxc:

 ~/projects/src/github.com/mighty-gerbils/gerbil  λ  ls -la ~/.gerbil                                                 ✖ 2
"/home/user/.gerbil": No such file or directory (os error 2)
 ~/projects/src/github.com/mighty-gerbils/gerbil  λ  cat hello.ss
(export main)
(def (main . args)
     (displayln "hello"))

 ~/projects/src/github.com/mighty-gerbils/gerbil  λ  gxc -exe -static hello.ss                                        (5s 732ms)
/home/user/.gerbil/lib/static/schemered__hello.scm:
/home/user/.gerbil/lib/hello__exe.scm:
...

 ~/projects/src/github.com/mighty-gerbils/gerbil  λ  ./hello                                                          (1s 739ms)
hello
 ~/projects/src/github.com/mighty-gerbils/gerbil  λ  tree ~/.gerbil/lib
/home/user/.gerbil/lib
├── hello__exe.scm
├── schemered
│   ├── hello~0.scm
│   ├── hello.scm
│   └── hello.ssi
└── static
    ├── schemered__hello.c
    ├── schemered__hello.o
    └── schemered__hello.scm

3 directories, 7 files
 ~/projects/src/github.com/mighty-gerbils/gerbil  λ  ls -la hello*
.rwxr-xr-x 15M user 20 Jul 00:57 hello
.rw-r--r--  59 user 20 Jul 00:57 hello.ss

This patch depends on changes in Gambit (but I am not sure, maybe we could improve it, so we don't need to change any thing in Gambit?) https://github.com/gambit/gambit/pull/914

netlify[bot] commented 4 months ago

Deploy request for elastic-ritchie-8f47f9 pending review.

Visit the deploys page to approve it

Name Link
Latest commit 8acf2d6c99ed792d09655d255ae8daa0466bf0cb
fare commented 4 months ago

The real fix is that the nix packaging needs to be updated to include pre-compiled objects.