GNU bug report logs - #77653
[PATCH 0/4] Add WASM toolchain, wasi-libc, and browser WASM sandbox support

Previous Next

Package: guix-patches;

Reported by: Ian Eure <ian <at> retrospec.tv>

Date: Tue, 8 Apr 2025 19:58:02 UTC

Severity: normal

Tags: patch

Full log


Message #41 received at 77653 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ian Eure <ian <at> retrospec.tv>
Cc: 77653 <at> debbugs.gnu.org
Subject: Re: [bug#77653] [PATCH 3/4] gnu: Add wasm32-wasi-clang.
Date: Fri, 25 Apr 2025 21:52:32 +0900
Hi,

Ian Eure <ian <at> retrospec.tv> writes:

> * gnu/packages/wasm.scm (wasm32-wasi-clang): New variable.
>
> Change-Id: Ibf1df3e93929442a8eed29eea20b2f83b491f3b3

[...]

> --- a/gnu/packages/wasm.scm
> +++ b/gnu/packages/wasm.scm
> @@ -24,7 +24,8 @@ (define-module (gnu packages wasm)
>    #:use-module (guix gexp)
>    #:use-module (guix git-download)
>    #:use-module ((guix licenses) #:prefix license:)
> -  #:use-module (guix packages))
> +  #:use-module (guix packages)
> +  #:use-module (guix utils))
>  
>  (define-public wasi-libc
>    (package
> @@ -106,3 +107,29 @@ (define-public wasm32-wasi-clang-runtime
>                ;; WASM only needs libclang_rt.builtins-wasm32.a from
>                ;; compiler-rt.
>                "../source/compiler-rt/lib/builtins")))))
> +
> +;; Although Clang can be built to support multiple compilation targets, Guix
> +;; builds only target the native architecture, so we have to build a build a
> +;; new toolchain that to target WASM.
> +
> +(define clang-from-llvm (@@ (gnu packages llvm) clang-from-llvm))
> +(define llvm-monorepo (@@ (gnu packages llvm) llvm-monorepo))
> +
> +(define-public wasm32-wasi-clang
> +  (let ((base (clang-from-llvm llvm-16 wasm32-wasi-clang-runtime)))
> +    (package (inherit base)

As explained previously, this should be package/inherit, and this new
clang variant should live in the same module as clang in (gnu packages
llvm).

> +      (name "wasm32-wasi-clang")
> +      (inputs
> +       (modify-inputs (package-inputs base)
> +         (prepend wasi-libc)))
> +      (arguments
> +       (substitute-keyword-arguments (package-arguments base)
> +         ((#:configure-flags flags)

Since it seems you strictly want to override #:configure-flags rather
than extend it, a better choice would be `ensure-keyword-arguments'.

> +          #~(list "-DCLANG_INCLUDE_TESTS=True"
> +                  ;; Use a sane default include directory.
> +                  (string-append "-DC_INCLUDE_DIRS="
> +                                 #$wasi-libc
> +                                 "/wasm32-wasi/include")))

It seems to be /include or /include/wasm32-wasi would be a "saner"
default :-).

> +         ((#:phases phases)
> +          `(modify-phases ,phases
> +             (delete 'symlink-cfi_ignorelist))))))))

Why is the above necessary?  A comment could help.

-- 
Thanks,
Maxim




This bug report was last modified 43 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.