wasi-sdk | WASI-enabled WebAssembly C/C++ toolchain | Compiler library

 by   WebAssembly Shell Version: wasi-sdk-20 License: Apache-2.0

kandi X-RAY | wasi-sdk Summary

kandi X-RAY | wasi-sdk Summary

wasi-sdk is a Shell library typically used in Utilities, Compiler applications. wasi-sdk has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

This repository contains no compiler or library code itself; it uses git submodules to pull in the upstream Clang and LLVM tree, as well as the wasi-libc tree. The libc portion of this SDK is the wasi-libc. Upstream Clang and LLVM (from 9.0 onwards) can compile for WASI out of the box, and WebAssembly support is included in them by default. So, all that's done here is to provide builds configured to set the default target and sysroot for convenience. One could also use a standard Clang installation, build a sysroot from the sources mentioned above, and compile with "--target=wasm32-wasi --sysroot=/path/to/sysroot".
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              wasi-sdk has a medium active ecosystem.
              It has 898 star(s) with 124 fork(s). There are 47 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 42 open issues and 109 have been closed. On average issues are closed in 250 days. There are 7 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of wasi-sdk is wasi-sdk-20

            kandi-Quality Quality

              wasi-sdk has 0 bugs and 0 code smells.

            kandi-Security Security

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

            kandi-License License

              wasi-sdk is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              wasi-sdk releases are available to install and integrate.
              Installation instructions, 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-sdk
            Get all kandi verified functions for this library.

            wasi-sdk Key Features

            No Key Features are available at this moment for wasi-sdk.

            wasi-sdk Examples and Code Snippets

            No Code Snippets are available at this moment for wasi-sdk.

            Community Discussions

            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

            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

            How to call WASI functions directly in C using wasi-sdk (import module problem)
            Asked 2020-Jul-25 at 07:33

            I'm trying to call a WASI function (fd_write) directly in a C program using wasi-sdk. This is the the library (lib.c):

            ...

            ANSWER

            Answered 2020-Jul-25 at 07:33

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

            Vulnerabilities

            No vulnerabilities reported

            Install wasi-sdk

            A typical installation from the release binaries might look like the following:.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            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/WebAssembly/wasi-sdk.git

          • CLI

            gh repo clone WebAssembly/wasi-sdk

          • sshUrl

            git@github.com:WebAssembly/wasi-sdk.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

            Explore Related Topics

            Consider Popular Compiler Libraries

            rust

            by rust-lang

            emscripten

            by emscripten-core

            zig

            by ziglang

            numba

            by numba

            kotlin-native

            by JetBrains

            Try Top Libraries by WebAssembly

            wabt

            by WebAssemblyC++

            WASI

            by WebAssemblyRust

            wasi-libc

            by WebAssemblyC

            component-model

            by WebAssemblyPython

            wasm-c-api

            by WebAssemblyC++