static build & macros pasted by megane on Fri Dec 28 13:58:45 2018

$ ./run.sh 
+ rm -rf '*.so' '*.o' m1.import.scm m2.import.scm 'src/*.so' src/m1.o src/m2.o
+ tree
.
├── main.scm
├── run.sh
└── src
    ├── m1.scm
    └── m2.scm

1 directory, 4 files
+ echo ----------------------------------------
----------------------------------------
+ more run.sh src/m1.scm src/m2.scm main.scm
+ cat
::::::::::::::
run.sh
::::::::::::::
#!/usr/bin/env bash
set -euox pipefail

rm -rf *.so *.o *.import.scm src/*.so src/*.o
tree

echo "----------------------------------------"
more run.sh src/m1.scm src/m2.scm main.scm | cat
echo "----------------------------------------"

csc -c -O3 -J -unit m1 src/m1.scm
csc -c -O3 -J -uses m1 -unit m2 src/m2.scm
tree
csc -static main.scm -uses m1 src/m1.o -uses m2 src/m2.o
./main
::::::::::::::
src/m1.scm
::::::::::::::
(module
 m1 (m1-bar) (import scheme (chicken base))
 (define (m1-bar f) (print "m1-bar called " f) `(list m1-bar ,f)))
::::::::::::::
src/m2.scm
::::::::::::::
(module
 m2
 (m2-macro)
 (import scheme (chicken base))
 (import m1)
 (define-syntax m2-macro
   (ir-macro-transformer (lambda (e inj cmp)
                           (m1-bar (cdr e))))))
::::::::::::::
main.scm
::::::::::::::
(import m2)
(print (m2-macro "hello" "there"))
+ echo ----------------------------------------
----------------------------------------
+ csc -c -O3 -J -unit m1 src/m1.scm
+ csc -c -O3 -J -uses m1 -unit m2 src/m2.scm
+ tree
.
├── m1.import.scm
├── m2.import.scm
├── main.scm
├── run.sh
└── src
    ├── m1.o
    ├── m1.scm
    ├── m2.o
    └── m2.scm

1 directory, 8 files
+ csc -static main.scm -uses m1 src/m1.o -uses m2 src/m2.o

Error: during expansion of (m2-macro ...) - unbound variable: m1#m1-bar

	Call history:

	<syntax>	  (##core#begin (print (m2-macro "hello" "there")))
	<syntax>	  (print (m2-macro "hello" "there"))
	<syntax>	  (m2-macro "hello" "there")
	<eval>	  (m1-bar (cdr e))	<--

no title pasted by megane on Fri Dec 28 14:15:54 2018

$ ./run.sh 
+ rm -rf '*.so' '*.o' m1.import.scm m2.import.scm 'src/*.so' src/m1.o src/m2.o
+ tree
.
├── main.scm
├── run.sh
├── src
│   ├── m1.scm
│   └── m2.scm
└── static-build.txt

1 directory, 5 files
+ echo ----------------------------------------
----------------------------------------
+ more run.sh src/m1.scm src/m2.scm main.scm
+ cat
::::::::::::::
run.sh
::::::::::::::
#!/usr/bin/env bash
set -euox pipefail

rm -rf *.so *.o *.import.scm src/*.so src/*.o
tree

echo "----------------------------------------"
more run.sh src/m1.scm src/m2.scm main.scm | cat
echo "----------------------------------------"

csc -c -O3 -J -unit m1 src/m1.scm
csc -c -O3 -J -uses m1 -unit m2 src/m2.scm
tree
csc -static main.scm -uses m1 src/m1.o -uses m2 src/m2.o
./main
::::::::::::::
src/m1.scm
::::::::::::::
(module
 m1 (m1-bar) (import scheme (chicken base))
 (define (m1-bar f) (print "m1-bar called " f) `(list m1-bar ,f)))
::::::::::::::
src/m2.scm
::::::::::::::
(module
 m2
 (m2-macro)
 (import scheme (chicken base))
 (import-for-syntax m1)
 (define-syntax m2-macro
   (ir-macro-transformer (lambda (e inj cmp)
                           (m1-bar (cdr e))))))
::::::::::::::
main.scm
::::::::::::::
(import m2)
(print (m2-macro "hello" "there"))
+ echo ----------------------------------------
----------------------------------------
+ csc -c -O3 -J -unit m1 src/m1.scm
+ csc -c -O3 -J -uses m1 -unit m2 src/m2.scm

Error: (require) cannot load extension: m1

	Call history:

	<syntax>	  (scheme#list)
	<syntax>	  (quote ((m1-bar . m1#m1-bar)))
	<syntax>	  (##core#quote ((m1-bar . m1#m1-bar)))
	<syntax>	  (scheme#list)
	<syntax>	  (scheme#list)
	<eval>	  (##sys#register-compiled-module (quote m1) (quote m1) (scheme#list) (quote ((m1-bar . m1#m1-bar))) (...
	<eval>	  (scheme#list)
	<eval>	  (scheme#list)
	<eval>	  (scheme#list)
	<syntax>	  (##core#begin (##core#require m1 m1#))
	<syntax>	  (##core#require m1 m1#)
	<syntax>	  (chicken.load#load-extension (##core#quote m1) (##core#quote (m1#)) (##core#quote require))
	<syntax>	  (##core#quote m1)
	<syntax>	  (##core#quote (m1#))
	<syntax>	  (##core#quote require)
	<eval>	  (chicken.load#load-extension (##core#quote m1) (##core#quote (m1#)) (##core#quote require))	<--

it works! added by megane on Fri Dec 28 14:20:54 2018

$ ./run.sh 
+ rm -rf '*.so' '*.o' m1.import.scm 'src/*.so' src/m1.o
+ tree
.
├── main
├── main.link
├── main.scm
├── run.sh
├── src
│   ├── m1.scm
│   └── m2.scm
├── static-build2.txt
└── static-build.txt

1 directory, 8 files
+ echo ----------------------------------------
----------------------------------------
+ more run.sh src/m1.scm src/m2.scm main.scm
+ cat
::::::::::::::
run.sh
::::::::::::::
#!/usr/bin/env bash
set -euox pipefail

rm -rf *.so *.o *.import.scm src/*.so src/*.o
tree

echo "----------------------------------------"
more run.sh src/m1.scm src/m2.scm main.scm | cat
echo "----------------------------------------"

csc -s -O3 -J -unit m1 src/m1.scm -o m1.so
csc -c -O3 -J -unit m1 src/m1.scm
csc -c -O3 -J -uses m1 -unit m2 src/m2.scm
csc -static main.scm -uses m1 src/m1.o -uses m2 src/m2.o
./main
::::::::::::::
src/m1.scm
::::::::::::::
(module
 m1 (m1-bar) (import scheme (chicken base))
 (define (m1-bar f) (print "m1-bar called " f) `(list m1-bar ,f)))
::::::::::::::
src/m2.scm
::::::::::::::
(module
 m2
 (m2-macro)
 (import scheme (chicken base))
 (import-for-syntax m1)
 (define-syntax m2-macro
   (ir-macro-transformer (lambda (e inj cmp)
                           (m1-bar (cdr e))))))
::::::::::::::
main.scm
::::::::::::::
(import m2)
(print (m2-macro "hello" "there"))
+ echo ----------------------------------------
----------------------------------------
+ csc -s -O3 -J -unit m1 src/m1.scm -o m1.so
+ csc -c -O3 -J -unit m1 src/m1.scm
+ csc -c -O3 -J -uses m1 -unit m2 src/m2.scm
+ csc -static main.scm -uses m1 src/m1.o -uses m2 src/m2.o
m1-bar called (hello there)

Warning: literal in operator position: ("hello" "there")

Warning: at toplevel:
  in procedure call to `"hello"', expected a value of type `(procedure (*) *)' but was given a value of type `string'
+ ./main

Error: call of non-procedure: "hello"