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

system_v <-> windows_fastcall mixup #146

Closed
bjorn3 opened this issue May 14, 2019 · 8 comments
Closed

system_v <-> windows_fastcall mixup #146

bjorn3 opened this issue May 14, 2019 · 8 comments

Comments

@bjorn3
Copy link
Contributor

bjorn3 commented May 14, 2019

error while processing main module ../../target/wasm32-wasi/release/rustc_binary.wasm: Instantiation error: Link error: wasi_unstable/environ_sizes_get: exported function with signature (i64 vmctx, i32, i32) -> i32 system_v incompatible with function import with signature (i64 vmctx, i32, i32) -> i32 windows_fastcall
@bjorn3
Copy link
Contributor Author

bjorn3 commented May 14, 2019

@bjorn3
Copy link
Contributor Author

bjorn3 commented May 14, 2019

Build from 1c0efd0.

@bjorn3
Copy link
Contributor Author

bjorn3 commented May 14, 2019

Same problem with 2b5be77 (master)

@bjorn3
Copy link
Contributor Author

bjorn3 commented May 14, 2019

This is on Linux, so I have no idea how it tried to use windows_fastcall.

@sunfishcode
Copy link
Member

When run that wasm module, I get:

thread 'main' panicked at 'env_logger::init_from_env should not be called after logger initialized: SetLoggerError(())', src/libcore/result.rs:999:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error while processing main module rustc_binary.wasm: Instantiation error: Trap occurred while invoking start function: wasm trap at 0x7fbe5ff9fef2

so something odd is going on.

@kubkon
Copy link
Member

kubkon commented May 15, 2019

I can confirm that I'm getting the same error as @sunfishcode.

@kubkon
Copy link
Member

kubkon commented May 15, 2019

I don't know how related that is, however, I have cloned your repo bjorn3/rust/tree/compile_rustc_for_wasm, I've built it, and managed to run it and print rustc help message OK in wasmtime.

In order to compile rustc, I've followed your instructions in the repo and the wasm32-wasi bit from #144. I've used the following wasmtime invocation when running the binary:

$ wasmtime rustc_binary.wasm -- --help

And got the expected output:

Usage: rustc [OPTIONS] INPUT

Options:
    -h, --help          Display this message
        --cfg SPEC      Configure the compilation environment
    -L [KIND=]PATH      Add a directory to the library search path. The
                        optional KIND can be one of dependency, crate, native,
                        framework or all (the default).
    -l [KIND=]NAME      Link the generated crate(s) to the specified native
                        library NAME. The optional KIND can be one of
                        static, dylib, or framework. If omitted, dylib is
                        assumed.
        --crate-type [bin|lib|rlib|dylib|cdylib|staticlib|proc-macro]
                        Comma separated list of types of crates
                        for the compiler to emit
        --crate-name NAME
                        Specify the name of the crate being built
        --edition 2015|2018
                        Specify which edition of the compiler to use when
                        compiling code.
        --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir]
                        Comma separated list of types of output for the
                        compiler to emit
        --print [crate-name|file-names|sysroot|cfg|target-list|target-cpus|target-features|relocation-models|code-models|tls-models|target-spec-json|native-static-libs]
                        Comma separated list of compiler information to print
                        on stdout
    -g                  Equivalent to -C debuginfo=2
    -O                  Equivalent to -C opt-level=2
    -o FILENAME         Write output to <filename>
        --out-dir DIR   Write output to compiler-chosen filename in <dir>
        --explain OPT   Provide a detailed explanation of an error message
        --test          Build a test harness
        --target TARGET Target triple for which the code is compiled
    -W, --warn OPT      Set lint warnings
    -A, --allow OPT     Set lint allowed
    -D, --deny OPT      Set lint denied
    -F, --forbid OPT    Set lint forbidden
        --cap-lints LEVEL
                        Set the most restrictive lint level. More restrictive
                        lints are capped at this level
    -C, --codegen OPT[=VALUE]
                        Set a codegen option
    -V, --version       Print version info and exit
    -v, --verbose       Use verbose output

Additional help:
    -C help             Print codegen options
    -W help             Print 'lint' options and default settings
    -Z help             Print unstable compiler options
    --help -v           Print the full set of options rustc accepts

Note that I've used the release version of wasmtime. Also, when simply running

$ wasmtime rustc_binary.wasm

I stumbled upon the following panic!

thread 'main' panicked at 'unsupported', src/libstd/sys/wasi/os.rs:58:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
error while processing main module target/wasm32-wasi/release/rustc_binary.wasm: Instantiation error: Trap occurred while invoking start function: wasm trap at 0x7f1483f9ff7e

The panic! originates from libstd/../split_paths which is not implemented for wasm32-wasi target just yet, so everything as expected ;-)

@bjorn3
Copy link
Contributor Author

bjorn3 commented May 15, 2019

After recompiling wasmtime from scratch it seems to work.

@bjorn3 bjorn3 closed this as completed May 15, 2019
pchickey added a commit to pchickey/wasmtime that referenced this issue May 12, 2023
We have only ever used Unknown for the stdio streams, and I don't expect
us to use it for anything else in the future, so rename it.

Set the returned filetype to character device: Closes bytecodealliance#146.

Also, fix some warnings.
dhil added a commit to dhil/wasmtime that referenced this issue Oct 9, 2024
This patch rebrands a few public APIs from typed-continuations to
stack-switching.

Resolves bytecodealliance#146.
avanhatt pushed a commit to wellesley-prog-sys/wasmtime that referenced this issue Oct 18, 2024
Add support for fetching models containing unspecified values.

With the addition of declared sorts in bytecodealliance#141, this broke the code that
parses constants from SMT models. The backend solvers differ on how they
implement this. This PR deals with the CVC5 format only, in which
unspecified values are represented as something like `(as @Unspecified_0
Unspecified)`.

Updates avanhatt#45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants