Skip to content

Commit

Permalink
Auto merge of rust-lang#126880 - Rejyr:migrate-rmake-vw, r=<try>
Browse files Browse the repository at this point in the history
Migrate `volatile-intrinsics`, `weird-output-filenames`, `wasm-override-linker`, `wasm-exceptions-nostd` to `rmake`

Also refactors `wasm-abi` and `compressed-debuginfo`.

Part of rust-lang#121876.

r? `@jieyouxu`

try-job: x86_64-gnu-debug
try-job: dist-various-2
  • Loading branch information
bors committed Jun 24, 2024
2 parents 2c243d9 + 5dcc559 commit 6b6cbbe
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 69 deletions.
4 changes: 0 additions & 4 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,4 @@ run-make/unknown-mod-stdin/Makefile
run-make/unstable-flag-required/Makefile
run-make/use-suggestions-rust-2018/Makefile
run-make/used-cdylib-macos/Makefile
run-make/volatile-intrinsics/Makefile
run-make/wasm-exceptions-nostd/Makefile
run-make/wasm-override-linker/Makefile
run-make/weird-output-filenames/Makefile
run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile
5 changes: 2 additions & 3 deletions tests/run-make/compressed-debuginfo/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// FIXME: This test isn't comprehensive and isn't covering all possible combinations.

use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc};
use run_make_support::{assert_contains, cmd, llvm_readobj, run_in_tmpdir, rustc};

fn check_compression(compression: &str, to_find: &str) {
run_in_tmpdir(|| {
Expand All @@ -19,8 +19,7 @@ fn check_compression(compression: &str, to_find: &str) {
.run();
let stderr = out.stderr_utf8();
if stderr.is_empty() {
// FIXME: `readelf` might need to be replaced with `llvm-readelf`.
cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
llvm_readobj().arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
} else {
assert_contains(
&stderr,
Expand Down
10 changes: 0 additions & 10 deletions tests/run-make/volatile-intrinsics/Makefile

This file was deleted.

18 changes: 18 additions & 0 deletions tests/run-make/volatile-intrinsics/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ ignore-cross-compile

use run_make_support::fs_wrapper::read;
use run_make_support::{assert_contains, run, rustc};

fn main() {
// The tests must pass...
rustc().input("main.rs").run();
run("main");

// ... and the loads/stores must not be optimized out.
rustc().input("main.rs").emit("llvm-ir").run();

let raw_llvm_ir = read("main.ll");
let llvm_ir = String::from_utf8_lossy(&raw_llvm_ir);
assert_contains(&llvm_ir, "load volatile");
assert_contains(&llvm_ir, "store volatile");
}
11 changes: 4 additions & 7 deletions tests/run-make/wasm-abi/rmake.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//@ only-wasm32-wasip1
//@ needs-wasmtime

use run_make_support::rustc;
use run_make_support::{cmd, rustc};
use std::path::Path;
use std::process::Command;

fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
Expand All @@ -19,14 +18,12 @@ fn main() {
}

fn run(file: &Path, method: &str, expected_output: &str) {
let output = Command::new("wasmtime")
cmd("wasmtime")
.arg("run")
.arg("--preload=host=host.wat")
.arg("--invoke")
.arg(method)
.arg(file)
.output()
.unwrap();
assert!(output.status.success());
assert_eq!(expected_output, String::from_utf8_lossy(&output.stdout));
.run()
.assert_stdout_equals(expected_output);
}
12 changes: 0 additions & 12 deletions tests/run-make/wasm-exceptions-nostd/Makefile

This file was deleted.

18 changes: 18 additions & 0 deletions tests/run-make/wasm-exceptions-nostd/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ only-wasm32-bare

use std::path::Path;

use run_make_support::{cmd, env_var, rustc};

fn main() {
// Add a few command line args to make exceptions work
rustc()
.input(Path::new("src").join("lib.rs"))
.target("wasm32-unknown-unknown")
.panic("unwind")
.arg("-Cllvm-args=-wasm-enable-eh")
.arg("-Ctarget-feature=+exception-handling")
.run();

cmd(&env_var("NODE")).arg("verify.mjs").arg("lib.wasm").run();
}
4 changes: 2 additions & 2 deletions tests/run-make/wasm-exceptions-nostd/src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fn panic_handler(info: &core::panic::PanicInfo<'_>) -> ! {
use alloc::boxed::Box;
use alloc::string::ToString;

let msg = info.message().map(|msg| msg.to_string()).unwrap_or("(no message)".to_string());
let exception = Box::new(msg.to_string());
let msg = info.message().to_string();
let exception = Box::new(msg);
unsafe {
let exception_raw = Box::into_raw(exception);
wasm_throw(exception_raw as *mut u8);
Expand Down
16 changes: 0 additions & 16 deletions tests/run-make/wasm-override-linker/Makefile

This file was deleted.

17 changes: 17 additions & 0 deletions tests/run-make/wasm-override-linker/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// How to run this
// $ RUSTBUILD_FORCE_CLANG_BASED_TESTS=1 ./x.py test tests/run-make/wasm-override-linker/

//@ needs-force-clang-based-tests

use run_make_support::{env_var, rustc, target};

fn main() {
if matches!(target().as_str(), "wasm32-unknown-unknown" | "wasm64-unknown-unknown") {
rustc()
.input("foo.rs")
.crate_type("cdylib")
.target(&target())
.linker(&env_var("CLANG"))
.run();
}
}
15 changes: 0 additions & 15 deletions tests/run-make/weird-output-filenames/Makefile

This file was deleted.

19 changes: 19 additions & 0 deletions tests/run-make/weird-output-filenames/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use run_make_support::fs_wrapper::copy;
use run_make_support::regex::Regex;
use run_make_support::{cwd, rustc};

fn main() {
let invalid_characters = [".foo.rs", ".foo.bar", "+foo+bar.rs"];
let re = Regex::new(r"invalid character.*in crate name:").unwrap();
for f in invalid_characters {
copy("foo.rs", f);
let stderr = rustc().input(f).run_fail().stderr_utf8();
assert!(re.is_match(&stderr));
}

copy("foo.rs", "-foo.rs");
rustc()
.input(cwd().join("-foo.rs"))
.run_fail()
.assert_stderr_contains("crate names cannot start with a `-`");
}

0 comments on commit 6b6cbbe

Please sign in to comment.