Skip to content

Commit 50f3d6e

Browse files
committed
Auto merge of #57094 - Centril:rollup, r=Centril
Rollup of 10 pull requests Successful merges: - #55470 (box: Add documentation for `From` impls) - #56242 (Add missing link in docs) - #56944 (bootstrap: Link LLVM as a dylib with ThinLTO) - #56978 (Add `std::os::fortanix_sgx` module) - #56985 (Allow testing pointers for inboundedness while forbidding dangling pointers) - #56986 (rustc: Move jemalloc from rustc_driver to rustc) - #57010 (Actually run compiletest tests on CI) - #57021 (Enable emission of alignment attrs for pointer params) - #57074 (Fix recursion limits) - #57085 (librustc_codegen_llvm: Don't eliminate empty structs in C ABI on linux-sparc64) Failed merges: r? @ghost
2 parents 94bf2c1 + 6ce748a commit 50f3d6e

File tree

43 files changed

+515
-379
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+515
-379
lines changed

Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
819819

820820
[[package]]
821821
name = "fortanix-sgx-abi"
822-
version = "0.3.1"
822+
version = "0.3.2"
823823
source = "registry+https://github.com/rust-lang/crates.io-index"
824824
dependencies = [
825825
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2216,6 +2216,7 @@ dependencies = [
22162216
name = "rustc-main"
22172217
version = "0.0.0"
22182218
dependencies = [
2219+
"jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
22192220
"rustc_codegen_ssa 0.0.0",
22202221
"rustc_driver 0.0.0",
22212222
"rustc_target 0.0.0",
@@ -2402,7 +2403,6 @@ dependencies = [
24022403
"arena 0.0.0",
24032404
"env_logger 0.5.13 (registry+https://github.com/rust-lang/crates.io-index)",
24042405
"graphviz 0.0.0",
2405-
"jemalloc-sys 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
24062406
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
24072407
"rustc 0.0.0",
24082408
"rustc-rayon 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2892,7 +2892,7 @@ dependencies = [
28922892
"compiler_builtins 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
28932893
"core 0.0.0",
28942894
"dlmalloc 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
2895-
"fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
2895+
"fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
28962896
"libc 0.2.45 (registry+https://github.com/rust-lang/crates.io-index)",
28972897
"panic_abort 0.0.0",
28982898
"panic_unwind 0.0.0",
@@ -3449,7 +3449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
34493449
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
34503450
"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
34513451
"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
3452-
"checksum fortanix-sgx-abi 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "26105e20b4c3f7a319db1376b54ac9a46e5761e949405553375095d05a0cee4d"
3452+
"checksum fortanix-sgx-abi 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3f8cbee5e872cf7db61a999a041f9bc4706ca7bf7df4cb914f53fabb1c1bc550"
34533453
"checksum fs2 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
34543454
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
34553455
"checksum fst 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d94485a00b1827b861dd9d1a2cc9764f9044d4c535514c0760a5a2012ef3399f"

src/bootstrap/check.rs

-5
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ impl Step for Std {
4848
builder.info(&format!("Checking std artifacts ({} -> {})", &compiler.host, target));
4949
run_cargo(builder,
5050
&mut cargo,
51-
vec![],
5251
&libstd_stamp(builder, compiler, target),
5352
true);
5453

@@ -95,7 +94,6 @@ impl Step for Rustc {
9594
builder.info(&format!("Checking compiler artifacts ({} -> {})", &compiler.host, target));
9695
run_cargo(builder,
9796
&mut cargo,
98-
vec![],
9997
&librustc_stamp(builder, compiler, target),
10098
true);
10199

@@ -146,7 +144,6 @@ impl Step for CodegenBackend {
146144
let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage));
147145
run_cargo(builder,
148146
&mut cargo,
149-
vec![],
150147
&codegen_backend_stamp(builder, compiler, target, backend),
151148
true);
152149
}
@@ -184,7 +181,6 @@ impl Step for Test {
184181
builder.info(&format!("Checking test artifacts ({} -> {})", &compiler.host, target));
185182
run_cargo(builder,
186183
&mut cargo,
187-
vec![],
188184
&libtest_stamp(builder, compiler, target),
189185
true);
190186

@@ -232,7 +228,6 @@ impl Step for Rustdoc {
232228
println!("Checking rustdoc artifacts ({} -> {})", &compiler.host, target);
233229
run_cargo(builder,
234230
&mut cargo,
235-
vec![],
236231
&rustdoc_stamp(builder, compiler, target),
237232
true);
238233

src/bootstrap/compile.rs

+8-41
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use build_helper::{output, mtime, up_to_date};
2929
use filetime::FileTime;
3030
use serde_json;
3131

32+
use crate::dist;
3233
use crate::util::{exe, libdir, is_dylib};
3334
use crate::{Compiler, Mode, GitRepo};
3435
use crate::native;
@@ -114,7 +115,6 @@ impl Step for Std {
114115
&compiler.host, target));
115116
run_cargo(builder,
116117
&mut cargo,
117-
vec![],
118118
&libstd_stamp(builder, compiler, target),
119119
false);
120120

@@ -375,7 +375,6 @@ impl Step for Test {
375375
&compiler.host, target));
376376
run_cargo(builder,
377377
&mut cargo,
378-
vec![],
379378
&libtest_stamp(builder, compiler, target),
380379
false);
381380

@@ -503,7 +502,6 @@ impl Step for Rustc {
503502
compiler.stage, &compiler.host, target));
504503
run_cargo(builder,
505504
&mut cargo,
506-
vec![],
507505
&librustc_stamp(builder, compiler, target),
508506
false);
509507

@@ -646,47 +644,18 @@ impl Step for CodegenBackend {
646644

647645
let out_dir = builder.cargo_out(compiler, Mode::Codegen, target);
648646

649-
let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "rustc");
647+
let mut cargo = builder.cargo(compiler, Mode::Codegen, target, "build");
650648
cargo.arg("--manifest-path")
651649
.arg(builder.src.join("src/librustc_codegen_llvm/Cargo.toml"));
652650
rustc_cargo_env(builder, &mut cargo);
653651

654652
let features = build_codegen_backend(&builder, &mut cargo, &compiler, target, backend);
655653

656-
let mut cargo_tails_args = vec![];
657-
658-
if builder.config.llvm_thin_lto {
659-
cargo_tails_args.push("--".to_string());
660-
661-
let num_jobs = builder.jobs();
662-
663-
if !target.contains("msvc") {
664-
// Here we assume that the linker is clang. If it's not, there'll
665-
// be linker errors.
666-
cargo_tails_args.push("-Clink-arg=-fuse-ld=lld".to_string());
667-
cargo_tails_args.push("-Clink-arg=-flto=thin".to_string());
668-
669-
if builder.config.llvm_optimize {
670-
cargo_tails_args.push("-Clink-arg=-O2".to_string());
671-
}
672-
673-
// Let's make LLD respect the `-j` option.
674-
let num_jobs_arg = format!("-Clink-arg=-Wl,--thinlto-jobs={}", num_jobs);
675-
cargo_tails_args.push(num_jobs_arg);
676-
} else {
677-
// Here we assume that the linker is lld-link.exe. lld-link.exe
678-
// does not need the extra arguments except for num_jobs
679-
let num_jobs_arg = format!("-Clink-arg=/opt:lldltojobs={}", num_jobs);
680-
cargo_tails_args.push(num_jobs_arg);
681-
}
682-
}
683-
684654
let tmp_stamp = out_dir.join(".tmp.stamp");
685655

686656
let _folder = builder.fold_output(|| format!("stage{}-rustc_codegen_llvm", compiler.stage));
687657
let files = run_cargo(builder,
688658
cargo.arg("--features").arg(features),
689-
cargo_tails_args,
690659
&tmp_stamp,
691660
false);
692661
if builder.config.dry_run {
@@ -759,7 +728,9 @@ pub fn build_codegen_backend(builder: &Builder,
759728
"libstdc++.a");
760729
cargo.env("LLVM_STATIC_STDCPP", file);
761730
}
762-
if builder.config.llvm_link_shared {
731+
if builder.config.llvm_link_shared ||
732+
(builder.config.llvm_thin_lto && backend != "emscripten")
733+
{
763734
cargo.env("LLVM_LINK_SHARED", "1");
764735
}
765736
}
@@ -999,6 +970,8 @@ impl Step for Assemble {
999970
copy_lld_to_sysroot(builder, target_compiler, &lld_install);
1000971
}
1001972

973+
dist::maybe_install_llvm_dylib(builder, target_compiler.host, &sysroot);
974+
1002975
// Link the compiler binary itself into place
1003976
let out_dir = builder.cargo_out(build_compiler, Mode::Rustc, host);
1004977
let rustc = out_dir.join(exe("rustc_binary", &*host));
@@ -1025,7 +998,6 @@ pub fn add_to_sysroot(builder: &Builder, sysroot_dst: &Path, stamp: &Path) {
1025998

1026999
pub fn run_cargo(builder: &Builder,
10271000
cargo: &mut Command,
1028-
tail_args: Vec<String>,
10291001
stamp: &Path,
10301002
is_check: bool)
10311003
-> Vec<PathBuf>
@@ -1048,7 +1020,7 @@ pub fn run_cargo(builder: &Builder,
10481020
// files we need to probe for later.
10491021
let mut deps = Vec::new();
10501022
let mut toplevel = Vec::new();
1051-
let ok = stream_cargo(builder, cargo, tail_args, &mut |msg| {
1023+
let ok = stream_cargo(builder, cargo, &mut |msg| {
10521024
let filenames = match msg {
10531025
CargoMessage::CompilerArtifact { filenames, .. } => filenames,
10541026
_ => return,
@@ -1173,7 +1145,6 @@ pub fn run_cargo(builder: &Builder,
11731145
pub fn stream_cargo(
11741146
builder: &Builder,
11751147
cargo: &mut Command,
1176-
tail_args: Vec<String>,
11771148
cb: &mut dyn FnMut(CargoMessage),
11781149
) -> bool {
11791150
if builder.config.dry_run {
@@ -1184,10 +1155,6 @@ pub fn stream_cargo(
11841155
cargo.arg("--message-format").arg("json")
11851156
.stdout(Stdio::piped());
11861157

1187-
for arg in tail_args {
1188-
cargo.arg(arg);
1189-
}
1190-
11911158
builder.verbose(&format!("running: {:?}", cargo));
11921159
let mut child = match cargo.spawn() {
11931160
Ok(child) => child,

src/bootstrap/dist.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1888,13 +1888,13 @@ impl Step for HashSign {
18881888
// LLVM tools are linked dynamically.
18891889
// Note: This function does no yet support Windows but we also don't support
18901890
// linking LLVM tools dynamically on Windows yet.
1891-
fn maybe_install_llvm_dylib(builder: &Builder,
1892-
target: Interned<String>,
1893-
image: &Path) {
1891+
pub fn maybe_install_llvm_dylib(builder: &Builder,
1892+
target: Interned<String>,
1893+
sysroot: &Path) {
18941894
let src_libdir = builder
18951895
.llvm_out(target)
18961896
.join("lib");
1897-
let dst_libdir = image.join("lib/rustlib").join(&*target).join("lib");
1897+
let dst_libdir = sysroot.join("lib/rustlib").join(&*target).join("lib");
18981898
t!(fs::create_dir_all(&dst_libdir));
18991899

19001900
if target.contains("apple-darwin") {

src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl Step for ToolBuild {
8787
let _folder = builder.fold_output(|| format!("stage{}-{}", compiler.stage, tool));
8888
builder.info(&format!("Building stage{} tool {} ({})", compiler.stage, tool, target));
8989
let mut duplicates = Vec::new();
90-
let is_expected = compile::stream_cargo(builder, &mut cargo, vec![], &mut |msg| {
90+
let is_expected = compile::stream_cargo(builder, &mut cargo, &mut |msg| {
9191
// Only care about big things like the RLS/Cargo for now
9292
match tool {
9393
| "rls"

src/ci/docker/mingw-check/Dockerfile

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ RUN sh /scripts/sccache.sh
2121

2222
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
2323
ENV SCRIPT python2.7 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \
24-
python2.7 ../x.py build --stage 0 src/tools/build-manifest
24+
python2.7 ../x.py build --stage 0 src/tools/build-manifest && \
25+
python2.7 ../x.py test --stage 0 src/tools/compiletest

src/liballoc/boxed.rs

+54
Original file line numberDiff line numberDiff line change
@@ -443,13 +443,28 @@ impl<T: ?Sized + Hasher> Hasher for Box<T> {
443443

444444
#[stable(feature = "from_for_ptrs", since = "1.6.0")]
445445
impl<T> From<T> for Box<T> {
446+
/// Converts a generic type `T` into a `Box<T>`
447+
///
448+
/// The conversion allocates on the heap and moves `t`
449+
/// from the stack into it.
450+
///
451+
/// # Examples
452+
/// ```rust
453+
/// let x = 5;
454+
/// let boxed = Box::new(5);
455+
///
456+
/// assert_eq!(Box::from(x), boxed);
457+
/// ```
446458
fn from(t: T) -> Self {
447459
Box::new(t)
448460
}
449461
}
450462

451463
#[stable(feature = "pin", since = "1.33.0")]
452464
impl<T> From<Box<T>> for Pin<Box<T>> {
465+
/// Converts a `Box<T>` into a `Pin<Box<T>>`
466+
///
467+
/// This conversion does not allocate on the heap and happens in place.
453468
fn from(boxed: Box<T>) -> Self {
454469
// It's not possible to move or replace the insides of a `Pin<Box<T>>`
455470
// when `T: !Unpin`, so it's safe to pin it directly without any
@@ -460,6 +475,19 @@ impl<T> From<Box<T>> for Pin<Box<T>> {
460475

461476
#[stable(feature = "box_from_slice", since = "1.17.0")]
462477
impl<'a, T: Copy> From<&'a [T]> for Box<[T]> {
478+
/// Converts a `&[T]` into a `Box<[T]>`
479+
///
480+
/// This conversion allocates on the heap
481+
/// and performs a copy of `slice`.
482+
///
483+
/// # Examples
484+
/// ```rust
485+
/// // create a &[u8] which will be used to create a Box<[u8]>
486+
/// let slice: &[u8] = &[104, 101, 108, 108, 111];
487+
/// let boxed_slice: Box<[u8]> = Box::from(slice);
488+
///
489+
/// println!("{:?}", boxed_slice);
490+
/// ```
463491
fn from(slice: &'a [T]) -> Box<[T]> {
464492
let mut boxed = unsafe { RawVec::with_capacity(slice.len()).into_box() };
465493
boxed.copy_from_slice(slice);
@@ -469,6 +497,16 @@ impl<'a, T: Copy> From<&'a [T]> for Box<[T]> {
469497

470498
#[stable(feature = "box_from_slice", since = "1.17.0")]
471499
impl<'a> From<&'a str> for Box<str> {
500+
/// Converts a `&str` into a `Box<str>`
501+
///
502+
/// This conversion allocates on the heap
503+
/// and performs a copy of `s`.
504+
///
505+
/// # Examples
506+
/// ```rust
507+
/// let boxed: Box<str> = Box::from("hello");
508+
/// println!("{}", boxed);
509+
/// ```
472510
#[inline]
473511
fn from(s: &'a str) -> Box<str> {
474512
unsafe { from_boxed_utf8_unchecked(Box::from(s.as_bytes())) }
@@ -477,6 +515,22 @@ impl<'a> From<&'a str> for Box<str> {
477515

478516
#[stable(feature = "boxed_str_conv", since = "1.19.0")]
479517
impl From<Box<str>> for Box<[u8]> {
518+
/// Converts a `Box<str>>` into a `Box<[u8]>`
519+
///
520+
/// This conversion does not allocate on the heap and happens in place.
521+
///
522+
/// # Examples
523+
/// ```rust
524+
/// // create a Box<str> which will be used to create a Box<[u8]>
525+
/// let boxed: Box<str> = Box::from("hello");
526+
/// let boxed_str: Box<[u8]> = Box::from(boxed);
527+
///
528+
/// // create a &[u8] which will be used to create a Box<[u8]>
529+
/// let slice: &[u8] = &[104, 101, 108, 108, 111];
530+
/// let boxed_slice = Box::from(slice);
531+
///
532+
/// assert_eq!(boxed_slice, boxed_str);
533+
/// ```
480534
#[inline]
481535
fn from(s: Box<str>) -> Self {
482536
unsafe { Box::from_raw(Box::into_raw(s) as *mut [u8]) }

src/libcore/iter/iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub trait Iterator {
162162
/// That said, the implementation should provide a correct estimation,
163163
/// because otherwise it would be a violation of the trait's protocol.
164164
///
165-
/// The default implementation returns `(0, None)` which is correct for any
165+
/// The default implementation returns `(0, `[`None`]`)` which is correct for any
166166
/// iterator.
167167
///
168168
/// [`usize`]: ../../std/primitive.usize.html

src/librustc/session/config.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1271,8 +1271,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
12711271
"set the MIR optimization level (0-3, default: 1)"),
12721272
mutable_noalias: Option<bool> = (None, parse_opt_bool, [TRACKED],
12731273
"emit noalias metadata for mutable references (default: yes on LLVM >= 6)"),
1274-
arg_align_attributes: bool = (false, parse_bool, [TRACKED],
1275-
"emit align metadata for reference arguments"),
12761274
dump_mir: Option<String> = (None, parse_opt_string, [UNTRACKED],
12771275
"dump MIR state to file.
12781276
`val` is used to select which passes and functions to dump. For example:

src/librustc_codegen_llvm/abi.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
456456
let linux_s390x = target.target_os == "linux"
457457
&& target.arch == "s390x"
458458
&& target.target_env == "gnu";
459+
let linux_sparc64 = target.target_os == "linux"
460+
&& target.arch == "sparc64"
461+
&& target.target_env == "gnu";
459462
let rust_abi = match sig.abi {
460463
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => true,
461464
_ => false
@@ -489,12 +492,6 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
489492
attrs.pointee_size = pointee.size;
490493
attrs.pointee_align = Some(pointee.align);
491494

492-
// HACK(eddyb) LLVM inserts `llvm.assume` calls when inlining functions
493-
// with align attributes, and those calls later block optimizations.
494-
if !is_return && !cx.tcx.sess.opts.debugging_opts.arg_align_attributes {
495-
attrs.pointee_align = None;
496-
}
497-
498495
// `Box` pointer parameters never alias because ownership is transferred
499496
// `&mut` pointer parameters never alias other parameters,
500497
// or mutable global data
@@ -526,8 +523,9 @@ impl<'tcx> FnTypeExt<'tcx> for FnType<'tcx, Ty<'tcx>> {
526523
if arg.layout.is_zst() {
527524
// For some forsaken reason, x86_64-pc-windows-gnu
528525
// doesn't ignore zero-sized struct arguments.
529-
// The same is true for s390x-unknown-linux-gnu.
530-
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x) {
526+
// The same is true for s390x-unknown-linux-gnu
527+
// and sparc64-unknown-linux-gnu.
528+
if is_return || rust_abi || (!win_x64_gnu && !linux_s390x && !linux_sparc64) {
531529
arg.mode = PassMode::Ignore;
532530
}
533531
}

0 commit comments

Comments
 (0)