Commit Graph

12 Commits

Author SHA1 Message Date
Alex Crichton cfd52bba1f rustc: Stop passing --allow-undefined on wasm targets
This commit updates how the linker is invoked on WebAssembly targets
(all of them) to avoid passing the `--allow-undefined` flag to the
linker. Historically, if I remember this correctly, when `wasm-ld` was
first integrated this was practically required because at the time it
was otherwise impossible to import a function from the host into a wasm
binary. Or, at least, I'm pretty sure that was why this was added.

At the time, as the documentation around this option indicates, it was
known that this was going to be a hazard. This doesn't match behavior on
native, for example, and can easily paper over what should be a linker
error with some sort of other obscure runtime error. An example is that
this program currently compiles and links, it just prints null:

    unsafe extern "C" {
        static nonexistent: u8;
    }

    fn main() {
        println!("{:?}", &raw const nonexistent);
    }

This can easily lead to mistakes like rust-lang/libc/4880 and defer what
should be a compile-time link error to weird or unusual behavior at link
time. Additionally, in the intervening time since `wasm-ld` was first
introduced here, lots has changed and notably this program works as
expected:

    #[link(wasm_import_module = "host")]
    unsafe extern "C" {
        fn foo();
    }

    fn main() {
        unsafe {
            foo();
        }
    }

Notably this continues to compile without error and the final wasm
binary indeed has an imported function from the host. What this change
means, however, is that this program:

    unsafe extern "C" {
        fn foo();
    }

    fn main() {
        unsafe {
            foo();
        }
    }

this currently compiles successfully and emits an import from the `env`
module. After this change, however, this will fail to compile with a
link error stating that the `foo` symbol is not defined.
2025-12-10 15:13:14 -08:00
Alex Crichton 006c884480 Fix two new failing tests
The updated wasi-sdk has debuginfo by default so be sure to strip the
debuginfo by default when testing the size of new executables.
2024-07-19 10:27:14 -07:00
许杰友 Jieyou Xu (Joe) d69cc1ccbf tests: update for rfs rename 2024-07-17 13:34:18 +00:00
许杰友 Jieyou Xu (Joe) 636be91cc0 tests: update for renamed fs module in run_make_support 2024-07-17 13:32:29 +00:00
Oneirical c84afee898 Implement fs wrapper for run_make_support 2024-06-11 09:53:31 -04:00
Jakub Beránek d86c981908 Remove all usages of tmp_dir from tests 2024-06-07 11:12:24 +02:00
León Orell Valerian Liehr 09aa77299b Cleanup: Rid the rmake test runners of extern crate run_make_support; 2024-05-02 17:57:23 +02:00
许杰友 Jieyou Xu (Joe) 08853804d0 Use compiletest directives for properly only running wasm32-wasip1 tests on that target 2024-03-27 21:55:09 +00:00
许杰友 Jieyou Xu (Joe) 1f2178b9e7 Rework rmake support library to have a weakly-typed API with helper methods 2024-03-24 15:37:24 +00:00
Alex Crichton 7141379559 Convert some WebAssembly run-make tests to Rust
This commit rewrites a number of `run-make` tests centered around wasm
to instead use `rmake.rs` and additionally use the `wasm32-wasip1`
target instead of `wasm32-unknown-unknown`. Testing no longer requires
Node.js and additionally uses the `wasmparser` crate from crates.io to
parse outputs and power assertions.
2024-03-11 09:36:35 -07:00
Joshua Nelson 26e1ce7394 move tools.mk to run-make
apparently I missed some tests in the last commit. Rather than having
dozens of tests use the long version, use the short version in
`run-make` and the long version in `run-make-fulldeps` (which is now
only three tests)
2023-03-30 07:58:50 -05:00
Albert Larsan cf2dff2b1e Move /src/test to /tests 2023-01-11 09:32:08 +00:00