Skip to content
Snippets Groups Projects
Unverified Commit c47daaf6 authored by Andrew Brown's avatar Andrew Brown Committed by GitHub
Browse files

Avoid re-copying include headers (#549)

This adds a `.stamp` file to the build directory that tracks when all
headers have been copied over to the sysroot `include` directory.
Previously, the `include_dirs` target was phony, which `make` will run
every time, regardless of whether it is needed. This was part of the
problem with all of libc being rebuilt at each `make` invocation.
parent 913e58e6
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,10 @@ ifeq ($(WASI_SNAPSHOT), p2)
TARGET_TRIPLE = wasm32-wasip2
endif
# These artifacts are "stamps" that we use to mark that some task (e.g., copying
# files) has been completed.
INCLUDE_DIRS := $(OBJDIR)/copy-include-headers.stamp
BUILTINS_LIB ?= $(shell ${CC} ${CFLAGS} --print-libgcc-file-name)
# These variables describe the locations of various files and directories in
......@@ -735,7 +739,7 @@ $(LIBSETJMP_OBJS) $(LIBSETJMP_SO_OBJS): CFLAGS += \
$(LIBWASI_EMULATED_SIGNAL_MUSL_OBJS) $(LIBWASI_EMULATED_SIGNAL_MUSL_SO_OBJS): CFLAGS += \
-D_WASI_EMULATED_SIGNAL
$(OBJDIR)/%.long-double.pic.o: %.c include_dirs
$(OBJDIR)/%.long-double.pic.o: %.c $(INCLUDE_DIRS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
......@@ -743,23 +747,23 @@ $(OBJDIR)/wasip2_component_type.pic.o $(OBJDIR)/wasip2_component_type.o: $(LIBC_
@mkdir -p "$(@D)"
cp $< $@
$(OBJDIR)/%.pic.o: %.c include_dirs
$(OBJDIR)/%.pic.o: %.c $(INCLUDE_DIRS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
$(OBJDIR)/%.long-double.o: %.c include_dirs
$(OBJDIR)/%.long-double.o: %.c $(INCLUDE_DIRS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
$(OBJDIR)/%.no-floating-point.o: %.c include_dirs
$(OBJDIR)/%.no-floating-point.o: %.c $(INCLUDE_DIRS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
$(OBJDIR)/%.o: %.c include_dirs
$(OBJDIR)/%.o: %.c $(INCLUDE_DIRS)
@mkdir -p "$(@D)"
$(CC) $(CFLAGS) -MD -MP -o $@ -c $<
$(OBJDIR)/%.o: %.s include_dirs
$(OBJDIR)/%.o: %.s $(INCLUDE_DIRS)
@mkdir -p "$(@D)"
$(CC) $(ASMFLAGS) -o $@ -c $<
......@@ -807,7 +811,10 @@ $(LIBWASI_EMULATED_PTHREAD_OBJS) $(LIBWASI_EMULATED_PTHREAD_SO_OBJS): CFLAGS +=
$(EMMALLOC_OBJS): CFLAGS += \
-fno-strict-aliasing
include_dirs:
ALL_POSSIBLE_HEADERS += $(shell find $(LIBC_TOP_HALF_MUSL_DIR) -name \*.h)
ALL_POSSIBLE_HEADERS += $(shell find $(LIBC_BOTTOM_HALF_HEADERS_PUBLIC) -name \*.h)
ALL_POSSIBLE_HEADERS += $(shell find $(MUSL_FTS_SRC_DIR) -name \*.h)
$(INCLUDE_DIRS): $(ALL_POSSIBLE_HEADERS)
#
# Install the include files.
#
......@@ -823,10 +830,12 @@ include_dirs:
# Copy in the bulk of musl's public header files.
cp -r "$(LIBC_TOP_HALF_MUSL_INC)"/* "$(SYSROOT_INC)"
# Copy in the musl's "bits" header files.
cp -r "$(LIBC_TOP_HALF_MUSL_DIR)"/arch/generic/bits/* "$(SYSROOT_INC)/bits"
cp -r "$(LIBC_TOP_HALF_MUSL_DIR)"/arch/wasm32/bits/* "$(SYSROOT_INC)/bits"
# Copy in the fts header files.
cp "$(MUSL_FTS_SRC_DIR)/fts.h" "$(SYSROOT_INC)/fts.h"
# Remove selected header files.
......@@ -836,7 +845,11 @@ ifeq ($(WASI_SNAPSHOT), p2)
> "$(SYSROOT_INC)/__wasi_snapshot.h"
endif
startup_files: include_dirs $(LIBC_BOTTOM_HALF_CRT_OBJS)
# Stamp the include installation.
@mkdir -p $(@D)
touch $@
startup_files: $(INCLUDE_DIRS) $(LIBC_BOTTOM_HALF_CRT_OBJS)
#
# Install the startup files (crt1.o etc).
#
......@@ -861,7 +874,7 @@ LIBC_SO += \
endif
endif
libc_so: include_dirs $(LIBC_SO)
libc_so: $(INCLUDE_DIRS) $(LIBC_SO)
STATIC_LIBS = \
$(SYSROOT_LIB)/libc.a \
......@@ -881,7 +894,7 @@ STATIC_LIBS += \
$(SYSROOT_LIB)/libsetjmp.a
endif
libc: include_dirs $(STATIC_LIBS)
libc: $(INCLUDE_DIRS) $(STATIC_LIBS)
DUMMY := m rt pthread crypt util xnet resolv
DUMMY_LIBS := $(patsubst %,$(SYSROOT_LIB)/lib%.a,$(DUMMY))
......@@ -1101,4 +1114,4 @@ clean:
$(RM) -r "$(OBJDIR)"
$(RM) -r "$(SYSROOT)"
.PHONY: default startup_files libc libc_so finish install include_dirs clean check-symbols bindings
.PHONY: default startup_files libc libc_so finish install clean check-symbols bindings
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment