﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	difficulty
1225	Strange static compilation behaviour	Kooda		"I’ve been experimenting on static compilation of CHICKEN programs in the last few days and stumbled upon this weird behaviour.

Here are the files used:

{{{
;; mod.scm
(module mod
    (func)
  (import scheme chicken)
  (define (func) (print ""Hello world!"")))
}}}

{{{
;; test.scm
(use mod)
(func)
}}}

When compiling the module with -J, everything goes well:
{{{
$ csc mod.scm -c -J -unit mod
$ csc test.scm mod.o -uses mod -static-libs
$ ./test -:D
[debug] application startup...
[debug] heap resized to 1048576 bytes
[debug] stack bottom is 0x7fff266950b0.
[debug] entering toplevel toplevel...
[debug] entering toplevel library_toplevel...
[debug] entering toplevel build_2dversion_toplevel...
[debug] entering toplevel eval_toplevel...
[debug] entering toplevel expand_toplevel...
[debug] entering toplevel modules_toplevel...
[debug] resizing mutation-stack from 8k to 16k ...
[debug] entering toplevel chicken_2dsyntax_toplevel...
[debug] entering toplevel mod_toplevel...
Hello world!
[debug] forcing finalizers...
[debug] application terminated normally
}}}


Now if I remove mod.o (note that I keep mod.import.scm so the compiler knows about the module) and recompile the application, here is what happens:
{{{
$ rm mod.o
$ csc mod.scm -c -unit mod
$ csc test.scm mod.o -uses mod -static-libs
$ ./test -:D
[debug] application startup...
[debug] heap resized to 1048576 bytes
[debug] stack bottom is 0x7ffea745e110.
[debug] entering toplevel toplevel...
[debug] entering toplevel library_toplevel...
[debug] entering toplevel build_2dversion_toplevel...
[debug] entering toplevel eval_toplevel...
[debug] entering toplevel expand_toplevel...
[debug] entering toplevel modules_toplevel...
[debug] resizing mutation-stack from 8k to 16k ...
[debug] entering toplevel chicken_2dsyntax_toplevel...
[debug] entering toplevel mod_toplevel...

Error: (import) during expansion of (import ...) - cannot import from undefined module: chicken

	Call history:

	mod.scm:1: eval	  
	<syntax>	  (import scheme chicken)	<--
}}}"	enhancement	closed	minor	someday	compiler	4.10.x	fixed			medium
