# These variables are specifically meant to be overridable via the make
# command-line.
WASM_CC ?= clang
-WASM_NM ?= $(patsubst %clang,%llvm-nm,$(WASM_CC))
-WASM_AR ?= $(patsubst %clang,%llvm-ar,$(WASM_CC))
+WASM_NM ?= $(patsubst %clang,%llvm-nm,$(filter-out ccache sccache,$(WASM_CC)))
+WASM_AR ?= $(patsubst %clang,%llvm-ar,$(filter-out ccache sccache,$(WASM_CC)))
WASM_CFLAGS ?= -O2 -DNDEBUG
# The directory where we build the sysroot.
SYSROOT ?= $(CURDIR)/sysroot
INSTALL_DIR ?= /usr/local
# single or posix
THREAD_MODEL ?= single
+# dlmalloc or none
+MALLOC_IMPL ?= dlmalloc
# yes or no
-BUILD_DLMALLOC ?= yes
BUILD_LIBC_TOP_HALF ?= yes
# The directory where we're store intermediate artifacts.
OBJDIR ?= $(CURDIR)/build
-# Check dependencies.
-ifneq ($(BUILD_DLMALLOC),yes)
-$(error build currently depends on BUILD_DLMALLOC=yes)
-endif
-
# Variables from this point on are not meant to be overridable via the
# make command-line.
env/setenv.c \
env/unsetenv.c \
unistd/posix_close.c \
+ stat/futimesat.c \
) \
$(filter-out %/procfdname.c %/syscall.c %/syscall_ret.c %/vdso.c %/version.c, \
$(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal/*.c)) \
-Wno-unused-function \
-Wno-ignored-attributes \
-Wno-missing-braces \
- -Wno-ignored-pragmas
+ -Wno-ignored-pragmas \
+ -Wno-unused-but-set-variable \
+ -Wno-unknown-warning-option
# Configure support for threads.
ifeq ($(THREAD_MODEL), single)
DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES))
LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES))
LIBC_TOP_HALF_ALL_OBJS = $(call objs,$(LIBC_TOP_HALF_ALL_SOURCES))
-ifeq ($(BUILD_DLMALLOC),yes)
+ifeq ($(MALLOC_IMPL),dlmalloc)
LIBC_OBJS += $(DLMALLOC_OBJS)
+else ifeq ($(MALLOC_IMPL),none)
+# No object files to add.
+else
+$(error unknown malloc implementation $(MALLOC_IMPL))
endif
# Add libc-bottom-half's objects.
LIBC_OBJS += $(LIBC_BOTTOM_HALF_ALL_OBJS)
$(OBJDIR)/%.long-double.o: $(CURDIR)/%.c include_dirs
@mkdir -p "$(@D)"
- "$(WASM_CC)" $(CFLAGS) -MD -MP -o $@ -c $<
+ $(WASM_CC) $(CFLAGS) -MD -MP -o $@ -c $<
$(OBJDIR)/%.no-floating-point.o: $(CURDIR)/%.c include_dirs
@mkdir -p "$(@D)"
- "$(WASM_CC)" $(CFLAGS) -MD -MP -o $@ -c $<
+ $(WASM_CC) $(CFLAGS) -MD -MP -o $@ -c $<
$(OBJDIR)/%.o: $(CURDIR)/%.c include_dirs
@mkdir -p "$(@D)"
- "$(WASM_CC)" $(CFLAGS) -MD -MP -o $@ -c $<
+ $(WASM_CC) $(CFLAGS) -MD -MP -o $@ -c $<
-include $(shell find $(OBJDIR) -name \*.d)
#
@mkdir -p "$(OBJDIR)"
cd "$(OBJDIR)" && \
- "$(WASM_CC)" $(CFLAGS) -c $(LIBC_BOTTOM_HALF_CRT_SOURCES) -MD -MP && \
+ $(WASM_CC) $(CFLAGS) -c $(LIBC_BOTTOM_HALF_CRT_SOURCES) -MD -MP && \
mkdir -p "$(SYSROOT_LIB)" && \
mv *.o "$(SYSROOT_LIB)"
$(WASM_AR) crs "$(SYSROOT_LIB)/lib$${name}.a"; \
done
+ #
+ # The build succeeded! The generated sysroot is in $(SYSROOT).
+ #
+
+# The check for defined and undefined symbols expects there to be a heap
+# alloctor (providing malloc, calloc, free, etc). Skip this step if the build
+# is done without a malloc implementation.
+ifneq ($(MALLOC_IMPL),none)
+finish: check-symbols
+endif
+
+check-symbols: startup_files libc
#
# Collect metadata on the sysroot and perform sanity checks.
#
#
# Test that it compiles.
#
- "$(WASM_CC)" $(CFLAGS) -fsyntax-only "$(SYSROOT_SHARE)/include-all.c" -Wno-\#warnings
+ $(WASM_CC) $(CFLAGS) -fsyntax-only "$(SYSROOT_SHARE)/include-all.c" -Wno-\#warnings
#
# Collect all the predefined macros, except for compiler version macros
@#
@# TODO: Undefine __FLOAT128__ for now since it's not in clang 8.0.
@# TODO: Filter out __FLT16_* for now, as not all versions of clang have these.
- "$(WASM_CC)" $(CFLAGS) "$(SYSROOT_SHARE)/include-all.c" \
+ $(WASM_CC) $(CFLAGS) "$(SYSROOT_SHARE)/include-all.c" \
-isystem $(SYSROOT_INC) \
-std=gnu17 \
-E -dM -Wno-\#warnings \
-U__clang_minor__ \
-U__clang_patchlevel__ \
-U__clang_version__ \
+ -U__clang_literal_encoding__ \
+ -U__clang_wide_literal_encoding__ \
-U__GNUC__ \
-U__GNUC_MINOR__ \
-U__GNUC_PATCHLEVEL__ \
# This ignores whitespace because on Windows the output has CRLF line endings.
diff -wur "$(CURDIR)/expected/$(MULTIARCH_TRIPLE)" "$(SYSROOT_SHARE)"
- #
- # The build succeeded! The generated sysroot is in $(SYSROOT).
- #
-
install: finish
mkdir -p "$(INSTALL_DIR)"
cp -r "$(SYSROOT)/lib" "$(SYSROOT)/share" "$(SYSROOT)/include" "$(INSTALL_DIR)"