Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

corpix
Copy link
Contributor

@corpix corpix commented Jul 20, 2024

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?) gambit/gambit#914

Copy link

netlify bot commented Jul 20, 2024

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

Visit the deploys page to approve it

Name Link
🔨 Latest commit 8acf2d6

Copy link
Collaborator

@vyzo vyzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to break hermetic package builds and mix/bleed intermediate build artifacts in a shared ditectory.

So this is not the right thing to do in the general case and it cannot be the default behavior.

We should only enable this when needed (eg for problem systems like nix), either with an env var or pethaps with a separate option?
Either way something the user says.

@fare
Copy link
Collaborator

fare commented Jul 23, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants