Skip to content

Updating the Rust compiler used by Servo

E. Dunham edited this page Jul 31, 2015 · 22 revisions

The Rust compiler is prebuilt for Servo, targeting our main host platforms (OSX and Linux), each targeting both the native host platform and Android.

Prebuilding a Rust compiler

To create a new cached Rust compiler:

  1. Fetch the latest upstream changes from a checkout of git@github.com:rust-lang/rust.git

    git fetch upstream
    
  2. Create a branch with the hash of the Rust commit you are interested in:

    git checkout 0935beba717bf6d3b54ad1b2eace359dea5dfca0
    
  3. Build with cross-compilation enabled. Linux (MUST have GLIBC version 2.17 installed locally!). Include the path to an Android NDK obtained following the directions on https://github.com/servo/servo/wiki/Building-for-Android.

    ./configure --host=x86_64-unknown-linux-gnu,i686-unknown-linux-gnu --target=arm-linux-androideabi --disable-llvm-assertions --android-cross-path=/home/larsberg/ndk-standalone && make clean ; make -j4 rustc-stage2 && make dist
    

OSX: ./configure --host=x86_64-apple-darwin,i686-apple-darwin --target=arm-linux-androideabi --disable-llvm-assertions --android-cross-path=/Users/larsberg/ndk-standalone/ && make clean ; make -j4 rustc-stage2 && make dist

  1. Upload the binary produced to the s3 bucket:
    s3cmd put dist/rust* s3://servo-rust/0935beba717bf6d3b54ad1b2eace359dea5dfca0/
    

Updating the Rust compiler version used in Servo

Once a build has been uploaded, the SHA of the head commit from our Rust fork needs to be entered into the file src/compiler/rust-snapshot-hash/. A subsequent run of the configure script will pull down the new compiler from our S3 bucket and use that instead of the old one.

All of our updates are done against a branch named rustup_DATE, which should be created using the date when we started performing the Rust upgrade.

Creating a good Linux host

Since rustc takes a dynamic dependency on GLIBC on Linux, you need to be careful with the host version of GLIBC when generating these binaries. I recommend the following steps:

  1. Install Ubuntu 12.04 LTS. This version has a GLIBC 2.15, which is old enough for even the most out-of-date of our Linux developers.

  2. Install gcc-4.7 and g++-4.7. You will also need to sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7 to make 4.7 the default instead of 4.6.3.

  3. Install the Rust depedendencies listed at: https://github.com/rust-lang/rust/.

  4. Install the Android NDK (link available at https://github.com/servo/servo/wiki/Building-for-Android; note that the SDK is NOT required!).

At this point, you should have a machine that has the proper basic system dependencies to build a snapshot.

Updating dependencies

Servo's dependencies fall into two categories:

  1. Libraries maintained by the servo team. For these projects, the main development "trunk" is the master branch in the servo/<project> repo, and this is also the branch used in Servo builds.

  2. Libraries with a separate upstream maintainer. For these projects, the Servo team maintains a fork at servo/<project> with a servo branch. This is the branch used in Servo builds, and it may also contain Servo-specific changes (e.g. changes that are not yet accepted upstream, or that are not useful outside of the Servo build system). The servo fork should not contain a master branch, since that branch is not used by the Servo team and could cause confusion if it is out of sync with the servo branch or the upstream master branch.

When upgrading Servo to a new version of Rust, use the following steps to update each submodule:

  1. Make a local clone of the project that you want to change.

  2. Update Servo's Cargo overrides to use that clone instead by editing the .cargo/config file to have an entry in paths pointing at the local clone (see http://doc.crates.io/config.html for an example).

  3. Merge any changes from the upstream repo (if there is one) into the servo repo's servo branch—except for changes that require a newer version of Rust than the one Servo is upgrading to.

  4. Create a new branch named rustup_<date> in the servo fork of the submodule. For example, rustup_20140508.

  5. Push any required changes to the rustup_* branch. When ready, submit a pull request to the upstream repo for any changes that apply to upstream (if there is one). Then submit a pull request to the servo repo to merge the same changes, plus any Servo-specific changes. (If there is no separate upstream, just submit a single pull request to the master branch in the servo repo.)

  6. If you do not have push access to that repo, submit a pull request against a rustup_* branch in that repo.

  7. After the changes are reviewed and merged, remove the .cargo/config paths entry and then use cargo update SUBMODULE -p HASH to update Servo to use the updated dependency.

  8. Either push your new changes to Servo's rustup_DATE branch or open a PR, if you do not have push access to the Servo repo. Note that we review all Rust upgrade changes at once at the end when it is about to be landed rather than incrementally as the upgrade progresses, in order to bias towards speed of getting the new build up and running.

Testing

To test whether a snapshot was built correctly, copy it into the local servo directory and attempt to build Servo.

Clone this wiki locally