wasi | Experimental WASI API bindings for Rust | Binary Executable Format library

 by   bytecodealliance Rust Version: Current License: Non-SPDX

kandi X-RAY | wasi Summary

kandi X-RAY | wasi Summary

wasi is a Rust library typically used in Programming Style, Binary Executable Format applications. wasi has no bugs, it has no vulnerabilities and it has low support. However wasi has a Non-SPDX License. You can download it from GitHub.

This crate contains API bindings for WASI system calls in Rust, and currently reflects the wasi_snapshot_preview1 module. This crate is quite low-level and provides conceptually a "system call" interface. In most settings, it's better to use the Rust standard library, which has WASI support.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              wasi has a low active ecosystem.
              It has 139 star(s) with 29 fork(s). There are 16 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 7 open issues and 16 have been closed. On average issues are closed in 24 days. There are 1 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of wasi is current.

            kandi-Quality Quality

              wasi has 0 bugs and 0 code smells.

            kandi-Security Security

              wasi has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              wasi code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              wasi has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              wasi releases are not available. You will need to build from source code and install.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of wasi
            Get all kandi verified functions for this library.

            wasi Key Features

            No Key Features are available at this moment for wasi.

            wasi Examples and Code Snippets

            No Code Snippets are available at this moment for wasi.

            Community Discussions

            QUESTION

            How to run in wee8 wasm code that was compiled from c++ with emcc? (WASI in wee8?)
            Asked 2022-Mar-14 at 17:50

            I am trying to compile C++ code to wasm and then embed it in other C++ code with wee8 (v8's wasm-api). Currently I'm getting a Segfault on instantiating the module:

            ...

            ANSWER

            Answered 2022-Mar-14 at 17:50

            I can answer part of your question:

            I'm missing is WASI support in wee8? Does it exist?

            No, wee8 does not implement WASI. Adding such support is theoretically possible, but not currently scheduled to get done.

            You can implement it yourself in your wee8 embedder, and make it available to loaded modules via imports. Most (or all?) of it could probably be a reusable (among many engine implementations) library, potentially offered and maintained by the WASI project itself. (I don't know whether such a library exists already.)

            You didn't say what imports object you're currently passing; it needs to be an array of wasm::Extern* pointers that's at least as long as the imports of the module, and ordered equivalently (i.e. imports[i] will be the module's ith import).

            (I agree that the Wasm C/C++ API is very barebones currently. Unless/until that is changed, you'll have to build any convenience mechanisms yourself. It's all possible with the information that's available, it's just clearly less convenient than instantiating Wasm modules from JavaScript.)

            Source https://stackoverflow.com/questions/71471462

            QUESTION

            ABI format of WASI functions
            Asked 2021-Dec-12 at 17:17

            I am building a Webassembly runtime and am currently implementing the WASI APIs. I'm wondering how the ABI looks like, according to this document: https://github.com/WebAssembly/WASI/blob/main/phases/snapshot/docs.md

            To test, I have compiled this C application with emscripten to a standalone WASM module.

            ...

            ANSWER

            Answered 2021-Dec-12 at 17:17

            In wasi-libc, the function signature of __wasi_fd_read is:

            Source https://stackoverflow.com/questions/69486132

            QUESTION

            WebAssembly + concurrency: trying to set a thread-local stack from C/C++
            Asked 2021-Nov-02 at 19:55

            I have a re-entrant C++ function whose wasm output is not "thread-safe" when using imported shared memory, because the function makes use of an aliased stack that lives on the shared linear memory on a hardcoded position.

            I'm aware that multithreading is not fully supported yet, and if I want to use multiple instances of the same module concurrently, avoiding crashing and data races it's my responsibility, but I accept the challenge.

            My X problem is: My code is not thread-safe, and I need it to be by having non-overlapping stacks.

            My Y problem is: I'm trying to modify the __stack_pointer so I can implement the stack separation, but it doesn't compile. I have tried with extern unsigned char __stack_pointer; but it throws me the following error:

            ...

            ANSWER

            Answered 2021-Nov-02 at 17:46

            Firstly, if you are doing multi-threading with emscripten then each thread will already have its own stack and its own value for __stack_pointer. Thats is part of what defines a thread.

            If you still want to manipulate the stack yourself (perhaps to have many stacks within a single thread) then you can use the emscripten helper functions stackSave (to get the SP of the current thread) and stackRestore (to set the SP of the current thread).

            If you are not using emscripten at all, then you are in uncharted territory (what runtime are using using? how are you starting new threads?), but the simplest way to do stack pointer manipulation would be with assembly code. See how emscripten implements these functions:

            https://github.com/emscripten-core/emscripten/blob/main/system/lib/compiler-rt/stack_ops.S

            So you could do something like this:

            Source https://stackoverflow.com/questions/69811603

            QUESTION

            Why does clang emit i64 instructions when targeting wasm32?
            Asked 2021-Oct-25 at 15:45

            I used clang --target=wasm32-unknown-wasi ... to compile a Hello World C program into WebAssembly. Everything goes fine, and the .wasm file can run correctly in runtime like wasmer.

            But when I check the .wasm file(in .wat format), I found some i64 instructions like:

            ...

            ANSWER

            Answered 2021-Oct-25 at 15:45

            I see nothing wrong with that. Targeting 32bits means that the memory addressing is 32bits. For this reason before the memory store instruction, all you have are 32bit instructions (i.e. the offset and the value are i32) you have this at some point:

            Source https://stackoverflow.com/questions/69708502

            QUESTION

            Cannot execute standalone webassembly file with wasmer
            Asked 2021-Jul-06 at 21:36

            I wrote a matrix multiplication program in C and compiled it using Emscripten with the following command

            emcc matrix.c -o matrix.wasm -s STANDALONE_WASM

            And the C program is as follows,

            ...

            ANSWER

            Answered 2021-Jul-06 at 21:36

            Compilers will often inline functions and remove code that isn't used, this is why your C program ends up with everything inside a _start function. As explained in the FAQ you may list functions to export using emcc -s EXPORTED_FUNCTIONS=_main,_matrix in order to prevent them from being inlined or removed. Adding this results in a wasm module with the function correctly exported.

            As for running functions directly, the source code for wasmer run has logic to determine which runtime environment should be exposed to the module. However, if you pass -i function, it entirely skips the environment setup and runs your function directly. In this case, the modules fails to initialize because it imports functions from WASI (in order to write things to the console, and get the current clock time).

            I believe the reason why wasm32-unknown-unknown works is that it doesn't link to any runtime, and implements dummy interfaces for things that it can't simulate (all filesystem calls result in errors, etc.)

            In summary, wasmer run -i function isn't meant to run functions from modules that have imports, it might be possible to patch wasmer-cli for that, but I'm not sure if it would work across all runtime environments.

            Source https://stackoverflow.com/questions/68265851

            QUESTION

            How to pass command line arguments to C code with WebAssembly and JS?
            Asked 2021-May-13 at 02:47

            I'm trying to run some small C demos on the web with WebAssembly and pure JS, and I'm compiling my code using WASI-SDK/WASI-libc:

            clang --target=wasm32-unknown-wasi --sysroot= -nostartfiles -O3 -flto -Wl,--no-entry -Wl,--export=malloc -Wl,--export-all -Wl,--lto-O3 src.c -o src.wasm

            I'm then using this small JS library to implement the WASI functions. This works fine for printing with stdout, and I've even tested passing strings and other types into different functions. But I can't figure out how to pass an array of strings into main as an argument.

            I don't want to use Node or Emscripten, which is why I went with a minimal JS implementation.

            Edit:

            To add command line arguments, I removed both -nostartfiles and -Wl,--no-entry from my compiler call and implemented args_get and args_sizes_get from the WASI standard. From there, it was as simple as calling _start from the wasm's exported functions.

            ...

            ANSWER

            Answered 2021-May-12 at 07:11

            If you want to use WASI then the way to pass args to main is to implement the wasi_snapshot_preview1.args_get and wasi_snapshot_preview1.args_sizes_get syscalls which are used by WASI programs to access the argv values. In that case you would want to call _start rather than main.

            If you want to bypass that and call main directly you would need to somehow allocate and array of char * pointers in the linear memory which you could then pass as your argv value. The problem that you face if you try to take this approach is that allocating memory (e.g. via malloc) before calling main is hard. My advise would be to go with the first method which is to call _start and implement that wasi syscall needed to access argv. (You can call also then remove the -Wl,--no-entry from your link command).

            Source https://stackoverflow.com/questions/67498446

            QUESTION

            Sorting linked list with multiple elements
            Asked 2021-Apr-20 at 21:33

            I have this csv file:

            ...

            ANSWER

            Answered 2021-Apr-20 at 21:33

            When you want to create a linked list, you should use a struct Cell that contains two types of date: the first is your data itself (Contact in your case) the other is a pointer to the next cell in the list (next). Using this type of implementation you make your code more readable, modular and reusable.

            Source https://stackoverflow.com/questions/67184694

            QUESTION

            Hash table didn't return correct value by it's Index
            Asked 2021-Apr-09 at 12:18

            I have this csv file contain people contact:

            ...

            ANSWER

            Answered 2021-Apr-09 at 12:18

            Couple of problems:

            1. The major problem is that there are two Contact *new = malloc(sizeof(Contact)); lines. One inside the loop and one outside. They are two different variables. The while loop condition is using the one outside the loop. Hence the fscanf is writing to the same memory for every loop. One way to fix that is to make the second instance just new = malloc(sizeof(Contact));. Note that this loop has a memory leak as the last allocated node is lost - left to you as an exercise to fix.

            2. searching_contact has an infinete loop as the if (strcmp(name, cursor->name) == 0) block is missing a break.

            Source https://stackoverflow.com/questions/67020532

            QUESTION

            host can choose which system calls pass to each webassembly module
            Asked 2021-Apr-08 at 06:42

            part of the talk of Lin Clark in https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/:

            It also gives us sandboxing because the host can choose which wasi-core functions to pass in — so, which system calls to allow — on a program-by-program basis. This preserves security.

            she says host can choose which system calls pass to each wasm module. for example read() system call passes to module A and write() system call to module B.

            is it implemented in wasmtime or lucet or other runtimes? or is it just a dream without implementation in real world?

            ...

            ANSWER

            Answered 2021-Apr-08 at 06:42

            Yes it is implemented in all runtimes implementing wasi. The reason is that this feature is related to import/export mechanism of WebAssembly.

            Source https://stackoverflow.com/questions/66949040

            QUESTION

            Comma separated for multiple items not working properly for SQL Sever 2012
            Asked 2021-Apr-05 at 14:31

            I am using SQL Server 2012 (v11.0.5058.0 - X64). I want to perform comma separated for multiple columns. Since my SQL Server version is 2012 I can't use string_agg or ListAgg so I am trying with a CTE and FOR XML PATH which is new for me.

            Output Explanation:

            Supposed If One staff ID Contain multiple Cost_Center then it should comma separated for respective Staff_ID

            Current table:

            ...

            ANSWER

            Answered 2021-Apr-05 at 14:31

            As a rule, a WHERE clause of SELECT .. FOR XML .. shoud make the subquery depend on exactly the same columns which are listed in the GROUP BY clause of the outer query. Try

            Source https://stackoverflow.com/questions/66951269

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install wasi

            You can download it from GitHub.
            Rust is installed and managed by the rustup tool. Rust has a 6-week rapid release process and supports a great number of platforms, so there are many builds of Rust available at any time. Please refer rust-lang.org for more information.

            Support

            Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/bytecodealliance/wasi.git

          • CLI

            gh repo clone bytecodealliance/wasi

          • sshUrl

            git@github.com:bytecodealliance/wasi.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular Binary Executable Format Libraries

            wasmer

            by wasmerio

            framework

            by aurelia

            tinygo

            by tinygo-org

            pyodide

            by pyodide

            wasmtime

            by bytecodealliance

            Try Top Libraries by bytecodealliance

            wasmtime

            by bytecodeallianceRust

            lucet

            by bytecodeallianceRust

            wasm-micro-runtime

            by bytecodeallianceC

            javy

            by bytecodeallianceRust

            rustix

            by bytecodeallianceRust