问题
I have seen one other answer link but what I don't understand is what is basis.cm and what's it's use?
回答1:
You are asking two questions.
What is basis.cm and what's it's use?
This is the Basis library. It allows the use of built-in functions.
How to compile and execute a stand-alone SML-NJ executable
Assuming you followed Jesper Reenberg's tutorial on how to execute a heap image, the next thing you need in order to have SML/NJ produce a stand-alone executable is to convert this heap image. One should hypothetically be able to do this using heap2exec, a tool that takes the heap image, e.g. the .x86-linux file generated on my system, and generates an .asm file that can be assembled and linked.
Unfortunately, this tool is not very well-maintained, so you have to
- Go to the smlnj.org page and fix the download-link by removing 'www.' (this page and the SourceForge page don't contain the same explanations or assumptions about argument count, and neither page's download link work).
- Download and extract this tool, and fix the 'build' script so it points to your ml-build tool
- Fix the tool's argument use by changing
[inf, outf]
to[_, inf, outf]
- Run
./build
which generates 'heap2asm.x86-linux' on my system For example, in order to generate an .asm file for the heap2asm program itself, run
sml @SMLload heap2asm.x86-linux heap2asm.x86-linux heap2asm.s
At this point, I have unfortunately been unable to produce an executable that works. E.g. if you run
gcc -c heap2asm.s
andld heap2asm.o
, you get a warning of a missing_start
label. The resulting executable segfaults even if you rename the existing_sml_heap_image
label to_start
. That is, it seems that a piece of entry code that the runtime environment normally delivers is missing here.At this point, discard SML/NJ and use MLton for producing stand-alone binaries.
来源:https://stackoverflow.com/questions/34015825/how-to-compile-and-execute-a-stand-alone-sml-nj-executable