Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#700 closed defect (invalid)

requiring uncompiled extensions that use `use' fails

Reported by: Moritz Heidkamp Owned by: sjamaan
Priority: minor Milestone: 4.9.0
Component: compiler Version: 4.7.x
Keywords: Cc: Jim Ursetto
Estimated difficulty:

Description (last modified by Moritz Heidkamp)

The problem can be reproduced by having a file foo.scm containing something like this:

(module foo

()
(import chicken scheme)
(use extras)

)

and a file test.scm containing just (require-library foo). Now generate an import library through csc -Jt foo.scm. csi -s test.scm will work whereas csc test.scm and then running ./test will result in:

Warning: reference to possibly unbound identifier `extras'

Warning: reference to possibly unbound identifier `use'

Error: module unresolved: foo

        Call history:

        ##sys#require     
        <syntax>          (module foo () (import chicken scheme) (use extras))
        <syntax>          (##core#module foo () (import chicken scheme) (use extras))
        <syntax>          (import chicken scheme)
        <syntax>          (##core#undefined)
        <syntax>          (use extras)  <--

Compiling foo.import.scm doesn't change this behavior. Compiling foo.scm to foo.so via csc -s foo.scm makes it work again. Looks like loading uncompiled extensions that use use (and possibly other special forms?) doesn't work from compiled programs. This has been tested with both 4.7.0 and aa2d6b8247b13476fe609d1fd263238cc10a6a8e.

Change History (11)

comment:1 Changed 10 years ago by Moritz Heidkamp

Description: modified (diff)

comment:2 Changed 10 years ago by Moritz Heidkamp

Using (require-extension extras) instead of (use extras) works in any case. Another way to work around the problem is putting (declare (uses chicken-syntax)) at the top of test.scm.

comment:3 Changed 10 years ago by felix winkelmann

I can't reproduce this. Can you confirm this happens with the current master?

comment:4 Changed 10 years ago by felix winkelmann

Milestone: 4.8.0

comment:5 Changed 9 years ago by sjamaan

Cc: Jim Ursetto added
Milestone: 4.8.0

I can't reproduce this either, but Jim mentioned he got a similar error with 4.7.0 and -st. Just in case, I'm restoring the 4.8.0 milestone. This is reasonably serious and if we can we should fix it before the release. It's been postponed a lot now, we can fix this too :)

comment:6 Changed 9 years ago by sjamaan

(if it hasn't been fixed already, that is. If so we should try to come up with a regression test to verify it really has disappeared and not merely hidden due to some other changes)

comment:7 Changed 9 years ago by sjamaan

I think I see the problem. You're using require-library, which just loads the code. It doesn't load the import library, which require-extension, use or import would do. The import library handles the loading of the dependencies of a module.

In csi some libraries are always available without importing them explicitly.

Looks like this works as designed...

comment:8 Changed 9 years ago by Moritz Heidkamp

sjamaan: Note that (require-extension extras) instead of (use extras) in foo worked though.

I confirm that it can't be reproduced with master (285f53dbca729cffb4c4d9ee84e4ba893c882546) anymore.

comment:9 Changed 9 years ago by sjamaan

I can reproduce it with master (rev 0e44970), but I think it's not a bug.

Here's a shell script that should print "OKAY INTERPRETED" followed by "OKAY COMPILED" if everything loads without error, otherwise it will stop after the first breakage. I wanted to give this to git's bisect command, but figured that the situation hasn't changed.

#!/bin/sh
cd /tmp
rm -f /tmp/foo.import.scm /tmp/foo.import.so /tmp/foo /tmp/test || exit 1
/home/sjamaan/chicken-test/bin/csc -Jt /tmp/foo.scm || exit 1
/home/sjamaan/chicken-test/bin/csi -s /tmp/test.scm && echo "OKAY INTERPRETED" || exit 1
/home/sjamaan/chicken-test/bin/csc /tmp/test.scm || exit 1
/tmp/test && echo "OKAY COMPILED" || exit 1

comment:10 Changed 9 years ago by sjamaan

Resolution: invalid
Status: newclosed

It's rather simple, really: test.scm is compiled, and this means all macros are eliminated. chicken-syntax is available to all programs by default, but not after compilation.

To get it back for use in LOADed code, you must (use chicken-syntax) in test.scm; the rest is just noise. The fact that require-extension works in foo.scm is because it isn't syntax; that's provided by library.scm (containing mostly standard Scheme bindings, including a few Chicken-specific ones -- like require-extension)

comment:11 Changed 9 years ago by felix winkelmann

Milestone: 4.8.04.9.0

Milestone 4.8.0 deleted

Note: See TracTickets for help on using tickets.