Skip to content

Commit

Permalink
test all targets; update preview2 expected output files
Browse files Browse the repository at this point in the history
Signed-off-by: Joel Dice <[email protected]>
  • Loading branch information
dicej committed Jan 5, 2024
1 parent 919436a commit 4a0839f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ jobs:
export WASI_DIR=$(realpath $($CLANG_DIR/clang -print-resource-dir)/lib/wasi/)
mkdir -p $WASI_DIR
cp download/lib/wasi/libclang_rt.builtins-wasm32.a $WASI_DIR
make test
TARGET_TRIPLE=wasm32-wasi make test
rm -r build
WASI_SNAPSHOT=preview2 make test
TARGET_TRIPLE=wasm32-wasi-preview2 make test
rm -r build
TARGET_TRIPLE=wasm32-wasi-threads make test
# The older version of Clang does not provide the expected symbol for the
# test entrypoints: `undefined symbol: __main_argc_argv`.
# The older (<15.0.7) version of wasm-ld does not provide `__heap_end`,
Expand Down
24 changes: 10 additions & 14 deletions expected/wasm32-wasi-preview2/defined-symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ __c_locale
__clock
__clock_gettime
__clock_nanosleep
__component_type_object_force_link_imports_public_use_in_this_compilation_unit
__component_type_object_force_link_preview2_public_use_in_this_compilation_unit
__cos
__cosdf
__cosl
Expand Down Expand Up @@ -522,10 +522,6 @@ environ
environment_get_arguments
environment_get_environment
environment_initial_cwd
environment_list_string_free
environment_list_tuple2_string_string_free
environment_option_string_free
environment_tuple2_string_string_free
erand48
erf
erfc
Expand Down Expand Up @@ -606,7 +602,6 @@ filesystem_directory_entry_free
filesystem_directory_entry_stream_drop_borrow
filesystem_directory_entry_stream_drop_own
filesystem_filesystem_error_code
filesystem_list_u8_free
filesystem_method_descriptor_advise
filesystem_method_descriptor_append_via_stream
filesystem_method_descriptor_create_directory_at
Expand Down Expand Up @@ -655,7 +650,6 @@ filesystem_result_own_output_stream_error_code_free
filesystem_result_string_error_code_free
filesystem_result_tuple2_list_u8_bool_error_code_free
filesystem_result_void_error_code_free
filesystem_tuple2_list_u8_bool_free
finite
finitef
floor
Expand Down Expand Up @@ -777,9 +771,6 @@ ilogbf
ilogbl
imaxabs
imaxdiv
imports_string_dup
imports_string_free
imports_string_set
in6addr_any
in6addr_loopback
index
Expand Down Expand Up @@ -992,7 +983,6 @@ perror
poll
poll_borrow_pollable
poll_list_borrow_pollable_free
poll_list_u32_free
poll_method_pollable_block
poll_method_pollable_ready
poll_poll
Expand All @@ -1010,6 +1000,15 @@ powf
powl
pread
preadv
preview2_list_string_free
preview2_list_tuple2_string_string_free
preview2_list_u32_free
preview2_list_u8_free
preview2_option_string_free
preview2_string_dup
preview2_string_free
preview2_string_set
preview2_tuple2_string_string_free
printf
program_invocation_name
program_invocation_short_name
Expand Down Expand Up @@ -1040,7 +1039,6 @@ random_get_random_u64
random_insecure_get_insecure_random_bytes
random_insecure_get_insecure_random_u64
random_insecure_seed_insecure_seed
random_list_u8_free
read
readdir
readlink
Expand Down Expand Up @@ -1147,7 +1145,6 @@ streams_borrow_input_stream
streams_borrow_output_stream
streams_input_stream_drop_borrow
streams_input_stream_drop_own
streams_list_u8_free
streams_method_input_stream_blocking_read
streams_method_input_stream_blocking_skip
streams_method_input_stream_read
Expand Down Expand Up @@ -1319,7 +1316,6 @@ udp_incoming_datagram_stream_drop_own
udp_ip_socket_address_free
udp_list_incoming_datagram_free
udp_list_outgoing_datagram_free
udp_list_u8_free
udp_method_incoming_datagram_stream_receive
udp_method_incoming_datagram_stream_subscribe
udp_method_outgoing_datagram_stream_check_send
Expand Down
2 changes: 1 addition & 1 deletion expected/wasm32-wasi-preview2/include-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
#include <netpacket/packet.h>
#include <nl_types.h>
#include <poll.h>
#include <preview2.h>
#include <regex.h>
#include <sched.h>
#include <search.h>
Expand Down Expand Up @@ -167,6 +168,5 @@
#include <wasi/libc-find-relpath.h>
#include <wasi/libc-nocwd.h>
#include <wasi/libc.h>
#include <wasi/preview2.h>
#include <wchar.h>
#include <wctype.h>
2 changes: 1 addition & 1 deletion expected/wasm32-wasi-preview2/predefined-macros.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2460,7 +2460,7 @@
#define __BIGGEST_ALIGNMENT__ 16
#define __BIG_ENDIAN 4321
#define __BIND 19950621
#define __BINDINGS_IMPORTS_H
#define __BINDINGS_PREVIEW2_H
#define __BYTE_ORDER __BYTE_ORDER__
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __CHAR16_TYPE__ unsigned short
Expand Down
2 changes: 1 addition & 1 deletion expected/wasm32-wasi-preview2/undefined-symbols.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__addtf3
__component_type_object_force_link_imports
__component_type_object_force_link_preview2
__divtf3
__eqtf2
__extenddftf2
Expand Down
20 changes: 9 additions & 11 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ test: run
OBJDIR ?= $(CURDIR)/build
DOWNDIR ?= $(CURDIR)/download

