Just An Application

May 28, 2013

Building Rust For Mac OS X: The Programming Language Not The Iron Oxide

Filed under: MacOSX, Programming Languages, Rust — Tags: , , , — Simon Lewis @ 6:11 pm

1.0 Prerequisites

To build Rust for Mac OS X you will need the Xcode development environment plus the lastest Rust tarball. At the time of writing that is version 0.6 which you can find here.

2.0 Building The Standard Way

Once you have downloaded the tarball and unpacked it, then on the command line cd to the root directory of the distribution

    cd $(WHEREVER_YOU_UNPACKED_THE_TARBALL)/rust-0.6

The instructions for building can be found in the file Readme.md in the root directory.

By default it is very simple.

On the command line, just do

    ./configure

followed by

    make

to build everything, followed by

    make install

which will install the various build products into the bin and lib subdirectories of

    /usr/local

Depending on who owns the various subdirectories of /usr/local you may need to run the last step as root

    sudo make install

3.0 Building The Non-Standard Way

I like to avoid ending up with a whole bunch of intermediate and final build products mixed up with the source code if I can help it, and I don’t like dumping everything and the kitchen sink into /usr/local so I did things a little differently.

If you do it this way the entire build is done in a completely separate directory tree, which is useful when you need to throw everything away and start again, or if you want to build multiple variants.

Once you have downloaded the tarball and unpacked it, decide where you want to do the build. The build directory can be anywhere you want.

Create the build directory if necessary then on the command line cd to it

   cd $(BUILD_DIR)

Now run the configure script which is in the root of the directory which was created when the tarball was created like this

    $(WHEREVER_YOU_UNPACKED_THE_TARBALL)/configure --prefix=$(WHEREVER_YOU_WANT_THINGS_TO_BE_INSTALLED)

In my case the root directory of the unpacked tarball was

    /Users/simon/Src/lang/rust-0.6

My build directory was

   /Users/simon/Scratch/rust/rust_0_6/macosx

and I wanted the binaries etc. installed in

   /Users/simon/Dev/tools/rust/macosx

so what I did was

  cd /Users/simon/Scratch/rust/rust_0_6/macosx

followed by

  /Users/simon/Src/lang/rust-0.6/configure --prefix=/Users/simon/Dev/tools/rust/macosx

If you don’t mind having everything dumped under /usr/local then omit the --prefix arg.

Once the configuration is complete just do

    make

on the command line.

If all goes well then this step is going to take a while since, amongst other things, it appears to build all of llvm from src.

Once it has finished do

    make install

on the command line to install the binaries and libraries that have been built.

5.0 Build Products

You should end up with the following in the directories under wherever you specified as the installation directory

  • in bin

    • rust

    • rustc

    • rustdoc

    • rusti

    • rustpkg

  • in lib

    • libcore-c3ca5d77d81b46c1-0.6.dylib

    • librust-39583f72884834e3-0.6.dylib

    • librustc-c84825241471686d-0.6.dylib

    • librusti-5047c7f210c7cac8-0.6.dylib

    • librustllvm.dylib

    • librustrt.dylib

    • libstd-4782a756585a81-0.6.dylib

    • libsyntax-84efebcb12c867a2-0.6.dylib

  • in lib/rustc/x86_64-apple-darwin/lib

    • libcore-c3ca5d77d81b46c1-0.6.dylib

    • libmorestack.a

    • librust-39583f72884834e3-0.6.dylib

    • librustc-c84825241471686d-0.6.dylib

    • librustdoc-1ac3c0763957e4b0-0.6.dylib

    • librusti-5047c7f210c7cac8-0.6.dylib

    • librustpkg-795073e423d025b-0.6.dylib

    • librustrt.dylib

    • libstd-4782a756585a81-0.6.dylib

    • libsyntax-84efebcb12c867a2-0.6.dylib


Copyright (c) 2013 By Simon Lewis. All Rights Reserved.

Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and owner Simon Lewis is strictly prohibited.

Excerpts and links may be used, provided that full and clear credit is given to Simon Lewis and justanapplication.wordpress.com with appropriate and specific direction to the original content.

Create a free website or blog at WordPress.com.

%d bloggers like this: