Subject: [bug#77653] [PATCH 1/4] gnu: Add wasi-libc.

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 25 Apr 2025 17:02:15 +0900

Hello,

Ian Eure <[email-masked]> writes:

> * gnu/packages/wasm.scm (wasi-libc): New variable.

[...]

> +(define-public wasi-libc
> +  (package
> +    (name "wasi-libc")
> +    (version "sdk-20")

That's an odd version string.  Should we strip 'sdk-' and keep just
'20'?

> +    (source (origin
> +              (method git-fetch)
> +              (uri (git-reference
> +                    (url "https://github.com/WebAssembly/wasi-libc")
> +                    (commit (string-append "wasi-" version))
> +                    (recursive? #t)))

The reason for using recursive? #t should be explained in a comment.
Typically these pull other package sources, which as a policy we'd
rather package separately.

> +              (file-name (git-file-name name version))
> +              (sha256
> +               (base32
> +                "0knm5ch499dksmv1k0kh7356pjd9n1gjn0p3vp9bw57mn478zp8z"))))
> +    (build-system gnu-build-system)
> +    (native-inputs (list clang-16))
> +    (arguments
> +     (list #:tests? #f ;No test suite

nitpick: no need to punctuate margin comments (standalone comments, yes).

> +           ;; Firefox uses wasm2c to compile WebAssembly to C code, and it
> +           ;; does not support the memory.copy opcode.
> +           ;; See https://bugzilla.mozilla.org/show_bug.cgi?id=1773200#c4
> +           #:make-flags ''("BULK_MEMORY_SOURCES=")
> +           #:phases
> +           #~(modify-phases %standard-phases
> +               (delete 'configure)
> +               (add-before 'build 'set-sysroot-include
> +                 (lambda _
> +                   (setenv "C_INCLUDE_PATH"
> +                           (string-append (getcwd) "/sysroot/include"))))
> +               (add-before 'install 'set-install-dir
> +                 (lambda _
> +                   (setenv "INSTALL_DIR"
> +                           (string-append #$output "/wasm32-wasi")))))))

That's a strange (non-FHSish) place to put the result, no?  Should in go
to /lib/wasm32-wasi, perhaps?

> +    (home-page "https://wasi.dev")
> +    (synopsis "WASI libc implementation for WebAssembly")
> +    (description
> +     "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.")

Please use 'file system' instead of filesystem, as a GNU convention.

-- 
Thanks,
Maxim