Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASI libc/sysroot #2336

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
221 changes: 221 additions & 0 deletions CMakeLists.txt
Expand Up @@ -5910,6 +5910,213 @@ set(ZIG_LIBC_FILES
"include/sparcv9-linux-gnu/sys/ptrace.h"
"include/sparcv9-linux-gnu/sys/ucontext.h"
"include/sparcv9-linux-gnu/sys/user.h"
"include/wasm32-wasi-sysroot/__errno.h"
"include/wasm32-wasi-sysroot/__errno_values.h"
"include/wasm32-wasi-sysroot/__fd_set.h"
"include/wasm32-wasi-sysroot/__function___isatty.h"
"include/wasm32-wasi-sysroot/__functions_malloc.h"
"include/wasm32-wasi-sysroot/__functions_memcpy.h"
"include/wasm32-wasi-sysroot/__header_bits_signal.h"
"include/wasm32-wasi-sysroot/__header_dirent.h"
"include/wasm32-wasi-sysroot/__header_fcntl.h"
"include/wasm32-wasi-sysroot/__header_inttypes.h"
"include/wasm32-wasi-sysroot/__header_netinet_in.h"
"include/wasm32-wasi-sysroot/__header_poll.h"
"include/wasm32-wasi-sysroot/__header_stdlib.h"
"include/wasm32-wasi-sysroot/__header_string.h"
"include/wasm32-wasi-sysroot/__header_sys_ioctl.h"
"include/wasm32-wasi-sysroot/__header_sys_resource.h"
"include/wasm32-wasi-sysroot/__header_sys_socket.h"
"include/wasm32-wasi-sysroot/__header_sys_stat.h"
"include/wasm32-wasi-sysroot/__header_time.h"
"include/wasm32-wasi-sysroot/__header_unistd.h"
"include/wasm32-wasi-sysroot/__macro_FD_SETSIZE.h"
"include/wasm32-wasi-sysroot/__macro_PAGESIZE.h"
"include/wasm32-wasi-sysroot/__struct_dirent.h"
"include/wasm32-wasi-sysroot/__struct_in6_addr.h"
"include/wasm32-wasi-sysroot/__struct_in_addr.h"
"include/wasm32-wasi-sysroot/__struct_iovec.h"
"include/wasm32-wasi-sysroot/__struct_msghdr.h"
"include/wasm32-wasi-sysroot/__struct_pollfd.h"
"include/wasm32-wasi-sysroot/__struct_rusage.h"
"include/wasm32-wasi-sysroot/__struct_sockaddr.h"
"include/wasm32-wasi-sysroot/__struct_sockaddr_in.h"
"include/wasm32-wasi-sysroot/__struct_sockaddr_in6.h"
"include/wasm32-wasi-sysroot/__struct_sockaddr_storage.h"
"include/wasm32-wasi-sysroot/__struct_sockaddr_un.h"
"include/wasm32-wasi-sysroot/__struct_stat.h"
"include/wasm32-wasi-sysroot/__struct_timespec.h"
"include/wasm32-wasi-sysroot/__struct_timeval.h"
"include/wasm32-wasi-sysroot/__struct_tm.h"
"include/wasm32-wasi-sysroot/__struct_tms.h"
"include/wasm32-wasi-sysroot/__typedef_DIR.h"
"include/wasm32-wasi-sysroot/__typedef_blkcnt_t.h"
"include/wasm32-wasi-sysroot/__typedef_blksize_t.h"
"include/wasm32-wasi-sysroot/__typedef_clock_t.h"
"include/wasm32-wasi-sysroot/__typedef_clockid_t.h"
"include/wasm32-wasi-sysroot/__typedef_dev_t.h"
"include/wasm32-wasi-sysroot/__typedef_fd_set.h"
"include/wasm32-wasi-sysroot/__typedef_gid_t.h"
"include/wasm32-wasi-sysroot/__typedef_in_addr_t.h"
"include/wasm32-wasi-sysroot/__typedef_in_port_t.h"
"include/wasm32-wasi-sysroot/__typedef_ino_t.h"
"include/wasm32-wasi-sysroot/__typedef_mode_t.h"
"include/wasm32-wasi-sysroot/__typedef_nfds_t.h"
"include/wasm32-wasi-sysroot/__typedef_nlink_t.h"
"include/wasm32-wasi-sysroot/__typedef_off_t.h"
"include/wasm32-wasi-sysroot/__typedef_sa_family_t.h"
"include/wasm32-wasi-sysroot/__typedef_sigset_t.h"
"include/wasm32-wasi-sysroot/__typedef_socklen_t.h"
"include/wasm32-wasi-sysroot/__typedef_ssize_t.h"
"include/wasm32-wasi-sysroot/__typedef_suseconds_t.h"
"include/wasm32-wasi-sysroot/__typedef_time_t.h"
"include/wasm32-wasi-sysroot/__typedef_uid_t.h"
"include/wasm32-wasi-sysroot/alloca.h"
"include/wasm32-wasi-sysroot/ar.h"
"include/wasm32-wasi-sysroot/arpa/ftp.h"
"include/wasm32-wasi-sysroot/arpa/inet.h"
"include/wasm32-wasi-sysroot/arpa/nameser.h"
"include/wasm32-wasi-sysroot/arpa/nameser_compat.h"
"include/wasm32-wasi-sysroot/arpa/telnet.h"
"include/wasm32-wasi-sysroot/arpa/tftp.h"
"include/wasm32-wasi-sysroot/assert.h"
"include/wasm32-wasi-sysroot/bits/alltypes.h"
"include/wasm32-wasi-sysroot/bits/endian.h"
"include/wasm32-wasi-sysroot/bits/fcntl.h"
"include/wasm32-wasi-sysroot/bits/fenv.h"
"include/wasm32-wasi-sysroot/bits/float.h"
"include/wasm32-wasi-sysroot/bits/hwcap.h"
"include/wasm32-wasi-sysroot/bits/io.h"
"include/wasm32-wasi-sysroot/bits/ioctl.h"
"include/wasm32-wasi-sysroot/bits/ioctl_fix.h"
"include/wasm32-wasi-sysroot/bits/limits.h"
"include/wasm32-wasi-sysroot/bits/mman.h"
"include/wasm32-wasi-sysroot/bits/poll.h"
"include/wasm32-wasi-sysroot/bits/posix.h"
"include/wasm32-wasi-sysroot/bits/reg.h"
"include/wasm32-wasi-sysroot/bits/resource.h"
"include/wasm32-wasi-sysroot/bits/signal.h"
"include/wasm32-wasi-sysroot/bits/socket.h"
"include/wasm32-wasi-sysroot/bits/stat.h"
"include/wasm32-wasi-sysroot/bits/stdint.h"
"include/wasm32-wasi-sysroot/bits/termios.h"
"include/wasm32-wasi-sysroot/byteswap.h"
"include/wasm32-wasi-sysroot/complex.h"
"include/wasm32-wasi-sysroot/cpio.h"
"include/wasm32-wasi-sysroot/crypt.h"
"include/wasm32-wasi-sysroot/ctype.h"
"include/wasm32-wasi-sysroot/dirent.h"
"include/wasm32-wasi-sysroot/endian.h"
"include/wasm32-wasi-sysroot/err.h"
"include/wasm32-wasi-sysroot/errno.h"
"include/wasm32-wasi-sysroot/fcntl.h"
"include/wasm32-wasi-sysroot/features.h"
"include/wasm32-wasi-sysroot/fenv.h"
"include/wasm32-wasi-sysroot/float.h"
"include/wasm32-wasi-sysroot/fmtmsg.h"
"include/wasm32-wasi-sysroot/fnmatch.h"
"include/wasm32-wasi-sysroot/ftw.h"
"include/wasm32-wasi-sysroot/getopt.h"
"include/wasm32-wasi-sysroot/glob.h"
"include/wasm32-wasi-sysroot/iconv.h"
"include/wasm32-wasi-sysroot/ifaddrs.h"
"include/wasm32-wasi-sysroot/inttypes.h"
"include/wasm32-wasi-sysroot/iso646.h"
"include/wasm32-wasi-sysroot/langinfo.h"
"include/wasm32-wasi-sysroot/libgen.h"
"include/wasm32-wasi-sysroot/libintl.h"
"include/wasm32-wasi-sysroot/limits.h"
"include/wasm32-wasi-sysroot/locale.h"
"include/wasm32-wasi-sysroot/malloc.h"
"include/wasm32-wasi-sysroot/math.h"
"include/wasm32-wasi-sysroot/memory.h"
"include/wasm32-wasi-sysroot/monetary.h"
"include/wasm32-wasi-sysroot/mqueue.h"
"include/wasm32-wasi-sysroot/net/ethernet.h"
"include/wasm32-wasi-sysroot/net/if.h"
"include/wasm32-wasi-sysroot/net/if_arp.h"
"include/wasm32-wasi-sysroot/net/route.h"
"include/wasm32-wasi-sysroot/netinet/ether.h"
"include/wasm32-wasi-sysroot/netinet/icmp6.h"
"include/wasm32-wasi-sysroot/netinet/if_ether.h"
"include/wasm32-wasi-sysroot/netinet/igmp.h"
"include/wasm32-wasi-sysroot/netinet/in.h"
"include/wasm32-wasi-sysroot/netinet/in_systm.h"
"include/wasm32-wasi-sysroot/netinet/ip.h"
"include/wasm32-wasi-sysroot/netinet/ip6.h"
"include/wasm32-wasi-sysroot/netinet/ip_icmp.h"
"include/wasm32-wasi-sysroot/netinet/tcp.h"
"include/wasm32-wasi-sysroot/netinet/udp.h"
"include/wasm32-wasi-sysroot/netpacket/packet.h"
"include/wasm32-wasi-sysroot/nl_types.h"
"include/wasm32-wasi-sysroot/poll.h"
"include/wasm32-wasi-sysroot/regex.h"
"include/wasm32-wasi-sysroot/sched.h"
"include/wasm32-wasi-sysroot/search.h"
"include/wasm32-wasi-sysroot/semaphore.h"
"include/wasm32-wasi-sysroot/signal.h"
"include/wasm32-wasi-sysroot/stdalign.h"
"include/wasm32-wasi-sysroot/stdarg.h"
"include/wasm32-wasi-sysroot/stdbool.h"
"include/wasm32-wasi-sysroot/stdc-predef.h"
"include/wasm32-wasi-sysroot/stddef.h"
"include/wasm32-wasi-sysroot/stdint.h"
"include/wasm32-wasi-sysroot/stdio.h"
"include/wasm32-wasi-sysroot/stdio_ext.h"
"include/wasm32-wasi-sysroot/stdlib.h"
"include/wasm32-wasi-sysroot/stdnoreturn.h"
"include/wasm32-wasi-sysroot/string.h"
"include/wasm32-wasi-sysroot/strings.h"
"include/wasm32-wasi-sysroot/stropts.h"
"include/wasm32-wasi-sysroot/sys/dir.h"
"include/wasm32-wasi-sysroot/sys/errno.h"
"include/wasm32-wasi-sysroot/sys/eventfd.h"
"include/wasm32-wasi-sysroot/sys/fcntl.h"
"include/wasm32-wasi-sysroot/sys/file.h"
"include/wasm32-wasi-sysroot/sys/ioctl.h"
"include/wasm32-wasi-sysroot/sys/mman.h"
"include/wasm32-wasi-sysroot/sys/param.h"
"include/wasm32-wasi-sysroot/sys/poll.h"
"include/wasm32-wasi-sysroot/sys/random.h"
"include/wasm32-wasi-sysroot/sys/reg.h"
"include/wasm32-wasi-sysroot/sys/resource.h"
"include/wasm32-wasi-sysroot/sys/select.h"
"include/wasm32-wasi-sysroot/sys/signal.h"
"include/wasm32-wasi-sysroot/sys/signalfd.h"
"include/wasm32-wasi-sysroot/sys/socket.h"
"include/wasm32-wasi-sysroot/sys/stat.h"
"include/wasm32-wasi-sysroot/sys/stropts.h"
"include/wasm32-wasi-sysroot/sys/syscall.h"
"include/wasm32-wasi-sysroot/sys/sysinfo.h"
"include/wasm32-wasi-sysroot/sys/sysmacros.h"
"include/wasm32-wasi-sysroot/sys/termios.h"
"include/wasm32-wasi-sysroot/sys/time.h"
"include/wasm32-wasi-sysroot/sys/timeb.h"
"include/wasm32-wasi-sysroot/sys/timerfd.h"
"include/wasm32-wasi-sysroot/sys/times.h"
"include/wasm32-wasi-sysroot/sys/timex.h"
"include/wasm32-wasi-sysroot/sys/ttydefaults.h"
"include/wasm32-wasi-sysroot/sys/types.h"
"include/wasm32-wasi-sysroot/sys/uio.h"
"include/wasm32-wasi-sysroot/sys/un.h"
"include/wasm32-wasi-sysroot/sys/utsname.h"
"include/wasm32-wasi-sysroot/sys/xattr.h"
"include/wasm32-wasi-sysroot/syscall.h"
"include/wasm32-wasi-sysroot/sysexits.h"
"include/wasm32-wasi-sysroot/tar.h"
"include/wasm32-wasi-sysroot/termios.h"
"include/wasm32-wasi-sysroot/tgmath.h"
"include/wasm32-wasi-sysroot/threads.h"
"include/wasm32-wasi-sysroot/time.h"
"include/wasm32-wasi-sysroot/uchar.h"
"include/wasm32-wasi-sysroot/unistd.h"
"include/wasm32-wasi-sysroot/utime.h"
"include/wasm32-wasi-sysroot/values.h"
"include/wasm32-wasi-sysroot/wasi/core.h"
"include/wasm32-wasi-sysroot/wasi/libc-find-relpath.h"
"include/wasm32-wasi-sysroot/wasi/libc.h"
"include/wasm32-wasi-sysroot/wchar.h"
"include/wasm32-wasi-sysroot/wctype.h"
"include/x86_64-linux-any/asm/auxvec.h"
"include/x86_64-linux-any/asm/bitsperlong.h"
"include/x86_64-linux-any/asm/byteorder.h"
Expand Down Expand Up @@ -6343,6 +6550,20 @@ set(ZIG_LIBC_FILES
"musl/crt/x86_64/crti.s"
"musl/crt/x86_64/crtn.s"
${ZIG_MUSL_SRC_FILES}
"wasi-sysroot/crt1.o"
"wasi-sysroot/libresolv.a"
"wasi-sysroot/libresolv.a"
"wasi-sysroot/libwasi-emulated-mman.a"
"wasi-sysroot/libc-printscan-no-floating-point.a"
"wasi-sysroot/libc-printscan-long-double.a"
"wasi-sysroot/libdl.a"
"wasi-sysroot/libxnet.a"
"wasi-sysroot/libm.a"
"wasi-sysroot/libcrypt.a"
"wasi-sysroot/libc.a"
"wasi-sysroot/librt.a"
"wasi-sysroot/libutil.a"
"wasi-sysroot/libpthread.a"
)

set(ZIG_LIBUNWIND_FILES
Expand Down
20 changes: 20 additions & 0 deletions libc/include/wasm32-wasi-sysroot/__errno.h
@@ -0,0 +1,20 @@
#ifndef __wasm_basics___errno_h
#define __wasm_basics___errno_h

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
extern thread_local int errno;
#else
extern _Thread_local int errno;
#endif

#define errno errno

#ifdef __cplusplus
}
#endif

#endif
86 changes: 86 additions & 0 deletions libc/include/wasm32-wasi-sysroot/__errno_values.h
@@ -0,0 +1,86 @@
#ifndef __wasilibc___errno_values_h
#define __wasilibc___errno_values_h

#include <wasi/core.h>

#define E2BIG __WASI_E2BIG
#define EACCES __WASI_EACCES
#define EADDRINUSE __WASI_EADDRINUSE
#define EADDRNOTAVAIL __WASI_EADDRNOTAVAIL
#define EAFNOSUPPORT __WASI_EAFNOSUPPORT
#define EAGAIN __WASI_EAGAIN
#define EALREADY __WASI_EALREADY
#define EBADF __WASI_EBADF
#define EBADMSG __WASI_EBADMSG
#define EBUSY __WASI_EBUSY
#define ECANCELED __WASI_ECANCELED
#define ECHILD __WASI_ECHILD
#define ECONNABORTED __WASI_ECONNABORTED
#define ECONNREFUSED __WASI_ECONNREFUSED
#define ECONNRESET __WASI_ECONNRESET
#define EDEADLK __WASI_EDEADLK
#define EDESTADDRREQ __WASI_EDESTADDRREQ
#define EDOM __WASI_EDOM
#define EDQUOT __WASI_EDQUOT
#define EEXIST __WASI_EEXIST
#define EFAULT __WASI_EFAULT
#define EFBIG __WASI_EFBIG
#define EHOSTUNREACH __WASI_EHOSTUNREACH
#define EIDRM __WASI_EIDRM
#define EILSEQ __WASI_EILSEQ
#define EINPROGRESS __WASI_EINPROGRESS
#define EINTR __WASI_EINTR
#define EINVAL __WASI_EINVAL
#define EIO __WASI_EIO
#define EISCONN __WASI_EISCONN
#define EISDIR __WASI_EISDIR
#define ELOOP __WASI_ELOOP
#define EMFILE __WASI_EMFILE
#define EMLINK __WASI_EMLINK
#define EMSGSIZE __WASI_EMSGSIZE
#define EMULTIHOP __WASI_EMULTIHOP
#define ENAMETOOLONG __WASI_ENAMETOOLONG
#define ENETDOWN __WASI_ENETDOWN
#define ENETRESET __WASI_ENETRESET
#define ENETUNREACH __WASI_ENETUNREACH
#define ENFILE __WASI_ENFILE
#define ENOBUFS __WASI_ENOBUFS
#define ENODEV __WASI_ENODEV
#define ENOENT __WASI_ENOENT
#define ENOEXEC __WASI_ENOEXEC
#define ENOLCK __WASI_ENOLCK
#define ENOLINK __WASI_ENOLINK
#define ENOMEM __WASI_ENOMEM
#define ENOMSG __WASI_ENOMSG
#define ENOPROTOOPT __WASI_ENOPROTOOPT
#define ENOSPC __WASI_ENOSPC
#define ENOSYS __WASI_ENOSYS
#define ENOTCONN __WASI_ENOTCONN
#define ENOTDIR __WASI_ENOTDIR
#define ENOTEMPTY __WASI_ENOTEMPTY
#define ENOTRECOVERABLE __WASI_ENOTRECOVERABLE
#define ENOTSOCK __WASI_ENOTSOCK
#define ENOTSUP __WASI_ENOTSUP
#define ENOTTY __WASI_ENOTTY
#define ENXIO __WASI_ENXIO
#define EOVERFLOW __WASI_EOVERFLOW
#define EOWNERDEAD __WASI_EOWNERDEAD
#define EPERM __WASI_EPERM
#define EPIPE __WASI_EPIPE
#define EPROTO __WASI_EPROTO
#define EPROTONOSUPPORT __WASI_EPROTONOSUPPORT
#define EPROTOTYPE __WASI_EPROTOTYPE
#define ERANGE __WASI_ERANGE
#define EROFS __WASI_EROFS
#define ESPIPE __WASI_ESPIPE
#define ESRCH __WASI_ESRCH
#define ESTALE __WASI_ESTALE
#define ETIMEDOUT __WASI_ETIMEDOUT
#define ETXTBSY __WASI_ETXTBSY
#define EXDEV __WASI_EXDEV
#define ENOTCAPABLE __WASI_ENOTCAPABLE

#define EOPNOTSUPP ENOTSUP
#define EWOULDBLOCK EAGAIN

#endif
26 changes: 26 additions & 0 deletions libc/include/wasm32-wasi-sysroot/__fd_set.h
@@ -0,0 +1,26 @@
#ifndef __wasilibc___fd_set_h
#define __wasilibc___fd_set_h

#include <__typedef_fd_set.h>

#ifdef __cplusplus
extern "C" {
#endif

void FD_CLR(int, fd_set *);
int FD_ISSET(int, const fd_set *);
void FD_SET(int, fd_set *);
void FD_ZERO(fd_set *);
void FD_COPY(const fd_set *, fd_set *);

#define FD_CLR(fd, set) FD_CLR((fd), (set))
#define FD_ISSET(fd, set) FD_ISSET((fd), (set))
#define FD_SET(fd, set) FD_SET((fd), (set))
#define FD_ZERO(set) FD_ZERO((set))
#define FD_COPY(from, to) FD_COPY(from, to)

#ifdef __cplusplus
}
#endif

#endif
14 changes: 14 additions & 0 deletions libc/include/wasm32-wasi-sysroot/__function___isatty.h
@@ -0,0 +1,14 @@
#ifndef __wasilibc___function___isatty_h
#define __wasilibc___function___isatty_h

#ifdef __cplusplus
extern "C" {
#endif

int __isatty(int fd);

#ifdef __cplusplus
}
#endif

#endif