Getting started - lkuper/rust GitHub Wiki

Prerequisites

Version numbers listed here are “what we’re using”; the code may well work with earlier versions of these tools, but we don’t know minimum version requirements.

  • A recent Linux, OS X or Win32 system
  • Python 3.1 (versions as old as Python 2.6.2 have also been used successfully)
  • GNU make 3.81
  • git 1.7
  • g++ 4.4 at least on linux, 4.5 on win32, and the 4.x gcc in Apple’s SDK for OS X.
  • curl
  • Valgrind 3.5 (recommended but not required for Linux)
  • Texinfo’s makeinfo and/or texi2pdf commands, if you wish to build HTML or PDF docs, respectively
  • A recent LLVM SVN revision, built for x86 (not x64 if you have one!). See the directions below for how to build LLVM.

Debian-based Linux distributions

You can install all the prerequisites you need to build Rust by running

sudo apt-get install python3 make git g++ curl valgrind texinfo

On 64-bit systems, you’ll also need:

sudo apt-get install g++-multilib ia32-libs

Arch Linux

See the information on multilib setups.

Windows

We recommend developing under the newest MinGW packages using their auto-installer.

For Git, we recommend MsysGit and if you use that you will want to put the git binary path after the MinGW path. So add a line like the following to your .bashrc:

export PATH=$PATH:/c/Program\ Files/Git/bin

Installing LLVM

Rust requires a 3.1svn build of LLVM at revision 142082. Follow the instructions on Clang’s Getting Started page to check out LLVM (and Clang, if you like), but don’t follow the build instructions on that page — see below.

svn co -r142082 http://llvm.org/svn/llvm-project/llvm/trunk llvm

Later revisions might work, but since Rust is building against LLVM’s trunk, not every revision will work correctly. The revision number listed above is a minimum that’s known to work. If you’re having trouble finding an LLVM revision that works, ask on IRC and somebody will tell you which revision is working for them.

Building with clang (Experimental)

The Rust runtime can be built with clang, though it is only regularly tested on Mac and known to have problems on Linux. To do so you’ll need to build clang from SVN along with LLVM. If you’re using clang (revision 137491), you will also need to check out compiler-rt revision 133487 (later revisions are broken):

cd llvm/projects
svn co -r133487 http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
cd llvm/tools
svn co -r137491 http://llvm.org/svn/llvm-project/cfe/trunk clang

Rust’s configure script will automatically use clang if it finds an appropriate version; otherwise, it will use gcc.

Building LLVM

Because Rust doesn’t support x86-64 yet, you may need to configure LLVM using some special flags. On the Mac, use:

cd llvm
CXX='g++ -m32' CC='gcc -m32' CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 ./configure --disable-bindings --{build,host,target}=i686-apple-darwin --enable-targets=x86,x86_64,cbe --enable-optimized
make
sudo make install

On 64-bit Linux, use:

cd llvm
CXX='g++ -m32' CC='gcc -m32' CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 ./configure --disable-bindings --{build,host,target}=i686-unknown-linux-gnu --enable-targets=x86,x86_64,cbe --enable-optimized
CXXFLAGS='-fno-omit-frame-pointer' make
sudo make install

(The `-fno-omit-frame-pointer` part is necessary if you want gdb backtraces when an LLVM assertion hits.)

On 32-bit Linux ./configure --enable-optimized; make; make install should be sufficient. If you omit the --enable-optimized flag, it’ll work, but more slowly.

Mingw-cross

Rust occasionally works under mingw-cross compilation on linux. This is experimental but can sometimes lead to a more pleasant windows development experience. To configure LLVM for this, do the following:

# assuming llvm is in $SRCROOT/llvm and rust in $SRCROOT/rust
sudo apt-get install wine1.2 mingw{,-binutils,-runtime} 
cd $SRCROOT
mkdir llvm-{build,inst}-mingw; cd llvm-build-mingw
STRIP=i586-mingw32msvc-strip NM=i586-mingw32msvc-nm CXX=i586-mingw32msvc-g++ CC=i586-mingw32msvc-gcc LD=i586-mingw32msvc-ld AS=i586-mingw32msvc-as RANLIB=i586-mingw32msvc-ranlib ../llvm/configure --prefix=$SRCROOT/llvm-inst-mingw32/ --disable-bindings --build=i686-unknown-linux-gnu --{host,target}=i586-mingw32 --enable-targets=x86,x86_64 --enable-optimized
make && make install
cd $SRCROOT/rust
mkdir mingw-build; cd mingw-build
CFG_LLVM_ROOT=$SRCROOT/llvm-inst-mingw32/ CFG_LLVM_CONFIG=$SRCROOT/llvm-inst-mingw32/bin/llvm-config ../configure --enable-mingw-cross

If you are tremendously lucky and patient, you may convince that to work. But as mentioned above, experimental. We’ll support this when we can.

Downloading and building Rust

git clone git://github.com/graydon/rust.git
cd rust
mkdir build
cd build
../configure
make check

This will build and test the compiler and standard library.

Note: On Linux or OS X, if you have Valgrind installed, the tests will run slowly because they are running under Valgrind. If you define CFG_DISABLE_VALGRIND=1 in your build environment or run configure with the --disable-valgrind flag, you can see the tests running at full speed.

For development, it is recommended that you configure with --disable-optimize, since this will greatly speed up your compilation.

Navigating

There’s a quick guide to the source of the compiler in src/comp/README. You should probably look through it if you’re going to be contributing.

Editor support

Syntax highlighting for vim is included in the Rust repository, under src/etc/vim. There is also a rust-mode for emacs and a BBEdit plugin.

The issue tracker

We use the GitHub issue tracker to track bugs and feature requests in Rust. If you prefer not to use the standard GitHub issue tracker, there’s a secondary front-end that is quite a bit more responsive and a tertiary front-end that is pleasantly minimal.

Picking something interesting to do

We’ve recently transitioned off the bootstrap compiler and are moving full steam ahead with the self-hosted compiler. To get an idea of where we’re going, see the Roadmap.

Outstanding bugs or feature requests in Rust typically have a corresponding test in the test suite that doesn’t yet pass. One good way to jump into Rust development is to look for files in the test/run-pass directory containing the string ‘xfail-test’. Those are all bugs that need to be fixed or features that someone needs to finish. Another way to get involved is to look through the issue tracker for open issues tagged with ‘easy’, or with ‘unassigned’, or both.

If in doubt, ask on IRC. Somebody will surely have a task that needs doing.

Communicating

Join irc.mozilla.org #rust for real-time discussion of Rust development. We try to remain on that channel during working hours in UTC-7 (US Pacific).

Join the mailing list for longer conversations.

In both cases, please follow the conduct guidelines on the Development policy page.

⚠️ **GitHub.com Fallback** ⚠️