wasi-libc | WASI libc implementation for WebAssembly

 by   WebAssembly C Version: v0.1-alpha License: Non-SPDX

kandi X-RAY | wasi-libc Summary

kandi X-RAY | wasi-libc Summary

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

WASI Libc is a libc for WebAssembly programs built on top of WASI system calls. It provides a wide array of POSIX-compatible C APIs, including support for standard I/O, file I/O, filesystem manipulation, memory management, time, string, environment variables, program startup, and many other APIs. WASI Libc is sufficiently stable and usable for many purposes, as most of the POSIX-compatible APIs are stable, though it is continuing to evolve to better align with wasm and WASI.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              wasi-libc has a low active ecosystem.
              It has 682 star(s) with 146 fork(s). There are 47 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 41 open issues and 68 have been closed. On average issues are closed in 81 days. There are 18 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of wasi-libc is v0.1-alpha

            kandi-Quality Quality

              wasi-libc has 0 bugs and 0 code smells.

            kandi-Security Security

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

            kandi-License License

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

            wasi-libc Key Features

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

            wasi-libc Examples and Code Snippets

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

            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

            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

            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

            Is there a way to run C program locally in a browser?
            Asked 2020-May-22 at 20:16

            Yes, there is a duplicate problem, but it was asked 5 years ago and haven't been updated for a long time.

            In 2020, with the development of WebAssembly, is there a way to compile and run a simple C program locally in the browser?

            There is a platform called WasmFiddle which can compile C to wasm in browser, but it lacks the support of standard libraries, such as stdio.h. I think we can implement standard librarys in js and maybe export it to wasm? But this requires lots of work.

            My original goal is to build a web-based IDE for students to learn C programming without costing a lot on servers for remote running. So, only libraries like stdio.h, math.h, string.h are required.

            UPDATE: this seems like a great implementation of libc to wasm.

            High performance is not required, so wasm-based solutions and maybe a VM running c implemented in JS are both greate solutions.

            ...

            ANSWER

            Answered 2020-May-21 at 01:03

            Emscripten and WASM are the two popular solutions here.

            Don't expect great performance, but you should then be able to link it up with a little bit of JavaScript, CSS and HTML for your code editing and console views.

            If you're okay with running a server, then you can use this Jupyter Notebook kernel: https://github.com/jupyter-xeus/xeus-cling

            Here's an example in WASM, with no server: https://github.com/tbfleming/cib

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

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

            Vulnerabilities

            No vulnerabilities reported

            Install wasi-libc

            You can download it from GitHub.

            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-libc.git

          • CLI

            gh repo clone WebAssembly/wasi-libc

          • sshUrl

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

            linux

            by torvalds

            scrcpy

            by Genymobile

            netdata

            by netdata

            redis

            by redis

            git

            by git

            Try Top Libraries by WebAssembly

            wabt

            by WebAssemblyC++

            WASI

            by WebAssemblyRust

            wasi-sdk

            by WebAssemblyShell

            component-model

            by WebAssemblyPython

            wasm-c-api

            by WebAssemblyC++