Skip to content

Commit 9755de7

Browse files
committed
README for esp-rs/rust
1 parent 33e0521 commit 9755de7

File tree

1 file changed

+10
-287
lines changed

1 file changed

+10
-287
lines changed

README.md

Lines changed: 10 additions & 287 deletions
Original file line numberDiff line numberDiff line change
@@ -1,287 +1,25 @@
1-
# The Rust Programming Language
1+
# The Rust Programming Language for Espressif chips
22

3-
[![Rust Community](https://img.shields.io/badge/Rust_Community%20-Join_us-brightgreen?style=plastic&logo=rust)](https://www.rust-lang.org/community)
3+
This fork enables projects to be built for the Xtensa-based ESP32, ESP32-SXX and ESP8266 using [Espressif's llvm fork](https://github.com/espressif/llvm-project). (RiscV chips like ESP32-CXX are already supported in stock Rust.)
44

5-
This is the main source code repository for [Rust]. It contains the compiler,
6-
standard library, and documentation.
5+
Moreover, this fork enables Rust STD support (networking, threads, and filesystem) for all chips in the ESP32 family (Xtensa and RiscV), by optionally linking with the ESP-IDF framework.
76

8-
[Rust]: https://www.rust-lang.org/
7+
The [esp-rs](https://github.com/esp-rs) organization has been formed to develop runtime, pac and hal crates for the Espressif chips (bare-metal as well as ESP-IDF based).
98

10-
**Note: this README is for _users_ rather than _contributors_.**
11-
If you wish to _contribute_ to the compiler, you should read
12-
[CONTRIBUTING.md](CONTRIBUTING.md) instead.
9+
Join in on the discussion: https://matrix.to/#/#esp-rs:matrix.org!
1310

14-
## Quick Start
11+
## Installation
1512

16-
Read ["Installation"] from [The Book].
13+
Please see the most up to date instructions in the [esp rust book](https://esp-rs.github.io/book/).
1714

18-
["Installation"]: https://doc.rust-lang.org/book/ch01-01-installation.html
19-
[The Book]: https://doc.rust-lang.org/book/index.html
15+
## Building from source
2016

21-
## Installing from Source
17+
If you wish to build this fork from source, the instructions are almost identical to the ones upstream ([follow here](https://github.com/rust-lang/rust#installing-from-source)), however before beginning the build, run the following `./configure` command:
2218

23-
The Rust build system uses a Python script called `x.py` to build the compiler,
24-
which manages the bootstrapping process. It lives at the root of the project.
25-
It also uses a file named `config.toml` to determine various configuration settings for the build.
26-
You can see a full list of options in `config.example.toml`.
27-
28-
The `x.py` command can be run directly on most Unix systems in the following
29-
format:
30-
31-
```sh
32-
./x.py <subcommand> [flags]
33-
```
34-
35-
This is how the documentation and examples assume you are running `x.py`.
36-
Some alternative ways are:
37-
38-
```sh
39-
# On a Unix shell if you don't have the necessary `python3` command
40-
./x <subcommand> [flags]
41-
42-
# On the Windows Command Prompt (if .py files are configured to run Python)
43-
x.py <subcommand> [flags]
44-
45-
# You can also run Python yourself, e.g.:
46-
python x.py <subcommand> [flags]
47-
```
48-
49-
More information about `x.py` can be found by running it with the `--help` flag
50-
or reading the [rustc dev guide][rustcguidebuild].
51-
52-
[gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html
53-
[rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html
54-
55-
### Dependencies
56-
57-
Make sure you have installed the dependencies:
58-
59-
* `python` 3 or 2.7
60-
* `git`
61-
* A C compiler (when building for the host, `cc` is enough; cross-compiling may
62-
need additional compilers)
63-
* `curl` (not needed on Windows)
64-
* `pkg-config` if you are compiling on Linux and targeting Linux
65-
* `libiconv` (already included with glibc on Debian-based distros)
66-
67-
To build Cargo, you'll also need OpenSSL (`libssl-dev` or `openssl-devel` on
68-
most Unix distros).
69-
70-
If building LLVM from source, you'll need additional tools:
71-
72-
* `g++`, `clang++`, or MSVC with versions listed on
73-
[LLVM's documentation](https://llvm.org/docs/GettingStarted.html#host-c-toolchain-both-compiler-and-standard-library)
74-
* `ninja`, or GNU `make` 3.81 or later (Ninja is recommended, especially on
75-
Windows)
76-
* `cmake` 3.13.4 or later
77-
* `libstdc++-static` may be required on some Linux distributions such as Fedora
78-
and Ubuntu
79-
80-
On tier 1 or tier 2 with host tools platforms, you can also choose to download
81-
LLVM by setting `llvm.download-ci-llvm = true`.
82-
Otherwise, you'll need LLVM installed and `llvm-config` in your path.
83-
See [the rustc-dev-guide for more info][sysllvm].
84-
85-
[sysllvm]: https://rustc-dev-guide.rust-lang.org/building/new-target.html#using-pre-built-llvm
86-
87-
88-
### Building on a Unix-like system
89-
90-
#### Build steps
91-
92-
1. Clone the [source] with `git`:
93-
94-
```sh
95-
git clone https://github.com/rust-lang/rust.git
96-
cd rust
97-
```
98-
99-
[source]: https://github.com/rust-lang/rust
100-
101-
2. Configure the build settings:
102-
103-
```sh
104-
./configure
105-
```
106-
107-
If you plan to use `x.py install` to create an installation, it is
108-
recommended that you set the `prefix` value in the `[install]` section to a
109-
directory: `./configure --set install.prefix=<path>`
110-
111-
3. Build and install:
112-
113-
```sh
114-
./x.py build && ./x.py install
115-
```
116-
117-
When complete, `./x.py install` will place several programs into
118-
`$PREFIX/bin`: `rustc`, the Rust compiler, and `rustdoc`, the
119-
API-documentation tool. By default, it will also include [Cargo], Rust's package manager.
120-
You can disable this behavior by passing `--set build.extended=false` to `./configure`.
121-
122-
[Cargo]: https://github.com/rust-lang/cargo
123-
124-
#### Configure and Make
125-
126-
This project provides a configure script and makefile (the latter of which just invokes `x.py`).
127-
`./configure` is the recommended way to programatically generate a `config.toml`. `make` is not
128-
recommended (we suggest using `x.py` directly), but it is supported and we try not to break it
129-
unnecessarily.
130-
131-
```sh
132-
./configure
133-
make && sudo make install
134-
```
135-
136-
`configure` generates a `config.toml` which can also be used with normal `x.py` invocations.
137-
138-
### Building on Windows
139-
140-
On Windows, we suggest using [winget] to install dependencies by running the
141-
following in a terminal:
142-
143-
```powershell
144-
winget install -e Python.Python.3
145-
winget install -e Kitware.CMake
146-
winget install -e Git.Git
147-
```
148-
149-
Then edit your system's `PATH` variable and add: `C:\Program Files\CMake\bin`.
150-
See
151-
[this guide on editing the system `PATH`](https://www.java.com/en/download/help/path.html)
152-
from the Java documentation.
153-
154-
[winget]: https://github.com/microsoft/winget-cli
155-
156-
There are two prominent ABIs in use on Windows: the native (MSVC) ABI used by
157-
Visual Studio and the GNU ABI used by the GCC toolchain. Which version of Rust
158-
you need depends largely on what C/C++ libraries you want to interoperate with.
159-
Use the MSVC build of Rust to interop with software produced by Visual Studio
160-
and the GNU build to interop with GNU software built using the MinGW/MSYS2
161-
toolchain.
162-
163-
#### MinGW
164-
165-
[MSYS2][msys2] can be used to easily build Rust on Windows:
166-
167-
[msys2]: https://www.msys2.org/
168-
169-
1. Download the latest [MSYS2 installer][msys2] and go through the installer.
170-
171-
2. Run `mingw32_shell.bat` or `mingw64_shell.bat` from the MSYS2 installation
172-
directory (e.g. `C:\msys64`), depending on whether you want 32-bit or 64-bit
173-
Rust. (As of the latest version of MSYS2 you have to run `msys2_shell.cmd
174-
-mingw32` or `msys2_shell.cmd -mingw64` from the command line instead.)
175-
176-
3. From this terminal, install the required tools:
177-
178-
```sh
179-
# Update package mirrors (may be needed if you have a fresh install of MSYS2)
180-
pacman -Sy pacman-mirrors
181-
182-
# Install build tools needed for Rust. If you're building a 32-bit compiler,
183-
# then replace "x86_64" below with "i686". If you've already got Git, Python,
184-
# or CMake installed and in PATH you can remove them from this list.
185-
# Note that it is important that you do **not** use the 'python2', 'cmake',
186-
# and 'ninja' packages from the 'msys2' subsystem.
187-
# The build has historically been known to fail with these packages.
188-
pacman -S git \
189-
make \
190-
diffutils \
191-
tar \
192-
mingw-w64-x86_64-python \
193-
mingw-w64-x86_64-cmake \
194-
mingw-w64-x86_64-gcc \
195-
mingw-w64-x86_64-ninja
196-
```
197-
198-
4. Navigate to Rust's source code (or clone it), then build it:
199-
200-
```sh
201-
python x.py setup user && python x.py build && python x.py install
202-
```
203-
204-
#### MSVC
205-
206-
MSVC builds of Rust additionally require an installation of Visual Studio 2017
207-
(or later) so `rustc` can use its linker. The simplest way is to get
208-
[Visual Studio], check the "C++ build tools" and "Windows 10 SDK" workload.
209-
210-
[Visual Studio]: https://visualstudio.microsoft.com/downloads/
211-
212-
(If you're installing CMake yourself, be careful that "C++ CMake tools for
213-
Windows" doesn't get included under "Individual components".)
214-
215-
With these dependencies installed, you can build the compiler in a `cmd.exe`
216-
shell with:
217-
218-
```sh
219-
python x.py setup user
220-
python x.py build
22119
```
222-
223-
Right now, building Rust only works with some known versions of Visual Studio.
224-
If you have a more recent version installed and the build system doesn't
225-
understand, you may need to force rustbuild to use an older version.
226-
This can be done by manually calling the appropriate vcvars file before running
227-
the bootstrap.
228-
229-
```batch
230-
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
231-
python x.py build
20+
./configure --experimental-targets=Xtensa --release-channel=nightly --enable-extended --tools=clippy,cargo,rustfmt --enable-lld
23221
```
23322

234-
#### Specifying an ABI
235-
236-
Each specific ABI can also be used from either environment (for example, using
237-
the GNU ABI in PowerShell) by using an explicit build triple. The available
238-
Windows build triples are:
239-
- GNU ABI (using GCC)
240-
- `i686-pc-windows-gnu`
241-
- `x86_64-pc-windows-gnu`
242-
- The MSVC ABI
243-
- `i686-pc-windows-msvc`
244-
- `x86_64-pc-windows-msvc`
245-
246-
The build triple can be specified by either specifying `--build=<triple>` when
247-
invoking `x.py` commands, or by creating a `config.toml` file (as described in
248-
[Building on a Unix-like system](#building-on-a-unix-like-system)), and passing `--set build.build=<triple>` to `./configure`.
249-
250-
## Building Documentation
251-
252-
If you'd like to build the documentation, it's almost the same:
253-
254-
```sh
255-
./x.py doc
256-
```
257-
258-
The generated documentation will appear under `doc` in the `build` directory for
259-
the ABI used. That is, if the ABI was `x86_64-pc-windows-msvc`, the directory
260-
will be `build\x86_64-pc-windows-msvc\doc`.
261-
262-
## Notes
263-
264-
Since the Rust compiler is written in Rust, it must be built by a precompiled
265-
"snapshot" version of itself (made in an earlier stage of development).
266-
As such, source builds require an Internet connection to fetch snapshots, and an
267-
OS that can execute the available snapshot binaries.
268-
269-
See https://doc.rust-lang.org/nightly/rustc/platform-support.html for a list of
270-
supported platforms.
271-
Only "host tools" platforms have a pre-compiled snapshot binary available; to
272-
compile for a platform without host tools you must cross-compile.
273-
274-
You may find that other platforms work, but these are our officially supported
275-
build environments that are most likely to work.
276-
277-
## Getting Help
278-
279-
See https://www.rust-lang.org/community for a list of chat platforms and forums.
280-
281-
## Contributing
282-
283-
See [CONTRIBUTING.md](CONTRIBUTING.md).
284-
28523
## License
28624

28725
Rust is primarily distributed under the terms of both the MIT license and the
@@ -290,18 +28,3 @@ licenses.
29028

29129
See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and
29230
[COPYRIGHT](COPYRIGHT) for details.
293-
294-
## Trademark
295-
296-
[The Rust Foundation][rust-foundation] owns and protects the Rust and Cargo
297-
trademarks and logos (the "Rust Trademarks").
298-
299-
If you want to use these names or brands, please read the
300-
[media guide][media-guide].
301-
302-
Third-party logos may be subject to third-party copyrights and trademarks. See
303-
[Licenses][policies-licenses] for details.
304-
305-
[rust-foundation]: https://foundation.rust-lang.org/
306-
[media-guide]: https://foundation.rust-lang.org/policies/logo-policy-and-media-guide/
307-
[policies-licenses]: https://www.rust-lang.org/policies/licenses

0 commit comments

Comments
 (0)