Skip to content

Commit f8012db

Browse files
authored
Rename src/libstd to library/std etc. (#815)
1 parent 5bde3ef commit f8012db

18 files changed

+78
-77
lines changed

src/backend/implicit-caller-location.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() {
1717
}
1818
```
1919

20-
Prior to Rust 1.42, panics like this `unwrap()` printed a location in libcore:
20+
Prior to Rust 1.42, panics like this `unwrap()` printed a location in core:
2121

2222
```
2323
$ rustc +1.41.0 example.rs; example.exe

src/building/bootstrapping.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The `stage2` compiler is the one distributed with `rustup` and all other
2525
install methods. However, it takes a very long time to build because one must
2626
first build the new compiler with an older compiler and then use that to
2727
build the new compiler with itself. For development, you usually only want
28-
the `stage1` compiler: `x.py build --stage 1 src/libstd`.
28+
the `stage1` compiler: `x.py build --stage 1 library/std`.
2929

3030
## Complications of bootstrapping
3131

@@ -128,7 +128,7 @@ The following tables indicate the outputs of various stage actions:
128128
|-----------------------------------------------------------|----------------------------------------------|
129129
| `beta` extracted | `build/HOST/stage0` |
130130
| `stage0` builds `bootstrap` | `build/bootstrap` |
131-
| `stage0` builds `libtest`/`libstd` | `build/HOST/stage0-std/TARGET` |
131+
| `stage0` builds `test`/`std` | `build/HOST/stage0-std/TARGET` |
132132
| copy `stage0-std` (HOST only) | `build/HOST/stage0-sysroot/lib/rustlib/HOST` |
133133
| `stage0` builds `rustc` with `stage0-sysroot` | `build/HOST/stage0-rustc/HOST` |
134134
| copy `stage0-rustc (except executable)` | `build/HOST/stage0-sysroot/lib/rustlib/HOST` |
@@ -143,7 +143,7 @@ The following tables indicate the outputs of various stage actions:
143143
| copy (uplift) `stage0-rustc` executable to `stage1` | `build/HOST/stage1/bin` |
144144
| copy (uplift) `stage0-codegen` to `stage1` | `build/HOST/stage1/lib` |
145145
| copy (uplift) `stage0-sysroot` to `stage1` | `build/HOST/stage1/lib` |
146-
| `stage1` builds `libtest`/`libstd` | `build/HOST/stage1-std/TARGET` |
146+
| `stage1` builds `test`/`std` | `build/HOST/stage1-std/TARGET` |
147147
| copy `stage1-std` (HOST only) | `build/HOST/stage1/lib/rustlib/HOST` |
148148
| `stage1` builds `rustc` | `build/HOST/stage1-rustc/HOST` |
149149
| copy `stage1-rustc` (except executable) | `build/HOST/stage1/lib/rustlib/HOST` |
@@ -155,7 +155,7 @@ The following tables indicate the outputs of various stage actions:
155155
|--------------------------------------------------------|-----------------------------------------------------------------|
156156
| copy (uplift) `stage1-rustc` executable | `build/HOST/stage2/bin` |
157157
| copy (uplift) `stage1-sysroot` | `build/HOST/stage2/lib and build/HOST/stage2/lib/rustlib/HOST` |
158-
| `stage2` builds `libtest`/`libstd` (not HOST targets) | `build/HOST/stage2-std/TARGET` |
158+
| `stage2` builds `test`/`std` (not HOST targets) | `build/HOST/stage2-std/TARGET` |
159159
| copy `stage2-std` (not HOST targets) | `build/HOST/stage2/lib/rustlib/TARGET` |
160160
| `stage2` builds `rustdoc` | `build/HOST/stage2-tools/HOST` |
161161
| copy `rustdoc` | `build/HOST/stage2/bin` |
@@ -196,21 +196,21 @@ later copied into stage2 as well (both the compiler's `libdir` and the
196196
This `std` is pretty much necessary for any useful work with the compiler.
197197
Specifically, it's used as the `std` for programs compiled by the newly compiled
198198
compiler (so when you compile `fn main() { }` it is linked to the last `std`
199-
compiled with `x.py build --stage 1 src/libstd`).
199+
compiled with `x.py build --stage 1 library/std`).
200200

201201
The `rustc` generated by the stage0 compiler is linked to the freshly-built
202-
`libstd`, which means that for the most part only `std` needs to be cfg-gated,
202+
`std`, which means that for the most part only `std` needs to be cfg-gated,
203203
so that `rustc` can use featured added to std immediately after their addition,
204-
without need for them to get into the downloaded beta. The `libstd` built by the
204+
without need for them to get into the downloaded beta. The `std` built by the
205205
`stage1/bin/rustc` compiler, also known as "stage1 std artifacts", is not
206206
necessarily ABI-compatible with that compiler.
207207
That is, the `rustc` binary most likely could not use this `std` itself.
208208
It is however ABI-compatible with any programs that the `stage1/bin/rustc`
209209
binary builds (including itself), so in that sense they're paired.
210210

211-
This is also where `--keep-stage 1 src/libstd` comes into play. Since most
211+
This is also where `--keep-stage 1 library/std` comes into play. Since most
212212
changes to the compiler don't actually change the ABI, once you've produced a
213-
`libstd` in stage 1, you can probably just reuse it with a different compiler.
213+
`std` in stage 1, you can probably just reuse it with a different compiler.
214214
If the ABI hasn't changed, you're good to go, no need to spend the time
215215
recompiling that `std`.
216216
`--keep-stage` simply assumes the previous compile is fine and copies those
@@ -254,12 +254,12 @@ variables that are used. If you are trying to run an intermediate version of
254254
manually. Otherwise, you get an error like the following:
255255

256256
```text
257-
thread 'main' panicked at 'RUSTC_STAGE was not set: NotPresent', src/libcore/result.rs:1165:5
257+
thread 'main' panicked at 'RUSTC_STAGE was not set: NotPresent', library/core/src/result.rs:1165:5
258258
```
259259

260260
If `./stageN/bin/rustc` gives an error about environment variables, that
261261
usually means something is quite wrong -- or you're trying to compile e.g.
262-
`librustc` or `libstd` or something that depends on environment variables. In
262+
`librustc` or `std` or something that depends on environment variables. In
263263
the unlikely case that you actually need to invoke rustc in such a situation,
264264
you can find the environment variable values by adding the following flag to
265265
your `x.py` command: `--on-fail=print-env`.

src/building/compiler-documenting.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ and then it documents the files.
3030
```bash
3131
./x.py doc src/doc/book
3232
./x.py doc src/doc/nomicon
33-
./x.py doc src/doc/book src/libstd
33+
./x.py doc src/doc/book library/std
3434
```
3535

3636
Much like individual tests or building certain components you can build only

src/building/how-to-build-and-run.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ assertions = true
5252
# `true`, because an unoptimized rustc with debugging
5353
# enabled becomes *unusably slow* (e.g. rust-lang/rust#24840
5454
# reported a 25x slowdown) and bootstrapping the supposed
55-
# "maximally debuggable" environment (notably libstd) takes
55+
# "maximally debuggable" environment (notably std) takes
5656
# hours to build.
5757
#
5858
debug = true
@@ -92,7 +92,7 @@ One thing to keep in mind is that `rustc` is a _bootstrapping_
9292
compiler. That is, since `rustc` is written in Rust, we need to use an
9393
older version of the compiler to compile the newer version. In
9494
particular, the newer version of the compiler and some of the artifacts needed
95-
to build it, such as `libstd` and other tooling, may use some unstable features
95+
to build it, such as `std` and other tooling, may use some unstable features
9696
internally, requiring a specific version which understands these unstable
9797
features.
9898

@@ -176,16 +176,16 @@ Once you've created a config.toml, you are now ready to run
176176
probably the best "go to" command for building a local rust:
177177

178178
```bash
179-
./x.py build -i src/libstd
179+
./x.py build -i library/std
180180
```
181181

182-
This may *look* like it only builds `libstd`, but that is not the case.
182+
This may *look* like it only builds `std`, but that is not the case.
183183
What this command does is the following:
184184

185-
- Build `libstd` using the stage0 compiler (using incremental)
185+
- Build `std` using the stage0 compiler (using incremental)
186186
- Build `librustc` using the stage0 compiler (using incremental)
187187
- This produces the stage1 compiler
188-
- Build `libstd` using the stage1 compiler (cannot use incremental)
188+
- Build `std` using the stage1 compiler (cannot use incremental)
189189

190190
This final product (stage1 compiler + libs built using that compiler)
191191
is what you need to build other rust programs (unless you use `#![no_std]` or
@@ -201,7 +201,7 @@ stage1 libraries. This is because incremental only works when you run
201201
the *same compiler* twice in a row. In this case, we are building a
202202
*new stage1 compiler* every time. Therefore, the old incremental
203203
results may not apply. **As a result, you will probably find that
204-
building the stage1 `libstd` is a bottleneck for you** -- but fear not,
204+
building the stage1 `std` is a bottleneck for you** -- but fear not,
205205
there is a (hacky) workaround. See [the section on "recommended
206206
workflows"](./suggested.md) below.
207207

@@ -211,23 +211,23 @@ build. The **full** `rustc` build (what you get if you say `./x.py build
211211

212212
- Build `librustc` and `rustc` with the stage1 compiler.
213213
- The resulting compiler here is called the "stage2" compiler.
214-
- Build `libstd` with stage2 compiler.
214+
- Build `std` with stage2 compiler.
215215
- Build `librustdoc` and a bunch of other things with the stage2 compiler.
216216

217217
<a name=toolchain></a>
218218

219219
## Build specific components
220220

221-
Build only the libcore library
221+
- Build only the core library
222222

223223
```bash
224-
./x.py build src/libcore
224+
./x.py build library/core
225225
```
226226

227-
Build the libcore and libproc_macro library only
227+
- Build the core and proc_macro libraries only
228228

229229
```bash
230-
./x.py build src/libcore src/libproc_macro
230+
./x.py build library/core library/proc_macro
231231
```
232232

233233
Sometimes you might just want to test if the part you’re working on can
@@ -277,11 +277,11 @@ in other sections:
277277

278278
- Building things:
279279
- `./x.py build` – builds everything using the stage 1 compiler,
280-
not just up to `libstd`
280+
not just up to `std`
281281
- `./x.py build --stage 2` – builds the stage2 compiler
282282
- Running tests (see the [section on running tests](../tests/running.html) for
283283
more details):
284-
- `./x.py test src/libstd` – runs the `#[test]` tests from `libstd`
284+
- `./x.py test library/std` – runs the `#[test]` tests from `std`
285285
- `./x.py test src/test/ui` – runs the `ui` test suite
286286
- `./x.py test src/test/ui/const-generics` - runs all the tests in
287287
the `const-generics/` subdirectory of the `ui` test suite

src/building/new-target.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ cross-compile `rustc`:
9494
```
9595
DESTDIR=/path/to/install/in \
9696
./x.py install -i --stage 1 --host aarch64-apple-darwin.json --target aarch64-apple-darwin \
97-
src/librustc src/libstd
97+
src/librustc library/std
9898
```
9999

100100
If your target specification is already available in the bootstrap

src/building/suggested.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ don't work (but that is easily detected and fixed).
5858

5959
The sequence of commands you want is as follows:
6060

61-
- Initial build: `./x.py build -i src/libstd`
61+
- Initial build: `./x.py build -i library/std`
6262
- As [documented above](#command), this will build a functional
6363
stage1 compiler as part of running all stage0 commands (which include
64-
building a `libstd` compatible with the stage1 compiler) as well as the
64+
building a `std` compatible with the stage1 compiler) as well as the
6565
first few steps of the "stage 1 actions" up to "stage1 (sysroot stage1)
66-
builds libstd".
67-
- Subsequent builds: `./x.py build -i src/libstd --keep-stage 1`
66+
builds std".
67+
- Subsequent builds: `./x.py build -i library/std --keep-stage 1`
6868
- Note that we added the `--keep-stage 1` flag here
6969

7070
As mentioned, the effect of `--keep-stage 1` is that we just *assume* that the

src/contributing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ You can find documentation style guidelines in [RFC 1574][rfc1574].
364364
In many cases, you don't need a full `./x.py doc --stage 2`, which will build
365365
the entire stage 2 compiler and compile the various books published on
366366
[doc.rust-lang.org][docs]. When updating documentation for the standard library,
367-
first try `./x.py doc src/libstd`. If that fails, or if you need to
367+
first try `./x.py doc library/std`. If that fails, or if you need to
368368
see the output from the latest version of `rustdoc`, add `--stage 1`.
369369
Results should appear in `build/$TARGET/crate-docs`.
370370

src/getting-started.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ should still read the rest of the section:
175175
| Command | When to use it |
176176
| --- | --- |
177177
| `x.py check` | Quick check to see if things compile; rust-analyzer can run this automatically for you |
178-
| `x.py build --stage 0 [src/libstd]` | Build only the standard library, without building the compiler |
179-
| `x.py build src/libstd` | Build just the 1st stage of the compiler, along with the standard library; this is faster than building stage 2 and usually good enough |
180-
| `x.py build --keep-stage 1 src/libstd` | Build the 1st stage of the compiler and skips rebuilding the standard library; this is useful after you've done an ordinary stage1 build to skip compilation time, but it can cause weird problems. (Just do a regular build to resolve.) |
178+
| `x.py build --stage 0 [library/std]` | Build only the standard library, without building the compiler |
179+
| `x.py build library/std` | Build just the 1st stage of the compiler, along with the standard library; this is faster than building stage 2 and usually good enough |
180+
| `x.py build --keep-stage 1 library/std` | Build the 1st stage of the compiler and skips rebuilding the standard library; this is useful after you've done an ordinary stage1 build to skip compilation time, but it can cause weird problems. (Just do a regular build to resolve.) |
181181
| `x.py test [--keep-stage 1]` | Run the test suite using the stage1 compiler |
182182
| `x.py test --bless [--keep-stage 1]` | Run the test suite using the stage1 compiler _and_ update expected test output. |
183183
| `x.py build --stage 2 src/rustc` | Do a full 2-stage build. You almost never want to do this. |
@@ -203,10 +203,10 @@ For most contributions, you only need to build stage 1, which saves a lot of tim
203203

204204
```sh
205205
# Build the compiler (stage 1)
206-
./x.py build src/libstd
206+
./x.py build library/std
207207

208208
# Subsequent builds
209-
./x.py build --keep-stage 1 src/libstd
209+
./x.py build --keep-stage 1 library/std
210210
```
211211

212212
This will take a while, especially the first time. Be wary of accidentally
@@ -294,10 +294,10 @@ stage 0, which uses the current beta compiler.
294294
```
295295

296296
```sh
297-
./x.py test --stage 0 src/libstd
297+
./x.py test --stage 0 library/std
298298
```
299299

300-
(The same works for `src/liballoc`, `src/libcore`, etc.)
300+
(The same works for `library/alloc`, `library/core`, etc.)
301301

302302
### Building and Testing `rustdoc`
303303

src/panic-implementation.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
#### Step 1: Invocation of the `panic!` macro.
44

5-
There are actually two panic macros - one defined in `libcore`, and one defined in `libstd`.
6-
This is due to the fact that code in `libcore` can panic. `libcore` is built before `libstd`,
7-
but we want panics to use the same machinery at runtime, whether they originate in `libcore`
8-
or `libstd`.
5+
There are actually two panic macros - one defined in `core`, and one defined in `std`.
6+
This is due to the fact that code in `core` can panic. `core` is built before `std`,
7+
but we want panics to use the same machinery at runtime, whether they originate in `core`
8+
or `std`.
99

10-
##### libcore definition of panic!
10+
##### core definition of panic!
1111

12-
The `libcore` `panic!` macro eventually makes the following call (in `src/libcore/panicking.rs`):
12+
The `core` `panic!` macro eventually makes the following call (in `library/core/src/panicking.rs`):
1313

1414
```rust
1515
// NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call
@@ -29,13 +29,13 @@ Actually resolving this goes through several layers of indirection:
2929
to set the actual symbol name to `rust_begin_unwind`.
3030

3131
Note that `panic_impl` is declared in an `extern "Rust"` block,
32-
which means that libcore will attempt to call a foreign symbol called `rust_begin_unwind`
32+
which means that core will attempt to call a foreign symbol called `rust_begin_unwind`
3333
(to be resolved at link time)
3434

35-
2. In `src/libstd/panicking.rs`, we have this definition:
35+
2. In `library/std/src/panicking.rs`, we have this definition:
3636

3737
```rust
38-
/// Entry point of panic from the libcore crate.
38+
/// Entry point of panic from the core crate.
3939
#[cfg(not(test))]
4040
#[panic_handler]
4141
#[unwind(allowed)]
@@ -47,18 +47,18 @@ pub fn begin_panic_handler(info: &PanicInfo<'_>) -> ! {
4747
The special `panic_handler` attribute is resolved via `src/librustc_middle/middle/lang_items`.
4848
The `extract` function converts the `panic_handler` attribute to a `panic_impl` lang item.
4949

50-
Now, we have a matching `panic_handler` lang item in the `libstd`. This function goes
51-
through the same process as the `extern { fn panic_impl }` definition in `libcore`, ending
52-
up with a symbol name of `rust_begin_unwind`. At link time, the symbol reference in `libcore`
53-
will be resolved to the definition of `libstd` (the function called `begin_panic_handler` in the
50+
Now, we have a matching `panic_handler` lang item in the `std`. This function goes
51+
through the same process as the `extern { fn panic_impl }` definition in `core`, ending
52+
up with a symbol name of `rust_begin_unwind`. At link time, the symbol reference in `core`
53+
will be resolved to the definition of `std` (the function called `begin_panic_handler` in the
5454
Rust source).
5555

56-
Thus, control flow will pass from libcore to std at runtime. This allows panics from `libcore`
56+
Thus, control flow will pass from core to std at runtime. This allows panics from `core`
5757
to go through the same infrastructure that other panics use (panic hooks, unwinding, etc)
5858

59-
##### libstd implementation of panic!
59+
##### std implementation of panic!
6060

61-
This is where the actual panic-related logic begins. In `src/libstd/panicking.rs`,
61+
This is where the actual panic-related logic begins. In `library/std/src/panicking.rs`,
6262
control passes to `rust_panic_with_hook`. This method is responsible
6363
for invoking the global panic hook, and checking for double panics. Finally,
6464
we call `__rust_start_panic`, which is provided by the panic runtime.
@@ -84,13 +84,13 @@ Finally, we call `__rust_start_panic` with this `usize`. We have now entered the
8484

8585
#### Step 2: The panic runtime
8686

87-
Rust provides two panic runtimes: `libpanic_abort` and `libpanic_unwind`. The user chooses
87+
Rust provides two panic runtimes: `panic_abort` and `panic_unwind`. The user chooses
8888
between them at build time via their `Cargo.toml`
8989

90-
`libpanic_abort` is extremely simple: its implementation of `__rust_start_panic` just aborts,
90+
`panic_abort` is extremely simple: its implementation of `__rust_start_panic` just aborts,
9191
as you would expect.
9292

93-
`libpanic_unwind` is the more interesting case.
93+
`panic_unwind` is the more interesting case.
9494

9595
In its implementation of `__rust_start_panic`, we take the `usize`, convert
9696
it back to a `*mut &mut dyn BoxMeUp`, dereference it, and call `box_me_up`
@@ -99,10 +99,11 @@ itself (a `*mut (dyn Send + Any)`): that is, a raw pointer to the actual value
9999
provided by the user who called `panic!`.
100100

101101
At this point, the platform-independent code ends. We now call into
102-
platform-specific unwinding logic (e.g `libunwind`). This code is
102+
platform-specific unwinding logic (e.g `unwind`). This code is
103103
responsible for unwinding the stack, running any 'landing pads' associated
104104
with each frame (currently, running destructors), and transferring control
105105
to the `catch_unwind` frame.
106106

107107
Note that all panics either abort the process or get caught by some call to `catch_unwind`:
108-
in `src/libstd/rt.rs`, the call to the user-provided `main` function is wrapped in `catch_unwind`.
108+
in `library/std/src/rt.rs`, the call to the user-provided
109+
`main` function is wrapped in `catch_unwind`.

0 commit comments

Comments
 (0)