# GCC Compile Farm for rustc

**URL:** <https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511>\
**Category:** community\
**Created:** [February 25, 2019, 1:46am UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511 "2019-02-25T01:46:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexreg](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexreg/32/1630_2.png) [@alexreg](https://internals.rust-lang.org/u/alexreg)\
**Post date:** [February 25, 2019, 1:46am UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/1 "2019-02-25T01:46:19Z")

</div>

I’ve noticed that some people like me have started to view the [GCC Compile Farm](https://cfarm.tetaneutral.net/) as an attractive option for building rustc in the case that you a) don’t have a powerful computer to build on, b) need to build on other architectures, c) other valid reasons. However, it is not terribly straightforward to setup and use the GCC Farm, and the nature of a compile farm presents challenges to the ordinary edit-build-test workflow that most people are used to running locally.

So, I thought I’d share my set-up along with a couple of Bash scripts I wrote to assist with using GCC Farm for rustc.

Firstly, ensure you have registered on the [GCC Compile Farm website](https://cfarm.tetaneutral.net/), been approved, uploaded your public key for SSH, and waited for it to sync to the farm machines. You probably want to edit your SSH configuration to something like:

[`~/.ssh/gcc-compile-farm`](https://gist.github.com/6a9160ec5bd726d79297665c59475ae5)

`~/.ssh/config` (append)

```rust
Host gcc*.fsffrance.org
	ControlMaster auto
	ControlPath ~/.ssh/control-%h:%p:%r
	HostName %h
	User <username>
	IdentityFile <keyfile>

Include gcc-compile-farm

```

Next, when you actually want to use a server, I recommend keeping an active connection to one so that a master control connection is always open an available. This makes the workflow a bit smoother and faster.

Finally, the workflow scripts… The idea is to make the workflow for the developer as analogous as possible to the typical machine-local one. Put these scripts in your path (and make sure they’re executable, of course).

[**Workflow Scripts**](https://gist.github.com/alexreg/49346f9f2026e528b248d0a240334c14)

Here’s an example session (assuming in you’re in a rustc repo directory):

```rust
$ export GCC_FARM_SERVER=gcc10 # gcc10.fsffrance.org
$ gcc-farm-rustc -s ./x.py build # syncs local dir to the server using rsync, then runs x.py to build
$ gcc-farm-rustc -t ./x.py test # runs x.py to perform all tests on server, then syncs back "blessed" test results using rsync
$ gcc-farm-rustc -s # just syncs local dir
$ gcc-farm-rustc -t # just syncs back test outputs to local dir

```

The working tree (i.e., current state of the directory) of rustc is in fact synchronised to the server, albeit ignoring all the same files that `.gitignore` does. Thus, there is no need to commit before syncing.

Note that the `gcc-farm` script can be used generically, or built upon by another script like how `gcc-farm-rustc` does. Inspect the scripts for environment variables that can be used to control behaviour.

In any case, your particular needs may deviate somewhat from my above set-up, but I thought I’d post this here as a guide to those getting started, in case it helps anyone. Feel free to post your own suggestions on this thread too.

(Thanks to @dlrobertson for discussing this with me and helping to test my scripts.)

---

<div class="post-metadata">

**Author:** ![mark-i-m](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/mark-i-m/32/3167_2.png) [@mark-i-m](https://internals.rust-lang.org/u/mark-i-m)\
**Post date:** [February 25, 2019, 6:53pm UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/2 "2019-02-25T18:53:04Z")

</div>

@alexreg How long does a build take? Would it be possible to use something like this to speed up CI builds?

---

<div class="post-metadata">

**Author:** ![alexreg](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexreg/32/1630_2.png) [@alexreg](https://internals.rust-lang.org/u/alexreg)\
**Post date:** [February 25, 2019, 9:03pm UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/3 "2019-02-25T21:03:40Z")

</div>

@mark-i-m Depends on the machine you’re using, but anywhere from on par with a good laptop to significantly faster. You can see the specs of the machines on the “list of machines” page of the website. Note that the maintainers instruct you to use only half the number of machine cores at most at one time.

---

<div class="post-metadata">

**Author:** ![dlrobertson](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/dlrobertson/32/3826_2.png) [@dlrobertson](https://internals.rust-lang.org/u/dlrobertson)\
**Post date:** [February 26, 2019, 11:45pm UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/4 "2019-02-26T23:45:41Z")

</div>

I wonder if fuzzers are within the intended use of GCC farm. I’ve thought about setting up a `rustc` fuzzer on a GCC farm box.

---

<div class="post-metadata">

**Author:** ![alexreg](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexreg/32/1630_2.png) [@alexreg](https://internals.rust-lang.org/u/alexreg)\
**Post date:** [March 14, 2019, 2:43am UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/5 "2019-03-14T02:43:14Z")

</div>

I’ve updated the Gist a bit lately, in case anyone is using them…

---

<div class="post-metadata">

**Author:** ![gnzlbg](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/gnzlbg/32/3858_2.png) [@gnzlbg](https://internals.rust-lang.org/u/gnzlbg)\
**Post date:** [March 14, 2019, 8:47am UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/6 "2019-03-14T08:47:35Z")

</div>

I’m using it and works for me, thank you. The GCC compile farm is great for those that don’t have a very powerful machine.

---

<div class="post-metadata">

**Author:** ![alexreg](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexreg/32/1630_2.png) [@alexreg](https://internals.rust-lang.org/u/alexreg)\
**Post date:** [May 6, 2019, 1:32am UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/7 "2019-05-06T01:32:58Z")

</div>

Glad to hear. Yes, it is. Or even for those of us with a decent machine who want to use it for something else relatively CPU-intensive while building rustc.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [August 4, 2019, 1:33am UTC](https://internals.rust-lang.org/t/gcc-compile-farm-for-rustc/9511/8 "2019-08-04T01:33:01Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
