@@ -35,8 +35,6 @@ $(SYSROOT):
3535
3636LIBC_TEST_URL ?= https://github.com/bytecodealliance/libc-test
3737LIBC_TEST = $(DOWNDIR ) /libc-test
38- LIBRT_URL ?= https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25/libclang_rt.builtins-wasm32-wasi-25.0.tar.gz
39- LIBRT = $(DOWNDIR ) /libclang_rt.builtins-wasm32.a
4038ARCH := $(shell uname -m)
4139WASMTIME_URL ?= https://github.com/bytecodealliance/wasmtime/releases/download/v29.0.1/wasmtime-v29.0.1-$(ARCH ) -linux.tar.xz
4240WASMTIME = $(abspath $(DOWNDIR ) /$(shell basename $(WASMTIME_URL ) .tar.xz) /wasmtime)
@@ -51,12 +49,6 @@ $(DOWNDIR):
5149$(LIBC_TEST ) : | $(DOWNDIR )
5250 git clone --depth 1 $(LIBC_TEST_URL ) $@
5351
54- # TODO: add install target to copy builtins library directly into a Clang
55- # installation.
56- $(LIBRT ) : | $(DOWNDIR )
57- wget --no-clobber --directory-prefix=$(DOWNDIR ) $(LIBRT_URL )
58- tar --extract --file=$(DOWNDIR ) /$(shell basename $(LIBRT_URL ) ) --strip-components=1 --directory=$(DOWNDIR ) /
59-
6052$(WASMTIME ) : | $(DOWNDIR )
6153 wget --no-clobber --directory-prefix=$(DOWNDIR ) $(WASMTIME_URL )
6254 tar --extract --file=$(DOWNDIR ) /$(shell basename $(WASMTIME_URL ) ) --directory=$(DOWNDIR ) /
@@ -69,7 +61,7 @@ $(ADAPTER): | $(DOWNDIR)
6961 wget --no-clobber --directory-prefix=$(DOWNDIR ) $(ADAPTER_URL )
7062
7163# Target to download all necessary dependencies.
72- TO_DOWNLOAD = $(LIBC_TEST ) $(LIBRT ) $( WASMTIME )
64+ TO_DOWNLOAD = $(LIBC_TEST ) $(WASMTIME )
7365ifeq ($(TARGET_TRIPLE ) , wasm32-wasip2)
7466TO_DOWNLOAD += $(ADAPTER ) $(WASM_TOOLS )
7567endif
@@ -133,6 +125,16 @@ ifneq ($(findstring -threads,$(TARGET_TRIPLE)),)
133125CFLAGS += -pthread
134126endif
135127
128+ # Handle compiler-rt which is required for tests. This is done by requesting
129+ # that the parent directory, the main wasi-libc directory, fetch its compiler-rt
130+ # which will create a `resource-dir` argument which we can then add to LDFLAGS
131+ # which gets fed down below into the actual linking of wasms.
132+ LDFLAGS += -resource-dir ../build/$(TARGET_TRIPLE ) /resource-dir
133+ BUILTINS_STAMP := $(OBJDIR ) /builtins.stamp
134+ $(BUILTINS_STAMP ) :
135+ make -C .. builtins
136+ touch $@
137+
136138# Build up all the `*.wasm.o` object files; these are the same regardless of
137139# whether we're building core modules or components.
138140$(WASM_OBJS ) : $(INFRA_HEADERS )
@@ -142,7 +144,7 @@ $(OBJDIR)/%.wasm.o: $(SRCDIR)/%.c $(DOWNLOADED) $(SYSROOT)
142144
143145# Build up all the `*.wasm` files.
144146obj_to_c = $(patsubst $(OBJDIR ) /% .wasm.o,$(SRCDIR ) /% .c,$1)
145- $(OBJDIR ) /% .core.wasm : $(OBJDIR ) /% .wasm.o $(INFRA_WASM_OBJS )
147+ $(OBJDIR ) /% .core.wasm : $(OBJDIR ) /% .wasm.o $(INFRA_WASM_OBJS ) $( BUILTINS_STAMP )
146148 @mkdir -p $(@D )
147149 $(CC ) $(CFLAGS ) $(LDFLAGS ) $(shell scripts/add-flags.py LDFLAGS $(call obj_to_c,$< ) ) $^ -o $@
148150
0 commit comments