PLT mz-MzScheme Compiler Manual

How to Design Programs: An Introduction to Programming and Computing

Info icon This preview shows pages 1–6. Sign up to view the full content.

PLT mzc : MzScheme Compiler Manual PLT ([email protected]) 372 Released December 2007
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Copyright notice Copyright c 1996-2007 PLT Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Library General Public License, Version 2 published by the Free Software Foundation. A copy of the license is included in the appendix entitled “License.”
Image of page 2
Contents 1 About mzc 1 1.1 mzc Is... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 Byte-Code Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.2 Native-Code Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 mzc Is Not... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.3 Running mzc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.4 Native Code Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Foreign-Function Interface to C 5 3 Compiling Individual Files with mzc 9 3.1 Compiling with Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.2 Compilation without Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 3.3 Autodetecting Compiled Files for Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.4 Compiling Multiple Files to a Single Native-Code Library . . . . . . . . . . . . . . . . . . . . . . . 10 4 Compiling Collections with mzc 12 5 Building and Distributing Stand-alone Executables 13 5.1 Stand-Alone Executables from Scheme Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 5.2 Distributing Stand-Alone Executables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5.3 Stand-Alone Executables from Native Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 6 Creating Library Distribution Archives 16 7 info.ss File Format 18 License 19 i
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

CONTENTS CONTENTS Index 23 ii
Image of page 4
1. About mzc 1.1 mzc Is... The mzc compiler takes MzScheme (or MrEd) source code and produces either platform-independent byte-code com- piled files ( .zo files, which are just-in-time compiled to native code when loaded on x86, x86 64, and PowerPC platforms) or platform-specific native-code libraries ( .so or .dll files) to be loaded into MzScheme (or MrEd). In the latter mode, mzc provides limited support for interfacing directly to C libraries. mzc works on either individual files or on collections. (A collection is a group of files that conform to MzScheme’s library collection system; see § in PLT MzScheme: Language Manual ). In general, mzc works best with code using the module form. As a convenience for programmers writing low-level MzScheme extensions, mzc can compile and link plain C files that use MzScheme’s escheme.h header. This facility is described in Inside PLT MzScheme . Finally, mzc can perform miscellaneous tasks, such as embedding Scheme code in a copy of the MzScheme (or MrEd) binary to produce a stand-alone executable, or creating .plt distribution archives. 1.1.1 Byte-Code Compilation A byte-code file typically uses the file extension .zo . The file starts with # followed by the byte-code data. Byte-code files are loaded into MzScheme in the same way as regular Scheme source files (e.g., with load ). The # marker causes MzScheme’s reader to load byte codes instead of normal Scheme expressions. When a .zo file exists in a compiled subdirectory, it is sometimes loaded in place of a source file; see § 3.3 for details. Byte-code programs produced by mzc run exactly the same as source code compiled by MzScheme directly (assuming the same set of bindings are in place at compile time and load time). In other words, byte-code compilation does not optimize the code any more than MzScheme’s normal evaluator. However, a byte-code file can be loaded into MzScheme much faster than a source-code file.
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 6
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '07
  • Fisler
  • MzScheme, mzc

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern