]> git.proxmox.com Git - wasi-libc.git/commitdiff
Makefile refactoring; NFC (#186)
authorDan Gohman <sunfish@mozilla.com>
Fri, 20 Mar 2020 22:45:37 +0000 (15:45 -0700)
committerGitHub <noreply@github.com>
Fri, 20 Mar 2020 22:45:37 +0000 (15:45 -0700)
* Use ?= for variables intended to be overridable.

* Use `override` consistently for variables not meant to be overridden.

* Omit miscellaneous comments from the build output.

* Tidy up some comments.

* Use `addprefix` to factor out a common prefix.

* Add a comment.

* Reorganize.

* Adjust indentation.

* Simplify the logic for the `check` rule.

* Remove the `override` keywords.

They theoretically protect what the Makefile considers to be
implementation details from being overridden on the command-line,
but in practice this isn't super important, and they add a lot of
clutter.

* Put source file names on their own lines.

Makefile

index f723e55b8c7e2360df5a8a74d0ec139fb5538352..a19507dcd818e77ee34f1358433a5a183b99c28d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-# These variables are specifically meant to be overridable via
-# the make command-line.
+# 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))
@@ -9,13 +9,13 @@ SYSROOT ?= $(CURDIR)/sysroot
 # A directory to install to for "make install".
 INSTALL_DIR ?= /usr/local
 # single or posix
-THREAD_MODEL = single
+THREAD_MODEL ?= single
 # yes or no
-BUILD_DLMALLOC = yes
-BUILD_LIBC_BOTTOM_HALF = yes
-BUILD_LIBC_TOP_HALF = yes
+BUILD_DLMALLOC ?= yes
+BUILD_LIBC_BOTTOM_HALF ?= yes
+BUILD_LIBC_TOP_HALF ?= yes
 # The directory where we're store intermediate artifacts.
-OBJDIR = $(CURDIR)/build
+OBJDIR ?= $(CURDIR)/build
 
 # Check dependencies.
 ifeq ($(BUILD_LIBC_TOP_HALF),yes)
@@ -29,8 +29,16 @@ $(error BUILD_LIBC_BOTTOM_HALF=yes depends on BUILD_DLMALLOC=yes)
 endif
 endif
 
-# These variables describe the locations of various files and
-# directories in the source tree.
+# Variables from this point on are not meant to be overridable via the
+# make command-line.
+
+# Set the target variables. Multiarch triples notably omit the vendor field,
+# which happens to be what we do for the main target triple too.
+TARGET_TRIPLE = wasm32-wasi
+MULTIARCH_TRIPLE = wasm32-wasi
+
+# These variables describe the locations of various files and directories in
+# the source tree.
 BASICS_DIR = $(CURDIR)/basics
 BASICS_INC = $(BASICS_DIR)/include
 BASICS_CRT_SOURCES = $(wildcard $(BASICS_DIR)/crt/*.c)
@@ -60,72 +68,74 @@ 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
 LIBC_TOP_HALF_MUSL_SOURCES = \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/a64l.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/basename.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/dirname.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/ffs.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/ffsl.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/ffsll.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/fmtmsg.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/getdomainname.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/gethostid.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/getopt.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/getopt_long.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/getsubopt.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/uname.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/misc/nftw.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/errno/strerror.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/htonl.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/htons.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/ntohl.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/ntohs.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/inet_ntop.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/inet_pton.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/inet_aton.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/in6addr_any.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/network/in6addr_loopback.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/fenv/fenv.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/fenv/fesetround.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/fenv/feupdateenv.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/fenv/fesetexceptflag.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/fenv/fegetexceptflag.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/fenv/feholdexcept.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/exit/exit.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/exit/atexit.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/exit/assert.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/exit/quick_exit.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/exit/at_quick_exit.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/strftime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/asctime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/asctime_r.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/ctime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/ctime_r.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/wcsftime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/strptime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/difftime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/timegm.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/ftime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/gmtime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/gmtime_r.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/timespec_get.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/getdate.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/localtime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/localtime_r.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/mktime.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/__tm_to_secs.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/__month_to_secs.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/__secs_to_tm.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/__year_to_secs.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/time/__tz.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/fcntl/creat.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/dirent/alphasort.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/dirent/versionsort.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/env/clearenv.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/env/getenv.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/env/putenv.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/env/setenv.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/env/unsetenv.c \
-    $(LIBC_TOP_HALF_MUSL_SRC_DIR)/unistd/posix_close.c \
+    $(addprefix $(LIBC_TOP_HALF_MUSL_SRC_DIR)/, \
+        misc/a64l.c \
+        misc/basename.c \
+        misc/dirname.c \
+        misc/ffs.c \
+        misc/ffsl.c \
+        misc/ffsll.c \
+        misc/fmtmsg.c \
+        misc/getdomainname.c \
+        misc/gethostid.c \
+        misc/getopt.c \
+        misc/getopt_long.c \
+        misc/getsubopt.c \
+        misc/uname.c \
+        misc/nftw.c \
+        errno/strerror.c \
+        network/htonl.c \
+        network/htons.c \
+        network/ntohl.c \
+        network/ntohs.c \
+        network/inet_ntop.c \
+        network/inet_pton.c \
+        network/inet_aton.c \
+        network/in6addr_any.c \
+        network/in6addr_loopback.c \
+        fenv/fenv.c \
+        fenv/fesetround.c \
+        fenv/feupdateenv.c \
+        fenv/fesetexceptflag.c \
+        fenv/fegetexceptflag.c \
+        fenv/feholdexcept.c \
+        exit/exit.c \
+        exit/atexit.c \
+        exit/assert.c \
+        exit/quick_exit.c \
+        exit/at_quick_exit.c \
+        time/strftime.c \
+        time/asctime.c \
+        time/asctime_r.c \
+        time/ctime.c \
+        time/ctime_r.c \
+        time/wcsftime.c \
+        time/strptime.c \
+        time/difftime.c \
+        time/timegm.c \
+        time/ftime.c \
+        time/gmtime.c \
+        time/gmtime_r.c \
+        time/timespec_get.c \
+        time/getdate.c \
+        time/localtime.c \
+        time/localtime_r.c \
+        time/mktime.c \
+        time/__tm_to_secs.c \
+        time/__month_to_secs.c \
+        time/__secs_to_tm.c \
+        time/__year_to_secs.c \
+        time/__tz.c \
+        fcntl/creat.c \
+        dirent/alphasort.c \
+        dirent/versionsort.c \
+        env/clearenv.c \
+        env/getenv.c \
+        env/putenv.c \
+        env/setenv.c \
+        env/unsetenv.c \
+        unistd/posix_close.c \
+    ) \
     $(filter-out %/procfdname.c %/syscall.c %/syscall_ret.c %/vdso.c %/version.c, \
                  $(wildcard $(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal/*.c)) \
     $(filter-out %/flockfile.c %/funlockfile.c %/__lockfile.c %/ftrylockfile.c \
@@ -176,83 +186,80 @@ LIBC_TOP_HALF_ALL_SOURCES = \
     $(LIBC_TOP_HALF_MUSL_SOURCES) \
     $(shell find $(LIBC_TOP_HALF_SOURCES) -name \*.c)
 
-# Set the target variables. Multiarch triples notably omit the vendor
-# field, which happens to be what we do for the main target triple too.
-TARGET_TRIPLE = wasm32-wasi
-MULTIARCH_TRIPLE = wasm32-wasi
-
-# These variables describe the locations of various files and
-# directories in the generated sysroot tree.
-SYSROOT_LIB = $(SYSROOT)/lib/$(MULTIARCH_TRIPLE)
-SYSROOT_INC = $(SYSROOT)/include
-SYSROOT_SHARE = $(SYSROOT)/share/$(MULTIARCH_TRIPLE)
-
 # Set the target.
-override WASM_CFLAGS += --target=$(TARGET_TRIPLE)
+WASM_CFLAGS += --target=$(TARGET_TRIPLE)
 # WebAssembly floating-point match doesn't trap.
 # TODO: Add -fno-signaling-nans when the compiler supports it.
-override WASM_CFLAGS += -fno-trapping-math
+WASM_CFLAGS += -fno-trapping-math
 
 # Configure support for threads.
 ifeq ($(THREAD_MODEL), single)
-override WASM_CFLAGS += -mthread-model single
+WASM_CFLAGS += -mthread-model single
 endif
 ifeq ($(THREAD_MODEL), posix)
-override WASM_CFLAGS += -mthread-model posix -pthread
+WASM_CFLAGS += -mthread-model posix -pthread
 endif
 
 # Set the sysroot.
-override WASM_CFLAGS += --sysroot="$(SYSROOT)"
+WASM_CFLAGS += --sysroot="$(SYSROOT)"
 
+# These variables describe the locations of various files and directories in
+# the build tree.
 objs = $(patsubst $(CURDIR)/%.c,$(OBJDIR)/%.o,$(1))
-override BASICS_OBJS = $(call objs,$(BASICS_SOURCES))
-override DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES))
-override LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES))
-override LIBC_TOP_HALF_ALL_OBJS = $(call objs,$(LIBC_TOP_HALF_ALL_SOURCES))
-override LIBC_OBJS := $(BASICS_OBJS)
+BASICS_OBJS = $(call objs,$(BASICS_SOURCES))
+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))
+LIBC_OBJS := $(BASICS_OBJS)
 ifeq ($(BUILD_DLMALLOC),yes)
-override LIBC_OBJS += $(DLMALLOC_OBJS)
+LIBC_OBJS += $(DLMALLOC_OBJS)
 endif
 ifeq ($(BUILD_LIBC_BOTTOM_HALF),yes)
 # Override basics' string.o with libc-bottom-half's.
-override LIBC_OBJS := $(filter-out %/string.o,$(LIBC_OBJS))
+LIBC_OBJS := $(filter-out %/string.o,$(LIBC_OBJS))
 # Add libc-bottom-half's objects.
-override LIBC_OBJS += $(LIBC_BOTTOM_HALF_ALL_OBJS)
+LIBC_OBJS += $(LIBC_BOTTOM_HALF_ALL_OBJS)
 endif
 ifeq ($(BUILD_LIBC_TOP_HALF),yes)
 # Override libc-bottom-half's string.o with libc-top-half's.
-override LIBC_OBJS := $(filter-out %/string.o,$(LIBC_OBJS))
+LIBC_OBJS := $(filter-out %/string.o,$(LIBC_OBJS))
 # Override libc-bottom-half's qsort.o with libc-top-half's.
-override LIBC_OBJS := $(filter-out %/qsort.o,$(LIBC_OBJS))
+LIBC_OBJS := $(filter-out %/qsort.o,$(LIBC_OBJS))
 # libc-top-half is musl.
-override LIBC_OBJS += $(LIBC_TOP_HALF_ALL_OBJS)
+LIBC_OBJS += $(LIBC_TOP_HALF_ALL_OBJS)
 endif
-override MUSL_PRINTSCAN_OBJS = $(call objs,$(MUSL_PRINTSCAN_SOURCES))
-override MUSL_PRINTSCAN_LONG_DOUBLE_OBJS = $(patsubst %.o,%.long-double.o,$(MUSL_PRINTSCAN_OBJS))
-override MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS = $(patsubst %.o,%.no-floating-point.o,$(MUSL_PRINTSCAN_OBJS))
-override LIBWASI_EMULATED_MMAN_OBJS = $(call objs,$(LIBWASI_EMULATED_MMAN_SOURCES))
+MUSL_PRINTSCAN_OBJS = $(call objs,$(MUSL_PRINTSCAN_SOURCES))
+MUSL_PRINTSCAN_LONG_DOUBLE_OBJS = $(patsubst %.o,%.long-double.o,$(MUSL_PRINTSCAN_OBJS))
+MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS = $(patsubst %.o,%.no-floating-point.o,$(MUSL_PRINTSCAN_OBJS))
+LIBWASI_EMULATED_MMAN_OBJS = $(call objs,$(LIBWASI_EMULATED_MMAN_SOURCES))
+
+# These variables describe the locations of various files and
+# directories in the generated sysroot tree.
+SYSROOT_LIB := $(SYSROOT)/lib/$(MULTIARCH_TRIPLE)
+SYSROOT_INC = $(SYSROOT)/include
+SYSROOT_SHARE = $(SYSROOT)/share/$(MULTIARCH_TRIPLE)
 
 # Files from musl's include directory that we don't want to install in the
 # sysroot's include directory.
-override MUSL_OMIT_HEADERS :=
+MUSL_OMIT_HEADERS :=
 
 # Remove files which aren't headers (we generate alltypes.h below).
-override MUSL_OMIT_HEADERS += \
+MUSL_OMIT_HEADERS += \
     "bits/syscall.h.in" \
     "bits/alltypes.h.in" \
     "alltypes.h.in"
 
 # Use the compiler's version of these headers.
-override MUSL_OMIT_HEADERS += \
+MUSL_OMIT_HEADERS += \
     "stdarg.h" \
     "stddef.h"
 
 # Use the WASI errno definitions.
-override MUSL_OMIT_HEADERS += \
+MUSL_OMIT_HEADERS += \
     "bits/errno.h"
 
 # Remove headers that aren't supported yet or that aren't relevant for WASI.
-override MUSL_OMIT_HEADERS += \
+MUSL_OMIT_HEADERS += \
     "sys/procfs.h" \
     "sys/user.h" \
     "sys/kd.h" "sys/vt.h" "sys/soundcard.h" "sys/sem.h" \
@@ -314,10 +321,10 @@ override MUSL_OMIT_HEADERS += \
 
 ifeq ($(THREAD_MODEL), single)
 # Remove headers not supported in single-threaded mode.
-override MUSL_OMIT_HEADERS += "aio.h" "pthread.h"
+MUSL_OMIT_HEADERS += "aio.h" "pthread.h"
 endif
 
-default: check
+default: finish
 
 $(SYSROOT_LIB)/libc.a: $(LIBC_OBJS)
 
@@ -338,11 +345,11 @@ $(SYSROOT_LIB)/libwasi-emulated-mman.a: $(LIBWASI_EMULATED_MMAN_OBJS)
        # silently dropping the tail.
        $(WASM_AR) crs $@ $(wordlist 800, 100000, $^)
 
-$(MUSL_PRINTSCAN_OBJS): override WASM_CFLAGS += \
+$(MUSL_PRINTSCAN_OBJS): WASM_CFLAGS += \
            -D__wasilibc_printscan_no_long_double \
            -D__wasilibc_printscan_full_support_option="\"add -lc-printscan-long-double to the link command\""
 
-$(MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS): override WASM_CFLAGS += \
+$(MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS): WASM_CFLAGS += \
            -D__wasilibc_printscan_no_floating_point \
            -D__wasilibc_printscan_floating_point_support_option="\"remove -lc-printscan-no-floating-point from the link command\""
 
@@ -360,15 +367,15 @@ $(OBJDIR)/%.o: $(CURDIR)/%.c include_dirs
 
 -include $(shell find $(OBJDIR) -name \*.d)
 
-$(DLMALLOC_OBJS): override WASM_CFLAGS += \
+$(DLMALLOC_OBJS): WASM_CFLAGS += \
     -I$(DLMALLOC_INC)
 
-startup_files $(LIBC_BOTTOM_HALF_ALL_OBJS): override WASM_CFLAGS += \
+startup_files $(LIBC_BOTTOM_HALF_ALL_OBJS): WASM_CFLAGS += \
     -I$(LIBC_BOTTOM_HALF_HEADERS_PRIVATE) \
     -I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC_INC) \
     -I$(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC)
 
-$(LIBC_TOP_HALF_ALL_OBJS) $(MUSL_PRINTSCAN_LONG_DOUBLE_OBJS) $(MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS): override WASM_CFLAGS += \
+$(LIBC_TOP_HALF_ALL_OBJS) $(MUSL_PRINTSCAN_LONG_DOUBLE_OBJS) $(MUSL_PRINTSCAN_NO_FLOATING_POINT_OBJS): WASM_CFLAGS += \
     -I$(LIBC_TOP_HALF_MUSL_SRC_DIR)/include \
     -I$(LIBC_TOP_HALF_MUSL_SRC_DIR)/internal \
     -I$(LIBC_TOP_HALF_MUSL_DIR)/arch/wasm32 \
@@ -409,9 +416,9 @@ include_dirs:
        $(RM) $(patsubst %,$(SYSROOT_INC)/%,$(MUSL_OMIT_HEADERS))
 
 ifeq ($(BUILD_LIBC_BOTTOM_HALF),no)
-override CRT_SOURCES = $(BASICS_CRT_SOURCES)
+CRT_SOURCES = $(BASICS_CRT_SOURCES)
 else
-override CRT_SOURCES = $(LIBC_BOTTOM_HALF_CRT_SOURCES)
+CRT_SOURCES = $(LIBC_BOTTOM_HALF_CRT_SOURCES)
 endif
 
 startup_files: include_dirs
@@ -443,11 +450,13 @@ finish: startup_files libc
        #
        mkdir -p "$(SYSROOT_SHARE)"
 
+       #
        # Collect symbol information.
-       # TODO: Use llvm-nm --extern-only instead of grep. This is blocked on
-       # LLVM PR40497, which is fixed in 9.0, but not in 8.0.
-       # Ignore certain llvm builtin symbols such as those starting with __mul
-       # since these dependencies can vary between llvm versions.
+       #
+       @# TODO: Use llvm-nm --extern-only instead of grep. This is blocked on
+       @# LLVM PR40497, which is fixed in 9.0, but not in 8.0.
+       @# Ignore certain llvm builtin symbols such as those starting with __mul
+       @# since these dependencies can vary between llvm versions.
        "$(WASM_NM)" --defined-only "$(SYSROOT_LIB)"/libc.a "$(SYSROOT_LIB)"/*.o \
            |grep ' [[:upper:]] ' |sed 's/.* [[:upper:]] //' |LC_ALL=C sort > "$(SYSROOT_SHARE)/defined-symbols.txt"
        for undef_sym in $$("$(WASM_NM)" --undefined-only "$(SYSROOT_LIB)"/*.a "$(SYSROOT_LIB)"/*.o \
@@ -457,27 +466,34 @@ finish: startup_files libc
        grep '^_*wasi_' "$(SYSROOT_SHARE)/undefined-symbols.txt" \
            > "$(SYSROOT_LIB)/libc.imports"
 
+       #
        # Generate a test file that includes all public header files.
+       #
        cd "$(SYSROOT)" && \
-       for header in $$(find include -type f -not -name mman.h |grep -v /bits/); do \
-           echo '#include <'$$header'>' | sed 's/include\///' ; \
+         for header in $$(find include -type f -not -name mman.h |grep -v /bits/); do \
+             echo '#include <'$$header'>' | sed 's/include\///' ; \
        done |LC_ALL=C sort >share/$(MULTIARCH_TRIPLE)/include-all.c ; \
        cd - >/dev/null
 
+       #
        # Test that it compiles.
+       #
        "$(WASM_CC)" $(WASM_CFLAGS) -fsyntax-only "$(SYSROOT_SHARE)/include-all.c" -Wno-\#warnings
 
-       # Collect all the predefined macros, except for compiler version macros
-       # which we don't need to track here. For the __*_ATOMIC_*_LOCK_FREE
-       # macros, squash individual compiler names to attempt, toward keeping
-       # these files compiler-independent.
        #
-       # We have to add `-isystem $(SYSROOT_INC)` because otherwise clang puts
-       # its builtin include path first, which produces compiler-specific
-       # output.
+       # Collect all the predefined macros, except for compiler version macros
+       # which we don't need to track here.
        #
-       # 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.
+       @#
+       @# For the __*_ATOMIC_*_LOCK_FREE macros, squash individual compiler names
+       @# to attempt, toward keeping these files compiler-independent.
+       @#
+       @# We have to add `-isystem $(SYSROOT_INC)` because otherwise clang puts
+       @# its builtin include path first, which produces compiler-specific
+       @# output.
+       @#
+       @# 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)" $(WASM_CFLAGS) "$(SYSROOT_SHARE)/include-all.c" \
            -isystem $(SYSROOT_INC) \
            -std=gnu17 \
@@ -498,17 +514,16 @@ finish: startup_files libc
            | grep -v '^#define __FLT16_' \
            > "$(SYSROOT_SHARE)/predefined-macros.txt"
 
-       #
-       # The build succeeded! The generated sysroot is in $(SYSROOT).
-       #
-
-check: finish
        # 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/$(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)"
 
-.PHONY: default startup_files libc finish check install include_dirs
+.PHONY: default startup_files libc finish install include_dirs