Skip to content

Commit 777361d

Browse files
authored
Avoid re-copying the startup object files (#555)
This adds a `.stamp` file to the process of copying over the `crt` files to the sysroot directory to avoid re-copying on each `make` invocation.
1 parent c47daaf commit 777361d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ $(OBJDIR)/%.o: %.s $(INCLUDE_DIRS)
772772
$(DLMALLOC_OBJS) $(DLMALLOC_SO_OBJS): CFLAGS += \
773773
-I$(DLMALLOC_INC)
774774

775-
startup_files $(LIBC_BOTTOM_HALF_ALL_OBJS) $(LIBC_BOTTOM_HALF_ALL_SO_OBJS): CFLAGS += \
775+
$(STARTUP_FILES) $(LIBC_BOTTOM_HALF_ALL_OBJS) $(LIBC_BOTTOM_HALF_ALL_SO_OBJS): CFLAGS += \
776776
-I$(LIBC_BOTTOM_HALF_HEADERS_PRIVATE) \
777777
-I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC_INC) \
778778
-I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC) \
@@ -849,13 +849,18 @@ endif
849849
@mkdir -p $(@D)
850850
touch $@
851851

852-
startup_files: $(INCLUDE_DIRS) $(LIBC_BOTTOM_HALF_CRT_OBJS)
852+
STARTUP_FILES := $(OBJDIR)/copy-startup-files.stamp
853+
$(STARTUP_FILES): $(INCLUDE_DIRS) $(LIBC_BOTTOM_HALF_CRT_OBJS)
853854
#
854-
# Install the startup files (crt1.o etc).
855+
# Install the startup files (crt1.o, etc.).
855856
#
856-
mkdir -p "$(SYSROOT_LIB)" && \
857+
mkdir -p "$(SYSROOT_LIB)"
857858
cp $(LIBC_BOTTOM_HALF_CRT_OBJS) "$(SYSROOT_LIB)"
858859

860+
# Stamp the startup file installation.
861+
@mkdir -p $(@D)
862+
touch $@
863+
859864
# TODO: As of this writing, wasi_thread_start.s uses non-position-independent
860865
# code, and I'm not sure how to make it position-independent. Once we've done
861866
# that, we can enable libc.so for the wasi-threads build.
@@ -907,7 +912,7 @@ $(DUMMY_LIBS):
907912
$(AR) crs "$$lib"; \
908913
done
909914

910-
finish: startup_files libc $(DUMMY_LIBS)
915+
finish: $(STARTUP_FILES) libc $(DUMMY_LIBS)
911916
#
912917
# The build succeeded! The generated sysroot is in $(SYSROOT).
913918
#
@@ -935,7 +940,7 @@ endif
935940
endif
936941

937942

938-
check-symbols: startup_files libc
943+
check-symbols: $(STARTUP_FILES) libc
939944
#
940945
# Collect metadata on the sysroot and perform sanity checks.
941946
#
@@ -1114,4 +1119,4 @@ clean:
11141119
$(RM) -r "$(OBJDIR)"
11151120
$(RM) -r "$(SYSROOT)"
11161121

1117-
.PHONY: default startup_files libc libc_so finish install clean check-symbols bindings
1122+
.PHONY: default libc libc_so finish install clean check-symbols bindings

0 commit comments

Comments
 (0)