Skip to content

Commit e2e29de

Browse files
committed
Auto merge of rust-lang#74375 - Manishearth:rollup-10vbpdh, r=Manishearth
Rollup of 14 pull requests Successful merges: - rust-lang#72973 (RISC-V GNU/Linux as host platform) - rust-lang#73918 (Clean up E0715 explanation) - rust-lang#73959 (Clean up E0716 explanation) - rust-lang#74119 (Remove `Compiler::compile()`.) - rust-lang#74196 (Add option to collapse automatically implementors) - rust-lang#74218 (Add margin after doc search results) - rust-lang#74276 (improve DiscriminantKind handling) - rust-lang#74291 (Added docs for `From<c_int>` for `ExitStatus`) - rust-lang#74294 (Update cross-compilation README) - rust-lang#74337 (Handle case of incomplete local ty more gracefully) - rust-lang#74344 (Remove string comparison and use diagnostic item instead) - rust-lang#74347 (Initialize default providers only once) - rust-lang#74353 (Edit docs for rustc_middle::dep_graph::dep_node) - rust-lang#74374 (Add a 1.45 release note on lto vs. embed-bitcode) Failed merges: - rust-lang#74251 (Teach bootstrap about target files vs target triples) r? @ghost
2 parents 7e11379 + 0bde1c3 commit e2e29de

File tree

35 files changed

+221
-198
lines changed

35 files changed

+221
-198
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ jobs:
297297
- name: dist-powerpc64le-linux
298298
os: ubuntu-latest-xl
299299
env: {}
300+
- name: dist-riscv64-linux
301+
os: ubuntu-latest-xl
302+
env: {}
300303
- name: dist-s390x-linux
301304
os: ubuntu-latest-xl
302305
env: {}

RELEASES.md

+10
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ Stabilized APIs
8282
Cargo
8383
-----
8484

