Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve timestamps for installed headers to improve incremental builds #530

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 22 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -764,32 +764,39 @@ $(LIBWASI_EMULATED_PROCESS_CLOCKS_OBJS) $(LIBWASI_EMULATED_PROCESS_CLOCKS_SO_OBJ
$(EMMALLOC_OBJS): CFLAGS += \
-fno-strict-aliasing

include_dirs:
#
# Install the include files.
#
mkdir -p "$(SYSROOT_INC)"
cp -r "$(LIBC_BOTTOM_HALF_HEADERS_PUBLIC)"/* "$(SYSROOT_INC)"

$(SYSROOT_INC)/bits/alltypes.h: $(LIBC_TOP_HALF_MUSL_DIR)/tools/mkalltypes.sed $(LIBC_TOP_HALF_MUSL_DIR)/arch/wasm32/bits/alltypes.h.in $(LIBC_TOP_HALF_MUSL_DIR)/include/alltypes.h.in
# Generate musl's bits/alltypes.h header.
mkdir -p "$(SYSROOT_INC)/bits"
sed -f $(LIBC_TOP_HALF_MUSL_DIR)/tools/mkalltypes.sed \
$(LIBC_TOP_HALF_MUSL_DIR)/arch/wasm32/bits/alltypes.h.in \
$(LIBC_TOP_HALF_MUSL_DIR)/include/alltypes.h.in \
> "$(SYSROOT_INC)/bits/alltypes.h"

$(SYSROOT_INC)/__wasi_snapshot.h:
mkdir -p "$(SYSROOT_INC)"
ifeq ($(WASI_SNAPSHOT), p2)
printf '#ifndef __wasilibc_use_wasip2\n#define __wasilibc_use_wasip2\n#endif\n' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use echo here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just kept the existing way but I don't find any reason not to use echo. Let me do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

> "$(SYSROOT_INC)/__wasi_snapshot.h"
else
printf '/* This file is (practically) empty by default. The Makefile will replace it\n with a non-empty version that defines `__wasilibc_use_wasip2` if targeting\n `wasm32-wasip2`.\n */\n\n' \
> "$(SYSROOT_INC)/__wasi_snapshot.h"
endif

include_dirs: $(SYSROOT_INC)/bits/alltypes.h $(SYSROOT_INC)/__wasi_snapshot.h
#
# Install the include files.
#
mkdir -p "$(SYSROOT_INC)"
cp -p -r "$(LIBC_BOTTOM_HALF_HEADERS_PUBLIC)"/* "$(SYSROOT_INC)"

# Copy in the bulk of musl's public header files.
cp -r "$(LIBC_TOP_HALF_MUSL_INC)"/* "$(SYSROOT_INC)"
cp -p -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"
cp -p -r "$(LIBC_TOP_HALF_MUSL_DIR)"/arch/generic/bits/* "$(SYSROOT_INC)/bits"
cp -p -r "$(LIBC_TOP_HALF_MUSL_DIR)"/arch/wasm32/bits/* "$(SYSROOT_INC)/bits"

# Remove selected header files.
$(RM) $(patsubst %,$(SYSROOT_INC)/%,$(MUSL_OMIT_HEADERS))
ifeq ($(WASI_SNAPSHOT), p2)
printf '#ifndef __wasilibc_use_wasip2\n#define __wasilibc_use_wasip2\n#endif\n' \
> "$(SYSROOT_INC)/__wasi_snapshot.h"
endif

startup_files: include_dirs $(LIBC_BOTTOM_HALF_CRT_OBJS)
#
Expand Down Expand Up @@ -981,7 +988,7 @@ check-symbols: startup_files libc

install: finish
mkdir -p "$(INSTALL_DIR)"
cp -r "$(SYSROOT)/lib" "$(SYSROOT)/share" "$(SYSROOT)/include" "$(INSTALL_DIR)"
cp -p -r "$(SYSROOT)/lib" "$(SYSROOT)/share" "$(SYSROOT)/include" "$(INSTALL_DIR)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using cp -ar everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-a has subtle behavior differences across implementations (e.g. darwin cp does not preserve hard link but GNU coreutils does.) and it's not a part of POSIX spec unlike -p https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/cp.html
So I prefer -p unless we have clear needs for -a


$(BINDING_WORK_DIR)/wasi-cli:
mkdir -p "$(BINDING_WORK_DIR)"
Expand Down
5 changes: 0 additions & 5 deletions libc-bottom-half/headers/public/__wasi_snapshot.h

This file was deleted.