Using CM from an ml-build'ed program

Matthew Fluet <[email protected]> Thu, 18 Feb 2010 13:50:12 -0500 (EST)
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
There seems to be a difference in functionality of the CM structure (in 
particular, CM.Graph.graph), depending on whether a heap image is made via 
ml-build or via a direct invocation of SMLofNJ.exportFn from the REPL.

The following transcript demonstrates the difference.  In another 
application, CM.Graph.graph doesn't raise an exception, but returns NONE 
when built via ml-build and returns SOME _ when built with a direct 
invocation of SMLofNJ.exportFn.

I understand that ml-build is supposed to be a bit more aggressive about 
dropping the compiler from the heap, so perhaps full CM functionality 
isn't expected in that case.

[mtf@fenrir tmp]$ cat test.cm
Library
   structure Test
is
   $/basis.cm
   $smlnj/cm.cm
   test.sml

[mtf@fenrir tmp]$ cat test.sml
structure Test =
struct
    fun message s = TextIO.output (TextIO.stdErr, s ^ "\n")
    fun die msg =
       (message ("Error: " ^ msg)
        ; OS.Process.exit OS.Process.failure)

    fun main (_, args) =
       (case args of
           [sources] =>
              (let
                  val _ =
                     case CM.Graph.graph sources of
                        SOME _ => print "SOME _\n"
                      | NONE => print "NONE\n"
               in
                  OS.Process.success
               end handle e => die (concat ["test failed: ", General.exnMessage e]))
         | _ => die ("missing file"))
end

[mtf@fenrir tmp]$ ( echo 'CM.make "test.cm";' ; echo 'SMLofNJ.exportFn("test",Test.main);' ) | sml
Standard ML of New Jersey v110.72 [built: Fri Feb 12 11:03:27 2010]
... (* no errors *) ...
[mtf@fenrir tmp]$ ls -la test.x86-darwin
-rw-r--r--  1 mtf  staff  11527188 Feb 18 13:48 test.x86-darwin
[mtf@fenrir tmp]$ sml 
@SMLload=test.x86-darwin test.cm [scanning test.cm]
SOME _
[mtf@fenrir tmp]$ rm test.x86-darwin
[mtf@fenrir tmp]$ ml-build test.cm Test.main test
Standard ML of New Jersey v110.72 [built: Fri Feb 12 11:03:27 2010]
... (* no errors *) ...
[mtf@fenrir tmp]$ ls -la test.x86-darwin
-rw-r--r--  1 mtf  staff  9173024 Feb 18 13:48 test.x86-darwin
[mtf@fenrir tmp]$ sml @SMLload=test.x86-darwin test.cm
Error: test failed: Fail: CMBoot: theValues not initialized


-- 
============================================
Matthew Fluet
Assistant Professor
Department of Computer Science
Rochester Institute of Technology
102 Lomb Memorial Drive
Rochester, NY 14623-5608
Tel: +1.585.475.2854 ; Fax: +1.585.475.4935
[email protected] ; http://www.cs.rit.edu/~mtf
============================================
CONFIDENTIALITY NOTE: The information transmitted, including attachments,
is intended only for the person(s) or entity to which it is addressed and
may contain confidential and/or privileged material.  Any review,
retransmission, dissemination or other use of, or taking of any action in
reliance upon this information by persons or entities other than the
intended recipient is prohibited.  If you received this in error, please
contact the sender ([email protected]) and destroy any copies of this
information.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev