Boot Files

348 views
Skip to first unread message

Pyroxin

unread,
Mar 23, 2017, 2:50:18 PM3/23/17
to chez-scheme
I just started with Chez Scheme (less than 24 hours ago). I'm trying to figure out the processes for compiling programs for redistribution. Section 2.8 of the documentation talks about boot files. I'm following the examples that are provided and I'm running into trouble when I try to load the produced boot file.

I'm compiling the program and creating the boot file as follows:

> (compile-program "hello-world.ss")

compiling hello-world.ss with output to hello-world.so

()

> (make-boot-file "hello-world.boot" '("scheme" "petite") "hello-world.so")


Then, I try to load Petite Chez with the boot file:

$ petite --boot ./hello-world.boot

Exception in compiler-internal: $invoke-program: unable to locate program descriptor for #{program...


The code for the program is barely more than the examples from Section 2.8 of the CSUG.
#!chezscheme
;;; hello-world.ss
;;; A super simple Hello World program for Chez Scheme.

(import (chezscheme))

(scheme-start
 (lambda fns
  (for-each
   (lambda (fn)
           (printf "loading ~a ..." fn)
           (load fn)
           (printf "~%"))
   fns)
  (display "Starting a new Café.")
  (new-cafe)))

It isn't clear if I have to call ((scheme-start)) in the code when intending to produce a boot file. If I add ((scheme-start)) to the end of the program and load the .so or the boot file as a program, the expected behavior occurs. I am only unable to execute the program when explicitly loaded as a boot file. What am I doing wrong?

Thanks.

Graham Watt

unread,
Mar 23, 2017, 3:29:35 PM3/23/17
to chez-scheme
Hi,
 It looks like the problems is using compile-program. It works for me either not compiling the file at all, or using compile-file.

;;; hello.ss
(define (hello)
 
(printf "hello world~n"))

(make-boot-file "hello.boot" '("petite") "hello.ss")
or
(compile-file "hello.ss")
(make-boot-file "hello.boot" '("petite") "hello.so")
both work for me:

graham.watt@gwatt-mbp: ~/code/scheme
519 $ scheme -b ./hello.boot
Petite Chez Scheme Version 9.4.1
Copyright 1984-2016 Cisco Systems, Inc.

> (hello)
hello world

I'm guessing at this, but I think the problem outlined by dybig here is coming into play: https://github.com/cisco/ChezScheme/issues/69
Reading this: http://cisco.github.io/ChezScheme/csug9.4/use.html#./use:h4 looks to me that top level programs (which are what compile-program compiles) require the use of the library loading code.

Pyroxin

unread,
Mar 23, 2017, 3:43:51 PM3/23/17
to chez-scheme
Using compile-file appears to address the problem. Changing the boot procedure with scheme-start also works now.

Using the same code as I posted in the original message...

> (compile-file  "hello-world.ss")

compiling hello-world.ss with output to hello-world.so

> (make-boot-file "hello-world.boot" '("scheme" "petite") "hello-world.so")

>


Then,

$ petite --boot ./hello-world.boot

Chez Scheme Version 9.4

Copyright 1984-2016 Cisco Systems, Inc.


Starting a new Café.

>

 
The string "Starting a new Café." is now observed as expected. The startup procedure was changed to the supplied lambda and invoking ((scheme-start)) explicitly is not necessary.

Thanks for the help!

Andy Keep

unread,
Apr 1, 2017, 12:13:21 PM4/1/17
to chez-scheme, Pyroxin
Hey All,

As you've discovered R6RS programs and libraries don't interact well with the make-bootfile feature.  make-bootfile is primarily useful for combining Scheme programs composed of pre-R6RS-style Chez Scheme programs.  If you'd like to use R6RS libraries and programs, however, we do have a mechanism for compiling programs into single units as well: compile-whole-program and compile-whole-library.  They impose certain requirements on your programs and libraries, but provide better optimization the separately compiled programs and libraries.   You would still need to distribute the petite.boot file along with the scheme binary in order to run the program, so it is at least one extra file.  (The scheme.boot is only needed if your program uses the compiler during it's runtime... for instance if you were writing a repl of some sort, or making bindings to foreign functions during runtime... petite.boot does contain the interpreter, so it doesn't preclude running new Scheme code, but the compiler is useful to have if these are significant, since compiled code runs faster than interpreted code, in general).

You can see information on compile-whole-program, compile-whole-library, and related functions in section 12.4 of the Chez Scheme User's Guide: http://cisco.github.io/ChezScheme/csug9.4/system.html#./system:h4

-andy:)
--
You received this message because you are subscribed to the Google Groups "chez-scheme" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chez-scheme...@googlegroups.com.
To post to this group, send email to chez-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/chez-scheme/311e60d1-c24b-4ea0-908f-634d063f9d53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages