summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:11:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:11:56 +0000
commite9699e2b995d3ded2efd5580ae6dadf555181d62 (patch)
treedd029bd1e3b8b9ffb627115e7ecc577f250fa742 /Makefile
parentAdding upstream version 0.0~git20230113.4362b18. (diff)
downloadwasi-libc-e9699e2b995d3ded2efd5580ae6dadf555181d62.tar.xz
wasi-libc-e9699e2b995d3ded2efd5580ae6dadf555181d62.zip
Adding upstream version 0.0~git20230621.7018e24.upstream/0.0_git20230621.7018e24
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile56
1 files changed, 33 insertions, 23 deletions
diff --git a/Makefile b/Makefile
index 57975a7..00d26d3 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ MALLOC_IMPL ?= dlmalloc
# yes or no
BUILD_LIBC_TOP_HALF ?= yes
# The directory where we will store intermediate artifacts.
-OBJDIR ?= $(CURDIR)/build/$(TARGET_TRIPLE)
+OBJDIR ?= build/$(TARGET_TRIPLE)
# When the length is no larger than this threshold, we consider the
# overhead of bulk memory opcodes to outweigh the performance benefit,
@@ -43,13 +43,13 @@ endif
# These variables describe the locations of various files and directories in
# the source tree.
-DLMALLOC_DIR = $(CURDIR)/dlmalloc
+DLMALLOC_DIR = dlmalloc
DLMALLOC_SRC_DIR = $(DLMALLOC_DIR)/src
DLMALLOC_SOURCES = $(DLMALLOC_SRC_DIR)/dlmalloc.c
DLMALLOC_INC = $(DLMALLOC_DIR)/include
-EMMALLOC_DIR = $(CURDIR)/emmalloc
+EMMALLOC_DIR = emmalloc
EMMALLOC_SOURCES = $(EMMALLOC_DIR)/emmalloc.c
-LIBC_BOTTOM_HALF_DIR = $(CURDIR)/libc-bottom-half
+LIBC_BOTTOM_HALF_DIR = libc-bottom-half
LIBC_BOTTOM_HALF_CLOUDLIBC_SRC = $(LIBC_BOTTOM_HALF_DIR)/cloudlibc/src
LIBC_BOTTOM_HALF_CLOUDLIBC_SRC_INC = $(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)/include
LIBC_BOTTOM_HALF_HEADERS_PUBLIC = $(LIBC_BOTTOM_HALF_DIR)/headers/public
@@ -79,7 +79,7 @@ LIBWASI_EMULATED_SIGNAL_MUSL_SOURCES = \
$(LIBC_TOP_HALF_MUSL_SRC_DIR)/signal/psignal.c \
$(LIBC_TOP_HALF_MUSL_SRC_DIR)/string/strsignal.c
LIBC_BOTTOM_HALF_CRT_SOURCES = $(wildcard $(LIBC_BOTTOM_HALF_DIR)/crt/*.c)
-LIBC_TOP_HALF_DIR = $(CURDIR)/libc-top-half
+LIBC_TOP_HALF_DIR = libc-top-half
LIBC_TOP_HALF_MUSL_DIR = $(LIBC_TOP_HALF_DIR)/musl
LIBC_TOP_HALF_MUSL_SRC_DIR = $(LIBC_TOP_HALF_MUSL_DIR)/src
LIBC_TOP_HALF_MUSL_INC = $(LIBC_TOP_HALF_MUSL_DIR)/include
@@ -262,6 +262,11 @@ LIBC_TOP_HALF_MUSL_SOURCES += \
thread/pthread_setcancelstate.c \
thread/pthread_setspecific.c \
thread/pthread_self.c \
+ thread/pthread_spin_destroy.c \
+ thread/pthread_spin_init.c \
+ thread/pthread_spin_lock.c \
+ thread/pthread_spin_trylock.c \
+ thread/pthread_spin_unlock.c \
thread/pthread_testcancel.c \
thread/sem_destroy.c \
thread/sem_getvalue.c \
@@ -320,6 +325,7 @@ ifeq ($(THREAD_MODEL), posix)
# Specify the tls-model until LLVM 15 is released (which should contain
# https://reviews.llvm.org/D130053).
CFLAGS += -mthread-model posix -pthread -ftls-model=local-exec
+ASMFLAGS += -matomics
# Include cloudlib's directory to access the structure definition of clockid_t
CFLAGS += -I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)
@@ -341,8 +347,8 @@ CFLAGS += -isystem "$(SYSROOT_INC)"
# These variables describe the locations of various files and directories in
# the build tree.
-objs = $(patsubst $(CURDIR)/%.c,$(OBJDIR)/%.o,$(1))
-asmobjs = $(patsubst $(CURDIR)/%.s,$(OBJDIR)/%.o,$(1))
+objs = $(patsubst %.c,$(OBJDIR)/%.o,$(1))
+asmobjs = $(patsubst %.s,$(OBJDIR)/%.o,$(1))
DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES))
EMMALLOC_OBJS = $(call objs,$(EMMALLOC_SOURCES))
LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES))
@@ -371,6 +377,7 @@ LIBWASI_EMULATED_PROCESS_CLOCKS_OBJS = $(call objs,$(LIBWASI_EMULATED_PROCESS_CL
LIBWASI_EMULATED_GETPID_OBJS = $(call objs,$(LIBWASI_EMULATED_GETPID_SOURCES))
LIBWASI_EMULATED_SIGNAL_OBJS = $(call objs,$(LIBWASI_EMULATED_SIGNAL_SOURCES))
LIBWASI_EMULATED_SIGNAL_MUSL_OBJS = $(call objs,$(LIBWASI_EMULATED_SIGNAL_MUSL_SOURCES))
+LIBC_BOTTOM_HALF_CRT_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_CRT_SOURCES))
# These variables describe the locations of various files and
# directories in the generated sysroot tree.
@@ -482,13 +489,13 @@ $(SYSROOT_LIB)/libwasi-emulated-signal.a: $(LIBWASI_EMULATED_SIGNAL_OBJS) $(LIBW
%.a:
@mkdir -p "$(@D)"
# On Windows, the commandline for the ar invocation got too long, so it needs to be split up.
- $(AR) crs $@ $(wordlist 1, 199, $^)
- $(AR) crs $@ $(wordlist 200, 399, $^)
- $(AR) crs $@ $(wordlist 400, 599, $^)
- $(AR) crs $@ $(wordlist 600, 799, $^)
+ $(AR) crs $@ $(wordlist 1, 199, $(sort $^))
+ $(AR) crs $@ $(wordlist 200, 399, $(sort $^))
+ $(AR) crs $@ $(wordlist 400, 599, $(sort $^))
+ $(AR) crs $@ $(wordlist 600, 799, $(sort $^))
# This might eventually overflow again, but at least it'll do so in a loud way instead of
# silently dropping the tail.
- $(AR) crs $@ $(wordlist 800, 100000, $^)
+ $(AR) crs $@ $(wordlist 800, 100000, $(sort $^))
$(MUSL_PRINTSCAN_OBJS): CFLAGS += \
-D__wasilibc_printscan_no_long_double \
@@ -509,19 +516,19 @@ $(BULK_MEMORY_OBJS): CFLAGS += \
$(LIBWASI_EMULATED_SIGNAL_MUSL_OBJS): CFLAGS += \
-D_WASI_EMULATED_SIGNAL
-$(OBJDIR)/%.long-double.o: $(CURDIR)/%.c include_dirs
+$(OBJDIR)/%.long-double.o: %.c include_dirs
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
-$(OBJDIR)/%.no-floating-point.o: $(CURDIR)/%.c include_dirs
+$(OBJDIR)/%.no-floating-point.o: %.c include_dirs
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
-$(OBJDIR)/%.o: $(CURDIR)/%.c include_dirs
+$(OBJDIR)/%.o: %.c include_dirs
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
-$(OBJDIR)/%.o: $(CURDIR)/%.s include_dirs
+$(OBJDIR)/%.o: %.s include_dirs
@mkdir -p "$(@D)"
$(CC) $(ASMFLAGS) -o $@ -c $<
@@ -577,15 +584,12 @@ include_dirs:
# Remove selected header files.
$(RM) $(patsubst %,$(SYSROOT_INC)/%,$(MUSL_OMIT_HEADERS))
-startup_files: include_dirs
+startup_files: include_dirs $(LIBC_BOTTOM_HALF_CRT_OBJS)
#
- # Build the startup files.
+ # Install the startup files (crt1.o etc).
#
- @mkdir -p "$(OBJDIR)"
- cd "$(OBJDIR)" && \
- $(CC) $(CFLAGS) -c $(LIBC_BOTTOM_HALF_CRT_SOURCES) -MD -MP && \
mkdir -p "$(SYSROOT_LIB)" && \
- mv *.o "$(SYSROOT_LIB)"
+ cp $(LIBC_BOTTOM_HALF_CRT_OBJS) "$(SYSROOT_LIB)"
libc: include_dirs \
$(SYSROOT_LIB)/libc.a \
@@ -668,6 +672,7 @@ check-symbols: startup_files libc
@#
@# TODO: Filter out __NO_MATH_ERRNO_ and a few __*WIDTH__ that are new to clang 14.
@# TODO: Filter out __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* that are new to clang 16.
+ @# TODO: Filter out __FPCLASS_* that are new to clang 17.
@# TODO: clang defined __FLT_EVAL_METHOD__ until clang 15, so we force-undefine it
@# for older versions.
@# TODO: Undefine __wasm_mutable_globals__ and __wasm_sign_ext__, that are new to
@@ -699,11 +704,16 @@ check-symbols: startup_files libc
| sed -e 's/__GNUC_VA_LIST $$/__GNUC_VA_LIST 1/' \
| grep -v '^#define __\(BOOL\|INT_\(LEAST\|FAST\)\(8\|16\|32\|64\)\|INT\|LONG\|LLONG\|SHRT\)_WIDTH__' \
| grep -v '^#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_\(1\|2\|4\|8\)' \
+ | grep -v '^#define __FPCLASS_' \
+ | grep -v '^#define NDEBUG' \
+ | grep -v '^#define __OPTIMIZE__' \
+ | grep -v '^#define assert' \
+ | grep -v '^#define __NO_INLINE__' \
> "$(SYSROOT_SHARE)/predefined-macros.txt"
# Check that the computed metadata matches the expected metadata.
# This ignores whitespace because on Windows the output has CRLF line endings.
- diff -wur "$(CURDIR)/expected/$(TARGET_TRIPLE)" "$(SYSROOT_SHARE)"
+ diff -wur "expected/$(TARGET_TRIPLE)" "$(SYSROOT_SHARE)"
install: finish
mkdir -p "$(INSTALL_DIR)"