Import lang/wasi-libc, the libc part of https://wasi.dev/

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.

this is one of the requirements to enable wasm sandboxing for bundled
libraries in firefox via rlbox, cf https://hacks.mozilla.org/2021/12/webassembly-and-back-again-fine-grained-sandboxing-in-firefox-95/

ok sthen@
This commit is contained in:
landry 2022-05-23 14:13:54 +00:00
parent c18ceee201
commit 024869a18e
5 changed files with 274 additions and 0 deletions

21
lang/wasi-libc/Makefile Normal file
View File

@ -0,0 +1,21 @@
COMMENT = C standard library for WebAssembly System Interface
GH_ACCOUNT = WebAssembly
GH_PROJECT = wasi-libc
GH_COMMIT = 05cd0af0af4b5a191117d47a182adff1d6546b87
DISTNAME = wasi-libc-0.20220413
CATEGORIES = lang
# Apache-2.0 with LLVM Exceptions, Apache-2.0, MIT
PERMIT_PACKAGE = Yes
COMPILER = ports-clang
USE_GMAKE = yes
ALL_TARGET = finish
MAKE_ENV += AR=${LOCALBASE}/bin/llvm-ar \
NM=${LOCALBASE}/bin/llvm-nm \
INSTALL_DIR=${WRKINST}${PREFIX}/share/wasi-sysroot
.include <bsd.port.mk>

2
lang/wasi-libc/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (wasi-libc-0.20220413-05cd0af0.tar.gz) = vgKb3dSRO5d5BYZjhUKPJBx+yeCRlteONLe2s2xUOmc=
SIZE (wasi-libc-0.20220413-05cd0af0.tar.gz) = 1251259

View File

@ -0,0 +1,15 @@
https://cgit.freebsd.org/ports/tree/devel/wasi-libc/Makefile#n40
avoid rebuilding everything in fake
Index: Makefile
--- Makefile.orig
+++ Makefile
@@ -565,7 +565,7 @@ check-symbols: startup_files libc
# This ignores whitespace because on Windows the output has CRLF line endings.
diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
-install: finish
+install:
mkdir -p "$(INSTALL_DIR)"
cp -r "$(SYSROOT)/lib" "$(SYSROOT)/share" "$(SYSROOT)/include" "$(INSTALL_DIR)"

4
lang/wasi-libc/pkg/DESCR Normal file
View File

@ -0,0 +1,4 @@
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.

232
lang/wasi-libc/pkg/PLIST Normal file
View File

