Skip to content

Commit

Permalink
Auto merge of rust-lang#132664 - matthiaskrgr:rollup-i27nr7i, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 5 pull requests

Successful merges:

 - rust-lang#131261 (Stabilize `UnsafeCell::from_mut`)
 - rust-lang#131405 (bootstrap/codegen_ssa: ship llvm-strip and use it for -Cstrip)
 - rust-lang#132077 (Add a new `wide-arithmetic` feature for WebAssembly)
 - rust-lang#132562 (Remove the `wasm32-wasi` target from rustc)
 - rust-lang#132660 (Remove unused errs.rs file)

Failed merges:

 - rust-lang#131721 (Add new unstable feature `const_eq_ignore_ascii_case`)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Nov 6, 2024
2 parents 4a91ff6 + 92c1ad8 commit a69df72
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 151 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
("x86", s) if s.starts_with("avx512") => {
Some(LLVMFeature::with_dependency(s, TargetFeatureFoldStrength::EnableOnly("evex512")))
}
// Support for `wide-arithmetic` will first land in LLVM 20 as part of
// llvm/llvm-project#111598
("wasm32" | "wasm64", "wide-arithmetic") if get_version() < (20, 0, 0) => None,
(_, s) => Some(LLVMFeature::new(s)),
}
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ codegen_ssa_L4Bender_exporting_symbols_unimplemented = exporting symbols not imp
codegen_ssa_add_native_library = failed to add native library {$library_path}: {$error}
codegen_ssa_aix_strip_not_used = using host's `strip` binary to cross-compile to AIX which is not guaranteed to work
codegen_ssa_apple_deployment_target_invalid =
failed to parse deployment target specified in {$env_var}: {$error}
Expand Down
22 changes: 17 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1085,9 +1085,7 @@ fn link_natively(
let strip = sess.opts.cg.strip;

if sess.target.is_like_osx {
// Use system `strip` when running on host macOS.
// <https://github.com/rust-lang/rust/pull/130781>
let stripcmd = if cfg!(target_os = "macos") { "/usr/bin/strip" } else { "strip" };
let stripcmd = "rust-objcopy";
match (strip, crate_type) {
(Strip::Debuginfo, _) => {
strip_symbols_with_external_utility(sess, stripcmd, out_filename, Some("-S"))
Expand All @@ -1103,11 +1101,14 @@ fn link_natively(
}
}

if sess.target.os == "illumos" {
if sess.target.is_like_solaris {
// Many illumos systems will have both the native 'strip' utility and
// the GNU one. Use the native version explicitly and do not rely on
// what's in the path.
let stripcmd = "/usr/bin/strip";
//
// If cross-compiling and there is not a native version, then use
// `llvm-strip` and hope.
let stripcmd = if !sess.host.is_like_solaris { "rust-objcopy" } else { "/usr/bin/strip" };
match strip {
// Always preserve the symbol table (-x).
Strip::Debuginfo => {
Expand All @@ -1120,6 +1121,10 @@ fn link_natively(
}

if sess.target.is_like_aix {
// `llvm-strip` doesn't work for AIX - their strip must be used.
if !sess.host.is_like_aix {
sess.dcx().emit_warn(errors::AixStripNotUsed);
}
let stripcmd = "/usr/bin/strip";
match strip {
Strip::Debuginfo => {
Expand Down Expand Up @@ -1147,6 +1152,13 @@ fn strip_symbols_with_external_utility(
if let Some(option) = option {
cmd.arg(option);
}

let mut new_path = sess.get_tools_search_paths(false);
if let Some(path) = env::var_os("PATH") {
new_path.extend(env::split_paths(&path));
}
cmd.env("PATH", env::join_paths(new_path).unwrap());

let prog = cmd.arg(out_filename).output();
match prog {
Ok(prog) => {
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,3 +1110,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for TargetFeatureDisableOrEnable<'_
diag
}
}

#[derive(Diagnostic)]
#[diag(codegen_ssa_aix_strip_not_used)]
pub(crate) struct AixStripNotUsed;
88 changes: 0 additions & 88 deletions compiler/rustc_hir_analysis/src/check/errs.rs

This file was deleted.

13 changes: 0 additions & 13 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,19 +1351,6 @@ pub fn build_target_config(early_dcx: &EarlyDiagCtxt, opts: &Options, sysroot: &
early_dcx.early_warn(warning)
}

// The `wasm32-wasi` target is being renamed to `wasm32-wasip1` as
// part of rust-lang/compiler-team#607 and
// rust-lang/compiler-team#695. Warn unconditionally on usage to
// raise awareness of the renaming. This code will be deleted in
// October 2024.
if opts.target_triple.tuple() == "wasm32-wasi" {
early_dcx.early_warn(
"the `wasm32-wasi` target is being renamed to \
`wasm32-wasip1` and the `wasm32-wasi` target will be \
removed from nightly in October 2024 and removed from \
stable Rust in January 2025",
)
}
if !matches!(target.pointer_width, 16 | 32 | 64) {
early_dcx.early_fatal(format!(
"target specification was invalid: unrecognized target-pointer-width {}",
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,6 @@ supported_targets! {
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
("wasm32-unknown-unknown", wasm32_unknown_unknown),
("wasm32v1-none", wasm32v1_none),
("wasm32-wasi", wasm32_wasi),
("wasm32-wasip1", wasm32_wasip1),
("wasm32-wasip2", wasm32_wasip2),
("wasm32-wasip1-threads", wasm32_wasip1_threads),
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_target/src/spec/targets/wasm32_wasi.rs

This file was deleted.

4 changes: 2 additions & 2 deletions compiler/rustc_target/src/spec/targets/wasm32_wasip1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub(crate) fn target() -> Target {

options.os = "wasi".into();
options.env = "p1".into();
options.add_pre_link_args(LinkerFlavor::WasmLld(Cc::Yes), &["--target=wasm32-wasi"]);
options.add_pre_link_args(LinkerFlavor::WasmLld(Cc::Yes), &["--target=wasm32-wasip1"]);

options.pre_link_objects_self_contained = crt_objects::pre_wasi_self_contained();
options.post_link_objects_self_contained = crt_objects::post_wasi_self_contained();
Expand Down Expand Up @@ -47,7 +47,7 @@ pub(crate) fn target() -> Target {
options.entry_name = "__main_void".into();

Target {
llvm_target: "wasm32-wasi".into(),
llvm_target: "wasm32-wasip1".into(),
metadata: crate::spec::TargetMetadata {
description: Some("WebAssembly with WASI".into()),
tier: Some(2),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/targets/wasm32_wasip2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! The `wasm32-wasip2` target is the next evolution of the
//! wasm32-wasi target. While the wasi specification is still under
//! wasm32-wasip1 target. While the wasi specification is still under
//! active development, the preview 2 iteration is considered an "island
//! of stability" that should allow users to rely on it indefinitely.
//!
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ const WASM_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
("relaxed-simd", Stable, &["simd128"]),
("sign-ext", Stable, &[]),
("simd128", Stable, &[]),
("wide-arithmetic", Unstable(sym::wasm_target_feature), &[]),
// tidy-alphabetical-end
];

Expand Down
5 changes: 3 additions & 2 deletions library/core/src/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2122,7 +2122,6 @@ impl<T: ?Sized> UnsafeCell<T> {
/// # Examples
///
/// ```
/// # #![feature(unsafe_cell_from_mut)]
/// use std::cell::UnsafeCell;
///
/// let mut val = 42;
Expand All @@ -2132,7 +2131,9 @@ impl<T: ?Sized> UnsafeCell<T> {
/// assert_eq!(*uc.get_mut(), 41);
/// ```
#[inline(always)]
#[unstable(feature = "unsafe_cell_from_mut", issue = "111645")]
#[stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "unsafe_cell_from_mut", since = "CURRENT_RUSTC_VERSION")]
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
pub const fn from_mut(value: &mut T) -> &mut UnsafeCell<T> {
// SAFETY: `UnsafeCell<T>` has the same memory layout as `T` due to #[repr(transparent)].
unsafe { &mut *(value as *mut T as *mut UnsafeCell<T>) }
Expand Down
11 changes: 9 additions & 2 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ impl Step for Std {
.join(compiler.host)
.join("bin");
if src_sysroot_bin.exists() {
let target_sysroot_bin =
builder.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin");
let target_sysroot_bin = builder.sysroot_target_bindir(compiler, target);
t!(fs::create_dir_all(&target_sysroot_bin));
builder.cp_link_r(&src_sysroot_bin, &target_sysroot_bin);
}
Expand Down Expand Up @@ -1977,6 +1976,14 @@ impl Step for Assemble {
}
}

{
// `llvm-strip` is used by rustc, which is actually just a symlink to `llvm-objcopy`,
// so copy and rename `llvm-objcopy`.
let src_exe = exe("llvm-objcopy", target_compiler.host);
let dst_exe = exe("rust-objcopy", target_compiler.host);
builder.copy_link(&libdir_bin.join(src_exe), &libdir_bin.join(dst_exe));
}

// In addition to `rust-lld` also install `wasm-component-ld` when
// LLD is enabled. This is a relatively small binary that primarily
// delegates to the `rust-lld` binary for linking and then runs
Expand Down
14 changes: 10 additions & 4 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ impl Step for Rustc {

// Copy over lld if it's there
if builder.config.lld_enabled {
let src_dir =
builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
let src_dir = builder.sysroot_target_bindir(compiler, host);
let rust_lld = exe("rust-lld", compiler.host);
builder.copy_link(&src_dir.join(&rust_lld), &dst_dir.join(&rust_lld));
let self_contained_lld_src_dir = src_dir.join("gcc-ld");
Expand All @@ -474,9 +473,16 @@ impl Step for Rustc {
);
}
}

{
let src_dir = builder.sysroot_target_bindir(compiler, host);
let llvm_objcopy = exe("llvm-objcopy", compiler.host);
let rust_objcopy = exe("rust-objcopy", compiler.host);
builder.copy_link(&src_dir.join(&llvm_objcopy), &dst_dir.join(&rust_objcopy));
}

if builder.tool_enabled("wasm-component-ld") {
let src_dir =
builder.sysroot_target_libdir(compiler, host).parent().unwrap().join("bin");
let src_dir = builder.sysroot_target_bindir(compiler, host);
let ld = exe("wasm-component-ld", compiler.host);
builder.copy_link(&src_dir.join(&ld), &dst_dir.join(&ld));
}
Expand Down
5 changes: 5 additions & 0 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1161,6 +1161,11 @@ impl<'a> Builder<'a> {
self.ensure(compile::Sysroot::new(compiler))
}

/// Returns the bindir for a compiler's sysroot.
pub fn sysroot_target_bindir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
self.sysroot_target_libdir(compiler, target).parent().unwrap().join("bin")
}

/// Returns the libdir where the standard library and other artifacts are
/// found for a compiler's sysroot.
pub fn sysroot_target_libdir(&self, compiler: Compiler, target: TargetSelection) -> PathBuf {
Expand Down
1 change: 0 additions & 1 deletion src/ci/docker/host-x86_64/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ ENV CARGO_TARGET_AARCH64_UNKNOWN_FUCHSIA_RUSTFLAGS \
ENV TARGETS=x86_64-unknown-fuchsia
ENV TARGETS=$TARGETS,aarch64-unknown-fuchsia
ENV TARGETS=$TARGETS,wasm32-unknown-unknown
ENV TARGETS=$TARGETS,wasm32-wasi
ENV TARGETS=$TARGETS,wasm32-wasip1
ENV TARGETS=$TARGETS,wasm32-wasip1-threads
ENV TARGETS=$TARGETS,wasm32-wasip2
Expand Down
5 changes: 2 additions & 3 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ target | std | notes
[`thumbv8m.main-none-eabihf`](platform-support/thumbv8m.main-none-eabi.md) | * | Bare Armv8-M Mainline, hardfloat
[`wasm32-unknown-emscripten`](platform-support/wasm32-unknown-emscripten.md) | ✓ | WebAssembly via Emscripten
[`wasm32-unknown-unknown`](platform-support/wasm32-unknown-unknown.md) | ✓ | WebAssembly
`wasm32-wasi` | ✓ | WebAssembly with WASI (undergoing a [rename to `wasm32-wasip1`][wasi-rename])
[`wasm32-wasip1`](platform-support/wasm32-wasip1.md) | ✓ | WebAssembly with WASI
[`wasm32-wasip1`](platform-support/wasm32-wasip1.md) | ✓ | WebAssembly with WASIp1
[`wasm32-wasip2`](platform-support/wasm32-wasip2.md) | ✓ | WebAssembly with WASIp2
[`wasm32-wasip1-threads`](platform-support/wasm32-wasip1-threads.md) | ✓ | WebAssembly with WASI Preview 1 and threads
[`wasm32v1-none`](platform-support/wasm32v1-none.md) | * | WebAssembly limited to 1.0 features and no imports
[`x86_64-apple-ios`](platform-support/apple-ios.md) | ✓ | 64-bit x86 iOS
Expand Down Expand Up @@ -377,7 +377,6 @@ target | std | host | notes
`thumbv7a-pc-windows-msvc` | ✓ | |
`thumbv7a-uwp-windows-msvc` | ✓ | |
`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-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
Expand Down
4 changes: 0 additions & 4 deletions src/doc/rustc/src/platform-support/wasm32-wasip1.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ the target with:
rustup target add wasm32-wasip1
```

> **Note**: the `wasm32-wasip1` target is new and may only be available
> on nightly by the time you're reading this. If `wasm32-wasip1` isn't
> available on stable Rust then `wasm32-wasi` should be available instead.
Rust programs can be built for that target:

```text
Expand Down
2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/compiler-flags/wasm-c-abi.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This option controls whether Rust uses the spec-compliant C ABI when compiling
for the `wasm32-unknown-unknown` target.

This makes it possible to be ABI-compatible with all other spec-compliant Wasm
like Rusts `wasm32-wasi`.
like Rusts `wasm32-wasip1`.

This compiler flag is perma-unstable, as it will be enabled by default in the
future with no option to fall back to the old non-spec-compliant ABI.
1 change: 0 additions & 1 deletion src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ static TARGETS: &[&str] = &[
"thumbv8m.main-none-eabihf",
"wasm32-unknown-emscripten",
"wasm32-unknown-unknown",
"wasm32-wasi",
"wasm32-wasip1",
"wasm32-wasip1-threads",
"wasm32-wasip2",
Expand Down
4 changes: 0 additions & 4 deletions src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,10 +583,6 @@ fn wasm_special() {
("wasm32-unknown-emscripten", "emscripten", true),
("wasm32-unknown-emscripten", "wasm32", true),
("wasm32-unknown-emscripten", "wasm32-bare", false),
("wasm32-wasi", "emscripten", false),
("wasm32-wasi", "wasm32", true),
("wasm32-wasi", "wasm32-bare", false),
("wasm32-wasi", "wasi", true),
("wasm32-wasip1", "emscripten", false),
("wasm32-wasip1", "wasm32", true),
("wasm32-wasip1", "wasm32-bare", false),
Expand Down
Loading

0 comments on commit a69df72

Please sign in to comment.