]> git.proxmox.com Git - wasi-libc.git/blobdiff - Makefile
Update README and add CI-tests for minimal supported LLVM-version (10) (#302)
[wasi-libc.git] / Makefile
index 44acdee993cf9c99a72b2773dac92a81f4337e7c..6eaf094790157b12029f842d558241b66317062c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,13 @@ BUILD_LIBC_TOP_HALF ?= yes
 # The directory where we're store intermediate artifacts.
 OBJDIR ?= $(CURDIR)/build
 
+# When the length is no larger than this threshold, we consider the
+# overhead of bulk memory opcodes to outweigh the performance benefit,
+# and fall back to the original musl implementation. See
+# https://github.com/WebAssembly/wasi-libc/pull/263 for relevant
+# discussion
+BULK_MEMORY_THRESHOLD ?= 32
+
 # Variables from this point on are not meant to be overridable via the
 # make command-line.
 
@@ -138,6 +145,7 @@ LIBC_TOP_HALF_MUSL_SOURCES = \
         env/unsetenv.c \
         unistd/posix_close.c \
         stat/futimesat.c \
+        legacy/getpagesize.c \
     ) \
     $(filter-out %/procfdname.c %/syscall.c %/syscall_ret.c %/vdso.c %/version.c, \
                  $(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal/*.c)) \
@@ -183,6 +191,10 @@ MUSL_PRINTSCAN_SOURCES = \
     $(LIBC_TOP_HALF_MUSL_SRC_DIR)/stdio/vfscanf.c \
     $(LIBC_TOP_HALF_MUSL_SRC_DIR)/stdlib/strtod.c \
     $(LIBC_TOP_HALF_MUSL_SRC_DIR)/stdlib/wcstod.c
+BULK_MEMORY_SOURCES = \
+    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/string/memcpy.c \
+    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/string/memmove.c \
+    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/string/memset.c
 LIBC_TOP_HALF_HEADERS_PRIVATE = $(LIBC_TOP_HALF_DIR)/headers/private
 LIBC_TOP_HALF_SOURCES = $(LIBC_TOP_HALF_DIR)/sources
 LIBC_TOP_HALF_ALL_SOURCES = \
@@ -253,6 +265,7 @@ endif
 MUSL_PRINTSCAN_OBJS = $(call objs,$(MUSL_PRINTSCAN_SOURCES))
 MUSL_PRINTSCAN_LONG_DOUBLE_OBJS = $(patsubst %.o,%.long-double.o,$(MUSL_PRINTSCAN_OBJS))
 MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS = $(patsubst %.o,%.no-floating-point.o,$(MUSL_PRINTSCAN_OBJS))
+BULK_MEMORY_OBJS = $(call objs,$(BULK_MEMORY_SOURCES))
 LIBWASI_EMULATED_MMAN_OBJS = $(call objs,$(LIBWASI_EMULATED_MMAN_SOURCES))
 LIBWASI_EMULATED_PROCESS_CLOCKS_OBJS = $(call objs,$(LIBWASI_EMULATED_PROCESS_CLOCKS_SOURCES))
 LIBWASI_EMULATED_GETPID_OBJS = $(call objs,$(LIBWASI_EMULATED_GETPID_SOURCES))
@@ -384,6 +397,14 @@ $(MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS): CFLAGS += \
            -D__wasilibc_printscan_no_floating_point \
            -D__wasilibc_printscan_floating_point_support_option="\"remove -lc-printscan-no-floating-point from the link command\""
 
+# TODO: apply -mbulk-memory globally, once
+# https://github.com/llvm/llvm-project/issues/52618 is resolved
+$(BULK_MEMORY_OBJS): CFLAGS += \
+        -mbulk-memory
+
+$(BULK_MEMORY_OBJS): CFLAGS += \
+        -DBULK_MEMORY_THRESHOLD=$(BULK_MEMORY_THRESHOLD)
+
 $(LIBWASI_EMULATED_SIGNAL_MUSL_OBJS): CFLAGS += \
            -D_WASI_EMULATED_SIGNAL
 
@@ -513,10 +534,10 @@ check-symbols: startup_files libc
            > "$(SYSROOT_LIB)/libc.imports"
 
        #
-       # Generate a test file that includes all public header files.
+       # Generate a test file that includes all public header files.
        #
        cd "$(SYSROOT_INC)" && \
-         for header in $$(find . -type f -not -name mman.h -not -name signal.h -not -name times.h -not -name resource.h |grep -v /bits/); do \
+         for header in $$(find . -type f -not -name mman.h -not -name signal.h -not -name times.h -not -name resource.h |grep -v /bits/ |grep -v /c++/); do \
              echo '#include <'$$header'>' | sed 's/\.\///' ; \
        done |LC_ALL=C sort >$(SYSROOT_SHARE)/include-all.c ; \
        cd - >/dev/null