mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Auto merge of #122036 - alexcrichton:test-wasm-with-wasi, r=oli-obk
Test wasm32-wasip1 in CI, not wasm32-unknown-unknown This commit changes CI to no longer test the `wasm32-unknown-unknown` target and instead test the `wasm32-wasip1` target. There was some discussion of this in a [Zulip thread], and the motivations for this PR are: * Runtime failures on `wasm32-unknown-unknown` print nothing, meaning all you get is "something failed". In contrast `wasm32-wasip1` can print to stdout/stderr. * The unknown-unknown target is missing lots of pieces of libstd, and while `wasm32-wasip1` is also missing some pieces (e.g. threads) it's missing fewer pieces. This means that many more tests can be run. Overall my hope is to improve the debuggability of wasm failures on CI and ideally be a bit less of a maintenance burden. This commit specifically removes the testing of `wasm32-unknown-unknown` and replaces it with testing of `wasm32-wasip1`. Along the way there were a number of other archiectural changes made as well, including: * A new `target.*.runtool` option can now be specified in `config.toml` which is passed as `--runtool` to `compiletest`. This is used to reimplement execution of WebAssembly in a less-wasm-specific fashion. * The default value for `runtool` is an ambiently located WebAssembly runtime found on the system, if any. I've implemented logic for Wasmtime. * Existing testing support for `wasm32-unknown-unknown` and Emscripten has been removed. I'm not aware of Emscripten testing being run any time recently and otherwise `wasm32-wasip1` is in theory the focus now. * I've added a new `//@ needs-threads` directive for `compiletest` and classified a bunch of wasm-ignored tests as needing threads. In theory these tests can run on `wasm32-wasi-preview1-threads`, for example. * I've tried to audit all existing tests that are either `ignore-emscripten` or `ignore-wasm*`. Many now run on `wasm32-wasip1` due to being able to emit error messages, for example. Many are updated with comments as to why they can't run as well. * The `compiletest` output matching for `wasm32-wasip1` automatically uses "match a subset" mode implemented in `compiletest`. This is because WebAssembly runtimes often add extra information on failure, such as the `unreachable` instruction in `panic!`, which isn't able to be matched against the golden output from native platforms. * I've ported most existing `run-make` tests that use custom Node.js wrapper scripts to the new run-make-based-in-Rust infrastructure. To do this I added `wasmparser` as a dependency of `run-make-support` for the various wasm tests to use that parse wasm files. The one test that executed WebAssembly now uses `wasmtime`-the-CLI to execute the test instead. I have not ported over an exception-handling test as Wasmtime doesn't implement this yet. * I've updated the `test` crate to print out timing information for WASI targets as it can do that (gets a previously ignored test now passing). * The `test-various` image now builds a WASI sysroot for the WASI target and additionally downloads a fixed release of Wasmtime, currently the latest one at 18.0.2, and uses that for testing. [Zulip thread]: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Have.20wasm.20tests.20ever.20caused.20problems.20on.20CI.3F/near/424317944
This commit is contained in:
commit
dc2ffa4054
@ -3309,6 +3309,9 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "run_make_support"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"wasmparser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rust-demangler"
|
||||
|
@ -323,10 +323,11 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Resu
|
||||
// Prevent the usage of `Instant` in some cases:
|
||||
// - It's currently not supported for wasm targets.
|
||||
// - We disable it for miri because it's not available when isolation is enabled.
|
||||
let is_instant_supported =
|
||||
!cfg!(target_family = "wasm") && !cfg!(target_os = "zkvm") && !cfg!(miri);
|
||||
let is_instant_unsupported = (cfg!(target_family = "wasm") && !cfg!(target_os = "wasi"))
|
||||
|| cfg!(target_os = "zkvm")
|
||||
|| cfg!(miri);
|
||||
|
||||
let start_time = is_instant_supported.then(Instant::now);
|
||||
let start_time = (!is_instant_unsupported).then(Instant::now);
|
||||
run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?;
|
||||
st.exec_time = start_time.map(|t| TestSuiteExecTime(t.elapsed()));
|
||||
|
||||
|
@ -1657,8 +1657,8 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
|
||||
// ensure that `libproc_macro` is available on the host.
|
||||
builder.ensure(compile::Std::new(compiler, compiler.host));
|
||||
|
||||
// As well as the target, except for plain wasm32, which can't build it
|
||||
if suite != "mir-opt" && !target.contains("wasm") && !target.contains("emscripten") {
|
||||
// As well as the target
|
||||
if suite != "mir-opt" {
|
||||
builder.ensure(TestHelpers { target });
|
||||
}
|
||||
|
||||
@ -2511,16 +2511,7 @@ fn prepare_cargo_test(
|
||||
dylib_path.insert(0, PathBuf::from(&*builder.sysroot_libdir(compiler, target)));
|
||||
cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
|
||||
|
||||
if target.contains("emscripten") {
|
||||
cargo.env(
|
||||
format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
|
||||
builder.config.nodejs.as_ref().expect("nodejs not configured"),
|
||||
);
|
||||
} else if target.starts_with("wasm32") {
|
||||
let node = builder.config.nodejs.as_ref().expect("nodejs not configured");
|
||||
let runner = format!("{} {}/src/etc/wasm32-shim.js", node.display(), builder.src.display());
|
||||
cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)), &runner);
|
||||
} else if builder.remote_tested(target) {
|
||||
if builder.remote_tested(target) {
|
||||
cargo.env(
|
||||
format!("CARGO_TARGET_{}_RUNNER", envify(&target.triple)),
|
||||
format!("{} run 0", builder.tool_exe(Tool::RemoteTestClient).display()),
|
||||
|
@ -1361,9 +1361,36 @@ impl Build {
|
||||
/// An example of this would be a WebAssembly runtime when testing the wasm
|
||||
/// targets.
|
||||
fn runner(&self, target: TargetSelection) -> Option<String> {
|
||||
let target = self.config.target_config.get(&target)?;
|
||||
let runner = target.runner.as_ref()?;
|
||||
Some(runner.to_owned())
|
||||
let configured_runner =
|
||||
self.config.target_config.get(&target).and_then(|t| t.runner.as_ref()).map(|p| &**p);
|
||||
if let Some(runner) = configured_runner {
|
||||
return Some(runner.to_owned());
|
||||
}
|
||||
|
||||
if target.starts_with("wasm") && target.contains("wasi") {
|
||||
self.default_wasi_runner()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// When a `runner` configuration is not provided and a WASI-looking target
|
||||
/// is being tested this is consulted to prove the environment to see if
|
||||
/// there's a runtime already lying around that seems reasonable to use.
|
||||
fn default_wasi_runner(&self) -> Option<String> {
|
||||
let mut finder = crate::core::sanity::Finder::new();
|
||||
|
||||
// Look for Wasmtime, and for its default options be sure to disable
|
||||
// its caching system since we're executing quite a lot of tests and
|
||||
// ideally shouldn't pollute the cache too much.
|
||||
if let Some(path) = finder.maybe_have("wasmtime") {
|
||||
if let Ok(mut path) = path.into_os_string().into_string() {
|
||||
path.push_str(" run -C cache=n --dir .");
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns the root of the "rootfs" image that this target will be using,
|
||||
|
@ -3,6 +3,7 @@ FROM ubuntu:22.04
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
clang-11 \
|
||||
llvm-11 \
|
||||
g++ \
|
||||
make \
|
||||
ninja-build \
|
||||
@ -38,10 +39,14 @@ WORKDIR /
|
||||
COPY scripts/sccache.sh /scripts/
|
||||
RUN sh /scripts/sccache.sh
|
||||
|
||||
COPY host-x86_64/dist-various-2/build-wasi-toolchain.sh /tmp/
|
||||
RUN /tmp/build-wasi-toolchain.sh
|
||||
|
||||
ENV RUST_CONFIGURE_ARGS \
|
||||
--musl-root-x86_64=/usr/local/x86_64-linux-musl \
|
||||
--set build.nodejs=/node-v18.12.0-linux-x64/bin/node \
|
||||
--set rust.lld
|
||||
--set rust.lld \
|
||||
--set target.wasm32-wasip1.wasi-root=/wasm32-wasip1
|
||||
|
||||
# Some run-make tests have assertions about code size, and enabling debug
|
||||
# assertions in libstd causes the binary to be much bigger than it would
|
||||
@ -50,7 +55,11 @@ ENV RUST_CONFIGURE_ARGS \
|
||||
ENV NO_DEBUG_ASSERTIONS=1
|
||||
ENV NO_OVERFLOW_CHECKS=1
|
||||
|
||||
ENV WASM_TARGETS=wasm32-unknown-unknown
|
||||
RUN curl -L https://github.com/bytecodealliance/wasmtime/releases/download/v18.0.2/wasmtime-v18.0.2-x86_64-linux.tar.xz | \
|
||||
tar -xJ
|
||||
ENV PATH "$PATH:/wasmtime-v18.0.2-x86_64-linux"
|
||||
|
||||
ENV WASM_TARGETS=wasm32-wasip1
|
||||
ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_TARGETS \
|
||||
tests/run-make \
|
||||
tests/ui \
|
||||
@ -59,7 +68,9 @@ ENV WASM_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $WASM_T
|
||||
tests/codegen \
|
||||
tests/assembly \
|
||||
library/core
|
||||
ENV CC_wasm32_unknown_unknown=clang-11
|
||||
ENV CC_wasm32_wasip1=clang-11 \
|
||||
CFLAGS_wasm32_wasip1="--sysroot /wasm32-wasip1" \
|
||||
AR_wasm32_wasip1=llvm-ar-11
|
||||
|
||||
ENV NVPTX_TARGETS=nvptx64-nvidia-cuda
|
||||
ENV NVPTX_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $NVPTX_TARGETS \
|
||||
|
@ -1,24 +0,0 @@
|
||||
// This is a small "shim" program which is used when wasm32 unit tests are run
|
||||
// in this repository. This program is intended to be run in node.js and will
|
||||
// load a wasm module into memory, instantiate it with a set of imports, and
|
||||
// then run it.
|
||||
//
|
||||
// There's a bunch of helper functions defined here in `imports.env`, but note
|
||||
// that most of them aren't actually needed to execute most programs. Many of
|
||||
// these are just intended for completeness or debugging. Hopefully over time
|
||||
// nothing here is needed for completeness.
|
||||
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
Error.stackTraceLimit = 20;
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let instance = new WebAssembly.Instance(m, {});
|
||||
try {
|
||||
instance.exports.main();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
process.exit(101);
|
||||
}
|
@ -493,12 +493,8 @@ impl<'test> TestCx<'test> {
|
||||
let expected_coverage_dump = self.load_expected_output(kind);
|
||||
let actual_coverage_dump = self.normalize_output(&proc_res.stdout, &[]);
|
||||
|
||||
let coverage_dump_errors = self.compare_output(
|
||||
kind,
|
||||
&actual_coverage_dump,
|
||||
&expected_coverage_dump,
|
||||
self.props.compare_output_lines_by_subset,
|
||||
);
|
||||
let coverage_dump_errors =
|
||||
self.compare_output(kind, &actual_coverage_dump, &expected_coverage_dump);
|
||||
|
||||
if coverage_dump_errors > 0 {
|
||||
self.fatal_proc_rec(
|
||||
@ -591,12 +587,8 @@ impl<'test> TestCx<'test> {
|
||||
self.fatal_proc_rec(&err, &proc_res);
|
||||
});
|
||||
|
||||
let coverage_errors = self.compare_output(
|
||||
kind,
|
||||
&normalized_actual_coverage,
|
||||
&expected_coverage,
|
||||
self.props.compare_output_lines_by_subset,
|
||||
);
|
||||
let coverage_errors =
|
||||
self.compare_output(kind, &normalized_actual_coverage, &expected_coverage);
|
||||
|
||||
if coverage_errors > 0 {
|
||||
self.fatal_proc_rec(
|
||||
@ -2632,9 +2624,7 @@ impl<'test> TestCx<'test> {
|
||||
// double the length.
|
||||
let mut f = self.output_base_dir().join("a");
|
||||
// FIXME: This is using the host architecture exe suffix, not target!
|
||||
if self.config.target.contains("emscripten") {
|
||||
f = f.with_extra_extension("js");
|
||||
} else if self.config.target.contains("wasm32") {
|
||||
if self.config.target.starts_with("wasm") {
|
||||
f = f.with_extra_extension("wasm");
|
||||
} else if self.config.target.contains("spirv") {
|
||||
f = f.with_extra_extension("spv");
|
||||
@ -2649,32 +2639,6 @@ impl<'test> TestCx<'test> {
|
||||
// then split apart its command
|
||||
let mut args = self.split_maybe_args(&self.config.runner);
|
||||
|
||||
// If this is emscripten, then run tests under nodejs
|
||||
if self.config.target.contains("emscripten") {
|
||||
if let Some(ref p) = self.config.nodejs {
|
||||
args.push(p.into());
|
||||
} else {
|
||||
self.fatal("emscripten target requested and no NodeJS binary found (--nodejs)");
|
||||
}
|
||||
// If this is otherwise wasm, then run tests under nodejs with our
|
||||
// shim
|
||||
} else if self.config.target.contains("wasm32") {
|
||||
if let Some(ref p) = self.config.nodejs {
|
||||
args.push(p.into());
|
||||
} else {
|
||||
self.fatal("wasm32 target requested and no NodeJS binary found (--nodejs)");
|
||||
}
|
||||
|
||||
let src = self
|
||||
.config
|
||||
.src_base
|
||||
.parent()
|
||||
.unwrap() // chop off `ui`
|
||||
.parent()
|
||||
.unwrap(); // chop off `tests`
|
||||
args.push(src.join("src/etc/wasm32-shim.js").into_os_string());
|
||||
}
|
||||
|
||||
let exe_file = self.make_exe_name();
|
||||
|
||||
args.push(exe_file.into_os_string());
|
||||
@ -4079,35 +4043,17 @@ impl<'test> TestCx<'test> {
|
||||
match output_kind {
|
||||
TestOutput::Compile => {
|
||||
if !self.props.dont_check_compiler_stdout {
|
||||
errors += self.compare_output(
|
||||
stdout_kind,
|
||||
&normalized_stdout,
|
||||
&expected_stdout,
|
||||
self.props.compare_output_lines_by_subset,
|
||||
);
|
||||
errors +=
|
||||
self.compare_output(stdout_kind, &normalized_stdout, &expected_stdout);
|
||||
}
|
||||
if !self.props.dont_check_compiler_stderr {
|
||||
errors += self.compare_output(
|
||||
stderr_kind,
|
||||
&normalized_stderr,
|
||||
&expected_stderr,
|
||||
self.props.compare_output_lines_by_subset,
|
||||
);
|
||||
errors +=
|
||||
self.compare_output(stderr_kind, &normalized_stderr, &expected_stderr);
|
||||
}
|
||||
}
|
||||
TestOutput::Run => {
|
||||
errors += self.compare_output(
|
||||
stdout_kind,
|
||||
&normalized_stdout,
|
||||
&expected_stdout,
|
||||
self.props.compare_output_lines_by_subset,
|
||||
);
|
||||
errors += self.compare_output(
|
||||
stderr_kind,
|
||||
&normalized_stderr,
|
||||
&expected_stderr,
|
||||
self.props.compare_output_lines_by_subset,
|
||||
);
|
||||
errors += self.compare_output(stdout_kind, &normalized_stdout, &expected_stdout);
|
||||
errors += self.compare_output(stderr_kind, &normalized_stderr, &expected_stderr);
|
||||
}
|
||||
}
|
||||
errors
|
||||
@ -4201,12 +4147,7 @@ impl<'test> TestCx<'test> {
|
||||
)
|
||||
});
|
||||
|
||||
errors += self.compare_output(
|
||||
"fixed",
|
||||
&fixed_code,
|
||||
&expected_fixed,
|
||||
self.props.compare_output_lines_by_subset,
|
||||
);
|
||||
errors += self.compare_output("fixed", &fixed_code, &expected_fixed);
|
||||
} else if !expected_fixed.is_empty() {
|
||||
panic!(
|
||||
"the `//@ run-rustfix` directive wasn't found but a `*.fixed` \
|
||||
@ -4701,17 +4642,19 @@ impl<'test> TestCx<'test> {
|
||||
}
|
||||
}
|
||||
|
||||
fn compare_output(
|
||||
&self,
|
||||
kind: &str,
|
||||
actual: &str,
|
||||
expected: &str,
|
||||
compare_output_by_lines: bool,
|
||||
) -> usize {
|
||||
fn compare_output(&self, kind: &str, actual: &str, expected: &str) -> usize {
|
||||
if actual == expected {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If `compare-output-lines-by-subset` is not explicitly enabled then
|
||||
// auto-enable it when a `runner` is in use since wrapper tools might
|
||||
// provide extra output on failure, for example a WebAssembly runtime
|
||||
// might print the stack trace of an `unreachable` instruction by
|
||||
// default.
|
||||
let compare_output_by_lines =
|
||||
self.props.compare_output_lines_by_subset || self.config.runner.is_some();
|
||||
|
||||
let tmp;
|
||||
let (expected, actual): (&str, &str) = if compare_output_by_lines {
|
||||
let actual_lines: HashSet<_> = actual.lines().collect();
|
||||
|
@ -4,3 +4,4 @@ version = "0.0.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
wasmparser = "0.118.2"
|
||||
|
@ -2,13 +2,16 @@ use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
|
||||
pub use wasmparser;
|
||||
|
||||
pub fn out_dir() -> PathBuf {
|
||||
env::var_os("TMPDIR").unwrap().into()
|
||||
}
|
||||
|
||||
fn setup_common_build_cmd() -> Command {
|
||||
let rustc = env::var("RUSTC").unwrap();
|
||||
let mut cmd = Command::new(rustc);
|
||||
cmd.arg("--out-dir")
|
||||
.arg(env::var("TMPDIR").unwrap())
|
||||
.arg("-L")
|
||||
.arg(env::var("TMPDIR").unwrap());
|
||||
cmd.arg("--out-dir").arg(out_dir()).arg("-L").arg(out_dir());
|
||||
cmd
|
||||
}
|
||||
|
||||
@ -45,6 +48,11 @@ impl RustcInvocationBuilder {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn args(&mut self, args: &[&str]) -> &mut RustcInvocationBuilder {
|
||||
self.cmd.args(args);
|
||||
self
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn run(&mut self) -> Output {
|
||||
let caller_location = std::panic::Location::caller();
|
||||
|
@ -1,4 +1,4 @@
|
||||
//@ only-wasm32-bare
|
||||
//@ only-wasm32
|
||||
//@ assembly-output: emit-asm
|
||||
//@ compile-flags: -C target-feature=+exception-handling
|
||||
//@ compile-flags: -C panic=unwind
|
||||
|
@ -4,6 +4,7 @@
|
||||
// This test is for targets with 32bit c_int only.
|
||||
//@ ignore-msp430
|
||||
//@ ignore-avr
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
//@ needs-unwind - this test verifies the amount of drop calls when unwinding is used
|
||||
//@ compile-flags: -C no-prepopulate-passes
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
//
|
||||
//@ ignore-msvc
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
|
||||
//@ compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// This is ignored for the fallback mode on MSVC due to problems with PDB.
|
||||
|
||||
//@ ignore-msvc
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
|
||||
//@ compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// This is ignored for the fallback mode on MSVC due to problems with PDB.
|
||||
|
||||
//@ ignore-msvc
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
|
||||
//@ compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
//
|
||||
//@ ignore-msvc
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
|
||||
//@ compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
//@ compile-flags: -g
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
//
|
||||
// CHECK-LABEL: @main
|
||||
// MSVC: {{.*}}DIDerivedType(tag: DW_TAG_pointer_type, name: "recursive_type$ (*)()",{{.*}}
|
||||
|
@ -1,4 +1,5 @@
|
||||
//@ ignore-windows
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
|
||||
//@ compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//@ ignore-emscripten default visibility is hidden
|
||||
//@ ignore-wasm32 custom sections work differently on wasm
|
||||
//@ compile-flags: -C no-prepopulate-passes
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
//@ ignore-windows
|
||||
//@ ignore-macos
|
||||
//@ ignore-wasi
|
||||
|
||||
//@ compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
//@ ignore-windows
|
||||
//@ ignore-macos
|
||||
//@ ignore-wasi wasi codegens the main symbol differently
|
||||
|
||||
//@ compile-flags: -g -C no-prepopulate-passes
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ ignore-msvc
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
//@ needs-unwind
|
||||
|
||||
//@ compile-flags: -O -C no-prepopulate-passes
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ compile-flags: -C opt-level=0 -Cpanic=abort
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ compile-flags: -C opt-level=0
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
//@ needs-unwind
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
@ -1,5 +1,5 @@
|
||||
//@ compile-flags: -C opt-level=0 -Cpanic=abort
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
//@ needs-unwind
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(c_unwind)]
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ compile-flags: -C opt-level=0
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
//@ needs-unwind
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ compile-flags: -C no-prepopulate-passes
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
//@ needs-unwind
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
//@ only-wasm32-bare
|
||||
//@ only-wasm32
|
||||
//@ compile-flags: -C panic=unwind
|
||||
|
||||
#![crate_type = "lib"]
|
||||
|
@ -1,7 +1,6 @@
|
||||
// Test that we detect changes to the `dep_kind` query. If the change is not
|
||||
// detected then -Zincremental-verify-ich will trigger an assertion.
|
||||
|
||||
//@ ignore-wasm32-bare compiled with panic=abort by default
|
||||
//@ needs-unwind
|
||||
//@ revisions:cfail1 cfail2
|
||||
//@ compile-flags: -Z query-dep-graph -Cpanic=unwind
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ aux-build:issue-54059.rs
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
//@ ignore-windows - dealing with weird symbols issues on dylibs isn't worth it
|
||||
//@ revisions: rpass1
|
||||
|
||||
|
@ -1,7 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown
|
||||
$(NODE) foo.js $(TMPDIR)/foo.wasm
|
@ -1,22 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
const m = new WebAssembly.Module(buffer);
|
||||
const i = new WebAssembly.Instance(m, {
|
||||
host: {
|
||||
two_i32: () => [100, 101],
|
||||
two_i64: () => [102n, 103n],
|
||||
two_f32: () => [104, 105],
|
||||
two_f64: () => [106, 107],
|
||||
mishmash: () => [108, 109, 110, 111n, 112, 113],
|
||||
}
|
||||
});
|
||||
|
||||
assert.deepEqual(i.exports.return_two_i32(), [1, 2])
|
||||
assert.deepEqual(i.exports.return_two_i64(), [3, 4])
|
||||
assert.deepEqual(i.exports.return_two_f32(), [5, 6])
|
||||
assert.deepEqual(i.exports.return_two_f64(), [7, 8])
|
||||
assert.deepEqual(i.exports.return_mishmash(), [9, 10, 11, 12, 13, 14])
|
||||
i.exports.call_imports();
|
22
tests/run-make/wasm-abi/host.wat
Normal file
22
tests/run-make/wasm-abi/host.wat
Normal file
@ -0,0 +1,22 @@
|
||||
(module
|
||||
(func (export "two_i32") (result i32 i32)
|
||||
i32.const 100
|
||||
i32.const 101)
|
||||
(func (export "two_i64") (result i64 i64)
|
||||
i64.const 102
|
||||
i64.const 103)
|
||||
(func (export "two_f32") (result f32 f32)
|
||||
f32.const 104
|
||||
f32.const 105)
|
||||
(func (export "two_f64") (result f64 f64)
|
||||
f64.const 106
|
||||
f64.const 107)
|
||||
|
||||
(func (export "mishmash") (result f64 f32 i32 i64 i32 i32)
|
||||
f64.const 108
|
||||
f32.const 109
|
||||
i32.const 110
|
||||
i64.const 111
|
||||
i32.const 112
|
||||
i32.const 113)
|
||||
)
|
43
tests/run-make/wasm-abi/rmake.rs
Normal file
43
tests/run-make/wasm-abi/rmake.rs
Normal file
@ -0,0 +1,43 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc};
|
||||
use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").run();
|
||||
let file = out_dir().join("foo.wasm");
|
||||
|
||||
let has_wasmtime = match Command::new("wasmtime").arg("--version").output() {
|
||||
Ok(s) => s.status.success(),
|
||||
_ => false,
|
||||
};
|
||||
if !has_wasmtime {
|
||||
println!("skipping test, wasmtime isn't available");
|
||||
return;
|
||||
}
|
||||
|
||||
run(&file, "return_two_i32", "1\n2\n");
|
||||
run(&file, "return_two_i64", "3\n4\n");
|
||||
run(&file, "return_two_f32", "5\n6\n");
|
||||
run(&file, "return_two_f64", "7\n8\n");
|
||||
run(&file, "return_mishmash", "9\n10\n11\n12\n13\n14\n");
|
||||
run(&file, "call_imports", "");
|
||||
}
|
||||
|
||||
fn run(file: &Path, method: &str, expected_output: &str) {
|
||||
let output = Command::new("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));
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown
|
||||
$(RUSTC) bar.rs -C lto -O --target wasm32-unknown-unknown
|
||||
$(NODE) foo.js $(TMPDIR)/bar.wasm
|
@ -1,36 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let sections = WebAssembly.Module.customSections(m, "baz");
|
||||
console.log('section baz', sections);
|
||||
assert.strictEqual(sections.length, 1);
|
||||
let section = new Uint8Array(sections[0]);
|
||||
console.log('contents', section);
|
||||
assert.strictEqual(section.length, 2);
|
||||
assert.strictEqual(section[0], 7);
|
||||
assert.strictEqual(section[1], 8);
|
||||
|
||||
sections = WebAssembly.Module.customSections(m, "bar");
|
||||
console.log('section bar', sections);
|
||||
assert.strictEqual(sections.length, 1, "didn't pick up `bar` section from dependency");
|
||||
section = new Uint8Array(sections[0]);
|
||||
console.log('contents', section);
|
||||
assert.strictEqual(section.length, 2);
|
||||
assert.strictEqual(section[0], 3);
|
||||
assert.strictEqual(section[1], 4);
|
||||
|
||||
sections = WebAssembly.Module.customSections(m, "foo");
|
||||
console.log('section foo', sections);
|
||||
assert.strictEqual(sections.length, 1, "didn't create `foo` section");
|
||||
section = new Uint8Array(sections[0]);
|
||||
console.log('contents', section);
|
||||
assert.strictEqual(section.length, 4, "didn't concatenate `foo` sections");
|
||||
assert.strictEqual(section[0], 5);
|
||||
assert.strictEqual(section[1], 6);
|
||||
assert.strictEqual(section[2], 1);
|
||||
assert.strictEqual(section[3], 2);
|
||||
|
||||
process.exit(0);
|
28
tests/run-make/wasm-custom-section/rmake.rs
Normal file
28
tests/run-make/wasm-custom-section/rmake.rs
Normal file
@ -0,0 +1,28 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").run();
|
||||
rustc().arg("bar.rs").arg("--target=wasm32-wasip1").arg("-Clto").arg("-O").run();
|
||||
|
||||
let file = std::fs::read(&out_dir().join("bar.wasm")).unwrap();
|
||||
|
||||
let mut custom = HashMap::new();
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::CustomSection(s) = payload {
|
||||
let prev = custom.insert(s.name(), s.data());
|
||||
assert!(prev.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(custom.remove("foo"), Some(&[5, 6, 1, 2][..]));
|
||||
assert_eq!(custom.remove("bar"), Some(&[3, 4][..]));
|
||||
assert_eq!(custom.remove("baz"), Some(&[7, 8][..]));
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs -O --target wasm32-unknown-unknown
|
||||
$(NODE) foo.js $(TMPDIR)/foo.wasm
|
@ -1,15 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
|
||||
sections = WebAssembly.Module.customSections(m, "foo");
|
||||
console.log('section foo', sections);
|
||||
assert.strictEqual(sections.length, 1, "didn't create `foo` section");
|
||||
section = new Uint8Array(sections[0]);
|
||||
console.log('contents', section);
|
||||
assert.strictEqual(section.length, 4, "didn't concatenate `foo` sections");
|
||||
|
||||
process.exit(0);
|
30
tests/run-make/wasm-custom-sections-opt/rmake.rs
Normal file
30
tests/run-make/wasm-custom-sections-opt/rmake.rs
Normal file
@ -0,0 +1,30 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").arg("-O").run();
|
||||
verify(&out_dir().join("foo.wasm"));
|
||||
}
|
||||
|
||||
fn verify(path: &Path) {
|
||||
eprintln!("verify {path:?}");
|
||||
let file = std::fs::read(&path).unwrap();
|
||||
|
||||
let mut custom = HashMap::new();
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::CustomSection(s) = payload {
|
||||
let prev = custom.insert(s.name(), s.data());
|
||||
assert!(prev.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
assert_eq!(custom.remove("foo"), Some(&[1, 2, 3, 4][..]));
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) main.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify.js $(TMPDIR)/main.wasm
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown -O
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -O
|
||||
$(NODE) verify.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) main.rs --target wasm32-unknown-unknown -O
|
||||
$(NODE) verify.js $(TMPDIR)/main.wasm
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -C lto
|
||||
$(NODE) verify.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) main.rs --target wasm32-unknown-unknown -C lto
|
||||
$(NODE) verify.js $(TMPDIR)/main.wasm
|
60
tests/run-make/wasm-export-all-symbols/rmake.rs
Normal file
60
tests/run-make/wasm-export-all-symbols/rmake.rs
Normal file
@ -0,0 +1,60 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
use wasmparser::ExternalKind::*;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
test(&[]);
|
||||
test(&["-O"]);
|
||||
test(&["-Clto"]);
|
||||
}
|
||||
|
||||
fn test(args: &[&str]) {
|
||||
eprintln!("running with {args:?}");
|
||||
rustc().arg("bar.rs").arg("--target=wasm32-wasip1").args(args).run();
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").args(args).run();
|
||||
rustc().arg("main.rs").arg("--target=wasm32-wasip1").args(args).run();
|
||||
|
||||
verify_exports(
|
||||
&out_dir().join("foo.wasm"),
|
||||
&[("foo", Func), ("FOO", Global), ("memory", Memory)],
|
||||
);
|
||||
verify_exports(
|
||||
&out_dir().join("main.wasm"),
|
||||
&[
|
||||
("foo", Func),
|
||||
("FOO", Global),
|
||||
("_start", Func),
|
||||
("__main_void", Func),
|
||||
("memory", Memory),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
fn verify_exports(path: &Path, exports: &[(&str, wasmparser::ExternalKind)]) {
|
||||
println!("verify {path:?}");
|
||||
let file = std::fs::read(path).unwrap();
|
||||
let mut wasm_exports = HashMap::new();
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::ExportSection(s) = payload {
|
||||
for export in s {
|
||||
let export = export.unwrap();
|
||||
wasm_exports.insert(export.name, export.kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eprintln!("found exports {wasm_exports:?}");
|
||||
|
||||
assert_eq!(exports.len(), wasm_exports.len());
|
||||
for (export, expected_kind) in exports {
|
||||
assert_eq!(wasm_exports[export], *expected_kind);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let list = WebAssembly.Module.exports(m);
|
||||
console.log('exports', list);
|
||||
|
||||
const my_exports = {};
|
||||
let nexports = 0;
|
||||
|
||||
for (const entry of list) {
|
||||
if (entry.kind == 'function'){
|
||||
nexports += 1;
|
||||
}
|
||||
my_exports[entry.name] = entry.kind;
|
||||
}
|
||||
|
||||
if (my_exports.foo != "function")
|
||||
throw new Error("`foo` wasn't defined");
|
||||
|
||||
if (my_exports.FOO != "global")
|
||||
throw new Error("`FOO` wasn't defined");
|
||||
|
||||
if (my_exports.main === undefined) {
|
||||
if (nexports != 1)
|
||||
throw new Error("should only have one function export");
|
||||
} else {
|
||||
if (nexports != 2)
|
||||
throw new Error("should only have two function exports");
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown
|
||||
$(RUSTC) bar.rs -C lto -O --target wasm32-unknown-unknown
|
||||
$(NODE) foo.js $(TMPDIR)/bar.wasm
|
@ -1,18 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let imports = WebAssembly.Module.imports(m);
|
||||
console.log('imports', imports);
|
||||
assert.strictEqual(imports.length, 2);
|
||||
|
||||
assert.strictEqual(imports[0].kind, 'function');
|
||||
assert.strictEqual(imports[1].kind, 'function');
|
||||
|
||||
let modules = [imports[0].module, imports[1].module];
|
||||
modules.sort();
|
||||
|
||||
assert.strictEqual(modules[0], './dep');
|
||||
assert.strictEqual(modules[1], './me');
|
32
tests/run-make/wasm-import-module/rmake.rs
Normal file
32
tests/run-make/wasm-import-module/rmake.rs
Normal file
@ -0,0 +1,32 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::collections::HashMap;
|
||||
use wasmparser::TypeRef::Func;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").run();
|
||||
rustc().arg("bar.rs").arg("--target=wasm32-wasip1").arg("-Clto").arg("-O").run();
|
||||
|
||||
let file = std::fs::read(&out_dir().join("bar.wasm")).unwrap();
|
||||
|
||||
let mut imports = HashMap::new();
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::ImportSection(s) = payload {
|
||||
for i in s {
|
||||
let i = i.unwrap();
|
||||
imports.entry(i.module).or_insert(Vec::new()).push((i.name, i.ty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let import = imports.remove("./dep");
|
||||
assert!(matches!(import.as_deref(), Some([("dep", Func(_))])), "bad import {:?}", import);
|
||||
let import = imports.remove("./me");
|
||||
assert!(matches!(import.as_deref(), Some([("me_in_dep", Func(_))])), "bad import {:?}", import);
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs -C lto -O --target wasm32-unknown-unknown --cfg a
|
||||
wc -c < $(TMPDIR)/foo.wasm
|
||||
[ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "1024" ]
|
||||
$(RUSTC) foo.rs -C lto -O --target wasm32-unknown-unknown --cfg b
|
||||
wc -c < $(TMPDIR)/foo.wasm
|
||||
[ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "5120" ]
|
||||
$(RUSTC) foo.rs -C lto -O --target wasm32-unknown-unknown --cfg c
|
||||
wc -c < $(TMPDIR)/foo.wasm
|
||||
[ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "5120" ]
|
||||
$(RUSTC) foo.rs -C lto -O --target wasm32-unknown-unknown --cfg d
|
||||
wc -c < $(TMPDIR)/foo.wasm
|
||||
[ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "5120" ]
|
32
tests/run-make/wasm-panic-small/rmake.rs
Normal file
32
tests/run-make/wasm-panic-small/rmake.rs
Normal file
@ -0,0 +1,32 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
test("a");
|
||||
test("b");
|
||||
test("c");
|
||||
test("d");
|
||||
}
|
||||
|
||||
fn test(cfg: &str) {
|
||||
eprintln!("running cfg {cfg:?}");
|
||||
rustc()
|
||||
.arg("foo.rs")
|
||||
.arg("--target=wasm32-wasip1")
|
||||
.arg("-Clto")
|
||||
.arg("-O")
|
||||
.arg("--cfg")
|
||||
.arg(cfg)
|
||||
.run();
|
||||
|
||||
let bytes = std::fs::read(&out_dir().join("foo.wasm")).unwrap();
|
||||
println!("{}", bytes.len());
|
||||
assert!(bytes.len() < 40_000);
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) main.rs -C overflow-checks=yes -C panic=abort -C lto -C opt-level=z --target wasm32-unknown-unknown
|
||||
$(NODE) verify.js $(TMPDIR)/main.wasm
|
35
tests/run-make/wasm-spurious-import/rmake.rs
Normal file
35
tests/run-make/wasm-spurious-import/rmake.rs
Normal file
@ -0,0 +1,35 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::collections::HashMap;
|
||||
use wasmparser::TypeRef::Func;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc()
|
||||
.arg("main.rs")
|
||||
.arg("--target=wasm32-wasip1")
|
||||
.arg("-Coverflow-checks=yes")
|
||||
.arg("-Cpanic=abort")
|
||||
.arg("-Clto")
|
||||
.arg("-Copt-level=z")
|
||||
.run();
|
||||
|
||||
let file = std::fs::read(&out_dir().join("main.wasm")).unwrap();
|
||||
|
||||
let mut imports = HashMap::new();
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::ImportSection(s) = payload {
|
||||
for i in s {
|
||||
let i = i.unwrap();
|
||||
imports.entry(i.module).or_insert(Vec::new()).push((i.name, i.ty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert!(imports.is_empty(), "imports are not empty {:?}", imports);
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let imports = WebAssembly.Module.imports(m);
|
||||
console.log('imports', imports);
|
||||
assert.strictEqual(imports.length, 0);
|
@ -1,10 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
ifeq ($(TARGET),wasm32-unknown-unknown)
|
||||
all:
|
||||
$(RUSTC) foo.rs -C lto -O --target wasm32-unknown-unknown
|
||||
wc -c < $(TMPDIR)/foo.wasm
|
||||
[ "`wc -c < $(TMPDIR)/foo.wasm`" -lt "25000" ]
|
||||
else
|
||||
all:
|
||||
endif
|
17
tests/run-make/wasm-stringify-ints-small/rmake.rs
Normal file
17
tests/run-make/wasm-stringify-ints-small/rmake.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#![deny(warnings)]
|
||||
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").arg("-Clto").arg("-O").run();
|
||||
|
||||
let bytes = std::fs::read(&out_dir().join("foo.wasm")).unwrap();
|
||||
println!("{}", bytes.len());
|
||||
assert!(bytes.len() < 50_000);
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify-imports.js $(TMPDIR)/foo.wasm a/foo b/foo
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -C lto
|
||||
$(NODE) verify-imports.js $(TMPDIR)/foo.wasm a/foo b/foo
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -O
|
||||
$(NODE) verify-imports.js $(TMPDIR)/foo.wasm a/foo b/foo
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -O -C lto
|
||||
$(NODE) verify-imports.js $(TMPDIR)/foo.wasm a/foo b/foo
|
||||
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify-imports.js $(TMPDIR)/bar.wasm m1/f m1/g m2/f
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown -C lto
|
||||
$(NODE) verify-imports.js $(TMPDIR)/bar.wasm m1/f m1/g m2/f
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown -O
|
||||
$(NODE) verify-imports.js $(TMPDIR)/bar.wasm m1/f m1/g m2/f
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown -O -C lto
|
||||
$(NODE) verify-imports.js $(TMPDIR)/bar.wasm m1/f m1/g m2/f
|
||||
|
||||
$(RUSTC) baz.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify-imports.js $(TMPDIR)/baz.wasm sqlite/allocate sqlite/deallocate
|
||||
|
||||
$(RUSTC) log.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify-imports.js $(TMPDIR)/log.wasm test/log
|
52
tests/run-make/wasm-symbols-different-module/rmake.rs
Normal file
52
tests/run-make/wasm-symbols-different-module/rmake.rs
Normal file
@ -0,0 +1,52 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]);
|
||||
test_file("bar.rs", &[("m1", &["f", "g"]), ("m2", &["f"])]);
|
||||
test_file("baz.rs", &[("sqlite", &["allocate", "deallocate"])]);
|
||||
test_file("log.rs", &[("test", &["log"])]);
|
||||
}
|
||||
|
||||
fn test_file(file: &str, expected_imports: &[(&str, &[&str])]) {
|
||||
test(file, &[], expected_imports);
|
||||
test(file, &["-Clto"], expected_imports);
|
||||
test(file, &["-O"], expected_imports);
|
||||
test(file, &["-Clto", "-O"], expected_imports);
|
||||
}
|
||||
|
||||
fn test(file: &str, args: &[&str], expected_imports: &[(&str, &[&str])]) {
|
||||
println!("test {file:?} {args:?} for {expected_imports:?}");
|
||||
|
||||
rustc().arg(file).arg("--target=wasm32-wasip1").args(args).run();
|
||||
|
||||
let file = std::fs::read(&out_dir().join(file).with_extension("wasm")).unwrap();
|
||||
|
||||
let mut imports = HashMap::new();
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::ImportSection(s) = payload {
|
||||
for i in s {
|
||||
let i = i.unwrap();
|
||||
imports.entry(i.module).or_insert(HashSet::new()).insert(i.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eprintln!("imports {imports:?}");
|
||||
|
||||
for (expected_module, expected_names) in expected_imports {
|
||||
let names = imports.remove(expected_module).unwrap();
|
||||
assert_eq!(names.len(), expected_names.len());
|
||||
for name in *expected_names {
|
||||
assert!(names.contains(name));
|
||||
}
|
||||
}
|
||||
assert!(imports.is_empty());
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let list = WebAssembly.Module.imports(m);
|
||||
console.log('imports', list);
|
||||
if (list.length !== process.argv.length - 3)
|
||||
throw new Error("wrong number of imports")
|
||||
|
||||
const imports = new Map();
|
||||
for (let i = 3; i < process.argv.length; i++) {
|
||||
const [module, name] = process.argv[i].split('/');
|
||||
if (!imports.has(module))
|
||||
imports.set(module, new Map());
|
||||
imports.get(module).set(name, true);
|
||||
}
|
||||
|
||||
for (let i of list) {
|
||||
if (imports.get(i.module) === undefined || imports.get(i.module).get(i.name) === undefined)
|
||||
throw new Error(`didn't find import of ${i.module}::${i.name}`);
|
||||
imports.get(i.module).delete(i.name);
|
||||
|
||||
if (imports.get(i.module).size === 0)
|
||||
imports.delete(i.module);
|
||||
}
|
||||
|
||||
console.log(imports);
|
||||
if (imports.size !== 0) {
|
||||
throw new Error('extra imports');
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify-exported-symbols.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -O
|
||||
$(NODE) verify-exported-symbols.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify-exported-symbols.js $(TMPDIR)/bar.wasm
|
||||
$(RUSTC) bar.rs --target wasm32-unknown-unknown -O
|
||||
$(NODE) verify-exported-symbols.js $(TMPDIR)/bar.wasm
|
41
tests/run-make/wasm-symbols-not-exported/rmake.rs
Normal file
41
tests/run-make/wasm-symbols-not-exported/rmake.rs
Normal file
@ -0,0 +1,41 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").run();
|
||||
verify_symbols(&out_dir().join("foo.wasm"));
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").arg("-O").run();
|
||||
verify_symbols(&out_dir().join("foo.wasm"));
|
||||
|
||||
rustc().arg("bar.rs").arg("--target=wasm32-wasip1").run();
|
||||
verify_symbols(&out_dir().join("bar.wasm"));
|
||||
rustc().arg("bar.rs").arg("--target=wasm32-wasip1").arg("-O").run();
|
||||
verify_symbols(&out_dir().join("bar.wasm"));
|
||||
}
|
||||
|
||||
fn verify_symbols(path: &Path) {
|
||||
eprintln!("verify {path:?}");
|
||||
let file = std::fs::read(&path).unwrap();
|
||||
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::ExportSection(s) = payload {
|
||||
for e in s {
|
||||
let e = e.unwrap();
|
||||
if e.kind != wasmparser::ExternalKind::Func {
|
||||
continue;
|
||||
}
|
||||
if e.name == "foo" {
|
||||
continue;
|
||||
}
|
||||
panic!("unexpected export {e:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let list = WebAssembly.Module.exports(m);
|
||||
console.log('exports', list);
|
||||
|
||||
let bad = false;
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const e = list[i];
|
||||
if (e.name == "foo" || e.kind != "function")
|
||||
continue;
|
||||
|
||||
console.log('unexpected exported symbol:', e.name);
|
||||
bad = true;
|
||||
}
|
||||
|
||||
if (bad)
|
||||
process.exit(1);
|
@ -1,13 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# only-wasm32-bare
|
||||
|
||||
all:
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown
|
||||
$(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -C lto
|
||||
$(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -O
|
||||
$(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
|
||||
$(RUSTC) foo.rs --target wasm32-unknown-unknown -O -C lto
|
||||
$(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
|
31
tests/run-make/wasm-symbols-not-imported/rmake.rs
Normal file
31
tests/run-make/wasm-symbols-not-imported/rmake.rs
Normal file
@ -0,0 +1,31 @@
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{out_dir, rustc, wasmparser};
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").run();
|
||||
verify_symbols(&out_dir().join("foo.wasm"));
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").arg("-Clto").run();
|
||||
verify_symbols(&out_dir().join("foo.wasm"));
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").arg("-O").run();
|
||||
verify_symbols(&out_dir().join("foo.wasm"));
|
||||
rustc().arg("foo.rs").arg("--target=wasm32-wasip1").arg("-Clto").arg("-O").run();
|
||||
verify_symbols(&out_dir().join("foo.wasm"));
|
||||
}
|
||||
|
||||
fn verify_symbols(path: &Path) {
|
||||
eprintln!("verify {path:?}");
|
||||
let file = std::fs::read(&path).unwrap();
|
||||
|
||||
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
||||
let payload = payload.unwrap();
|
||||
if let wasmparser::Payload::ImportSection(_) = payload {
|
||||
panic!("import section found");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
const fs = require('fs');
|
||||
const process = require('process');
|
||||
const assert = require('assert');
|
||||
const buffer = fs.readFileSync(process.argv[2]);
|
||||
|
||||
let m = new WebAssembly.Module(buffer);
|
||||
let list = WebAssembly.Module.imports(m);
|
||||
console.log('imports', list);
|
||||
if (list.length !== 0)
|
||||
throw new Error("there are some imports");
|
@ -1,4 +1,4 @@
|
||||
//@ ignore-emscripten
|
||||
//@ ignore-wasm32 no subprocess support
|
||||
//@ ignore-sgx no processes
|
||||
//@ ignore-macos this needs valgrind 3.11 or higher; see
|
||||
// https://github.com/rust-lang/rust/pull/30365#issuecomment-165763679
|
||||
|
@ -1,6 +1,5 @@
|
||||
//@ run-pass
|
||||
//@ pretty-expanded FIXME #23616
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
//@ run-pass
|
||||
//@ pretty-expanded FIXME #23616
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc to test with
|
||||
//@ ignore-sgx no libc
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern "C" {
|
||||
|
@ -1,7 +1,6 @@
|
||||
//@ run-pass
|
||||
//@ aux-build:anon-extern-mod-cross-crate-1.rs
|
||||
//@ pretty-expanded FIXME #23616
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
extern crate anonexternmod;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
//@ aux-build:anon-extern-mod-cross-crate-1.rs
|
||||
//@ aux-build:anon-extern-mod-cross-crate-1.rs
|
||||
//@ pretty-expanded FIXME #23616
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
extern crate anonexternmod;
|
||||
|
||||
|
1
tests/ui/abi/extern/extern-call-deep.rs
vendored
1
tests/ui/abi/extern/extern-call-deep.rs
vendored
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
//@ ignore-emscripten blows the JS stack
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
1
tests/ui/abi/extern/extern-call-indirect.rs
vendored
1
tests/ui/abi/extern/extern-call-indirect.rs
vendored
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
1
tests/ui/abi/extern/extern-crosscrate.rs
vendored
1
tests/ui/abi/extern/extern-crosscrate.rs
vendored
@ -1,6 +1,5 @@
|
||||
//@ run-pass
|
||||
//@ aux-build:extern-crosscrate-source.rs
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
|
2
tests/ui/abi/extern/extern-pass-TwoU16s.rs
vendored
2
tests/ui/abi/extern/extern-pass-TwoU16s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a foreign function that accepts and returns a struct
|
||||
// by value.
|
||||
|
||||
|
2
tests/ui/abi/extern/extern-pass-TwoU32s.rs
vendored
2
tests/ui/abi/extern/extern-pass-TwoU32s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a foreign function that accepts and returns a struct
|
||||
// by value.
|
||||
|
||||
|
2
tests/ui/abi/extern/extern-pass-TwoU64s.rs
vendored
2
tests/ui/abi/extern/extern-pass-TwoU64s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a foreign function that accepts and returns a struct
|
||||
// by value.
|
||||
|
||||
|
2
tests/ui/abi/extern/extern-pass-TwoU8s.rs
vendored
2
tests/ui/abi/extern/extern-pass-TwoU8s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a foreign function that accepts and returns a struct
|
||||
// by value.
|
||||
|
||||
|
1
tests/ui/abi/extern/extern-pass-char.rs
vendored
1
tests/ui/abi/extern/extern-pass-char.rs
vendored
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a function that takes/returns a u8.
|
||||
|
||||
|
1
tests/ui/abi/extern/extern-pass-double.rs
vendored
1
tests/ui/abi/extern/extern-pass-double.rs
vendored
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern "C" {
|
||||
|
1
tests/ui/abi/extern/extern-pass-u32.rs
vendored
1
tests/ui/abi/extern/extern-pass-u32.rs
vendored
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a function that takes/returns a u32.
|
||||
|
||||
|
1
tests/ui/abi/extern/extern-pass-u64.rs
vendored
1
tests/ui/abi/extern/extern-pass-u64.rs
vendored
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc for ffi testing
|
||||
|
||||
// Test a call to a function that takes/returns a u64.
|
||||
|
||||
|
2
tests/ui/abi/extern/extern-return-TwoU16s.rs
vendored
2
tests/ui/abi/extern/extern-return-TwoU16s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
pub struct TwoU16s {
|
||||
one: u16,
|
||||
two: u16,
|
||||
|
2
tests/ui/abi/extern/extern-return-TwoU32s.rs
vendored
2
tests/ui/abi/extern/extern-return-TwoU32s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
pub struct TwoU32s {
|
||||
one: u32,
|
||||
two: u32,
|
||||
|
2
tests/ui/abi/extern/extern-return-TwoU64s.rs
vendored
2
tests/ui/abi/extern/extern-return-TwoU64s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
pub struct TwoU64s {
|
||||
one: u64,
|
||||
two: u64,
|
||||
|
2
tests/ui/abi/extern/extern-return-TwoU8s.rs
vendored
2
tests/ui/abi/extern/extern-return-TwoU8s.rs
vendored
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
pub struct TwoU8s {
|
||||
one: u8,
|
||||
two: u8,
|
||||
|
@ -1,6 +1,5 @@
|
||||
//@ run-pass
|
||||
//@ aux-build:foreign_lib.rs
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
// Check that we can still call duplicated extern (imported) functions
|
||||
// which were declared in another crate. See issues #32740 and #32783.
|
||||
|
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(improper_ctypes, improper_ctypes_definitions)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct S {
|
||||
x: u64,
|
||||
|
@ -1,7 +1,6 @@
|
||||
//@ run-pass
|
||||
// ABI is cdecl by default
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
//@ pretty-expanded FIXME #23616
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
@ -1,6 +1,5 @@
|
||||
//@ run-pass
|
||||
//@ aux-build:foreign_lib.rs
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
// The purpose of this test is to check that we can
|
||||
// successfully (and safely) invoke external, cdecl
|
||||
|
@ -5,7 +5,7 @@
|
||||
// without #[repr(simd)]
|
||||
|
||||
//@ run-pass
|
||||
//@ ignore-emscripten
|
||||
//@ ignore-wasm32 no processes
|
||||
//@ ignore-sgx no processes
|
||||
|
||||
#![feature(avx512_target_feature)]
|
||||
|
@ -2,8 +2,6 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Quad {
|
||||
a: u64,
|
||||
|
@ -2,8 +2,6 @@
|
||||
#![allow(dead_code)]
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct QuadFloats {
|
||||
a: f32,
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm
|
||||
#![allow(dead_code)]
|
||||
#![allow(improper_ctypes)]
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
//@ dont-check-compiler-stderr (rust-lang/rust#54222)
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
//@ compile-flags: -lrust_test_helpers
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#[link(name = "rust_test_helpers", kind = "static")]
|
||||
extern "C" {
|
||||
|
@ -1,7 +1,7 @@
|
||||
//@ run-pass
|
||||
|
||||
#![allow(unused_imports)]
|
||||
//@ ignore-emscripten can't run commands
|
||||
//@ ignore-wasm32 can't run commands
|
||||
//@ ignore-sgx no processes
|
||||
//@ ignore-fuchsia must translate zircon signal to SIGSEGV/SIGBUS, FIXME (#58590)
|
||||
#![feature(rustc_private)]
|
||||
|
@ -3,8 +3,6 @@
|
||||
// statics cannot. This ensures that there's some form of error if this is
|
||||
// attempted.
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
extern crate libc;
|
||||
|
@ -1,5 +1,5 @@
|
||||
warning: creating a shared reference to mutable static is discouraged
|
||||
--> $DIR/static-mut-foreign.rs:35:18
|
||||
--> $DIR/static-mut-foreign.rs:33:18
|
||||
|
|
||||
LL | static_bound(&rust_dbg_static_mut);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ shared reference to mutable static
|
||||
@ -14,7 +14,7 @@ LL | static_bound(addr_of!(rust_dbg_static_mut));
|
||||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
warning: creating a mutable reference to mutable static is discouraged
|
||||
--> $DIR/static-mut-foreign.rs:37:22
|
||||
--> $DIR/static-mut-foreign.rs:35:22
|
||||
|
|
||||
LL | static_bound_set(&mut rust_dbg_static_mut);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference to mutable static
|
||||
|
@ -1,6 +1,5 @@
|
||||
//@ run-pass
|
||||
#![allow(dead_code)]
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
|
@ -1,8 +1,6 @@
|
||||
//@ run-pass
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(C)]
|
||||
struct LARGE_INTEGER_U {
|
||||
|
@ -1,5 +1,4 @@
|
||||
//@ run-pass
|
||||
//@ ignore-wasm32-bare no libc to test ffi with
|
||||
#![feature(c_variadic)]
|
||||
|
||||
use std::ffi::VaList;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user