Getting Started with HLVM

  1. Quick Start (For The Impatient)
  2. Overview
  3. Requirements
    1. Hardware
    2. Software
  4. Building Other Packages
    1. Single Separate Install Area
    2. apr
    3. apr-util
    4. llvm
    5. llvm-gcc4
    6. gperf
    7. deja-gnu/
  5. Building HLVM With SCons
    1. Quick Start
    2. About SCons And HLVM
    3. SCons Options Supported
    4. Build Targets
  6. Building HLVM With Make
    1. Targets Supported
    2. Tips And Tricks

Author: Reid Spencer.

Quick Start (For The Impatient)

Here's the quick start for getting up and running quickly with HLVM. Note that this is for experts and the impatient only.

  1. Read the documentation.
  2. Read the documentation.
  3. Remember that you were warned twice about reading the documentation.
  4. Obtain, build, and install the dependent packages. You need llvm, llvm-gcc4, apr, apr-util, libxml2, scons, gperf, gcc, dejagnu, python, tcl, and expect.
  5. Obtain the HLVM Source Code (http://llvm.org/svn/llvm-project/hlvm/trunk).
  6. Build hlvm with: scons -Q mode=debug confpath=/paths/to/pkgs
  7. The configuration utility might ask you where your 3rd party software is located. Please enter the paths appropriately.
  8. Run the test suite with: scons -Q check
  9. Install hlvm with: scons -Q mode=debug install prefix=/path/to/put/hlvm

Overview

Welcome to HLVM! This document shows you how to get started with the High Level Virtual Machine. Before you do that, lets get some questions answered up front to make sure you actually want to get started with HLVM.

What is HLVM?
HLVM is a toolkit for building virtual machines for dynamic languages. Its not something everyone is going to want to mess with. Generally, it is highly technical and doesn't really do much for an end user. On the other hand, if you're developing your own dynamic programming language, HLVM is just the ticket.
Who uses HLVM?
Generally, programming language researchers and software tool vendors use HLVM.
What does HLVM do?
HLVM doesn't really do anything. While it provides a few executables, these are ancillary in nature. Most of HLVM's capabilities are provided through a set of code libraries that can be incorporated into other programs. HLVM does provide a virtual machine executable but without a program to run (one that has been compiled by HLVM based tools), the virtual machine won't do anything. So, if you're an end user of software, HLVM probably isn't for you. If you're a developer, however, we think you'll find HLVM quite spiffy.
How hard is HLVM to build?
Although we've tried to make building HLVM dead simple, it is a complicated system and you must understand some of those complexities to get it right. One of its major complexities is that it incorporates many other packages that are not distributed with HLVM. You must build and install those packages yourself.

Okay, if you're still interested in HLVM, then we have a few more introductory things to cover:

  1. HLVM provides a suite of libraries and a few tools. These are statically linked (archive files and object files) so that you can incorporate the appropriate pieces into your project. This was done purposefully since we don't believe that creating a monolithic shared library (DLL) is particularly useful. This architecture gives you the freedom to construct your own libraries by picking the appropriate things from the palette that HLVM offers.
  2. Although HLVM provides several tools, these are ancillary in nature. They are provided to help either with testing HLVM or to help you use HLVM. The hlvm program (the actual virtual machine) is a reference implementation. You may choose to implement it differently (with the help of HLVM's runtime libraries, of course).

Requirements

Before you attempt to build HLVM, you need to understand its requirements. HLVM is non-trivial and depends on a number of other software packages. These packages will be required before you can build HLVM. Taking a moment to familiarize yourself with HLVM's requirements may save you some time in the long run.

The table below shows the software that HLVM depends on. You must obtain and build these packages yourself if they are not already present on your system. HLVM won't compile or run without them.

Hardware

HLVM supports whatever hardware LLVM supports. For details, please see LLVM's documentation

Software

Compiling HLVM requires that you have several software packages installed. The table below lists those required packages. The Package column is the usual name for the software package that HLVM depends on. The Version column provides "known to work" versions of the package. The Notes column describes how HLVM uses the package and provides other details.

PackageVersionNotes
gcc ≥3.4.6 (4.1 recommended) C/C++ compiler for compiling HLVM.
llvm 1 1.8cvs Low Level Virtual Machine. This compler infrastructure provides the low level code generation and optimization, linking, bytecode, JIT, and other facilities HLVM needs. LLVM is HLVM's sister project. It handles all the low level details for
llvm-gcc4 1 4 LLVM C/C++ Frontend, Version 4. This is a full GCC (Gnu Compiler Collection) compiler but with extensions for generating code via LLVM instead of GCC's normal RTL-based backend. This tool can compile C, C++, Objective-C and Objective-C++ languages into either native binary or LLVM bytecode. In either case, it utilizes LLVM's suite of passes for code optimization.
apr 1.2.7 Apache Portable Runtime. APR is used as the portability layer to abstract away differences between the various operating systems that HLVM runs on. This simplifies the HLVM Runtime library implementation and also endows it with some robustness. It handles various OS abstraction such as file I/O, threading, locking, loading, etc.
apr-util 1.2.7 Apache Portable Runtime Utilities. Additional runtime utilities for DBM database access, code set conversion (iconv) and miscellaneous other utilities.
libxml2 2.6.24 XML parsing and validation toolkit. This is used for reading and writing XML forms of the Abstract Syntax Tree.
gperf 2.7.2 (3.0.1 won't work) GNU Perfect Hash Function Generator. This is used for recognizing element and attribute names in XML documents.
subversion ≥1.1 Subversion source Subversion access to HLVM source repository.
scons 0.96.92 Software Construction system used for HLVM's build system.
python 2.3 Python programming language, required by scons
dejagnu 1.4.2 Test suite automation package. You only need this if you want to run the automated test suite.
expect 5.38.0 Test scripting language. DejaGnu is based on this. You only need this if you want to run the automated test suite.
tcl 8.3, 8.4 Test Control Language. Expect is based on this. You only need this if you want to run the automated test suite.
doxygen ≥1.4.43 C/C++ automated documentation generator for building the XHTML documentation from the comments in the HLVM header files. You only need this if you intend to build the documentation.
xsltproc ≥2.6.243 XSLT Processor (comes with libxml2). This is used to transform the Relax NG schema for the HLVM Abstract Syntax Tree (AST) into documentation that describes the AST. You only need this if you intend to build the documentation.

Notes:

  1. Certain LLVM tools are being modified to accommodate HLVM as it progresses. Until this situation stabilizes you will be required to have a very fresh (recent) version of LLVM from the CVS sources. At some point in the future, an LLVM release will contain all the features that HLVM needs and this notice will be removed. Until then, you should obtain and build LLVM from CVS and keep it up to date regularly.

Additionally, your compilation host is expected to have the usual Unix utilities, specifically:

Building Other Packages

Single Separate Install Area

It is suggested that you keep a separate installation area for building the things upon which HLVM depends. This is the location in your file system where you will install the built packages. It is the parameter to the --prefix options to the configure programs of those packages. By using a separate install area, you ensure that the HLVM version of required packages doesn't interfere with any of your system installed packages.

libxml2

apr

apr-util

llvm

llvm-gcc4

gperf

deja-gnu/

Building HLVM With SCons

Quick Start

If you took our advice and built all dependent packages (except llvm-gcc4) into a separate install area, then you can build HLVM quickly by using this command:

  scons -Q mode=debug confpath=/path/to/llvm-gcc4/install:/path/to/install

The confpath option indicates to the HLVM build system some additional places to search for software. The first path should be the location in which the llmv-gcc4 software was installed. The second path should be the Single Separate Install Area where you installed all the other packages such as llvm, apr, apr-util, etc.

About SCons And HLVM

HLVM uses the SCons tool for software construction. While make and the various auto* tools were originally used, the full programming language support of SCons (Python) was attractive because of the platform support and the need to do intricate things to build HLVM. HLVM's use of SCons departs a bit from the norm because SCons doesn't provide everything that HLVM needs. If you are not familiar with SCons, we recommend you take a quick peek at the SCons User Manual. While an in depth knowledge is not needed to build HLVM, having some understanding of scons will definitely help.

The details on using scons for HLVM can be found in the Developer's Guide, but here's a precis to help you get started:

SCons Options Supported

The important options that may be given on the scons command line are:

Build Targets

The default build target will simply build all the libraries and tools. There are additional pseudo-targets (aliases in SCons lingo) that you can build:

Building HLVM With Make

If you don't want to learn how to use SCons, HLVM provides a Makefile that will invoke it for you. All the usual targets are provided. To use this facility, simply do a local edit of the Makefile and adjust the three variables:

MYMODE
Indicates the name of the build mode you want to build by default. This can be any string, but it will be more useful if it is one of these:
  • Debug - specifies a debug build with assertions turned on and inline functions turned off. Initialize this build mode with make Debug.
  • Optimized - specifies an optimized build with debug turned off, inline turned on, and assertions turned on. Initialize this build mode with make Optimized.
  • Release - specifies an optimized build with assertions turned off and symbols stripped. Initialize this build with make Release.
  • Profile - specifies an optimized profiling build with assertions turned off, inline turned on and with profiling options suitable for profiling the tools with gmon. Initialize this build with make Profile.
MYPATH
This provides a path for the 3rd party software that HLVM depends on. You should change this path to match your local environment. If you don't get this right then the first time you run scons, it will ask you to manually enter paths for things like the APR library and LLVM.
MYPREFIX
This provides the directory into which HLVM will be installed. If it is not specifed, the default will be /usr/local.

Once you've made these adjustments you can use the various targets in the Makefile to build HLVM. Note that these targets just convert the target into the appropriate invocation of the scons command.

Targets Supported

You can use the following targets to build HLVM in various ways:

all
Builds HLVM in the default mode, as specified by MYMODE. Typically this is a Debug build.
debug Debug
This builds HLVM in a mode named "Debug" and sets the various options appropriately for a debug build. You should use this target the first time you want a Debug build.
optimized Optimized
This builds HLVM in a mode named "Optimized" and sets the various options appropriately for an optimized build. You should use this target the first time you want an Optimized build.
release Release
This builds HLVM in a mode named "Release" and sets the various options appropriately for a release build. You should use this target the first time you want a Release build.
profile Profile
This builds HLVM in a mode named "Profile" and sets the various options appropriately for an profiled build. You should use this target the first time you want an Profile build.
check
This doesn't build HLVM but instead invokes the test suite via dejagnu. Use this to make sure that your local modifications haven't caused any regressions.
clean
This removes all the build targets that were previously built. The next time you build the all target, everything will be rebuilt.
doc
This builds the documentation for HLVM. It will run doxygen and xsltproc to build the generated portion of the documentation.
hlvm
This provides a partial build of HLVM. It descends into the hlvm directory and builds only the libraries located there.
install
This will installed HLVM libraries, headers and executable tools into the directory named by the MYPREFIX variable.
tools
This provides a partial build of HLVM. It skips building the libraries in the hlvm directory and instead descends into the tools and builds the executable tools there.

Tips And Tricks