Skip to content
Snippets Groups Projects
  1. Jun 28, 2025
  2. Jun 25, 2025
  3. Jun 20, 2025
  4. Jun 19, 2025
    • Yuta Saito's avatar
      Opt-in busywait mode for futexes (#562) · 859062ba
      Yuta Saito authored
      We are heavily using wasi-libc + wasip1-threads on browsers. Since
      wasi-libc uses `memory.atomic.wait32` to implement futex, and the usage
      of `memory.atomic.wait32` on the main thread is prohibited on browsers,
      we currently need to write code carefully not to reach the instruction.
      
      Emscripten addresses this limitation by [employing a busy-wait on the
      main
      thread](https://github.com/emscripten-core/emscripten/blob/058a9fff/system/lib/pthread/emscripten_futex_wait.c#L111-L150)
      as a workaround. Rust has [always employs busywait regardless of the
      current thread is
      main](https://github.com/rust-lang/rust/blob/a47555110cf09b3ed59811d9b02235443e76a595/library/std/src/sys/alloc/wasm.rs#L75-L144).
      This approach, while effective for browsers, introduces unnecessary
      overhead in environments where memory.atomic.wait32 is permitted.
      
      This change provides a similar solution by introducing an opt-in
      busy-wait mode for futexes. By making this an optional feature, we avoid
      imposing the overhead of busy-waiting in non-browser environments while
      ensuring compatibility with browser-based restrictions.
      
      ```c
      #include <wasi/libc-busywait.h>
      
      /// Enable busywait in futex on current thread.
      void __wasilibc_enable_futex_busywait_on_current_thread(void);
      ```
      
      This change slightly adds some runtime overheads in futex to check if we
      should use busywait, but it can be optimized away as long as
      `__wasilibc_enable_futex_busywait_on_current_thread` is not used by user
      program and LTO is enabled.
      859062ba
    • Henri Nurmi's avatar
      wasi-sockets: Add services database and implement getservbyname/getservbyport functions (#532) · a3a95960
      Henri Nurmi authored
      This is a follow-up PR for #524 by implementing the following features:
      
      - Embeds a minimal network services database with 17 common protocols,
      suggested by @badeend. The database array is a weak symbol allowing
      applications to override the default database at link time.
      - Updates `getaddrinfo` to resolve named services in the address info.
      For example `getaddrinfo("google.com", "https", NULL, &res);`
      - Implements the `getservbyname` and `getservbyport` functions. These
      functions are implemented using a static variable (`global_serv`), which
      holds the returned service entry. This approach is acceptable because
      these functions [are defined as not being
      thread-safe](https://man.archlinux.org/man/getservbyname.3.en).
      
      ~~Additionally, this PR introduces an optional, more comprehensive
      services database (`sockets_full_services_db.c`), based on Debian
      Bookworm's `/etc/services` file (320 entries). To use this database,
      link with the `-lc-full-services-db` flag.~~
      a3a95960
    • Alex Crichton's avatar
      Refactor how CI works in this repository (#588) · 48eb92c1
      Alex Crichton authored
      There are a number of changes in this commit aimed at addressing #587
      and making it easier to test #586 in CI. Notable changes here are:
      
      * The matrix of what to test is much different from before. One matrix
      entry now builds just one target and optionally tests that target.
      
      * The CI matrix ensures that wasi-libc builds on a variety of platforms,
      e.g. Windows/macOS/Linux as well as Linux aarch64.
      
      * The CI matrix has one entry for building with an older version of
      LLVM. This version was bumped from LLVM to LLVM 11 since LLVM is
      installed through `apt-get`, not through downloads any more.
      
      * On Linux LLVM/Clang are downloaded through `apt-get` instead of from
      llvm-project binaries to avoid dealing with `libtinfo5` and
      dependencies.
      
      * The CI matrix has a test job per-target. This can be expanded/shrunk
      as necessary but currently everything is tested with LLVM 16 (as before)
      and only on Linux (also as before). The test run is seqeunced to happen
      after the build of libc itself.
      
      * The CI matrix has split out V8 headless tests into their own job to
      avoid running multiple suites of tests in a single job.
      
      * Installation of LLVM is refactored to a separate action to reduce the
      noise in `main.yml`.
      
      * Setting `TARGET_TRIPLE` can now be done through environment variables
      as opposed to only through arguments to `make`.
      
      * Handling of `BULITINS_LIB` has improved. Previously the build target
      for `libc_so` would modify the compiler's resource directory and this is
      updated to use a custom directory in `OBJDIR`.
      
      * Arranging compiler-rt for tests is now done with `-resource-dir`
      instead of copying the directory into the system compiler's location.
      
      Overall it's the intention that no amount of testing is lost in this PR.
      The goal is to expand things out in such a way that it's much easier to
      add one-off tests of wasi-libc in various build configurations and such.
      The theory is that this is as "simple" as adding a new matrix entry,
      copied from previous ones, customized with various variables and
      environment variables to affect the build (e.g. `CFLAGS`).
      
      Closes #587
      48eb92c1
  5. Jun 03, 2025
  6. Jun 02, 2025
    • Lukas's avatar
      clang > 20.1.4 compat: unterminated strings (#584) · e0bc5c20
      Lukas authored
      clang introduced a new warning (following gcc) for string initialization
      to char arrays that do not fit the null terminal.
      
      Introduced here: https://github.com/llvm/llvm-project/pull/137829
      Included in LLVM version [LLVM
      20.1.4](https://github.com/llvm/llvm-project/releases/tag/llvmorg-20.1.4)+
      
      More detail:
      -Wunterminated-string-initialization warns for c string literals that
      are written to a buffer too small to include a null terminator. This
      warning is also included in -Wextra which is enabled for wasi-libc and
      fails compilation due to -Werror.
      
      Possible fixes:
       1. deactivate the warning
      2. add `__attribute__ ((nonstring))` to the three occurrences where this
      is a problem.
      
      Chosen solution: 1.
      Since the attribute is not available on older clang versions, it would
      trigger another warning there.
      
      (included a small formatting change in the commit - pls ignore)
      e0bc5c20
  7. May 13, 2025
  8. May 09, 2025
  9. Feb 04, 2025
  10. Feb 03, 2025
  11. Feb 02, 2025
    • mcbarton's avatar
      Pin MacOS Github runner version in ci to MacOS 15 (#565) · 76702e42
      mcbarton authored
      Rather than using Macos-latest this makes the ci used a pinned version
      of Macos (set to the latest version available). This is so if you happen
      to have an issue with the MacOS build you know exactly which version of
      MacOS it is running, rather than having to dig into the ci, or Github
      runner documentation.
      76702e42
    • mcbarton's avatar
      [ci] Pin Windows runner to Windows 2025 (#566) · 86d142fc
      mcbarton authored
      Rather than using Windows-latest this PR updates the ci to use a pinned
      version of Windows (set to the latest version available). This is so if
      you happen to have an issue with the Windows build you know exactly
      which version of Windows it is running, rather than having to dig into
      the ci, or Github runner documentation.
      86d142fc
  12. Jan 28, 2025
  13. Jan 20, 2025
  14. Dec 09, 2024
    • Mike Hommey's avatar
    • Andrew Brown's avatar
      test: improve test infrastructure (#554) · 2b853ff0
      Andrew Brown authored
      This change represents a rather large re-design in how `wasi-libc`
      builds and runs its tests. Initially, #346 retrieved the `libc-test`
      repository and built a subset of those tests to give us some amount of
      test coverage. Later, because there was no way to add custom C tests,
      #522 added a `smoke` directory which allowed this. But (a) each of these
      test suites was built and run separately and (b) it was unclear how to
      add more tests flexibly--some tests should only run on `*p2` targets or
      `*-threads` targets, e.g.
      
      This change reworks all of this so that all tests are built the same
      way, in the same place. For downloaded tests like those from
      `libc-test`, I chose to add "stub tests" that `#include` the original
      version. This not only keeps all enabled tests in one place, it also
      allows us to add "directives," C comments that the `Makefile` uses to
      filter out tests for certain targets or add special compile, link or run
      flags. These rudimentary scripts, along with other Bash logic I moved
      out of the Makefile now live in the `scripts` directory.
      
      Finally, all of this is explained more clearly in an updated
      `README.md`. The hope with documenting this a bit better is that it
      would be easier for drive-by contributors to be able to either dump in
      new C tests for regressions they may find or enable more libc-tests. As
      of my current count, we only enable 40/75 of libc-test's functional
      tests, 0/228 math tests, 0/69 regression tests, and 0/79 API tests.
      Though many of these may not apply to WASI programs, it would be nice to
      explore how many more of these tests can be enabled to increase
      wasi-libc's test coverage. This change should explain how to do that
      and, with directives, make it possible to condition how the tests
      compile and run.
      2b853ff0
  15. Dec 04, 2024
    • Andrew Brown's avatar
      Move installation of include headers into a separate script (NFC) (#552) · 29c22a4b
      Andrew Brown authored
      This change is not meant to change any functionality, only move some
      Bash-specific logic out of the `Makefile` into its own script:
      `install-include-headers.sh`. This reduces the perceived complexity of
      the `Makefile` but the complexity is still there, tucked away in this
      script. This script also has the advantage that it can be run separately
      if needed.
      
      This commit comes after a few different attempts at building up
      `Makefile` lists of headers to copy over along with the various
      locations they must be copied from. It is certainly possible to do this,
      but due to how we need to remove some headers from the list, it ends up
      being easier to just `cp` and then `rm`, which this script retains.
      29c22a4b
  16. Nov 27, 2024
  17. Nov 20, 2024
    • Andrew Brown's avatar
      Avoid re-copying include headers (#549) · c47daaf6
      Andrew Brown authored
      This adds a `.stamp` file to the build directory that tracks when all
      headers have been copied over to the sysroot `include` directory.
      Previously, the `include_dirs` target was phony, which `make` will run
      every time, regardless of whether it is needed. This was part of the
      problem with all of libc being rebuilt at each `make` invocation.
      c47daaf6
    • Andrew Brown's avatar
      Avoid rebuilding empty placeholder libraries (#550) · 913e58e6
      Andrew Brown authored
      Previously, these were rebuilt each time as a part of the phone
      `dummy_libs` target. This change only rebuilds them if they don't exist.
      913e58e6
Loading