# preview1 or preview2
WASI_SNAPSHOT ?= preview1
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/v16.0.0/wasmtime-v16.0.0-x86_64-linux.tar.xz
# TODO: Switch to Wasmtime 17 once it's released, which will include https://github.com/bytecodealliance/wasmtime/pull/7750
WASMTIME_URL ?= https://github.com/bytecodealliance/wasmtime/releases/download/dev/wasmtime-dev-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/v16.0.0/wasi_snapshot_preview1.command.wasm
ADAPTER = $(DOWNDIR)/wasi_snapshot_preview1.command.wasm

TO_DOWNLOAD = $(LIBC_TEST) $(LIBRT) $(WASMTIME)
ifeq ($(WASI_SNAPSHOT), preview2)
ifeq ($(TARGET_TRIPLE), wasm32-wasi-preview2)
TO_DOWNLOAD += $(ADAPTER) $(WASM_TOOLS)
endif

Expand Down Expand Up @@ -129,11 +129,6 @@ WASM_OBJS += $(INFRA_WASM_OBJS)
DIRS := $(patsubst $(OBJDIR)/%/,%,$(sort $(dir $(WASM_OBJS))))
OBJDIRS := $(DIRS:%=$(OBJDIR)/%)

TARGET_TRIPLE = wasm32-wasi
ifeq ($(WASI_SNAPSHOT), preview2)
TARGET_TRIPLE = wasm32-wasi-preview2
endif

# Allow $(CC) to be set from the command line; ?= doesn't work for CC because
# make has a default value for it.
ifeq ($(origin CC), default)
Expand All @@ -143,6 +138,9 @@ LDFLAGS ?=
CFLAGS ?= --target=$(TARGET_TRIPLE) --sysroot=../sysroot
# Always include the `libc-test` infrastructure headers.
CFLAGS += -I$(LIBC_TEST)/src/common
ifeq ($(TARGET_TRIPLE), wasm32-wasi-threads)
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.
Expand All @@ -154,7 +152,7 @@ build: download $(WASMS)
$(WASMS): | $(OBJDIRS)
$(OBJDIR)/%.wasm: $(OBJDIR)/%.wasm.o $(INFRA_WASM_OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
ifeq ($(WASI_SNAPSHOT), preview2)
ifeq ($(TARGET_TRIPLE), wasm32-wasi-preview2)
$(WASM_TOOLS) component new --adapt $(ADAPTER) $@ -o $@
endif

Expand All @@ -171,7 +169,7 @@ clean::
##### RUN ######################################################################

ENGINE ?= $(WASMTIME) run
ifeq ($(WASI_SNAPSHOT), preview2)
ifeq ($(TARGET_TRIPLE), wasm32-wasi-preview2)
ENGINE += --wasm component-model
endif
ERRS:=$(WASMS:%.wasm=%.wasm.err)
Expand Down

0 comments on commit 4a0839f

Please sign in to comment.