diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:08:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-26 16:08:03 +0000 |
commit | d53be633495379df577148d121a9cf52246b0c5e (patch) | |
tree | bbc827718e0859af4dc7332e03e2e8ddc56cc09c /test | |
parent | Adding debian version 0.0~git20230821.ec4566b-2. (diff) | |
download | wasi-libc-d53be633495379df577148d121a9cf52246b0c5e.tar.xz wasi-libc-d53be633495379df577148d121a9cf52246b0c5e.zip |
Merging upstream version 0.0~git20240411.9e8c542.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/test/Makefile b/test/Makefile index 61e1756..02b436a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -16,16 +16,27 @@ test: run OBJDIR ?= $(CURDIR)/build DOWNDIR ?= $(CURDIR)/download +TARGET_TRIPLE ?= wasm32-wasi + ##### DOWNLOAD ################################################################# LIBC_TEST_URL ?= https://github.com/bytecodealliance/libc-test LIBC_TEST = $(DOWNDIR)/libc-test LIBRT_URL ?= https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-16/libclang_rt.builtins-wasm32-wasi-16.0.tar.gz LIBRT = $(DOWNDIR)/lib/wasi/libclang_rt.builtins-wasm32.a -WASMTIME_URL ?= https://github.com/bytecodealliance/wasmtime/releases/download/v3.0.0/wasmtime-v3.0.0-x86_64-linux.tar.xz +WASMTIME_URL ?= https://github.com/bytecodealliance/wasmtime/releases/download/v17.0.0/wasmtime-v17.0.0-x86_64-linux.tar.xz WASMTIME = $(DOWNDIR)/$(shell basename $(WASMTIME_URL) .tar.xz)/wasmtime +WASM_TOOLS_URL ?= https://github.com/bytecodealliance/wasm-tools/releases/download/wasm-tools-1.0.54/wasm-tools-1.0.54-x86_64-linux.tar.gz +WASM_TOOLS = $(DOWNDIR)/$(shell basename $(WASM_TOOLS_URL) .tar.gz)/wasm-tools +ADAPTER_URL ?= https://github.com/bytecodealliance/wasmtime/releases/download/v17.0.0/wasi_snapshot_preview1.command.wasm +ADAPTER = $(DOWNDIR)/wasi_snapshot_preview1.command.wasm + +TO_DOWNLOAD = $(LIBC_TEST) $(LIBRT) $(WASMTIME) +ifeq ($(TARGET_TRIPLE), wasm32-wasip2) +TO_DOWNLOAD += $(ADAPTER) $(WASM_TOOLS) +endif -download: $(LIBC_TEST) $(LIBRT) $(WASMTIME) +download: $(TO_DOWNLOAD) $(DOWNDIR): mkdir -p download @@ -36,12 +47,19 @@ $(LIBC_TEST): | $(DOWNDIR) # TODO install target to place into... $(LIBRT): | $(DOWNDIR) wget --no-clobber --directory-prefix=$(DOWNDIR) $(LIBRT_URL) - tar --extract --file=$(DOWNDIR)/$(shell basename $(LIBRT_URL)) --directory=$(DOWNDIR)/ + tar --extract --file=$(DOWNDIR)/$(shell basename $(LIBRT_URL)) --directory=$(DOWNDIR)/ $(WASMTIME): | $(DOWNDIR) wget --no-clobber --directory-prefix=$(DOWNDIR) $(WASMTIME_URL) tar --extract --file=$(DOWNDIR)/$(shell basename $(WASMTIME_URL)) --directory=$(DOWNDIR)/ +$(WASM_TOOLS): | $(DOWNDIR) + wget --no-clobber --directory-prefix=$(DOWNDIR) $(WASM_TOOLS_URL) + tar --extract --file=$(DOWNDIR)/$(shell basename $(WASM_TOOLS_URL)) --directory=$(DOWNDIR)/ + +$(ADAPTER): | $(DOWNDIR) + wget --no-clobber --directory-prefix=$(DOWNDIR) $(ADAPTER_URL) + clean:: rm -rf download @@ -103,7 +121,7 @@ COMMON_TEST_INFRA = \ # $(WASM_OBJS) are compiled in the $(OBJDIRS) and then linked together to form # the $(WASMS) tests. NAMES := $(TESTS:$(LIBC_TEST)/src/%.c=%) -WASMS := $(TESTS:$(LIBC_TEST)/src/%.c=$(OBJDIR)/%.wasm) +WASMS := $(TESTS:$(LIBC_TEST)/src/%.c=$(OBJDIR)/%.core.wasm) WASM_OBJS := $(TESTS:$(LIBC_TEST)/src/%.c=$(OBJDIR)/%.wasm.o) INFRA_WASM_OBJS := $(COMMON_TEST_INFRA:$(LIBC_TEST)/src/%.c=$(OBJDIR)/%.wasm.o) WASM_OBJS += $(INFRA_WASM_OBJS) @@ -116,9 +134,12 @@ ifeq ($(origin CC), default) CC := clang endif LDFLAGS ?= -CFLAGS ?= --target=wasm32-wasi --sysroot=../sysroot +CFLAGS ?= --target=$(TARGET_TRIPLE) --sysroot=../sysroot # Always include the `libc-test` infrastructure headers. CFLAGS += -I$(LIBC_TEST)/src/common +ifneq ($(findstring -threads,$(TARGET_TRIPLE)),) +CFLAGS += -pthread +endif # Compile each selected test using Clang. Note that failures here are likely # due to a missing `libclang_rt.builtins-wasm32.a` in the Clang lib directory. @@ -128,12 +149,17 @@ CFLAGS += -I$(LIBC_TEST)/src/common build: download $(WASMS) $(WASMS): | $(OBJDIRS) -$(OBJDIR)/%.wasm: $(OBJDIR)/%.wasm.o $(INFRA_WASM_OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ +$(OBJDIR)/%.core.wasm: $(OBJDIR)/%.wasm.o $(INFRA_WASM_OBJS) + $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ + +ifeq ($(TARGET_TRIPLE), wasm32-wasip2) +$(OBJDIR)/%.wasm: $(OBJDIR)/%.core.wasm + $(WASM_TOOLS) component new --adapt $(ADAPTER) $< -o $@ +endif $(WASM_OBJS): $(LIBC_TEST)/src/common/test.h | $(OBJDIRS) $(OBJDIR)/%.wasm.o: $(LIBC_TEST)/src/%.c - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CFLAGS) -c -o $@ $< $(OBJDIRS): mkdir -p $@ @@ -144,7 +170,7 @@ clean:: ##### RUN ###################################################################### ENGINE ?= $(WASMTIME) run -ERRS:=$(WASMS:%.wasm=%.wasm.err) +ERRS:=$(WASMS:%.core.wasm=%.wasm.err) # Use the provided Wasm engine to execute each test, emitting its output into # a `.err` file. @@ -153,8 +179,13 @@ run: build $(ERRS) $(ERRS): | $(OBJDIRS) +ifeq ($(TARGET_TRIPLE), wasm32-wasip2) %.wasm.err: %.wasm + $(ENGINE) --wasm component-model $< >$@ +else +%.wasm.err: %.core.wasm $(ENGINE) $< >$@ +endif clean:: rm -rf $(OBJDIR)/*/*.err |