[WebAssembly] Enable building with 'make' command

This change enables all of the .c sources in musl
be built with the clang -target wasm32-unknown-unknown-wasm
This commit is contained in:
Sam Clegg 2017-10-19 17:28:13 -07:00
parent 357305e18f
commit 94500fb127
8 changed files with 32 additions and 10 deletions

View File

@ -53,13 +53,27 @@ ARCH_INCLUDES = $(wildcard $(srcdir)/arch/$(ARCH)/bits/*.h)
INCLUDES = $(wildcard $(srcdir)/include/*.h $(srcdir)/include/*/*.h)
ALL_INCLUDES = $(sort $(INCLUDES:$(srcdir)/%=%) $(GENH:obj/%=%) $(ARCH_INCLUDES:$(srcdir)/arch/$(ARCH)/%=include/%))
-include config.mak
ifeq ($(ARCH),)
$(error Please set ARCH in config.mak before running make.)
endif
EMPTY_LIB_NAMES = m rt pthread crypt util xnet resolv dl
EMPTY_LIBS = $(EMPTY_LIB_NAMES:%=lib/lib%.a)
ifeq ($(ARCH),wasm32)
CRT_LIBS = lib/crt1.o lib/Scrt1.o lib/rcrt1.o
else
CRT_LIBS = lib/crt1.o lib/Scrt1.o lib/rcrt1.o lib/crti.o lib/crtn.o
endif
STATIC_LIBS = lib/libc.a
SHARED_LIBS = lib/libc.so
TOOL_LIBS = lib/musl-gcc.specs
ifeq ($(ARCH),wasm32)
ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
else
ALL_LIBS = $(CRT_LIBS) $(STATIC_LIBS) $(SHARED_LIBS) $(EMPTY_LIBS) $(TOOL_LIBS)
endif
ALL_TOOLS = obj/musl-gcc
WRAPCC_GCC = gcc
@ -67,12 +81,6 @@ WRAPCC_CLANG = clang
LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1
-include config.mak
ifeq ($(ARCH),)
$(error Please set ARCH in config.mak before running make.)
endif
all: $(ALL_LIBS) $(ALL_TOOLS)
OBJ_DIRS = $(sort $(patsubst %/,%,$(dir $(ALL_LIBS) $(ALL_TOOLS) $(OBJS) $(LDSO_OBJS) $(GENH) $(GENH_INT))) $(addprefix obj/, crt crt/$(ARCH) include))

View File

@ -1,7 +1,9 @@
#ifndef __NR_restart_syscall
#include <bits/syscall.h>
#include <syscall.h>
#endif
#include <stdlib.h>
#define a_barrier() syscall(__NR_membarrier)
#define a_cas(p, t, s) (abort(), s)

View File

@ -15,6 +15,7 @@
#define O_DIRECT 040000
#define O_LARGEFILE 0100000
#define O_NOATIME 01000000
#define O_PATH 010000000
#define O_TMPFILE 020000000
#define O_NDELAY O_NONBLOCK

View File

@ -5,9 +5,9 @@
#define LDBL_MAX 1.79769313486231570815e+308L
#define LDBL_EPSILON 2.22044604925031308085e-16L
#define LDBL_MANT_DIG 53
#define LDBL_MIN_EXP (-1021)
#define LDBL_MAX_EXP 1024
#define LDBL_MANT_DIG 64
#define LDBL_MIN_EXP (-16381)
#define LDBL_MAX_EXP 16384
#define LDBL_DIG 15
#define LDBL_MIN_10_EXP (-307)

View File

@ -1,6 +1,11 @@
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define MINSIGSTKSZ 2048
#define SIGSTKSZ 8192
#endif
#ifdef _GNU_SOURCE
#define REG_GS 0
#define REG_FS 1

View File

@ -697,4 +697,7 @@
#define SYS_process_vm_writev 348
#define SYS_kcmp 349
#define SYS_finit_module 350
#define SYS_recvmmsg 357
#define SYS_fanotify_init 367
#define SYS_fanotify_mark 368
#define SYS_membarrier 375

View File

@ -3,3 +3,5 @@ static inline struct pthread *__pthread_self(void) { return pthread_self(); }
#define TP_ADJ(p) (p)
#define CANCEL_REG_IP 16
#define MC_PC gregs[REG_EIP]

1
arch/wasm32/reloc.h Normal file
View File

@ -0,0 +1 @@
#define LDSO_ARCH "wasm32"