blob: 2298aeb2fdd45abef2ee20ba68e79f907661e68f [file] [log] [blame] [view]
Brian Andersona08c5aa2012-07-10 05:18:371# The Rust Programming Language
Austin Seipp62c4d2c2012-01-23 21:53:122
Brian Anderson77938292015-11-09 21:22:163This is the main source code repository for [Rust]. It contains the compiler, standard library,
4and documentation.
Nick Hamann74f18182015-05-15 05:43:405
Brian Anderson77938292015-11-09 21:22:166[Rust]: https://www.rust-lang.org
Tshepang Lekhonkhobea8680de2015-06-18 21:48:517
Jack Moffitt8d64fa32013-07-18 23:27:438## Quick Start
Brian Andersonc92d2ed2012-07-10 05:13:489
Brian Anderson73cc4ed2015-02-16 05:20:2710Read ["Installing Rust"] from [The Book].
Austin Seipp62c4d2c2012-01-23 21:53:1211
Andrew Barchuk1339ca92016-01-29 09:45:3712["Installing Rust"]: https://doc.rust-lang.org/book/getting-started.html#installing-rust
Eli Friedmanbbbfed22015-08-09 21:15:0513[The Book]: https://doc.rust-lang.org/book/index.html
Jack Moffitt8d64fa32013-07-18 23:27:4314
Alex Crichton46867cc2014-04-02 23:59:3915## Building from Source
Jack Moffitt8d64fa32013-07-18 23:27:4316
Adrien Tétara30d61b2014-01-11 14:19:38171. Make sure you have installed the dependencies:
Kevin Yap24fa6be2015-02-21 22:46:0618
19 * `g++` 4.7 or `clang++` 3.x
Robin Kruppe999051d2016-02-13 20:19:4420 * `python` 2.7 (but not 3.x)
Kevin Yap24fa6be2015-02-21 22:46:0621 * GNU `make` 3.81 or later
22 * `curl`
23 * `git`
Steve Klabnikf645cad2015-02-13 17:26:4424
Brian Anderson7430e582015-02-18 21:46:20252. Clone the [source] with `git`:
Jack Moffitt8d64fa32013-07-18 23:27:4326
Kevin Yap24fa6be2015-02-21 22:46:0627 ```sh
28 $ git clone https://github.com/rust-lang/rust.git
29 $ cd rust
30 ```
Jack Moffitt8d64fa32013-07-18 23:27:4331
Brian Anderson4acc4832015-02-16 04:20:2532[source]: https://github.com/rust-lang/rust
33
343. Build and install:
Adrien Tétara30d61b2014-01-11 14:19:3835
Kevin Yap24fa6be2015-02-21 22:46:0636 ```sh
37 $ ./configure
38 $ make && make install
39 ```
Adrien Tétara30d61b2014-01-11 14:19:3840
Kevin Yap24fa6be2015-02-21 22:46:0641 > ***Note:*** You may need to use `sudo make install` if you do not
42 > normally have permission to modify the destination directory. The
43 > install locations can be adjusted by passing a `--prefix` argument
44 > to `configure`. Various other options are also supported pass
45 > `--help` for more information on them.
Jack Moffitt8d64fa32013-07-18 23:27:4346
47 When complete, `make install` will place several programs into
Corey Richardson25fe2ca2014-02-02 07:56:5548 `/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
Brian Anderson21ed20b2015-02-16 04:41:1649 API-documentation tool. This install does not include [Cargo],
50 Rust's package manager, which you may also want to build.
51
52[Cargo]: https://github.com/rust-lang/cargo
Jack Moffitt8d64fa32013-07-18 23:27:4353
Luqman Aden8b833552014-06-27 00:07:4454### Building on Windows
55
Steve Klabnik011a23e2016-01-04 17:33:4356There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by
57Visual Studio, and the GNU ABI used by the GCC toolchain. Which version of Rust
58you need depends largely on what C/C++ libraries you want to interoperate with:
59for interop with software produced by Visual Studio use the MSVC build of Rust;
60for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU
61build.
62
63
64#### MinGW
65
Kevin Yap24fa6be2015-02-21 22:46:0666[MSYS2](http://msys2.github.io/) can be used to easily build Rust on Windows:
Luqman Aden8b833552014-06-27 00:07:4467
681. Grab the latest MSYS2 installer and go through the installer.
Luqman Aden8b833552014-06-27 00:07:4469
Kevin Yap24fa6be2015-02-21 22:46:06702. From the MSYS2 terminal, install the `mingw64` toolchain and other required
71 tools.
Luqman Aden8b833552014-06-27 00:07:4472
Kevin Yap24fa6be2015-02-21 22:46:0673 ```sh
Jake Shadle371c0ea2015-08-28 07:46:2374 # Update package mirrors (may be needed if you have a fresh install of MSYS2)
Jake Shadle7ab8ed82015-08-28 18:24:1375 $ pacman -Sy pacman-mirrors
Steve Klabnik011a23e2016-01-04 17:33:4376 ```
Carlos Liam3967e1c2015-10-06 15:14:1177
Steve Klabnik011a23e2016-01-04 17:33:4378Download [MinGW from
79here](http://mingw-w64.org/doku.php/download/mingw-builds), and choose the
Vadim Petrochenkov90474c72016-03-20 20:36:4880`version=4.9.x,threads=win32,exceptions=dwarf/seh` flavor when installing. Also, make sure to install to a path without spaces in it. After installing,
Joshua Olson797e6fc2016-01-16 03:50:0381add its `bin` directory to your `PATH`. This is due to [#28260](https://github.com/rust-lang/rust/issues/28260), in the future,
Steve Klabnik011a23e2016-01-04 17:33:4382installing from pacman should be just fine.
Tamir Dubersteinf5765792015-03-14 23:09:2683
Steve Klabnik011a23e2016-01-04 17:33:4384 ```
Bryce Van Dyk3ed49ef2015-10-20 08:02:1985 # Make git available in MSYS2 (if not already available on path)
86 $ pacman -S git
87
Kevin Yap24fa6be2015-02-21 22:46:0688 $ pacman -S base-devel
89 ```
Steve Klabnik59923252015-01-12 21:00:0390
Kevin Yap24fa6be2015-02-21 22:46:06913. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
Kagami Sascha Rosylightf24089c2015-07-03 08:16:1392 MSYS2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
Luqman Aden8b833552014-06-27 00:07:4493
Kevin Yap24fa6be2015-02-21 22:46:06944. Navigate to Rust's source code, configure and build it:
95
96 ```sh
97 $ ./configure
98 $ make && make install
99 ```
Bryce Van Dykee24add2015-10-22 08:52:17100
Steve Klabnik011a23e2016-01-04 17:33:43101#### MSVC
102
103MSVC builds of Rust additionally require an installation of Visual Studio 2013
104(or later) so `rustc` can use its linker. Make sure to check the C++ tools
105option. In addition, `cmake` needs to be installed to build LLVM.
106
107With these dependencies installed, the build takes two steps:
108
109```sh
110$ ./configure
111$ make && make install
112```
Luqman Aden8b833552014-06-27 00:07:44113
Steve Klabnikfd53ea22015-08-18 17:49:20114## Building Documentation
115
116If youd like to build the documentation, its almost the same:
117
118```sh
119./configure
120$ make docs
121```
122
123Building the documentation requires building the compiler, so the above
124details will apply. Once you have the compiler built, you can
125
126```sh
Bryce Van Dyk3ed49ef2015-10-20 08:02:19127$ make docs NO_REBUILD=1
Steve Klabnikfd53ea22015-08-18 17:49:20128```
129
130To make sure you dont re-build the compiler because you made a change
131to some documentation.
132
133The generated documentation will appear in a top-level `doc` directory,
134created by the `make` rule.
135
Jack Moffitt8d64fa32013-07-18 23:27:43136## Notes
137
138Since the Rust compiler is written in Rust, it must be built by a
139precompiled "snapshot" version of itself (made in an earlier state of
140development). As such, source builds require a connection to the Internet, to
141fetch snapshots, and an OS that can execute the available snapshot binaries.
Austin Seipp62c4d2c2012-01-23 21:53:12142
Brian Anderson4c833af2012-10-11 00:56:38143Snapshot binaries are currently built and tested on several platforms:
Brian Anderson3403e412012-07-10 05:20:32144
Richo Healey6f3701d2015-05-12 06:43:58145| Platform \ Architecture | x86 | x86_64 |
146|--------------------------------|-----|--------|
147| Windows (7, 8, Server 2008 R2) | | |
148| Linux (2.6.18 or later) | | |
149| OSX (10.7 Lion or later) | | |
Austin Seipp62c4d2c2012-01-23 21:53:12150
Adrien Tétara30d61b2014-01-11 14:19:38151You may find that other platforms work, but these are our officially
Brian Anderson4c833af2012-10-11 00:56:38152supported build environments that are most likely to work.
Austin Seipp62c4d2c2012-01-23 21:53:12153
petevine5294f202015-12-07 00:12:53154Rust currently needs between 600MiB and 1.5GiB to build, depending on platform. If it hits
Jack Moffitt8d64fa32013-07-18 23:27:43155swap, it will take a very long time to build.
Brian Anderson4c833af2012-10-11 00:56:38156
Brian Andersonc2735712015-02-18 21:48:46157There is more advice about hacking on Rust in [CONTRIBUTING.md].
Austin Seipp62c4d2c2012-01-23 21:53:12158
Brian Andersonc2735712015-02-18 21:48:46159[CONTRIBUTING.md]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md
Austin Seipp62c4d2c2012-01-23 21:53:12160
Kevin Yap24fa6be2015-02-21 22:46:06161## Getting Help
Brian Andersoncd1fabe2014-08-22 18:04:35162
163The Rust community congregates in a few places:
164
Kevin Yap24fa6be2015-02-21 22:46:06165* [Stack Overflow] - Direct questions about using the language.
166* [users.rust-lang.org] - General discussion and broader questions.
Brian Anderson5716ede2015-01-29 23:49:00167* [/r/rust] - News and general discussion.
Brian Andersoncd1fabe2014-08-22 18:04:35168
Kevin Yap24fa6be2015-02-21 22:46:06169[Stack Overflow]: http://stackoverflow.com/questions/tagged/rust
Brian Andersoncd1fabe2014-08-22 18:04:35170[/r/rust]: http://reddit.com/r/rust
Eli Friedmanbbbfed22015-08-09 21:15:05171[users.rust-lang.org]: https://users.rust-lang.org/
Steve Klabnikf645cad2015-02-13 17:26:44172
173## Contributing
174
Daniel Lobato García13d5e572015-03-08 21:37:23175To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).
Brian Andersoncd1fabe2014-08-22 18:04:35176
Brian Anderson46189552015-02-16 04:58:06177Rust has an [IRC] culture and most real-time collaboration happens in a
178variety of channels on Mozilla's IRC network, irc.mozilla.org. The
179most popular channel is [#rust], a venue for general discussion about
Kevin Yap24fa6be2015-02-21 22:46:06180Rust, and a good place to ask for help.
Brian Anderson46189552015-02-16 04:58:06181
182[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
Brian Anderson7430e582015-02-18 21:46:20183[#rust]: irc://irc.mozilla.org/rust
Brian Anderson46189552015-02-16 04:58:06184
Brian Andersonc92d2ed2012-07-10 05:13:48185## License
Austin Seipp62c4d2c2012-01-23 21:53:12186
Brian Anderson11a99182012-12-28 21:40:33187Rust is primarily distributed under the terms of both the MIT license
188and the Apache License (Version 2.0), with portions covered by various
189BSD-like licenses.
Austin Seipp62c4d2c2012-01-23 21:53:12190
Daniel Lobato García13d5e572015-03-08 21:37:23191See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and [COPYRIGHT](COPYRIGHT) for details.