From 9f7e049744bcbc77150c66f5ab39fd46c074a22c Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Sun, 30 Jun 2024 17:09:46 +0000 Subject: [PATCH 01/12] Distribute rustc_codegen_cranelift for arm64 macOS --- compiler/rustc_codegen_cranelift/Readme.md | 2 +- src/bootstrap/src/utils/helpers.rs | 4 +++- src/ci/github-actions/jobs.yml | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_codegen_cranelift/Readme.md b/compiler/rustc_codegen_cranelift/Readme.md index eb21e027dd0e0..3b3c86a1bd17b 100644 --- a/compiler/rustc_codegen_cranelift/Readme.md +++ b/compiler/rustc_codegen_cranelift/Readme.md @@ -70,7 +70,7 @@ For more docs on how to build and test see [build_system/usage.txt](build_system |FreeBSD|✅[^no-rustup]|❓|❓|❓| |AIX|❌[^xcoff]|N/A|N/A|❌[^xcoff]| |Other unixes|❓|❓|❓|❓| -|macOS|✅|✅[^no-rustup]|N/A|N/A| +|macOS|✅|✅|N/A|N/A| |Windows|✅[^no-rustup]|❌|N/A|N/A| ✅: Fully supported and tested diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index adf18c0ace1b4..0d45b8302dcc5 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -202,7 +202,9 @@ pub fn target_supports_cranelift_backend(target: TargetSelection) -> bool { || target.contains("aarch64") || target.contains("s390x") || target.contains("riscv64gc") - } else if target.contains("darwin") || target.is_windows() { + } else if target.contains("darwin") { + target.contains("x86_64") || target.contains("aarch64") + } else if target.is_windows() { target.contains("x86_64") } else { false diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index a6e12c6ff954d..638f14ad53fef 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -326,6 +326,7 @@ auto: NO_DEBUG_ASSERTIONS: 1 NO_OVERFLOW_CHECKS: 1 DIST_REQUIRE_ALL_TOOLS: 1 + CODEGEN_BACKENDS: llvm,cranelift <<: *job-macos-m1 # This target only needs to support 11.0 and up as nothing else supports the hardware From 64ec2703c654c73b4d3df433832f8fe2f0820d3a Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 13 Jun 2024 23:46:05 +0200 Subject: [PATCH 02/12] Promote Mac Catalyst targets to tier 2, and ship with rustup - aarch64-apple-ios-macabi - x86_64-apple-ios-macabi --- src/ci/github-actions/jobs.yml | 2 +- src/doc/rustc/src/platform-support.md | 4 ++-- src/doc/rustc/src/platform-support/apple-ios-macabi.md | 2 +- src/tools/build-manifest/src/main.rs | 2 ++ 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index a6e12c6ff954d..aeb4bd5acb7ed 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -285,7 +285,7 @@ auto: - image: dist-apple-various env: - SCRIPT: ./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim + SCRIPT: ./x.py dist bootstrap --include-default-paths --host='' --target=aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim,aarch64-apple-ios-macabi,x86_64-apple-ios-macabi RUST_CONFIGURE_ARGS: --enable-sanitizers --enable-profiler --set rust.jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 MACOSX_DEPLOYMENT_TARGET: 10.12 diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 370dbed50fa1a..98af93506f8d7 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -135,6 +135,7 @@ so Rustup may install the documentation for a similar tier 1 target instead. target | std | notes -------|:---:|------- [`aarch64-apple-ios`](platform-support/apple-ios.md) | ✓ | ARM64 iOS +[`aarch64-apple-ios-macabi`](platform-support/apple-ios-macabi.md) | ✓ | Mac Catalyst on ARM64 [`aarch64-apple-ios-sim`](platform-support/apple-ios.md) | ✓ | Apple iOS Simulator on ARM64 `aarch64-fuchsia` | ✓ | Alias for `aarch64-unknown-fuchsia` [`aarch64-unknown-fuchsia`](platform-support/fuchsia.md) | ✓ | ARM64 Fuchsia @@ -195,6 +196,7 @@ target | std | notes [`wasm32-wasip1`](platform-support/wasm32-wasip1.md) | ✓ | WebAssembly with WASI [`wasm32-wasip1-threads`](platform-support/wasm32-wasip1-threads.md) | ✓ | WebAssembly with WASI Preview 1 and threads [`x86_64-apple-ios`](platform-support/apple-ios.md) | ✓ | 64-bit x86 iOS +[`x86_64-apple-ios-macabi`](platform-support/apple-ios-macabi.md) | ✓ | Mac Catalyst on x86_64 [`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX `x86_64-fuchsia` | ✓ | Alias for `x86_64-unknown-fuchsia` [`x86_64-unknown-fuchsia`](platform-support/fuchsia.md) | ✓ | 64-bit x86 Fuchsia @@ -244,7 +246,6 @@ target | std | host | notes -------|:---:|:----:|------- [`arm64e-apple-ios`](platform-support/arm64e-apple-ios.md) | ✓ | | ARM64e Apple iOS [`arm64e-apple-darwin`](platform-support/arm64e-apple-darwin.md) | ✓ | ✓ | ARM64e Apple Darwin -[`aarch64-apple-ios-macabi`](platform-support/apple-ios-macabi.md) | ✓ | | Apple Catalyst on ARM64 [`aarch64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | ARM64 tvOS [`aarch64-apple-tvos-sim`](platform-support/apple-tvos.md) | ✓ | | ARM64 tvOS Simulator [`aarch64-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | ARM64 Apple WatchOS @@ -370,7 +371,6 @@ target | std | host | notes `thumbv7neon-unknown-linux-musleabihf` | ? | | Thumb2-mode Armv7-A Linux with NEON, musl 1.2.3 [`wasm32-wasip2`](platform-support/wasm32-wasip2.md) | ✓ | | WebAssembly [`wasm64-unknown-unknown`](platform-support/wasm64-unknown-unknown.md) | ? | | WebAssembly -[`x86_64-apple-ios-macabi`](platform-support/apple-ios-macabi.md) | ✓ | | Apple Catalyst on x86_64 [`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS [`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator [`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS | diff --git a/src/doc/rustc/src/platform-support/apple-ios-macabi.md b/src/doc/rustc/src/platform-support/apple-ios-macabi.md index 15ba31e0f0645..c34c47ef12c9e 100644 --- a/src/doc/rustc/src/platform-support/apple-ios-macabi.md +++ b/src/doc/rustc/src/platform-support/apple-ios-macabi.md @@ -2,7 +2,7 @@ Apple Mac Catalyst targets. -**Tier: 3** +**Tier: 2 (without Host Tools)** - `aarch64-apple-ios-macabi`: Mac Catalyst on ARM64. - `x86_64-apple-ios-macabi`: Mac Catalyst on 64-bit x86. diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index a2e7907b532e4..ce44593e6e50c 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -54,6 +54,7 @@ static TARGETS: &[&str] = &[ "arm64e-apple-darwin", "aarch64-apple-ios", "arm64e-apple-ios", + "aarch64-apple-ios-macabi", "aarch64-apple-ios-sim", "aarch64-unknown-fuchsia", "aarch64-linux-android", @@ -159,6 +160,7 @@ static TARGETS: &[&str] = &[ "wasm32-wasip1-threads", "x86_64-apple-darwin", "x86_64-apple-ios", + "x86_64-apple-ios-macabi", "x86_64-fortanix-unknown-sgx", "x86_64-unknown-fuchsia", "x86_64-linux-android", From 5b0b4ff03c83f03defc3b2a4919aaf5d1ce893ea Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 19 Jul 2024 10:05:30 -0700 Subject: [PATCH 03/12] Update wasi-sdk in CI to latest release This commit updates the `wasi-sdk` download used by the `wasm32-wasi*` targets. The motivation for this commit is generally just "keep things up to date" and is not intended to cause any issues or differences from before, just a routine update. --- src/ci/docker/host-x86_64/dist-various-2/Dockerfile | 4 ++-- src/ci/docker/host-x86_64/test-various/Dockerfile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile index 962484593b4be..2621e9a603185 100644 --- a/src/ci/docker/host-x86_64/dist-various-2/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-various-2/Dockerfile @@ -85,9 +85,9 @@ RUN /tmp/build-solaris-toolchain.sh sparcv9 sparcv9 solaris-sparc sun COPY host-x86_64/dist-various-2/build-x86_64-fortanix-unknown-sgx-toolchain.sh /tmp/ RUN /tmp/build-x86_64-fortanix-unknown-sgx-toolchain.sh -RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz | \ +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-23/wasi-sdk-23.0-x86_64-linux.tar.gz | \ tar -xz -ENV WASI_SDK_PATH=/tmp/wasi-sdk-22.0 +ENV WASI_SDK_PATH=/tmp/wasi-sdk-23.0-x86_64-linux COPY scripts/freebsd-toolchain.sh /tmp/ RUN /tmp/freebsd-toolchain.sh i686 diff --git a/src/ci/docker/host-x86_64/test-various/Dockerfile b/src/ci/docker/host-x86_64/test-various/Dockerfile index f874b2ed475fd..c2f5a87b1234f 100644 --- a/src/ci/docker/host-x86_64/test-various/Dockerfile +++ b/src/ci/docker/host-x86_64/test-various/Dockerfile @@ -40,9 +40,9 @@ WORKDIR / COPY scripts/sccache.sh /scripts/ RUN sh /scripts/sccache.sh -RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz | \ +RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-23/wasi-sdk-23.0-x86_64-linux.tar.gz | \ tar -xz -ENV WASI_SDK_PATH=/wasi-sdk-22.0 +ENV WASI_SDK_PATH=/wasi-sdk-23.0-x86_64-linux ENV RUST_CONFIGURE_ARGS \ --musl-root-x86_64=/usr/local/x86_64-linux-musl \ From 006c884480d2d0ecf727660cbd6535b0e6479dfd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 19 Jul 2024 10:27:14 -0700 Subject: [PATCH 04/12] Fix two new failing tests The updated wasi-sdk has debuginfo by default so be sure to strip the debuginfo by default when testing the size of new executables. --- tests/run-make/wasm-panic-small/rmake.rs | 9 ++++++++- tests/run-make/wasm-stringify-ints-small/rmake.rs | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/run-make/wasm-panic-small/rmake.rs b/tests/run-make/wasm-panic-small/rmake.rs index 8d0944ed98d5b..e69fbac96356a 100644 --- a/tests/run-make/wasm-panic-small/rmake.rs +++ b/tests/run-make/wasm-panic-small/rmake.rs @@ -13,7 +13,14 @@ fn main() { fn test(cfg: &str) { eprintln!("running cfg {cfg:?}"); - rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().cfg(cfg).run(); + rustc() + .input("foo.rs") + .target("wasm32-wasip1") + .arg("-Clto") + .arg("-Cstrip=debuginfo") + .opt() + .cfg(cfg) + .run(); let bytes = rfs::read("foo.wasm"); println!("{}", bytes.len()); diff --git a/tests/run-make/wasm-stringify-ints-small/rmake.rs b/tests/run-make/wasm-stringify-ints-small/rmake.rs index 93eb38b098766..c0448c59c037b 100644 --- a/tests/run-make/wasm-stringify-ints-small/rmake.rs +++ b/tests/run-make/wasm-stringify-ints-small/rmake.rs @@ -4,7 +4,13 @@ use run_make_support::{rfs, rustc}; fn main() { - rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); + rustc() + .input("foo.rs") + .target("wasm32-wasip1") + .arg("-Clto") + .arg("-Cstrip=debuginfo") + .opt() + .run(); let bytes = rfs::read("foo.wasm"); println!("{}", bytes.len()); From 7b19389d586a4bb29180c365e69138609b8a6f01 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 19 Jul 2024 14:05:09 -0400 Subject: [PATCH 05/12] rewrite test-benches to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/test-benches/Makefile | 12 ----------- tests/run-make/test-benches/rmake.rs | 21 +++++++++++++++++++ 3 files changed, 21 insertions(+), 13 deletions(-) delete mode 100644 tests/run-make/test-benches/Makefile create mode 100644 tests/run-make/test-benches/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index bd25a6c144e64..8612d591c7e40 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -100,7 +100,6 @@ run-make/staticlib-dylib-linkage/Makefile run-make/symbol-mangling-hashed/Makefile run-make/symbol-visibility/Makefile run-make/sysroot-crates-are-unstable/Makefile -run-make/test-benches/Makefile run-make/thumb-none-cortex-m/Makefile run-make/thumb-none-qemu/Makefile run-make/translation/Makefile diff --git a/tests/run-make/test-benches/Makefile b/tests/run-make/test-benches/Makefile deleted file mode 100644 index 11aed2e4c79a6..0000000000000 --- a/tests/run-make/test-benches/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -include ../tools.mk - -# ignore-cross-compile -# needs-unwind #[bench] and -Zpanic-abort-tests can't be combined - -all: - # Smoke-test that `#[bench]` isn't entirely broken. - $(RUSTC) --test smokebench.rs -O - $(call RUN,smokebench --bench) - $(call RUN,smokebench --bench noiter) - $(call RUN,smokebench --bench yesiter) - $(call RUN,smokebench) diff --git a/tests/run-make/test-benches/rmake.rs b/tests/run-make/test-benches/rmake.rs new file mode 100644 index 0000000000000..acf9b04becb23 --- /dev/null +++ b/tests/run-make/test-benches/rmake.rs @@ -0,0 +1,21 @@ +// #[bench] is a Rust feature to run benchmarks on performance-critical +// code, which previously experienced a runtime panic bug in #103794. +// In order to ensure future breakages of this feature are detected, this +// smoke test was created, using the benchmarking feature with various +// runtime flags. +// See https://github.com/rust-lang/rust/issues/103794 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ needs-unwind +// Reason: #[bench] and -Zpanic-abort-tests can't be combined + +use run_make_support::{run, run_with_args, rustc}; + +fn main() { + rustc().arg("--test").input("smokebench.rs").opt().run(); + run_with_args("smokebench", &["--bench"]); + run_with_args("smokebench", &["--bench", "noiter"]); + run_with_args("smokebench", &["--bench", "yesiter"]); + run("smokebench"); +} From 27334943ed92216760e232f0276610271ee3305b Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 19 Jul 2024 14:39:42 -0400 Subject: [PATCH 06/12] rewrite c-unwind-abi-catch-panic to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/c-unwind-abi-catch-panic/Makefile | 10 ---------- .../run-make/c-unwind-abi-catch-panic/rmake.rs | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 11 deletions(-) delete mode 100644 tests/run-make/c-unwind-abi-catch-panic/Makefile create mode 100644 tests/run-make/c-unwind-abi-catch-panic/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 8612d591c7e40..ed1ae071f07ca 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -4,7 +4,6 @@ run-make/c-dynamic-rlib/Makefile run-make/c-static-dylib/Makefile run-make/c-static-rlib/Makefile run-make/c-unwind-abi-catch-lib-panic/Makefile -run-make/c-unwind-abi-catch-panic/Makefile run-make/cat-and-grep-sanity-check/Makefile run-make/cdylib-dylib-linkage/Makefile run-make/compiler-lookup-paths-2/Makefile diff --git a/tests/run-make/c-unwind-abi-catch-panic/Makefile b/tests/run-make/c-unwind-abi-catch-panic/Makefile deleted file mode 100644 index 0a38d838e32a7..0000000000000 --- a/tests/run-make/c-unwind-abi-catch-panic/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# Exercise unwinding a panic. This catches a panic across an FFI boundary and downcasts it into an integer. The Rust code that panics is in the same directory. -# See https://github.com/rust-lang/rust/commit/baf227ea0c1e07fc54395a51e4b3881d701180cb - -# ignore-cross-compile -# needs-unwind -include ../tools.mk - -all: $(call NATIVE_STATICLIB,add) - $(RUSTC) main.rs - $(call RUN,main) || exit 1 diff --git a/tests/run-make/c-unwind-abi-catch-panic/rmake.rs b/tests/run-make/c-unwind-abi-catch-panic/rmake.rs new file mode 100644 index 0000000000000..a99dbd18ec619 --- /dev/null +++ b/tests/run-make/c-unwind-abi-catch-panic/rmake.rs @@ -0,0 +1,18 @@ +// A test for calling `C-unwind` functions across foreign function boundaries (FFI). +// This test triggers a panic when calling a foreign function that calls *back* into Rust. +// This catches a panic across an FFI boundary and downcasts it into an integer. +// The Rust code that panics is in the same directory, unlike `c-unwind-abi-catch-lib-panic`. +// See https://github.com/rust-lang/rust/pull/76570 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ needs-unwind +// Reason: this test exercises panic unwinding + +use run_make_support::{build_native_static_lib, run, rustc}; + +fn main() { + build_native_static_lib("add"); + rustc().input("main.rs").run(); + run("main"); +} From 2192a916d4193c2a602e1ab6c9e236f389a962b5 Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 19 Jul 2024 15:00:10 -0400 Subject: [PATCH 07/12] rewrite compiler-lookup-paths-2 to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - .../run-make/compiler-lookup-paths-2/Makefile | 11 ---------- .../run-make/compiler-lookup-paths-2/rmake.rs | 20 +++++++++++++++++++ tests/run-make/test-benches/rmake.rs | 1 + 4 files changed, 21 insertions(+), 12 deletions(-) delete mode 100644 tests/run-make/compiler-lookup-paths-2/Makefile create mode 100644 tests/run-make/compiler-lookup-paths-2/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index ed1ae071f07ca..23ce7f242f71d 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -6,7 +6,6 @@ run-make/c-static-rlib/Makefile run-make/c-unwind-abi-catch-lib-panic/Makefile run-make/cat-and-grep-sanity-check/Makefile run-make/cdylib-dylib-linkage/Makefile -run-make/compiler-lookup-paths-2/Makefile run-make/compiler-rt-works-on-mingw/Makefile run-make/crate-hash-rustc-version/Makefile run-make/cross-lang-lto-clang/Makefile diff --git a/tests/run-make/compiler-lookup-paths-2/Makefile b/tests/run-make/compiler-lookup-paths-2/Makefile deleted file mode 100644 index ecc0577384ab6..0000000000000 --- a/tests/run-make/compiler-lookup-paths-2/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# This test checks that extern crate declarations in Cargo without a corresponding declaration in the manifest of a dependency are NOT allowed. -# See https://github.com/rust-lang/rust/pull/21113 - -include ../tools.mk - -all: - mkdir -p $(TMPDIR)/a $(TMPDIR)/b - $(RUSTC) a.rs && mv $(TMPDIR)/liba.rlib $(TMPDIR)/a - $(RUSTC) b.rs -L $(TMPDIR)/a && mv $(TMPDIR)/libb.rlib $(TMPDIR)/b - $(RUSTC) c.rs -L crate=$(TMPDIR)/b -L dependency=$(TMPDIR)/a \ - && exit 1 || exit 0 diff --git a/tests/run-make/compiler-lookup-paths-2/rmake.rs b/tests/run-make/compiler-lookup-paths-2/rmake.rs new file mode 100644 index 0000000000000..99efb157b5378 --- /dev/null +++ b/tests/run-make/compiler-lookup-paths-2/rmake.rs @@ -0,0 +1,20 @@ +// This test checks that extern crate declarations in Cargo without a corresponding declaration +// in the manifest of a dependency are NOT allowed. The last rustc call does it anyways, which +// should result in a compilation failure. +// See https://github.com/rust-lang/rust/pull/21113 + +use run_make_support::{path, rfs, rust_lib_name, rustc}; + +fn main() { + rfs::create_dir("a"); + rfs::create_dir("b"); + rustc().input("a.rs").run(); + rfs::rename(rust_lib_name("a"), path("a").join(rust_lib_name("a"))); + rustc().input("b.rs").library_search_path("a").run(); + rfs::rename(rust_lib_name("b"), path("b").join(rust_lib_name("b"))); + rustc() + .input("c.rs") + .library_search_path("crate=b") + .library_search_path("dependency=a") + .run_fail(); +} diff --git a/tests/run-make/test-benches/rmake.rs b/tests/run-make/test-benches/rmake.rs index acf9b04becb23..1458fb8c9904a 100644 --- a/tests/run-make/test-benches/rmake.rs +++ b/tests/run-make/test-benches/rmake.rs @@ -13,6 +13,7 @@ use run_make_support::{run, run_with_args, rustc}; fn main() { + // Smoke-test that #[bench] isn't entirely broken. rustc().arg("--test").input("smokebench.rs").opt().run(); run_with_args("smokebench", &["--bench"]); run_with_args("smokebench", &["--bench", "noiter"]); From ee034f4912f21291c523b4525d4ecafce8a92cfa Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 20 Jul 2024 22:28:13 +0200 Subject: [PATCH 08/12] Fix stab display in doc blocks --- src/librustdoc/html/static/css/rustdoc.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 28ed94432c86e..caa9bd563b11e 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -831,6 +831,10 @@ pre, .rustdoc.src .example-wrap { background: var(--table-alt-row-background-color); } +.docblock .stab, .docblock-short .stab { + display: inline-block; +} + /* "where ..." clauses with block display are also smaller */ div.where { white-space: pre-wrap; From 95335444f7171c4582fd56f20ade6f84da84c984 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Sun, 21 Jul 2024 02:28:04 +0200 Subject: [PATCH 09/12] rustdoc: short descr. cause word-breaks in tables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `.item-table` class is used to display name+description lists, e.g. the exported functions, as a table. If the names are long and the descriptions are short, then the width of the table does not expand to the whole size, but only uses a fraction. This causes a some names to break inside a word. This change makes the table always use 100% of its parent width. The `.width-limiter` wrapper already ensures that the used width still does not become excessive. Signed-off-by: René Kijewski --- src/librustdoc/html/static/css/rustdoc.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 28ed94432c86e..867275cf4fbb6 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -953,6 +953,7 @@ table, display: table; padding: 0; margin: 0; + width: 100%; } .item-table > li { display: table-row; From e4d701b1d3f1cc04574c9b92abfa33e2a4c0e9c3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 20 Jul 2024 22:28:27 +0200 Subject: [PATCH 10/12] Add regression test for stab display in doc blocks --- tests/rustdoc-gui/src/test_docs/lib.rs | 8 ++++---- tests/rustdoc-gui/stab-in-doc.goml | 9 +++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 tests/rustdoc-gui/stab-in-doc.goml diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 7e34178e56f03..360ad3edefa1f 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -20,10 +20,10 @@ Also, stop using `bar` as it's deprecated Also, stop using `bar` as it's deprecated. Also, stop using `bar` as it's deprecated. -Finally, you can use `quz` only on Unix or x86-64 -. -Finally, you can use `quz` only on Unix or x86-64 -. +Finally, you can use `quz` only on Unix or x86-64 +. +Finally, you can use `quz` only on Unix or x86-64 +. */ use std::convert::AsRef; diff --git a/tests/rustdoc-gui/stab-in-doc.goml b/tests/rustdoc-gui/stab-in-doc.goml new file mode 100644 index 0000000000000..6a03a51fe9f27 --- /dev/null +++ b/tests/rustdoc-gui/stab-in-doc.goml @@ -0,0 +1,9 @@ +// This test ensure that `stab` elements if used in doc blocks are not breaking the text layout. +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" +// We make the window wide enough for the two stabs who are looking into to be on the same line. +set-window-size: (1100, 600) +compare-elements-position: ( + ".top-doc .docblock span[data-span='1']", + ".top-doc .docblock span[data-span='2']", + ["y"], +) From 84db684f49d9e1e4250fe24a90b5a5d2d4737df0 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 21 Jul 2024 12:47:34 +0200 Subject: [PATCH 11/12] Update `source-code-page-code-scroll.goml` GUI test --- tests/rustdoc-gui/source-code-page-code-scroll.goml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/rustdoc-gui/source-code-page-code-scroll.goml b/tests/rustdoc-gui/source-code-page-code-scroll.goml index 35f338ea32834..31ab281d6ce09 100644 --- a/tests/rustdoc-gui/source-code-page-code-scroll.goml +++ b/tests/rustdoc-gui/source-code-page-code-scroll.goml @@ -2,7 +2,7 @@ go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" set-window-size: (800, 1000) // "scrollWidth" should be superior than "clientWidth". -assert-property: ("body", {"scrollWidth": 1047, "clientWidth": 800}) +assert-property: ("body", {"scrollWidth": 1114, "clientWidth": 800}) // Both properties should be equal (ie, no scroll on the code block). -assert-property: (".example-wrap .rust", {"scrollWidth": 933, "clientWidth": 933}) +assert-property: (".example-wrap .rust", {"scrollWidth": 1000, "clientWidth": 1000}) From ae42efc522a5ed43631b95f1cce80520c7929e15 Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Wed, 10 Jul 2024 19:42:54 +0200 Subject: [PATCH 12/12] Deal with invalid UTF-8 from `gai_strerror` When the system is using a non-UTF-8 locale, the value will indeed not be UTF-8. That sucks for everyone involved, but is no reason for panic. We can "handle" this gracefully by just using from lossy, replacing the invalid UTF-8 with the ? and keeping the accidentally valid UTF-8. Good luck when debugging, but at least it's not a crash. We already do this for `strerror_r`. --- library/std/src/sys/pal/unix/net.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/pal/unix/net.rs b/library/std/src/sys/pal/unix/net.rs index b8dc1538a6378..bedb06043a7b4 100644 --- a/library/std/src/sys/pal/unix/net.rs +++ b/library/std/src/sys/pal/unix/net.rs @@ -4,7 +4,6 @@ use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::mem; use crate::net::{Shutdown, SocketAddr}; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; -use crate::str; use crate::sys::fd::FileDesc; use crate::sys::pal::unix::IsMinusOne; use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr}; @@ -47,7 +46,9 @@ pub fn cvt_gai(err: c_int) -> io::Result<()> { #[cfg(not(target_os = "espidf"))] let detail = unsafe { - str::from_utf8(CStr::from_ptr(libc::gai_strerror(err)).to_bytes()).unwrap().to_owned() + // We can't always expect a UTF-8 environment. When we don't get that luxury, + // it's better to give a low-quality error message than none at all. + CStr::from_ptr(libc::gai_strerror(err)).to_string_lossy() }; #[cfg(target_os = "espidf")]