WebAssembly / WebAssembly/wasi-libc
A few packaging nits, coming from Nixpkgs/NixOS
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 1k
- Forks
- 251
- Avg merge
- 7h 15m
- Merged PRs (30d)
- 3
Description
Hi, you can see how we currently package this in https://github.com/nixos/nixpkgs/blob/master/pkgs/development/libraries/wasilibc/default.nix.
There are no imminent problems (the situation is less fraught than I thought) but I few things I think could be improved.
Install dirs
We generally like to have "mutliple outputs" for our libraries. That means we install to something like /nix/store/random-foo/lib, /nix/store/random-bar/include, etc. notice the random-{foo,bar} are not the same.
We generally use the "GNU-style: install dirs" to achieve this. C.f.
- Autoconf: https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Installation-Directory-Variables.html
- CMake: https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
- Meson: https://mesonbuild.com/Builtin-options.html#directories
You have
https://github.com/WebAssembly/wasi-libc/blob/079adff840032c3455eb1cb34dc9ceaa0b2bfc0c/Makefile#L8
and
https://github.com/WebAssembly/wasi-libc/blob/079adff840032c3455eb1cb34dc9ceaa0b2bfc0c/Makefile#L246-L248
for this. It would be nice to make the second ones ?= too, and relax the assumption that that they share a parent directory.
That list bit part means getting rid of other uses of SYSROOT (it can just be a way to default the defaults for those three, so e.g.:
Tool env vars
You use WASM_*, e.g. WASM_CC. The convention however is that CC, LD, etc. are the tools for the current package, for the current platform, one is installing too. Conversely, if one needed to build e.g. some temporary codegen tool (a common use case, but not on in wasi libc to my knowledge), one would use CC_FOR_BUILD, LD_FOR_BUILD etc.
This means the WASM_ prefix is not needed.
I would suggest just getting rid of them. The wrapper wasi-sdk already does recursive make:
https://github.com/WebAssembly/wasi-sdk/blob/20c5bcd791e22895ea1c9721c9bd88081e3ed1f6/Makefile#L92-L96
build/wasi-libc.BUILT: build/llvm.BUILT
$(MAKE) -C $(ROOT_DIR)/src/wasi-libc \
WASM_CC=$(BUILD_PREFIX)/bin/clang \
...
This makes scoped variables easy, so you can just do
build/wasi-libc.BUILT: build/llvm.BUILT
$(MAKE) -C $(ROOT_DIR)/src/wasi-libc \
CC=$(BUILD_PREFIX)/bin/clang \
...
instead, and not worry about clashes with any "global" CC.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the referenced Makefile assignments at lines 8 and 246-248, then inspect other SYSROOT and WASM_* uses. Review the wasi-sdk Makefile rule that invokes wasi-libc and the nixpkgs package definition. Done means install directories can be set independently and the tool environment follows the proposed convention without breaking the wrapper.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100