85+
- [Cargo uses the `embed-bitcode` flag to optimize disk usage and build
86+
time.][cargo/8066]
87+
8588
Misc
8689
----
8790
- [Rustdoc now supports strikethrough text in Markdown.][71928] E.g.
@@ -97,12 +100,18 @@ Compatibility Notes
97100
- [Rustdoc's CLI's extra error exit codes have been removed.][71900] These were
98101
previously undocumented and not intended for public use. Rustdoc still provides
99102
a non-zero exit code on errors.
103+
- [Rustc's `lto` flag is incompatible with the new `embed-bitcode=no`.][71848]
104+
This may cause issues if LTO is enabled through `RUSTFLAGS` or `cargo rustc`
105+
flags while cargo is adding `embed-bitcode` itself. The recommended way to
106+
control LTO is with Cargo profiles, either in `Cargo.toml` or `.cargo/config`,
107+
or by setting `CARGO_PROFILE_<name>_LTO` in the environment.
100108

101109
Internals Only
102110
--------------
103111
- [Make clippy a git subtree instead of a git submodule][70655]
104112
- [Unify the undo log of all snapshot types][69464]
105113

114+
[71848]: https://github.com/rust-lang/rust/issues/71848/
106115
[73420]: https://github.com/rust-lang/rust/issues/73420/
107116
[72324]: https://github.com/rust-lang/rust/pull/72324/
108117
[71843]: https://github.com/rust-lang/rust/pull/71843/
@@ -129,6 +138,7 @@ Internals Only
129138
[69813]: https://github.com/rust-lang/rust/pull/69813/
130139
[69464]: https://github.com/rust-lang/rust/pull/69464/
131140
[68717]: https://github.com/rust-lang/rust/pull/68717/
141+
[cargo/8066]: https://github.com/rust-lang/cargo/pull/8066
132142
[`Arc::as_ptr`]: https://doc.rust-lang.org/stable/std/sync/struct.Arc.html#method.as_ptr
133143
[`BTreeMap::remove_entry`]: https://doc.rust-lang.org/stable/std/collections/struct.BTreeMap.html#method.remove_entry
134144
[`Rc::as_ptr`]: https://doc.rust-lang.org/stable/std/rc/struct.Rc.html#method.as_ptr

src/bootstrap/native.rs

+22-2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ impl Step for Llvm {
112112
/// Compile LLVM for `target`.
113113
fn run(self, builder: &Builder<'_>) -> PathBuf {
114114
let target = self.target;
115+
let target_native = if self.target.starts_with("riscv") {
116+
// RISC-V target triples in Rust is not named the same as C compiler target triples.
117+
// This converts Rust RISC-V target triples to C compiler triples.
118+
let idx = target.find('-').unwrap();
119+
120+
format!("riscv{}{}", &target[5..7], &target[idx..])
121+
} else {
122+
target.to_string()
123+
};
115124

116125
let Meta { stamp, build_llvm_config, out_dir, root } =
117126
match prebuilt_llvm_config(builder, target) {
@@ -165,8 +174,8 @@ impl Step for Llvm {
165174
.define("LLVM_ENABLE_BINDINGS", "OFF")
166175
.define("LLVM_ENABLE_Z3_SOLVER", "OFF")
167176
.define("LLVM_PARALLEL_COMPILE_JOBS", builder.jobs().to_string())
168-
.define("LLVM_TARGET_ARCH", target.split('-').next().unwrap())
169-
.define("LLVM_DEFAULT_TARGET_TRIPLE", target);
177+
.define("LLVM_TARGET_ARCH", target_native.split('-').next().unwrap())
178+
.define("LLVM_DEFAULT_TARGET_TRIPLE", target_native);
170179

171180
if !target.contains("netbsd") {
172181
cfg.define("LLVM_ENABLE_ZLIB", "ON");
@@ -213,6 +222,17 @@ impl Step for Llvm {
213222
}
214223
}
215224

225+
if target.starts_with("riscv") {
226+
// In RISC-V, using C++ atomics require linking to `libatomic` but the LLVM build
227+
// system check cannot detect this. Therefore it is set manually here.
228+
if !builder.config.llvm_tools_enabled {
229+
cfg.define("CMAKE_EXE_LINKER_FLAGS", "-latomic");
230+
} else {
231+
cfg.define("CMAKE_EXE_LINKER_FLAGS", "-latomic -static-libstdc++");
232+
}
233+
cfg.define("CMAKE_SHARED_LINKER_FLAGS", "-latomic");
234+
}
235+
216236
if target.contains("msvc") {
217237
cfg.define("LLVM_USE_CRT_DEBUG", "MT");
218238
cfg.define("LLVM_USE_CRT_RELEASE", "MT");

src/ci/azure-pipelines/auto.yml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ jobs:
5353
dist-powerpc-linux: {}
5454
dist-powerpc64-linux: {}
5555
dist-powerpc64le-linux: {}
56+
dist-riscv64-linux: {}
5657
dist-s390x-linux: {}
5758
dist-x86_64-freebsd: {}
5859
dist-x86_64-illumos: {}

src/ci/docker/README.md

+31-8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ for example:
1616

1717
Images will output artifacts in an `obj` dir at the root of a repository.
1818

19+
To match conditions in rusts CI, also set the environment variable `DEPLOY=1`, e.g.:
20+
```
21+
DEPLOY=1 ./src/ci/docker/run.sh x86_64-gnu
22+
```
23+
1924
**NOTE**: Re-using the same `obj` dir with different docker images with
2025
the same target triple (e.g. `dist-x86_64-linux` and `dist-various-1`)
2126
may result in strange linker errors, due shared library versions differing between platforms.
@@ -85,42 +90,60 @@ how to generate them, and how the existing ones were generated.
8590
8691
### Generating a `.config` file
8792
93+
**NOTE:** Existing Dockerfiles can also be a good guide for the process and order
94+
of script execution.
95+
8896
If you have a `linux-cross` image lying around you can use that and skip the
8997
next two steps.
9098
91-
- First we spin up a container and copy `build_toolchain_root.sh` into it. All
99+
- First we spin up a container and copy all scripts into it. All
92100
these steps are outside the container:
93101
94102
```
95-
# Note: We use ubuntu:15.10 because that's the "base" of linux-cross Docker
96-
# image
97-
$ docker run -it ubuntu:15.10 bash
103+
# Note: We use ubuntu:16.04 because that's the "base" of linux-cross Docker
104+
# image, or simply run ./src/ci/docker/run.sh once, which will download the correct
105+
# one and you can check it out with `docker images`
106+
$ docker run -it ubuntu:16.04 bash
107+
# in another terminal:
98108
$ docker ps
99109
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
100-
cfbec05ed730 ubuntu:15.10 "bash" 16 seconds ago Up 15 seconds drunk_murdock
101-
$ docker cp build_toolchain_root.sh drunk_murdock:/
110+
cfbec05ed730 ubuntu:16.04 "bash" 16 seconds ago Up 15 seconds drunk_murdock
111+
$ docker cp src/ci/docker/scripts drunk_murdock:/tmp/
102112
```
103113
104114
- Then inside the container we build crosstool-ng by simply calling the bash
105115
script we copied in the previous step:
106116
107117
```
108-
$ bash build_toolchain_root.sh
118+
$ cd /tmp/scripts
119+
# Download packages necessary for building
120+
$ bash ./cross-apt-packages.sh
121+
# Download and build crosstool-ng
122+
$ bash ./crosstool-ng.sh
123+
```
124+
125+
- In case you want to adjust or start from an existing config, copy that
126+
to the container. `crosstool-ng` will automatically load `./.config` if
127+
present. Otherwise one can use the TUI to load any config-file.
128+
129+
```
130+
$ docker cp arm-linux-gnueabi.config drunk_murdock:/tmp/.config
109131
```
110132
111133
- Now, inside the container run the following command to configure the
112134
toolchain. To get a clue of which options need to be changed check the next
113135
section and come back.
114136
115137
```
138+
$ cd /tmp/
116139
$ ct-ng menuconfig
117140
```
118141
119142
- Finally, we retrieve the `.config` file from the container and give it a
120143
meaningful name. This is done outside the container.
121144
122145
```
123-
$ docker drunk_murdock:/.config arm-linux-gnueabi.config
146+
$ docker cp drunk_murdock:/tmp/.config arm-linux-gnueabi.config
124147
```
125148
126149
- Now you can shutdown the container or repeat the two last steps to generate a
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM ubuntu:18.04
2+
3+
COPY scripts/cross-apt-packages.sh /scripts/
4+
RUN sh /scripts/cross-apt-packages.sh
5+
6+
COPY host-x86_64/dist-riscv64-linux/crosstool-ng.sh /scripts/
7+
RUN sh /scripts/crosstool-ng.sh
8+
9+
COPY scripts/rustbuild-setup.sh /scripts/
10+
RUN sh /scripts/rustbuild-setup.sh
11+
USER rustbuild
12+
WORKDIR /tmp
13+
14+
COPY host-x86_64/dist-riscv64-linux/build-toolchains.sh host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.config /tmp/
15+
RUN ./build-toolchains.sh
16+
17+
USER root
18+
19+
COPY scripts/sccache.sh /scripts/
20+
RUN sh /scripts/sccache.sh
21+
22+
ENV PATH=$PATH:/x-tools/riscv64-unknown-linux-gnu/bin
23+
24+
ENV CC_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-gcc \
25+
AR_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-ar \
26+
CXX_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-g++
27+
28+
ENV HOSTS=riscv64gc-unknown-linux-gnu
29+
30+
ENV RUST_CONFIGURE_ARGS --enable-extended --disable-docs
31+
ENV SCRIPT python3 ../x.py dist --target $HOSTS --host $HOSTS

src/ci/docker/host-x86_64/dist-various-1/build-riscv-toolchain.sh src/ci/docker/host-x86_64/dist-riscv64-linux/build-toolchains.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ exit 1
1919
set -x
2020
}
2121

22-
mkdir -p /tmp/build-riscv
23-
cp riscv64-unknown-linux-gnu.config /tmp/build-riscv/.config
24-
cd /tmp/build-riscv
22+
mkdir build
23+
cd build
24+
cp ../riscv64-unknown-linux-gnu.config .config
2525
hide_output ct-ng build
2626
cd ..
27-
rm -rf build-riscv
27+
rm -rf build

src/ci/docker/host-x86_64/dist-various-1/crosstool-ng.sh src/ci/docker/host-x86_64/dist-riscv64-linux/crosstool-ng.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/bin/bash
21
set -ex
32

43
# Mirrored from https://github.com/crosstool-ng/crosstool-ng/archive/crosstool-ng-1.24.0.tar.gz

src/ci/docker/host-x86_64/dist-various-1/riscv64-unknown-linux-gnu.config src/ci/docker/host-x86_64/dist-riscv64-linux/riscv64-unknown-linux-gnu.config

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ CT_CONFIGURE_has_gnu_m4_1_4_12_or_newer=y
1717
CT_CONFIGURE_has_python_3_4_or_newer=y
1818
CT_CONFIGURE_has_bison_2_7_or_newer=y
1919
CT_CONFIGURE_has_python=y
20-
CT_CONFIGURE_has_dtc=y
21-
CT_CONFIGURE_has_svn=y
2220
CT_CONFIGURE_has_git=y
2321
CT_CONFIGURE_has_md5sum=y
2422
CT_CONFIGURE_has_sha1sum=y

src/ci/docker/host-x86_64/dist-various-1/Dockerfile

-16
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ RUN add-apt-repository ppa:team-gcc-arm-embedded/ppa && \
4747
apt-get update && \
4848
apt-get install -y --no-install-recommends gcc-arm-embedded
4949

50-
COPY scripts/rustbuild-setup.sh host-x86_64/dist-various-1/build-riscv-toolchain.sh host-x86_64/dist-various-1/riscv64-unknown-linux-gnu.config host-x86_64/dist-various-1/crosstool-ng.sh /build/
51-
RUN ./crosstool-ng.sh
52-
53-
# Crosstool-ng will refuse to build as root
54-
RUN sh ./rustbuild-setup.sh
55-
USER rustbuild
56-
57-
RUN ./build-riscv-toolchain.sh
58-
59-
USER root
60-
ENV PATH=/x-tools/riscv64-unknown-linux-gnu/bin:$PATH
61-
6250
COPY host-x86_64/dist-various-1/build-rumprun.sh /build
6351
RUN ./build-rumprun.sh
6452

@@ -158,7 +146,6 @@ ENV TARGETS=$TARGETS,riscv32imc-unknown-none-elf
158146
ENV TARGETS=$TARGETS,riscv32imac-unknown-none-elf
159147
ENV TARGETS=$TARGETS,riscv64imac-unknown-none-elf
160148
ENV TARGETS=$TARGETS,riscv64gc-unknown-none-elf
161-
ENV TARGETS=$TARGETS,riscv64gc-unknown-linux-gnu
162149
ENV TARGETS=$TARGETS,armebv7r-none-eabi
163150
ENV TARGETS=$TARGETS,armebv7r-none-eabihf
164151
ENV TARGETS=$TARGETS,armv7r-none-eabi
@@ -186,9 +173,6 @@ ENV CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc \
186173
CFLAGS_aarch64_unknown_none_softfloat=-mstrict-align -march=armv8-a+nofp+nosimd \
187174
CC_aarch64_unknown_none=aarch64-none-elf-gcc \
188175
CFLAGS_aarch64_unknown_none=-mstrict-align -march=armv8-a+fp+simd \
189-
CC_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-gcc \
190-
AR_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-ar \
191-
CXX_riscv64gc_unknown_linux_gnu=riscv64-unknown-linux-gnu-g++ \
192176
CC_riscv32i_unknown_none_elf=false \
193177
CC_riscv32imc_unknown_none_elf=false \
194178
CC_riscv32imac_unknown_none_elf=false \

src/ci/github-actions/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ jobs:
341341
- name: dist-powerpc64le-linux
342342
<<: *job-linux-xl
343343

344+
- name: dist-riscv64-linux
345+
<<: *job-linux-xl
346+
344347
- name: dist-s390x-linux
345348
<<: *job-linux-xl
346349

src/libcore/marker.rs

+1
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ mod impls {
693693
pub trait DiscriminantKind {
694694
/// The type of the discriminant, which must satisfy the trait
695695
/// bounds required by `mem::Discriminant`.
696+
#[cfg_attr(not(bootstrap), lang = "discriminant_type")]
696697
type Discriminant: Clone + Copy + Debug + Eq + PartialEq + Hash + Send + Sync + Unpin;
697698
}
698699

src/libcore/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1681,6 +1681,7 @@ impl<A, V: FromIterator<A>> FromIterator<Option<A>> for Option<V> {
16811681
/// to allow `x?` (where `x` is an `Option<T>`) to be converted into your error type, you can
16821682
/// implement `impl From<NoneError>` for `YourErrorType`. In that case, `x?` within a function that
16831683
/// returns `Result<_, YourErrorType>` will translate a `None` value into an `Err` result.
1684+
#[rustc_diagnostic_item = "none_error"]
16841685
#[unstable(feature = "try_trait", issue = "42327")]
16851686
#[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
16861687
pub struct NoneError;

src/librustc_error_codes/error_codes/E0715.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ struct OverrideConst;
1515
impl Marker for OverrideConst { // error!
1616
const N: usize = 1;
1717
}
18-
19-
fn main() {}
18+
# fn main() {}
2019
```
2120

2221
Because marker traits are allowed to have multiple implementations for the same

0 commit comments

Comments
 (0)