blob: 283efdd2411564f962cdaf210c43eec37384a55a [file] [log] [blame] [view]
Brian Andersona08c5aa2012-07-10 05:18:371# The Rust Programming Language
Austin Seipp62c4d2c2012-01-23 21:53:122
Peter Atashianbe43c652016-06-27 17:51:273This is the main source code repository for [Rust]. It contains the compiler,
4standard library, and 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
Demetri Obenour08207c92016-04-30 21:21:1819 * `g++` 4.7 or later 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
Brian Anderson59db95b2016-06-02 00:41:2722 * `cmake` 2.8.8 or later
Kevin Yap24fa6be2015-02-21 22:46:0623 * `curl`
24 * `git`
Steve Klabnikf645cad2015-02-13 17:26:4425
Brian Anderson7430e582015-02-18 21:46:20262. Clone the [source] with `git`:
Jack Moffitt8d64fa32013-07-18 23:27:4327
Kevin Yap24fa6be2015-02-21 22:46:0628 ```sh
29 $ git clone https://github.com/rust-lang/rust.git
30 $ cd rust
31 ```
Jack Moffitt8d64fa32013-07-18 23:27:4332
Brian Anderson4acc4832015-02-16 04:20:2533[source]: https://github.com/rust-lang/rust
34
353. Build and install:
Adrien Tétara30d61b2014-01-11 14:19:3836
Kevin Yap24fa6be2015-02-21 22:46:0637 ```sh
38 $ ./configure
39 $ make && make install
40 ```
Adrien Tétara30d61b2014-01-11 14:19:3841
Kevin Yap24fa6be2015-02-21 22:46:0642 > ***Note:*** You may need to use `sudo make install` if you do not
43 > normally have permission to modify the destination directory. The
44 > install locations can be adjusted by passing a `--prefix` argument
45 > to `configure`. Various other options are also supported pass
46 > `--help` for more information on them.
Jack Moffitt8d64fa32013-07-18 23:27:4347
48 When complete, `make install` will place several programs into
Corey Richardson25fe2ca2014-02-02 07:56:5549 `/usr/local/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
Brian Anderson21ed20b2015-02-16 04:41:1650 API-documentation tool. This install does not include [Cargo],
51 Rust's package manager, which you may also want to build.
52
53[Cargo]: https://github.com/rust-lang/cargo
Jack Moffitt8d64fa32013-07-18 23:27:4354
Luqman Aden8b833552014-06-27 00:07:4455### Building on Windows
56
Steve Klabnik011a23e2016-01-04 17:33:4357There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by
58Visual Studio, and the GNU ABI used by the GCC toolchain. Which version of Rust
59you need depends largely on what C/C++ libraries you want to interoperate with:
60for interop with software produced by Visual Studio use the MSVC build of Rust;
61for interop with GNU software built using the MinGW/MSYS2 toolchain use the GNU
62build.
63
64
65#### MinGW
66
Alex Crichtoncb74a582016-06-27 23:02:0667[MSYS2][msys2] can be used to easily build Rust on Windows:
Luqman Aden8b833552014-06-27 00:07:4468
Alex Crichtonb67f23c2016-07-06 18:35:3369[msys2]: https://msys2.github.io/
Luqman Aden8b833552014-06-27 00:07:4470
Alex Crichtoncb74a582016-06-27 23:02:06711. Grab the latest [MSYS2 installer][msys2] and go through the installer.
72
732. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
74 MSYS2 (i.e. `C:\msys64`), depending on whether you want 32-bit or 64-bit
75 Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd
76 -mingw32` or `msys2_shell.cmd -mingw64` from the command line instead)
77
783. From this terminal, install the required tools:
Luqman Aden8b833552014-06-27 00:07:4479
Kevin Yap24fa6be2015-02-21 22:46:0680 ```sh
Jake Shadle371c0ea2015-08-28 07:46:2381 # Update package mirrors (may be needed if you have a fresh install of MSYS2)
Jake Shadle7ab8ed82015-08-28 18:24:1382 $ pacman -Sy pacman-mirrors
Alex Crichtoncb74a582016-06-27 23:02:0683
84 # Install build tools needed for Rust. If you're building a 32-bit compiler,
85 # then replace "x86_64" below with "i686". If you've already got git, python,
86 # or CMake installed and in PATH you can remove them from this list. Note
87 # that it is important that the `python2` and `cmake` packages **not** used.
88 # The build has historically been known to fail with these packages.
89 $ pacman -S git \
90 make \
91 diffutils \
92 mingw-w64-x86_64-python2 \
93 mingw-w64-x86_64-cmake \
94 mingw-w64-x86_64-gcc
Steve Klabnik011a23e2016-01-04 17:33:4395 ```
Carlos Liam3967e1c2015-10-06 15:14:1196
Alex Crichtoncb74a582016-06-27 23:02:06974. Navigate to Rust's source code (or clone it), then configure and build it:
Kevin Yap24fa6be2015-02-21 22:46:0698
99 ```sh
100 $ ./configure
101 $ make && make install
102 ```
Bryce Van Dykee24add2015-10-22 08:52:17103
Steve Klabnik011a23e2016-01-04 17:33:43104#### MSVC
105
106MSVC builds of Rust additionally require an installation of Visual Studio 2013
107(or later) so `rustc` can use its linker. Make sure to check the “C++ tools”
Alex Crichtonb67f23c2016-07-06 18:35:33108option.
Steve Klabnik011a23e2016-01-04 17:33:43109
110With these dependencies installed, the build takes two steps:
111
112```sh
113$ ./configure
114$ make && make install
115```
Luqman Aden8b833552014-06-27 00:07:44116
Peter Atashianbe43c652016-06-27 17:51:27117#### MSVC with rustbuild
118
Alex Crichtonb67f23c2016-07-06 18:35:33119The old build system, based on makefiles, is currently being rewritten into a
120Rust-based build system called rustbuild. This can be used to bootstrap the
121compiler on MSVC without needing to install MSYS or MinGW. All you need are
122[Python 2](https://www.python.org/downloads/),
123[CMake](https://cmake.org/download/), and
124[Git](https://git-scm.com/downloads) in your PATH (make sure you do not use the
125ones from MSYS if you have it installed). You'll also need Visual Studio 2013 or
126newer with the C++ tools. Then all you need to do is to kick off rustbuild.
Peter Atashianbe43c652016-06-27 17:51:27127
Alex Crichtonb67f23c2016-07-06 18:35:33128```
129python .\src\bootstrap\bootstrap.py
130```
131
132Currently rustbuild only works with some known versions of Visual Studio. If you
133have a more recent version installed that a part of rustbuild doesn't understand
134then you may need to force rustbuild to use an older version. This can be done
135by manually calling the appropriate vcvars file before running the bootstrap.
136
137```
Peter Atashianbe43c652016-06-27 17:51:27138CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat"
139python .\src\bootstrap\bootstrap.py
140```
141
Steve Klabnikfd53ea22015-08-18 17:49:20142## Building Documentation
143
144If you’d like to build the documentation, it’s almost the same:
145
146```sh
Joachim Viideb18ed5b2016-06-30 13:15:17147$ ./configure
Steve Klabnikfd53ea22015-08-18 17:49:20148$ make docs
149```
150
151Building the documentation requires building the compiler, so the above
152details will apply. Once you have the compiler built, you can
153
154```sh
Bryce Van Dyk3ed49ef2015-10-20 08:02:19155$ make docs NO_REBUILD=1
Steve Klabnikfd53ea22015-08-18 17:49:20156```
157
158To make sure you don’t re-build the compiler because you made a change
159to some documentation.
160
161The generated documentation will appear in a top-level `doc` directory,
162created by the `make` rule.
163
Jack Moffitt8d64fa32013-07-18 23:27:43164## Notes
165
166Since the Rust compiler is written in Rust, it must be built by a
167precompiled "snapshot" version of itself (made in an earlier state of
168development). As such, source builds require a connection to the Internet, to
169fetch snapshots, and an OS that can execute the available snapshot binaries.
Austin Seipp62c4d2c2012-01-23 21:53:12170
Brian Anderson4c833af2012-10-11 00:56:38171Snapshot binaries are currently built and tested on several platforms:
Brian Anderson3403e412012-07-10 05:20:32172
Richo Healey6f3701d2015-05-12 06:43:58173| Platform \ Architecture | x86 | x86_64 |
174|--------------------------------|-----|--------|
175| Windows (7, 8, Server 2008 R2) | ✓ | ✓ |
176| Linux (2.6.18 or later) | ✓ | ✓ |
177| OSX (10.7 Lion or later) | ✓ | ✓ |
Austin Seipp62c4d2c2012-01-23 21:53:12178
Adrien Tétara30d61b2014-01-11 14:19:38179You may find that other platforms work, but these are our officially
Brian Anderson4c833af2012-10-11 00:56:38180supported build environments that are most likely to work.
Austin Seipp62c4d2c2012-01-23 21:53:12181
Peter Atashianbe43c652016-06-27 17:51:27182Rust currently needs between 600MiB and 1.5GiB to build, depending on platform.
183If it hits swap, it will take a very long time to build.
Brian Anderson4c833af2012-10-11 00:56:38184
Brian Andersonc2735712015-02-18 21:48:46185There is more advice about hacking on Rust in [CONTRIBUTING.md].
Austin Seipp62c4d2c2012-01-23 21:53:12186
Brian Andersonc2735712015-02-18 21:48:46187[CONTRIBUTING.md]: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md
Austin Seipp62c4d2c2012-01-23 21:53:12188
Kevin Yap24fa6be2015-02-21 22:46:06189## Getting Help
Brian Andersoncd1fabe2014-08-22 18:04:35190
191The Rust community congregates in a few places:
192
Kevin Yap24fa6be2015-02-21 22:46:06193* [Stack Overflow] - Direct questions about using the language.
194* [users.rust-lang.org] - General discussion and broader questions.
Brian Anderson5716ede2015-01-29 23:49:00195* [/r/rust] - News and general discussion.
Brian Andersoncd1fabe2014-08-22 18:04:35196
Kevin Yap24fa6be2015-02-21 22:46:06197[Stack Overflow]: http://stackoverflow.com/questions/tagged/rust
Brian Andersoncd1fabe2014-08-22 18:04:35198[/r/rust]: http://reddit.com/r/rust
Eli Friedmanbbbfed22015-08-09 21:15:05199[users.rust-lang.org]: https://users.rust-lang.org/
Steve Klabnikf645cad2015-02-13 17:26:44200
201## Contributing
202
Daniel Lobato García13d5e572015-03-08 21:37:23203To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).
Brian Andersoncd1fabe2014-08-22 18:04:35204
Brian Anderson46189552015-02-16 04:58:06205Rust has an [IRC] culture and most real-time collaboration happens in a
206variety of channels on Mozilla's IRC network, irc.mozilla.org. The
207most popular channel is [#rust], a venue for general discussion about
David AO Lozanoc233f2e2016-03-31 02:07:53208Rust. And a good place to ask for help would be [#rust-beginners].
Brian Anderson46189552015-02-16 04:58:06209
210[IRC]: https://en.wikipedia.org/wiki/Internet_Relay_Chat
Brian Anderson7430e582015-02-18 21:46:20211[#rust]: irc://irc.mozilla.org/rust
David AO Lozanoc233f2e2016-03-31 02:07:53212[#rust-beginners]: irc://irc.mozilla.org/rust-beginners
Brian Anderson46189552015-02-16 04:58:06213
Brian Andersonc92d2ed2012-07-10 05:13:48214## License
Austin Seipp62c4d2c2012-01-23 21:53:12215
Brian Anderson11a99182012-12-28 21:40:33216Rust is primarily distributed under the terms of both the MIT license
217and the Apache License (Version 2.0), with portions covered by various
218BSD-like licenses.
Austin Seipp62c4d2c2012-01-23 21:53:12219
Peter Atashianbe43c652016-06-27 17:51:27220See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and
221[COPYRIGHT](COPYRIGHT) for details.