@ -0,0 +1,232 @@
share/wasi-sysroot/
share/wasi-sysroot/include/
share/wasi-sysroot/include/__errno.h
share/wasi-sysroot/include/__errno_values.h
share/wasi-sysroot/include/__fd_set.h
share/wasi-sysroot/include/__function___isatty.h
share/wasi-sysroot/include/__functions_malloc.h
share/wasi-sysroot/include/__functions_memcpy.h
share/wasi-sysroot/include/__header_dirent.h
share/wasi-sysroot/include/__header_fcntl.h
share/wasi-sysroot/include/__header_inttypes.h
share/wasi-sysroot/include/__header_netinet_in.h
share/wasi-sysroot/include/__header_poll.h
share/wasi-sysroot/include/__header_stdlib.h
share/wasi-sysroot/include/__header_string.h
share/wasi-sysroot/include/__header_sys_ioctl.h
share/wasi-sysroot/include/__header_sys_resource.h
share/wasi-sysroot/include/__header_sys_socket.h
share/wasi-sysroot/include/__header_sys_stat.h
share/wasi-sysroot/include/__header_time.h
share/wasi-sysroot/include/__header_unistd.h
share/wasi-sysroot/include/__macro_FD_SETSIZE.h
share/wasi-sysroot/include/__macro_PAGESIZE.h
share/wasi-sysroot/include/__mode_t.h
share/wasi-sysroot/include/__seek.h
share/wasi-sysroot/include/__struct_dirent.h
share/wasi-sysroot/include/__struct_in6_addr.h
share/wasi-sysroot/include/__struct_in_addr.h
share/wasi-sysroot/include/__struct_iovec.h
share/wasi-sysroot/include/__struct_msghdr.h
share/wasi-sysroot/include/__struct_pollfd.h
share/wasi-sysroot/include/__struct_rusage.h
share/wasi-sysroot/include/__struct_sockaddr.h
share/wasi-sysroot/include/__struct_sockaddr_in.h
share/wasi-sysroot/include/__struct_sockaddr_in6.h
share/wasi-sysroot/include/__struct_sockaddr_storage.h
share/wasi-sysroot/include/__struct_sockaddr_un.h
share/wasi-sysroot/include/__struct_stat.h
share/wasi-sysroot/include/__struct_timespec.h
share/wasi-sysroot/include/__struct_timeval.h
share/wasi-sysroot/include/__struct_tm.h
share/wasi-sysroot/include/__struct_tms.h
share/wasi-sysroot/include/__typedef_DIR.h
share/wasi-sysroot/include/__typedef_blkcnt_t.h
share/wasi-sysroot/include/__typedef_blksize_t.h
share/wasi-sysroot/include/__typedef_clock_t.h
share/wasi-sysroot/include/__typedef_clockid_t.h
share/wasi-sysroot/include/__typedef_dev_t.h
share/wasi-sysroot/include/__typedef_fd_set.h
share/wasi-sysroot/include/__typedef_gid_t.h
share/wasi-sysroot/include/__typedef_in_addr_t.h
share/wasi-sysroot/include/__typedef_in_port_t.h
share/wasi-sysroot/include/__typedef_ino_t.h
share/wasi-sysroot/include/__typedef_mode_t.h
share/wasi-sysroot/include/__typedef_nfds_t.h
share/wasi-sysroot/include/__typedef_nlink_t.h
share/wasi-sysroot/include/__typedef_off_t.h
share/wasi-sysroot/include/__typedef_sa_family_t.h
share/wasi-sysroot/include/__typedef_sigset_t.h
share/wasi-sysroot/include/__typedef_socklen_t.h
share/wasi-sysroot/include/__typedef_ssize_t.h
share/wasi-sysroot/include/__typedef_suseconds_t.h
share/wasi-sysroot/include/__typedef_time_t.h
share/wasi-sysroot/include/__typedef_uid_t.h
share/wasi-sysroot/include/alloca.h
share/wasi-sysroot/include/ar.h
share/wasi-sysroot/include/arpa/
share/wasi-sysroot/include/arpa/ftp.h
share/wasi-sysroot/include/arpa/inet.h
share/wasi-sysroot/include/arpa/nameser.h
share/wasi-sysroot/include/arpa/nameser_compat.h
share/wasi-sysroot/include/arpa/telnet.h
share/wasi-sysroot/include/arpa/tftp.h
share/wasi-sysroot/include/assert.h
share/wasi-sysroot/include/bits/
share/wasi-sysroot/include/bits/alltypes.h
share/wasi-sysroot/include/bits/dirent.h
share/wasi-sysroot/include/bits/fcntl.h
share/wasi-sysroot/include/bits/fenv.h
share/wasi-sysroot/include/bits/float.h
share/wasi-sysroot/include/bits/hwcap.h
share/wasi-sysroot/include/bits/io.h
share/wasi-sysroot/include/bits/ioctl.h
share/wasi-sysroot/include/bits/ioctl_fix.h
share/wasi-sysroot/include/bits/ipcstat.h
share/wasi-sysroot/include/bits/limits.h
share/wasi-sysroot/include/bits/mman.h
share/wasi-sysroot/include/bits/poll.h
share/wasi-sysroot/include/bits/posix.h
share/wasi-sysroot/include/bits/reg.h
share/wasi-sysroot/include/bits/resource.h
share/wasi-sysroot/include/bits/signal.h
share/wasi-sysroot/include/bits/socket.h
share/wasi-sysroot/include/bits/stat.h
share/wasi-sysroot/include/bits/stdint.h
share/wasi-sysroot/include/byteswap.h
share/wasi-sysroot/include/complex.h
share/wasi-sysroot/include/cpio.h
share/wasi-sysroot/include/crypt.h
share/wasi-sysroot/include/ctype.h
share/wasi-sysroot/include/dirent.h
share/wasi-sysroot/include/endian.h
share/wasi-sysroot/include/err.h
share/wasi-sysroot/include/errno.h
share/wasi-sysroot/include/fcntl.h
share/wasi-sysroot/include/features.h
share/wasi-sysroot/include/fenv.h
share/wasi-sysroot/include/float.h
share/wasi-sysroot/include/fmtmsg.h
share/wasi-sysroot/include/fnmatch.h
share/wasi-sysroot/include/ftw.h
share/wasi-sysroot/include/getopt.h
share/wasi-sysroot/include/glob.h
share/wasi-sysroot/include/iconv.h
share/wasi-sysroot/include/ifaddrs.h
share/wasi-sysroot/include/inttypes.h
share/wasi-sysroot/include/iso646.h
share/wasi-sysroot/include/langinfo.h
share/wasi-sysroot/include/libgen.h
share/wasi-sysroot/include/limits.h
share/wasi-sysroot/include/locale.h
share/wasi-sysroot/include/malloc.h
share/wasi-sysroot/include/math.h
share/wasi-sysroot/include/memory.h
share/wasi-sysroot/include/monetary.h
share/wasi-sysroot/include/mqueue.h
share/wasi-sysroot/include/net/
share/wasi-sysroot/include/netinet/
share/wasi-sysroot/include/netinet/icmp6.h
share/wasi-sysroot/include/netinet/igmp.h
share/wasi-sysroot/include/netinet/in.h
share/wasi-sysroot/include/netinet/in_systm.h
share/wasi-sysroot/include/netinet/ip.h
share/wasi-sysroot/include/netinet/ip6.h
share/wasi-sysroot/include/netinet/ip_icmp.h
share/wasi-sysroot/include/netinet/tcp.h
share/wasi-sysroot/include/netinet/udp.h
share/wasi-sysroot/include/netpacket/
share/wasi-sysroot/include/netpacket/packet.h
share/wasi-sysroot/include/nl_types.h
share/wasi-sysroot/include/poll.h
share/wasi-sysroot/include/regex.h
share/wasi-sysroot/include/sched.h
share/wasi-sysroot/include/scsi/
share/wasi-sysroot/include/search.h
share/wasi-sysroot/include/semaphore.h
share/wasi-sysroot/include/signal.h
share/wasi-sysroot/include/stdalign.h
share/wasi-sysroot/include/stdbool.h
share/wasi-sysroot/include/stdc-predef.h
share/wasi-sysroot/include/stdint.h
share/wasi-sysroot/include/stdio.h
share/wasi-sysroot/include/stdio_ext.h
share/wasi-sysroot/include/stdlib.h
share/wasi-sysroot/include/stdnoreturn.h
share/wasi-sysroot/include/string.h
share/wasi-sysroot/include/strings.h
share/wasi-sysroot/include/stropts.h
share/wasi-sysroot/include/sys/
share/wasi-sysroot/include/sys/dir.h
share/wasi-sysroot/include/sys/errno.h
share/wasi-sysroot/include/sys/eventfd.h
share/wasi-sysroot/include/sys/fcntl.h
share/wasi-sysroot/include/sys/file.h
share/wasi-sysroot/include/sys/ioctl.h
share/wasi-sysroot/include/sys/mman.h
share/wasi-sysroot/include/sys/param.h
share/wasi-sysroot/include/sys/poll.h
share/wasi-sysroot/include/sys/random.h
share/wasi-sysroot/include/sys/reg.h
share/wasi-sysroot/include/sys/resource.h
share/wasi-sysroot/include/sys/select.h
share/wasi-sysroot/include/sys/signal.h
share/wasi-sysroot/include/sys/socket.h
share/wasi-sysroot/include/sys/stat.h
share/wasi-sysroot/include/sys/stropts.h
share/wasi-sysroot/include/sys/syscall.h
share/wasi-sysroot/include/sys/sysinfo.h
share/wasi-sysroot/include/sys/time.h
share/wasi-sysroot/include/sys/timeb.h
share/wasi-sysroot/include/sys/times.h
share/wasi-sysroot/include/sys/timex.h
share/wasi-sysroot/include/sys/ttydefaults.h
share/wasi-sysroot/include/sys/types.h
share/wasi-sysroot/include/sys/uio.h
share/wasi-sysroot/include/sys/un.h
share/wasi-sysroot/include/sys/utsname.h
share/wasi-sysroot/include/syscall.h
share/wasi-sysroot/include/sysexits.h
share/wasi-sysroot/include/tar.h
share/wasi-sysroot/include/tgmath.h
share/wasi-sysroot/include/threads.h
share/wasi-sysroot/include/time.h
share/wasi-sysroot/include/uchar.h
share/wasi-sysroot/include/unistd.h
share/wasi-sysroot/include/utime.h
share/wasi-sysroot/include/values.h
share/wasi-sysroot/include/wasi/
share/wasi-sysroot/include/wasi/api.h
share/wasi-sysroot/include/wasi/libc-environ.h
share/wasi-sysroot/include/wasi/libc-find-relpath.h
share/wasi-sysroot/include/wasi/libc-nocwd.h
share/wasi-sysroot/include/wasi/libc.h
share/wasi-sysroot/include/wchar.h
share/wasi-sysroot/include/wctype.h
share/wasi-sysroot/lib/
share/wasi-sysroot/lib/wasm32-wasi/
share/wasi-sysroot/lib/wasm32-wasi/crt1-command.o
share/wasi-sysroot/lib/wasm32-wasi/crt1-reactor.o
share/wasi-sysroot/lib/wasm32-wasi/crt1.o
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libc-printscan-long-double.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libc-printscan-no-floating-point.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libc.a
share/wasi-sysroot/lib/wasm32-wasi/libc.imports
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libcrypt.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libdl.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libm.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libpthread.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libresolv.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/librt.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libutil.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-getpid.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-mman.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-process-clocks.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libwasi-emulated-signal.a
@static-lib share/wasi-sysroot/lib/wasm32-wasi/libxnet.a
share/wasi-sysroot/share/
share/wasi-sysroot/share/wasm32-wasi/
share/wasi-sysroot/share/wasm32-wasi/defined-symbols.txt
share/wasi-sysroot/share/wasm32-wasi/include-all.c
share/wasi-sysroot/share/wasm32-wasi/predefined-macros.txt
share/wasi-sysroot/share/wasm32-wasi/undefined-symbols.txt