Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename wasm32-wasi to wasm32-wasi-preview1 #110596

Closed
wants to merge 14 commits into from
Closed
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ jobs:
- name: dist-x86_64-linux
os: ubuntu-20.04-16core-64gb
env: {}
- name: dist-various-2
os: ubuntu-20.04-8core-32gb
env: {}
timeout-minutes: 600
runs-on: "${{ matrix.os }}"
steps:
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1400,7 +1400,7 @@ supported_targets! {
("asmjs-unknown-emscripten", asmjs_unknown_emscripten),
("wasm32-unknown-emscripten", wasm32_unknown_emscripten),
("wasm32-unknown-unknown", wasm32_unknown_unknown),
("wasm32-wasi", wasm32_wasi),
("wasm32-wasi-preview1", wasm32_wasi_preview1),
("wasm64-unknown-unknown", wasm64_unknown_unknown),

("thumbv6m-none-eabi", thumbv6m_none_eabi),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! The `wasm32-wasi` target is a new and still (as of April 2019) an
//! The `wasm32-wasi-preview1` target is a new and still (as of April 2019) an
//! experimental target. The definition in this file is likely to be tweaked
//! over time and shouldn't be relied on too much.
//!
Expand All @@ -13,12 +13,12 @@
//! serve two use cases here with this target:
//!
//! * First, we want Rust usage of the target to be as hassle-free as possible,
//! ideally avoiding the need to configure and install a local wasm32-wasi
//! ideally avoiding the need to configure and install a local wasm32-wasi-preview1
//! toolchain.
//!
//! * Second, one of the primary use cases of LLVM's new wasm backend and the
//! wasm support in LLD is that any compiled language can interoperate with
//! any other. To that the `wasm32-wasi` target is the first with a viable C
//! any other. To that the `wasm32-wasi-preview1` target is the first with a viable C
//! standard library and sysroot common definition, so we want Rust and C/C++
//! code to interoperate when compiled to `wasm32-unknown-unknown`.
//!
Expand All @@ -39,7 +39,7 @@
//! necessary.
//!
//! All in all, by default, no external dependencies are required. You can
//! compile `wasm32-wasi` binaries straight out of the box. You can't, however,
//! compile `wasm32-wasi-preview1` binaries straight out of the box. You can't, however,
//! reliably interoperate with C code in this mode (yet).
//!
//! ## Interop with C required
Expand All @@ -53,7 +53,7 @@
//!
//! 2. If you're using rustc to build a linked artifact then you'll need to
//! specify `-C linker` to a `clang` binary that supports
//! `wasm32-wasi` and is configured with the `wasm32-wasi` sysroot. This
//! `wasm32-wasi-preview1` and is configured with the `wasm32-wasi-preview1` sysroot. This
//! will cause Rust code to be linked against the libc.a that the specified
//! `clang` provides.
//!
Expand Down
6 changes: 3 additions & 3 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ changelog-seen = 2
# The full path to the musl libdir.
#musl-libdir = musl-root/lib

# The root location of the `wasm32-wasi` sysroot. Only used for the
# `wasm32-wasi` target. If you are building wasm32-wasi target, make sure to
# create a `[target.wasm32-wasi]` section and move this field there.
# The root location of the `wasm32-wasi-preview1` sysroot. Only used for the
# `wasm32-wasi-preview1` target. If you are building wasm32-wasi-preview1 target, make sure to
# create a `[target.wasm32-wasi-preview1]` section and move this field there.
#wasi-root = <none> (path)

# Used in testing for configuring where the QEMU images are located, you
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fortanix-sgx-abi = { version = "0.5.0", features = ['rustc-dep-of-std'], public
[target.'cfg(target_os = "hermit")'.dependencies]
hermit-abi = { version = "0.3.0", features = ['rustc-dep-of-std'] }

[target.wasm32-wasi.dependencies]
[target.wasm32-wasi-preview1.dependencies]
wasi = { version = "0.11.0", features = ['rustc-dep-of-std'], default-features = false }

[features]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/wasi/io/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// As a result, the items in os::fd::raw were given the
// rustc_allowed_through_unstable_modules attribute.
// No regression tests were added to ensure this property,
// as CI is not configured to test wasm32-wasi.
// as CI is not configured to test wasm32-wasi-preview1.
// If this module is stabilized,
// you may want to remove those attributes
// (assuming no other unstable modules need them).
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ fn copy_self_contained_objects(
.unwrap_or_else(|| {
panic!("Target {:?} does not have a \"wasi-root\" key", target.triple)
})
.join("lib/wasm32-wasi");
.join("lib/wasm32-wasi-preview1");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it able to find wasi-libc sysroot? My understanding wasi-libc targets doesn't mention -preview1

Copy link
Contributor

@g0djan g0djan Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to compile a simple file with rustc +stage1 -v --target=wasm32-wasi-preview1 main2.rs

fn main() {
        println!("hi");
}

And it failed with

  = note: rust-lld: error: cannot open crt1-command.o: No such file or directory
          rust-lld: error: unable to find library -lc

Also I ran the tests the same way I did here #112922 (comment)
and many more tests(almost 4k) failed due to the same error that I showed above.

Without this change I'm able to compile the same file to wasm32-wasi and only 191 test fails without this change instead of 4007 with this change.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I might be doing something wrong though, but could you try to run it yourself please @yoshuawuyts

Copy link
Contributor

@g0djan g0djan Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to fix it by removing -preview1 from here, but it doesn't fix the problem

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried to fix it by removing -preview1 from here, but it doesn't fix the problem

You most likely have to revert the other change in the same file (line 411) as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I did, stiil the same

Copy link
Contributor

@g0djan g0djan Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, several lines above it should check for containing wasi instead of ending with it. I will send a patch

Copy link
Contributor

@g0djan g0djan Jul 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I don't have permissions to update your branch @yoshuawuyts , here's the fix + merge master branch and resolving of conflicts https://github.com/rust-lang/rust/compare/master...g0djan:rust:rename-wasm32-wasi?expand=1

I also reran ui tests and now your pr doesn't break or fix any tests compared to running tests without your pr.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've spoken to the maintainers of wasi-libc, and they indeed haven't updated the target yet to include the -preview1 suffix. This is coming down the pipeline at some point in the near future, but hasn't happened yet.

So thank you for catching and fixing this; we indeed should land this change!

for &obj in &["libc.a", "crt1-command.o", "crt1-reactor.o"] {
copy_and_stamp(
builder,
Expand Down Expand Up @@ -408,7 +408,7 @@ pub fn std_cargo(builder: &Builder<'_>, target: TargetSelection, stage: u32, car

if target.ends_with("-wasi") {
if let Some(p) = builder.wasi_root(target) {
let root = format!("native={}/lib/wasm32-wasi", p.to_str().unwrap());
let root = format!("native={}/lib/wasm32-wasi-preview1", p.to_str().unwrap());
cargo.rustflag("-L").rustflag(&root);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ impl Step for CompiletestTest {
&[],
);
cargo.allow_features("test");
cargo.env("RUSTC_STAGE", builder.top_stage.to_string());
run_cargo_test(cargo, &[], &[], "compiletest", compiler, host, builder);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ 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-wasi-preview1
ENV TARGETS=$TARGETS,sparcv9-sun-solaris
ENV TARGETS=$TARGETS,x86_64-pc-solaris
ENV TARGETS=$TARGETS,x86_64-sun-solaris
Expand All @@ -135,7 +135,7 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi
RUN ln -s /usr/include/asm-generic /usr/local/include/asm

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
--set target.wasm32-wasi-preview1.wasi-root=/wasm32-wasi-preview1 \
--musl-root-armv7=/musl-armv7

ENV SCRIPT python3 ../x.py dist --host='' --target $TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ make -j$(nproc) \
CC="$bin/clang" \
NM="$bin/llvm-nm" \
AR="$bin/llvm-ar" \
INSTALL_DIR=/wasm32-wasi \
INSTALL_DIR=/wasm32-wasi-preview1 \
install

cd ..
Expand Down
2 changes: 2 additions & 0 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,8 @@ jobs:
- &dist-x86_64-linux
name: dist-x86_64-linux
<<: *job-linux-16c
- name: dist-various-2
<<: *job-linux-8c

master:
name: master
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ target | std | notes
`thumbv8m.main-none-eabihf` | * | Bare ARMv8-M Mainline, hardfloat
`wasm32-unknown-emscripten` | ✓ | WebAssembly via Emscripten
`wasm32-unknown-unknown` | ✓ | WebAssembly
`wasm32-wasi` | ✓ | WebAssembly with WASI
`wasm32-wasi-preview1` | ✓ | WebAssembly with WASI Preview 1
`x86_64-apple-ios` | ✓ | 64-bit x86 iOS
[`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`
Expand Down
2 changes: 1 addition & 1 deletion src/tools/build-manifest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static TARGETS: &[&str] = &[
"thumbv8m.main-none-eabihf",
"wasm32-unknown-emscripten",
"wasm32-unknown-unknown",
"wasm32-wasi",
"wasm32-wasi-preview1",
"x86_64-apple-darwin",
"x86_64-apple-ios",
"x86_64-fortanix-unknown-sgx",
Expand Down
28 changes: 23 additions & 5 deletions src/tools/compiletest/src/header/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ fn pointer_width() {

#[test]
fn wasm_special() {
let ignores = [
let mut ignores = vec![
("wasm32-unknown-unknown", "emscripten", true),
("wasm32-unknown-unknown", "wasm32", true),
("wasm32-unknown-unknown", "wasm32-bare", true),
Expand All @@ -446,15 +446,33 @@ 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),
("wasm64-unknown-unknown", "emscripten", false),
("wasm64-unknown-unknown", "wasm32", false),
("wasm64-unknown-unknown", "wasm32-bare", false),
("wasm64-unknown-unknown", "wasm64", true),
];

// FIXME(yosh): We're updating the "wasm32-wasi" target name to "wasm32-wasi-preview1".
// The MinGW tests run a beta compiler on stage 0 which means we're having a target mismatch
// for a brief period. When a new beta release is cut, the `if` part of this conditional should be
// removed, and the `else` part should be re-inlined in the original `ignores` list.
// cfg(bootstrap)
if env!("RUSTC_STAGE") == "0" {
ignores.append(&mut vec![
("wasm32-wasi", "emscripten", false),
("wasm32-wasi", "wasm32", true),
("wasm32-wasi", "wasm32-bare", false),
("wasm32-wasi", "wasi", true),
]);
} else {
ignores.append(&mut vec![
("wasm32-wasi-preview1", "emscripten", false),
("wasm32-wasi-preview1", "wasm32", true),
("wasm32-wasi-preview1", "wasm32-bare", false),
("wasm32-wasi-preview1", "wasi", true),
]);
}

for (target, pattern, ignore) in ignores {
let mut config = config();
config.target = target.to_string();
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ case $HOST_TARGET in
MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
MIRI_TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal hello integer vec panic/panic concurrency/simple atomic data_race env/var
MIRI_TEST_TARGET=aarch64-linux-android run_tests_minimal hello integer vec panic/panic
MIRI_TEST_TARGET=wasm32-wasi run_tests_minimal no_std integer strings
MIRI_TEST_TARGET=wasm32-wasi-preview1 run_tests_minimal no_std integer strings
MIRI_TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std integer strings
MIRI_TEST_TARGET=thumbv7em-none-eabihf MIRI_NO_STD=1 run_tests_minimal no_std # no_std embedded architecture
MIRI_TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std # JSON target file
Expand Down
33 changes: 1 addition & 32 deletions src/tools/opt-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use log::LevelFilter;

use crate::environment::{create_environment, Environment};
use crate::exec::Bootstrap;
use crate::tests::run_tests;
use crate::timer::Timer;
use crate::training::{gather_llvm_bolt_profiles, gather_llvm_profiles, gather_rustc_profiles};
use crate::utils::io::reset_directory;
Expand All @@ -12,15 +11,10 @@ use crate::utils::{clear_llvm_files, format_env_variables, print_free_disk_space
mod environment;
mod exec;
mod metrics;
mod tests;
mod timer;
mod training;
mod utils;

fn is_try_build() -> bool {
std::env::var("DIST_TRY_BUILD").unwrap_or_else(|_| "0".to_string()) != "0"
}

fn execute_pipeline(
env: &dyn Environment,
timer: &mut Timer,
Expand Down Expand Up @@ -117,14 +111,6 @@ fn execute_pipeline(
// The previous PGO optimized rustc build and PGO optimized LLVM builds should be reused.
timer.section("Stage 4 (final build)", |stage| dist.run(stage))?;

// After dist has finished, run a subset of the test suite on the optimized artifacts to discover
// possible regressions.
// The tests are not executed for try builds, which can be in various broken states, so we don't
// want to gatekeep them with tests.
if !is_try_build() {
timer.section("Run tests", |_| run_tests(env))?;
}

Ok(())
}

Expand All @@ -138,31 +124,14 @@ fn main() -> anyhow::Result<()> {
.parse_default_env()
.init();

let mut build_args: Vec<String> = std::env::args().skip(1).collect();
let build_args: Vec<String> = std::env::args().skip(1).collect();
log::info!("Running optimized build pipeline with args `{}`", build_args.join(" "));
log::info!("Environment values\n{}", format_env_variables());

if let Ok(config) = std::fs::read_to_string("config.toml") {
log::info!("Contents of `config.toml`:\n{config}");
}

// Skip components that are not needed for try builds to speed them up
if is_try_build() {
log::info!("Skipping building of unimportant components for a try build");
for target in [
"rust-docs",
"rustc-docs",
"rust-docs-json",
"rust-analyzer",
"rustc-src",
"clippy",
"miri",
"rustfmt",
] {
build_args.extend(["--exclude".to_string(), target.to_string()]);
}
}

let mut timer = Timer::new();
let env = create_environment();

Expand Down
101 changes: 0 additions & 101 deletions src/tools/opt-dist/src/tests.rs

This file was deleted.

Loading