@@ -20,7 +20,7 @@ MALLOC_IMPL ?= dlmalloc
2020# yes or no
2121BUILD_LIBC_TOP_HALF ?= yes
2222# The directory where we will store intermediate artifacts.
23- OBJDIR ?= $( CURDIR ) / build/$(TARGET_TRIPLE )
23+ OBJDIR ?= build/$(TARGET_TRIPLE )
2424
2525# When the length is no larger than this threshold, we consider the
2626# overhead of bulk memory opcodes to outweigh the performance benefit,
@@ -43,13 +43,13 @@ endif
4343
4444# These variables describe the locations of various files and directories in
4545# the source tree.
46- DLMALLOC_DIR = $( CURDIR ) / dlmalloc
46+ DLMALLOC_DIR = dlmalloc
4747DLMALLOC_SRC_DIR = $(DLMALLOC_DIR ) /src
4848DLMALLOC_SOURCES = $(DLMALLOC_SRC_DIR ) /dlmalloc.c
4949DLMALLOC_INC = $(DLMALLOC_DIR ) /include
50- EMMALLOC_DIR = $( CURDIR ) / emmalloc
50+ EMMALLOC_DIR = emmalloc
5151EMMALLOC_SOURCES = $(EMMALLOC_DIR ) /emmalloc.c
52- LIBC_BOTTOM_HALF_DIR = $( CURDIR ) / libc-bottom-half
52+ LIBC_BOTTOM_HALF_DIR = libc-bottom-half
5353LIBC_BOTTOM_HALF_CLOUDLIBC_SRC = $(LIBC_BOTTOM_HALF_DIR ) /cloudlibc/src
5454LIBC_BOTTOM_HALF_CLOUDLIBC_SRC_INC = $(LIBC_BOTTOM_HALF_CLOUDLIBC_SRC ) /include
5555LIBC_BOTTOM_HALF_HEADERS_PUBLIC = $(LIBC_BOTTOM_HALF_DIR ) /headers/public
@@ -79,7 +79,7 @@ LIBWASI_EMULATED_SIGNAL_MUSL_SOURCES = \
7979 $(LIBC_TOP_HALF_MUSL_SRC_DIR ) /signal/psignal.c \
8080 $(LIBC_TOP_HALF_MUSL_SRC_DIR ) /string/strsignal.c
8181LIBC_BOTTOM_HALF_CRT_SOURCES = $(wildcard $(LIBC_BOTTOM_HALF_DIR ) /crt/* .c)
82- LIBC_TOP_HALF_DIR = $( CURDIR ) / libc-top-half
82+ LIBC_TOP_HALF_DIR = libc-top-half
8383LIBC_TOP_HALF_MUSL_DIR = $(LIBC_TOP_HALF_DIR ) /musl
8484LIBC_TOP_HALF_MUSL_SRC_DIR = $(LIBC_TOP_HALF_MUSL_DIR ) /src
8585LIBC_TOP_HALF_MUSL_INC = $(LIBC_TOP_HALF_MUSL_DIR ) /include
@@ -346,8 +346,8 @@ CFLAGS += -isystem "$(SYSROOT_INC)"
346346
347347# These variables describe the locations of various files and directories in
348348# the build tree.
349- objs = $(patsubst $( CURDIR ) / % .c,$(OBJDIR ) /% .o,$(1 ) )
350- asmobjs = $(patsubst $( CURDIR ) / % .s,$(OBJDIR ) /% .o,$(1 ) )
349+ objs = $(patsubst % .c,$(OBJDIR ) /% .o,$(1 ) )
350+ asmobjs = $(patsubst % .s,$(OBJDIR ) /% .o,$(1 ) )
351351DLMALLOC_OBJS = $(call objs,$(DLMALLOC_SOURCES ) )
352352EMMALLOC_OBJS = $(call objs,$(EMMALLOC_SOURCES ) )
353353LIBC_BOTTOM_HALF_ALL_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_ALL_SOURCES ) )
@@ -376,6 +376,7 @@ LIBWASI_EMULATED_PROCESS_CLOCKS_OBJS = $(call objs,$(LIBWASI_EMULATED_PROCESS_CL
376376LIBWASI_EMULATED_GETPID_OBJS = $(call objs,$(LIBWASI_EMULATED_GETPID_SOURCES ) )
377377LIBWASI_EMULATED_SIGNAL_OBJS = $(call objs,$(LIBWASI_EMULATED_SIGNAL_SOURCES ) )
378378LIBWASI_EMULATED_SIGNAL_MUSL_OBJS = $(call objs,$(LIBWASI_EMULATED_SIGNAL_MUSL_SOURCES ) )
379+ LIBC_BOTTOM_HALF_CRT_OBJS = $(call objs,$(LIBC_BOTTOM_HALF_CRT_SOURCES ) )
379380
380381# These variables describe the locations of various files and
381382# directories in the generated sysroot tree.
@@ -514,19 +515,19 @@ $(BULK_MEMORY_OBJS): CFLAGS += \
514515$(LIBWASI_EMULATED_SIGNAL_MUSL_OBJS ) : CFLAGS += \
515516 -D_WASI_EMULATED_SIGNAL
516517
517- $(OBJDIR ) /% .long-double.o : $( CURDIR ) / % .c include_dirs
518+ $(OBJDIR ) /% .long-double.o : % .c include_dirs
518519 @mkdir -p " $( @D) "
519520 $(CC ) $(CFLAGS ) -MD -MP -o $@ -c $<
520521
521- $(OBJDIR ) /% .no-floating-point.o : $( CURDIR ) / % .c include_dirs
522+ $(OBJDIR ) /% .no-floating-point.o : % .c include_dirs
522523 @mkdir -p " $( @D) "
523524 $(CC ) $(CFLAGS ) -MD -MP -o $@ -c $<
524525
525- $(OBJDIR ) /% .o : $( CURDIR ) / % .c include_dirs
526+ $(OBJDIR ) /% .o : % .c include_dirs
526527 @mkdir -p " $( @D) "
527528 $(CC ) $(CFLAGS ) -MD -MP -o $@ -c $<
528529
529- $(OBJDIR ) /% .o : $( CURDIR ) / % .s include_dirs
530+ $(OBJDIR ) /% .o : % .s include_dirs
530531 @mkdir -p " $( @D) "
531532 $(CC ) $(ASMFLAGS ) -o $@ -c $<
532533
@@ -582,15 +583,12 @@ include_dirs:
582583 # Remove selected header files.
583584 $(RM) $(patsubst %,$(SYSROOT_INC)/%,$(MUSL_OMIT_HEADERS))
584585
585- startup_files : include_dirs
586+ startup_files : include_dirs $( LIBC_BOTTOM_HALF_CRT_OBJS )
586587 #
587- # Build the startup files.
588+ # Install the startup files (crt1.o etc) .
588589 #
589- @mkdir -p " $( OBJDIR) "
590- cd " $( OBJDIR) " && \
591- $(CC ) $(CFLAGS ) -c $(LIBC_BOTTOM_HALF_CRT_SOURCES ) -MD -MP && \
592590 mkdir -p " $( SYSROOT_LIB) " && \
593- mv * .o " $( SYSROOT_LIB) "
591+ cp $( LIBC_BOTTOM_HALF_CRT_OBJS ) " $( SYSROOT_LIB) "
594592
595593libc : include_dirs \
596594 $(SYSROOT_LIB)/libc.a \
@@ -708,7 +706,7 @@ check-symbols: startup_files libc
708706
709707 # Check that the computed metadata matches the expected metadata.
710708 # This ignores whitespace because on Windows the output has CRLF line endings.
711- diff -wur "$(CURDIR)/ expected/$(TARGET_TRIPLE)" "$(SYSROOT_SHARE)"
709+ diff -wur "expected/$(TARGET_TRIPLE)" "$(SYSROOT_SHARE)"
712710
713711install : finish
714712 mkdir -p " $( INSTALL_DIR) "
0 commit comments